GBDK 2020 Docs  4.1.1
API Documentation for GBDK 2020
metasprites.h
Go to the documentation of this file.
1 
34 #ifndef _METASPRITES_H_INCLUDE
35 #define _METASPRITES_H_INCLUDE
36 
37 #include <sms/hardware.h>
38 #include <types.h>
39 #include <stdint.h>
40 
53 typedef struct metasprite_t {
54  int8_t dy, dx;
55  uint8_t dtile;
57 
58 #define metasprite_end -128
59 #define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt)}
60 #define METASPR_TERM {metasprite_end}
61 
62 extern const void * __current_metasprite;
65 
66 
67 static uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
68 static uint8_t __move_metasprite_flipx(uint8_t id, uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
69 static uint8_t __move_metasprite_flipy(uint8_t id, uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
70 static uint8_t __move_metasprite_flipxy(uint8_t id, uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
71 static void __hide_metasprite(uint8_t id) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
72 
79 
100 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) {
101  base_prop;
102  __current_metasprite = metasprite;
103  __current_base_tile = base_tile;
104  return __move_metasprite(base_sprite, x, y);
105 }
106 
109 inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
110  __current_metasprite = metasprite;
111  __current_base_tile = base_tile;
112  return __move_metasprite(base_sprite, x, y);
113 }
114 
137 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) {
138  base_prop;
139  __current_metasprite = metasprite;
140  __current_base_tile = base_tile;
141  return __move_metasprite_flipx(base_sprite, x - 8, y);
142 }
143 
166 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) {
167  base_prop;
168  __current_metasprite = metasprite;
169  __current_base_tile = base_tile;
170  return __move_metasprite_flipy(base_sprite, x, y - ((__READ_VDP_REG(VDP_R1) & R1_SPR_8X16) ? 16 : 8) );
171 }
172 
195 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) {
196  base_prop;
197  __current_metasprite = metasprite;
198  __current_base_tile = base_tile;
199  return __move_metasprite_flipxy(base_sprite, x - 8, y - ((__READ_VDP_REG(VDP_R1) & R1_SPR_8X16) ? 16 : 8));
200 }
201 
211 inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
212  __current_metasprite = metasprite;
213  __hide_metasprite(base_sprite);
214 }
215 
216 #endif
unsigned char UINT8
Definition: types.h:49
#define PRESERVES_REGS(...)
Definition: types.h:31
#define Z88DK_CALLEE
Definition: types.h:45
#define Z88DK_FASTCALL
Definition: types.h:46
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 __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
const void * __current_metasprite
struct metasprite_t metasprite_t
void hide_sprites_range(UINT8 from, UINT8 to)
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:290
#define VDP_R1
Definition: hardware.h:73
static uint8_t iyl
Definition: metasprites.h:69
#define __READ_VDP_REG(REG)
Definition: msx.h:84
void iyh
Definition: msx.h:86
#define R1_SPR_8X16
Definition: hardware.h:83
unsigned char uint8_t
Definition: stdint.h:51
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 dtile
Definition: metasprites.h:89