GBDK 2020 Docs  4.1.1
API Documentation for GBDK 2020
metasprites.h
Go to the documentation of this file.
1 
67 #ifndef _METASPRITES_H_INCLUDE
68 #define _METASPRITES_H_INCLUDE
69 
70 #include <gb/hardware.h>
71 #include <types.h>
72 #include <stdint.h>
73 
87 typedef struct metasprite_t {
92 
93 #define metasprite_end -128
94 #define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)}
95 #define METASPR_TERM {metasprite_end}
96 
97 extern const void * __current_metasprite;
101 
102 
103 static uint8_t __move_metasprite(uint8_t id, uint16_t yx);
104 static uint8_t __move_metasprite_flipx(uint8_t id, uint16_t yx);
105 static uint8_t __move_metasprite_flipy(uint8_t id, uint16_t yx);
106 static uint8_t __move_metasprite_flipxy(uint8_t id, uint16_t yx);
107 static uint8_t __move_metasprite_vflip(uint8_t id, uint16_t yx);
108 static uint8_t __move_metasprite_hflip(uint8_t id, uint16_t yx);
109 static uint8_t __move_metasprite_hvflip(uint8_t id, uint16_t yx);
110 static void __hide_metasprite(uint8_t id);
111 
120 
144 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) {
145  __current_metasprite = metasprite;
146  __current_base_tile = base_tile;
147  __current_base_prop = base_prop;
148  return __move_metasprite(base_sprite, (y << 8) | (uint8_t)x);
149 }
150 
153 inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
154  __current_metasprite = metasprite;
155  __current_base_tile = base_tile;
157  return __move_metasprite(base_sprite, (y << 8) | (uint8_t)x);
158 }
159 
184 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) {
185  __current_metasprite = metasprite;
186  __current_base_tile = base_tile;
187  __current_base_prop = base_prop;
188  return __move_metasprite_flipx(base_sprite, (y << 8) | (uint8_t)(x - 8u));
189 }
190 
193 inline uint8_t move_metasprite_vflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
194  __current_metasprite = metasprite;
195  __current_base_tile = base_tile;
197  return __move_metasprite_vflip(base_sprite, (y << 8) | (uint8_t)(x - 8u));
198 }
199 
200 
225 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) {
226  __current_metasprite = metasprite;
227  __current_base_tile = base_tile;
228  __current_base_prop = base_prop;
229  return __move_metasprite_flipy(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | x);
230 }
231 
234 inline uint8_t move_metasprite_hflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
235  __current_metasprite = metasprite;
236  __current_base_tile = base_tile;
238  return __move_metasprite_hflip(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | x);
239 }
240 
265 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) {
266  __current_metasprite = metasprite;
267  __current_base_tile = base_tile;
268  __current_base_prop = base_prop;
269  return __move_metasprite_flipxy(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | (uint8_t)(x - 8));
270 }
271 
274 inline uint8_t move_metasprite_hvflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
275  __current_metasprite = metasprite;
276  __current_base_tile = base_tile;
278  return __move_metasprite_hvflip(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | (uint8_t)(x - 8));
279 }
280 
290 inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
291  __current_metasprite = metasprite;
292  __hide_metasprite(base_sprite);
293 }
294 
295 #endif
unsigned char UINT8
Definition: types.h:49
#define LCDCF_OBJ16
Definition: hardware.h:227
__REG LCDC_REG
Definition: hardware.h:162
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:184
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:265
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:234
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:274
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:225
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:144
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:153
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:193
const void * __current_metasprite
struct metasprite_t metasprite_t
void hide_sprites_range(UINT8 from, UINT8 to)
uint8_t __current_base_prop
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:290
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:87
int8_t dy
Definition: metasprites.h:88
int8_t dx
Definition: metasprites.h:88
uint8_t props
Definition: metasprites.h:90
uint8_t dtile
Definition: metasprites.h:89