metasprites.h
Go to the documentation of this file.
#ifndef _METASPRITES_H_INCLUDE
#define _METASPRITES_H_INCLUDE
#include <sms/sms.h>
#include <sms/hardware.h>
#include <types.h>
#include <stdint.h>
typedef struct metasprite_t {
int8_t dy, dx;
uint8_t dtile;
} metasprite_t;
#define metasprite_end -128
#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt)}
#define METASPR_TERM {metasprite_end}
extern const void * __current_metasprite;
extern uint8_t __current_base_tile;
extern uint8_t __render_shadow_OAM;
static uint8_t __move_metasprite(uint8_t id, int16_t x, int16_t y);
static uint8_t __move_metasprite_flipx(uint8_t id, int16_t x, int16_t y);
static uint8_t __move_metasprite_flipy(uint8_t id, int16_t x, int16_t y);
static uint8_t __move_metasprite_flipxy(uint8_t id, int16_t x, int16_t y);
static void __hide_metasprite(uint8_t id) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
void hide_sprites_range(uint8_t from, uint8_t to) PRESERVES_REGS(iyh, iyl);
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) {
base_prop;
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite(base_sprite, x, y);
}
inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, int16_t x, int16_t y) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite(base_sprite, x, y);
}
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) {
base_prop;
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite_flipx(base_sprite, x - 8, y);
}
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) {
base_prop;
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite_flipy(base_sprite, x, y - ((__READ_VDP_REG(VDP_R1) & R1_SPR_8X16) ? 16 : 8) );
}
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) {
base_prop;
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite_flipxy(base_sprite, x - 8, y - ((__READ_VDP_REG(VDP_R1) & R1_SPR_8X16) ? 16 : 8));
}
inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
__current_metasprite = metasprite;
__hide_metasprite(base_sprite);
}
#endif
PRESERVES_REGS
#define PRESERVES_REGS(...)
Definition: types.h:32
Z88DK_FASTCALL
#define Z88DK_FASTCALL
Definition: types.h:47
__current_base_tile
uint8_t __current_base_tile
__current_metasprite
const void * __current_metasprite
__render_shadow_OAM
uint8_t __render_shadow_OAM
hide_metasprite
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:305
hide_sprites_range
void hide_sprites_range(uint8_t from, uint8_t to)
metasprite_t
struct metasprite_t metasprite_t
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
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_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_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
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
int8_t
signed char int8_t
Definition: stdint.h:43
uint8_t
unsigned char uint8_t
Definition: stdint.h:51
metasprite_t
Definition: metasprites.h:102
metasprite_t::dtile
uint8_t dtile
Definition: metasprites.h:104
metasprite_t::dx
int8_t dx
Definition: metasprites.h:103
metasprite_t::dy
int8_t dy
Definition: metasprites.h:103