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 <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;
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;
46 
47 
48 static uint8_t __move_metasprite(uint8_t id, uint16_t x, uint16_t y);
49 static uint8_t __move_metasprite_flipx(uint8_t id, uint16_t x, uint16_t y);
50 static uint8_t __move_metasprite_flipy(uint8_t id, uint16_t x, uint16_t y);
51 static uint8_t __move_metasprite_flipxy(uint8_t id, uint16_t x, uint16_t y);
52 static void __hide_metasprite(uint8_t id) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
53 
60 
81 inline uint8_t move_metasprite_ex(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_prop, uint8_t base_sprite, uint16_t x, uint16_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, uint16_t x, uint16_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, uint16_t x, uint16_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, uint16_t x, uint16_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, uint16_t x, uint16_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
#define PRESERVES_REGS(...)
Definition: types.h:32
#define Z88DK_FASTCALL
Definition: types.h:47
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 __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)
const void * __current_metasprite
struct metasprite_t metasprite_t
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:305
#define VDP_R1
Definition: hardware.h:53
static uint8_t iyl
Definition: metasprites.h:49
#define __READ_VDP_REG(REG)
Definition: msx.h:100
void iyh
Definition: msx.h:102
#define R1_SPR_8X16
Definition: hardware.h:138
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:102
int8_t dy
Definition: metasprites.h:103
int8_t dx
Definition: metasprites.h:103
uint8_t dtile
Definition: metasprites.h:104