GBDK 2020 Docs 4.4.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;
38 } metasprite_t;
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;
45 extern uint8_t __current_base_tile;
46 extern uint8_t __current_base_prop;
47 extern uint8_t __render_shadow_OAM;
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
64 void hide_sprites_range(uint8_t from, uint8_t to) OLDCALL;
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;
102 __current_base_prop = 0;
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;
141 __current_base_prop = 0;
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;
181 __current_base_prop = 0;
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;
220 __current_base_prop = 0;
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
OLDCALL
#define OLDCALL
Definition: types.h:21
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
hardware.h
PPUCTRL_SPR_8X16
#define PPUCTRL_SPR_8X16
Definition: hardware.h:16
shadow_PPUCTRL
__SHADOW_REG shadow_PPUCTRL
Definition: hardware.h:20
stdint.h
int16_t
short int int16_t
Definition: stdint.h:44
uint8_t
unsigned char uint8_t
Definition: stdint.h:51
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