GBDK 2020 Docs 4.4.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 {
103 int8_t dy, dx;
104 uint8_t dtile;
105 uint8_t props;
106 } 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;
113 extern uint8_t __current_base_tile;
114 extern uint8_t __current_base_prop;
115 extern uint8_t __render_shadow_OAM;
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
134 void hide_sprites_range(uint8_t from, uint8_t to);
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;
171 __current_base_prop = 0;
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;
211 __current_base_prop = 0;
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;
252 __current_base_prop = 0;
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;
292 __current_base_prop = 0;
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
hardware.h
LCDCF_OBJ16
#define LCDCF_OBJ16
Definition: hardware.h:247
LCDC_REG
__REG LCDC_REG
Definition: hardware.h:182
move_metasprite_flipx
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
move_metasprite_flipxy
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
move_metasprite_hflip
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
move_metasprite_hvflip
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
__current_base_tile
uint8_t __current_base_tile
__render_shadow_OAM
uint8_t __render_shadow_OAM
move_metasprite_flipy
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
move_metasprite_ex
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
move_metasprite
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
hide_sprites_range
void hide_sprites_range(uint8_t from, uint8_t to)
move_metasprite_vflip
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
__current_metasprite
const void * __current_metasprite
metasprite_t
struct metasprite_t metasprite_t
__current_base_prop
uint8_t __current_base_prop
hide_metasprite
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:305
stdint.h
uint8_t
unsigned char uint8_t
Definition: stdint.h:51
uint16_t
unsigned short int uint16_t
Definition: stdint.h:52
int8_t
signed char int8_t
Definition: stdint.h:43
metasprite_t
Definition: metasprites.h:102
metasprite_t::dy
int8_t dy
Definition: metasprites.h:103
metasprite_t::dx
int8_t dx
Definition: metasprites.h:103
metasprite_t::props
uint8_t props
Definition: metasprites.h:105
metasprite_t::dtile
uint8_t dtile
Definition: metasprites.h:104