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 <sms/sms.h>
18 #include <sms/hardware.h>
19 #include <types.h>
20 #include <stdint.h>
21
34 typedef struct metasprite_t {
35 int8_t dy, dx;
36 uint8_t dtile;
37 } metasprite_t;
38
39 #define metasprite_end -128
40 #define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt)}
41 #define METASPR_TERM {metasprite_end}
42
43 extern const void * __current_metasprite;
44 extern uint8_t __current_base_tile;
45 extern uint8_t __render_shadow_OAM;
46
47
48 static uint8_t __move_metasprite(uint8_t id, int16_t x, int16_t y);
49 static uint8_t __move_metasprite_flipx(uint8_t id, int16_t x, int16_t y);
50 static uint8_t __move_metasprite_flipy(uint8_t id, int16_t x, int16_t y);
51 static uint8_t __move_metasprite_flipxy(uint8_t id, int16_t x, int16_t y);
52 static void __hide_metasprite(uint8_t id) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
53
59 void hide_sprites_range(uint8_t from, uint8_t to) PRESERVES_REGS(iyh, iyl);
60
81 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) {
82 base_prop;
83 __current_metasprite = metasprite;
84 __current_base_tile = base_tile;
85 return __move_metasprite(base_sprite, x, y);
86 }
87
90 inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, int16_t x, int16_t y) {
91 __current_metasprite = metasprite;
92 __current_base_tile = base_tile;
93 return __move_metasprite(base_sprite, x, y);
94 }
95
118 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) {
119 base_prop;
120 __current_metasprite = metasprite;
121 __current_base_tile = base_tile;
122 return __move_metasprite_flipx(base_sprite, x - 8, y);
123 }
124
147 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) {
148 base_prop;
149 __current_metasprite = metasprite;
150 __current_base_tile = base_tile;
151 return __move_metasprite_flipy(base_sprite, x, y - ((__READ_VDP_REG(VDP_R1) & R1_SPR_8X16) ? 16 : 8) );
152 }
153
176 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) {
177 base_prop;
178 __current_metasprite = metasprite;
179 __current_base_tile = base_tile;
180 return __move_metasprite_flipxy(base_sprite, x - 8, y - ((__READ_VDP_REG(VDP_R1) & R1_SPR_8X16) ? 16 : 8));
181 }
182
192 inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
193 __current_metasprite = metasprite;
194 __hide_metasprite(base_sprite);
195 }
196
197 #endif
PRESERVES_REGS
#define PRESERVES_REGS(...)
Definition: types.h:32
Z88DK_FASTCALL
#define Z88DK_FASTCALL
Definition: types.h:47
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
__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)
__current_metasprite
const void * __current_metasprite
metasprite_t
struct metasprite_t metasprite_t
hide_metasprite
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:305
VDP_R1
#define VDP_R1
Definition: hardware.h:53
iyl
static uint8_t iyl
Definition: metasprites.h:49
__READ_VDP_REG
#define __READ_VDP_REG(REG)
Definition: msx.h:100
iyh
void iyh
Definition: msx.h:102
hardware.h
R1_SPR_8X16
#define R1_SPR_8X16
Definition: hardware.h:138
sms.h
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::dtile
uint8_t dtile
Definition: metasprites.h:104