GBDK 2020 Docs  4.3.0
API Documentation for GBDK 2020
metasprites.h
Go to the documentation of this file.
1 
82 #ifndef _METASPRITES_H_INCLUDE
83 #define _METASPRITES_H_INCLUDE
84 
85 #include <gb/hardware.h>
86 #include <types.h>
87 #include <stdint.h>
88 
102 typedef struct metasprite_t {
107 
108 #define metasprite_end -128
109 #define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)}
110 #define METASPR_TERM {metasprite_end}
111 
112 extern const void * __current_metasprite;
116 
117 
118 static uint8_t __move_metasprite(uint8_t id, uint16_t yx);
119 static uint8_t __move_metasprite_flipx(uint8_t id, uint16_t yx);
120 static uint8_t __move_metasprite_flipy(uint8_t id, uint16_t yx);
121 static uint8_t __move_metasprite_flipxy(uint8_t id, uint16_t yx);
122 static uint8_t __move_metasprite_vflip(uint8_t id, uint16_t yx);
123 static uint8_t __move_metasprite_hflip(uint8_t id, uint16_t yx);
124 static uint8_t __move_metasprite_hvflip(uint8_t id, uint16_t yx);
125 static void __hide_metasprite(uint8_t id);
126 
135 
159 inline uint8_t move_metasprite_ex(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y) {
160  __current_metasprite = metasprite;
161  __current_base_tile = base_tile;
162  __current_base_prop = base_prop;
163  return __move_metasprite(base_sprite, (y << 8) | (uint8_t)x);
164 }
165 
168 inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
169  __current_metasprite = metasprite;
170  __current_base_tile = base_tile;
172  return __move_metasprite(base_sprite, (y << 8) | (uint8_t)x);
173 }
174 
199 inline uint8_t move_metasprite_flipx(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y) {
200  __current_metasprite = metasprite;
201  __current_base_tile = base_tile;
202  __current_base_prop = base_prop;
203  return __move_metasprite_flipx(base_sprite, (y << 8) | (uint8_t)(x - 8u));
204 }
205 
208 inline uint8_t move_metasprite_vflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
209  __current_metasprite = metasprite;
210  __current_base_tile = base_tile;
212  return __move_metasprite_vflip(base_sprite, (y << 8) | (uint8_t)(x - 8u));
213 }
214 
215 
240 inline uint8_t move_metasprite_flipy(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y) {
241  __current_metasprite = metasprite;
242  __current_base_tile = base_tile;
243  __current_base_prop = base_prop;
244  return __move_metasprite_flipy(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | x);
245 }
246 
249 inline uint8_t move_metasprite_hflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
250  __current_metasprite = metasprite;
251  __current_base_tile = base_tile;
253  return __move_metasprite_hflip(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | x);
254 }
255 
280 inline uint8_t move_metasprite_flipxy(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y) {
281  __current_metasprite = metasprite;
282  __current_base_tile = base_tile;
283  __current_base_prop = base_prop;
284  return __move_metasprite_flipxy(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | (uint8_t)(x - 8));
285 }
286 
289 inline uint8_t move_metasprite_hvflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
290  __current_metasprite = metasprite;
291  __current_base_tile = base_tile;
293  return __move_metasprite_hvflip(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | (uint8_t)(x - 8));
294 }
295 
305 inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
306  __current_metasprite = metasprite;
307  __hide_metasprite(base_sprite);
308 }
309 
310 #endif
#define LCDCF_OBJ16
Definition: hardware.h:231
__REG LCDC_REG
Definition: hardware.h:166
uint8_t move_metasprite_flipx(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:199
uint8_t move_metasprite_flipxy(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:280
uint8_t move_metasprite_hflip(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:249
uint8_t move_metasprite_hvflip(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:289
uint8_t __current_base_tile
uint8_t __render_shadow_OAM
uint8_t move_metasprite_flipy(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:240
uint8_t move_metasprite_ex(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:159
uint8_t move_metasprite(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:168
void hide_sprites_range(uint8_t from, uint8_t to)
uint8_t move_metasprite_vflip(const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y)
Definition: metasprites.h:208
const void * __current_metasprite
struct metasprite_t metasprite_t
uint8_t __current_base_prop
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:305
unsigned char uint8_t
Definition: stdint.h:51
unsigned short int uint16_t
Definition: stdint.h:52
signed char int8_t
Definition: stdint.h:43
Definition: metasprites.h:102
int8_t dy
Definition: metasprites.h:103
int8_t dx
Definition: metasprites.h:103
uint8_t props
Definition: metasprites.h:105
uint8_t dtile
Definition: metasprites.h:104