GBDK 2020 Docs  4.3.0
API Documentation for GBDK 2020
metasprites.h
Go to the documentation of this file.
1 
14 #ifndef _METASPRITES_H_INCLUDE
15 #define _METASPRITES_H_INCLUDE
16 
17 #include <nes/hardware.h>
18 #include <types.h>
19 #include <stdint.h>
20 
34 typedef struct metasprite_t {
35  int8_t dy, dx;
36  uint8_t dtile;
37  uint8_t props;
39 
40 #define metasprite_end -128
41 #define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)}
42 #define METASPR_TERM {metasprite_end}
43 
44 extern const void * __current_metasprite;
48 
49 
50 static uint8_t __move_metasprite(uint8_t id, int16_t x, int16_t y) OLDCALL;
51 static uint8_t __move_metasprite_flipx(uint8_t id, int16_t x, int16_t y) OLDCALL;
52 static uint8_t __move_metasprite_flipy(uint8_t id, int16_t x, int16_t y) OLDCALL;
53 static uint8_t __move_metasprite_flipxy(uint8_t id, int16_t x, int16_t y) OLDCALL;
54 static uint8_t __move_metasprite_vflip(uint8_t id, int16_t x, int16_t y) OLDCALL;
55 static uint8_t __move_metasprite_hflip(uint8_t id, int16_t x, int16_t y) OLDCALL;
56 static uint8_t __move_metasprite_hvflip(uint8_t id, int16_t x, int16_t y) OLDCALL;
57 static void __hide_metasprite(uint8_t id) OLDCALL;
58 
65 
89 inline uint8_t move_metasprite_ex(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, int16_t x, int16_t y) {
90  base_prop;
91  __current_metasprite = metasprite;
92  __current_base_tile = base_tile;
93  __current_base_prop = base_prop;
94  return __move_metasprite(base_sprite, x, y);
95 }
96 
99 inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, int16_t x, int16_t y) {
100  __current_metasprite = metasprite;
101  __current_base_tile = base_tile;
103  return __move_metasprite(base_sprite, x, y);
104 }
105 
128 inline uint8_t move_metasprite_flipx(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, int16_t x, int16_t y) {
129  base_prop;
130  __current_metasprite = metasprite;
131  __current_base_tile = base_tile;
132  __current_base_prop = base_prop;
133  return __move_metasprite_flipx(base_sprite, x - 8, y);
134 }
135 
138 inline uint8_t move_metasprite_vflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, int16_t x, int16_t y) {
139  __current_metasprite = metasprite;
140  __current_base_tile = base_tile;
142  return __move_metasprite_vflip(base_sprite, x - 8, y);
143 }
144 
145 
168 inline uint8_t move_metasprite_flipy(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, int16_t x, int16_t y) {
169  base_prop;
170  __current_metasprite = metasprite;
171  __current_base_tile = base_tile;
172  __current_base_prop = base_prop;
173  return __move_metasprite_flipy(base_sprite, x, y - ((shadow_PPUCTRL & PPUCTRL_SPR_8X16) ? 16 : 8) );
174 }
175 
178 inline uint8_t move_metasprite_hflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, int16_t x, int16_t y) {
179  __current_metasprite = metasprite;
180  __current_base_tile = base_tile;
182  return __move_metasprite_hflip(base_sprite, x, y - ((shadow_PPUCTRL & PPUCTRL_SPR_8X16) ? 16 : 8) );
183 }
184 
207 inline uint8_t move_metasprite_flipxy(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, int16_t x, int16_t y) {
208  base_prop;
209  __current_metasprite = metasprite;
210  __current_base_tile = base_tile;
211  __current_base_prop = base_prop;
212  return __move_metasprite_flipxy(base_sprite, x - 8, y - ((shadow_PPUCTRL & PPUCTRL_SPR_8X16) ? 16 : 8));
213 }
214 
217 inline uint8_t move_metasprite_hvflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, int16_t x, int16_t y) {
218  __current_metasprite = metasprite;
219  __current_base_tile = base_tile;
221  return __move_metasprite_hvflip(base_sprite, x - 8, y - ((shadow_PPUCTRL & PPUCTRL_SPR_8X16) ? 16 : 8));
222 }
223 
233 inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
234  __current_metasprite = metasprite;
235  __hide_metasprite(base_sprite);
236 }
237 
238 #endif
#define OLDCALL
Definition: types.h:21
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
#define PPUCTRL_SPR_8X16
Definition: hardware.h:16
__SHADOW_REG shadow_PPUCTRL
Definition: hardware.h:20
short int int16_t
Definition: stdint.h:44
unsigned char uint8_t
Definition: stdint.h:51
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