# GBDK 2020 Docs: gb/metasprites.h Source File

metasprites.h
Go to the documentation of this file.
#ifndef _METASPRITES_H_INCLUDE
#define _METASPRITES_H_INCLUDE
#include <gb/hardware.h>
#include <types.h>
#include <stdint.h>
typedef struct metasprite_t {
int8_t dy, dx;
uint8_t dtile;
uint8_t props;
} metasprite_t;
#define metasprite_end -128
#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)}
#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, uint8_t x, uint8_t y) OLDCALL;
static uint8_t __move_metasprite_vflip(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
static uint8_t __move_metasprite_hflip(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
static uint8_t __move_metasprite_hvflip(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
static void __hide_metasprite(uint8_t id) OLDCALL;
void hide_sprites_range(UINT8 from, UINT8 to) OLDCALL PRESERVES_REGS(b, c);
inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite(base_sprite, x, y);
}
inline uint8_t move_metasprite_vflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite_vflip(base_sprite, x - 8, y);
}
inline uint8_t move_metasprite_hflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite_hflip(base_sprite, x, y - ((LCDC_REG & 0x04U) ? 16 : 8) );
}
inline uint8_t move_metasprite_hvflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
return __move_metasprite_hvflip(base_sprite, x - 8, y - ((LCDC_REG & 0x04U) ? 16 : 8));
}
inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
__current_metasprite = metasprite;
__hide_metasprite(base_sprite);
}
#endif
UINT8
unsigned char UINT8
Definition: types.h:46
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:87
metasprite_t::props
uint8_t props
Definition: metasprites.h:90
metasprite_t::dy
int8_t dy
Definition: metasprites.h:88
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:225
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:196
__current_base_tile
uint8_t __current_base_tile
LCDC_REG
__REG LCDC_REG
Definition: hardware.h:162
metasprite_t::dx
int8_t dx
Definition: metasprites.h:88
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:137
hide_metasprite
void hide_metasprite(const metasprite_t *metasprite, uint8_t base_sprite)
Definition: metasprites.h:240
stdint.h
hide_sprites_range
void hide_sprites_range(UINT8 from, UINT8 to) OLDCALL PRESERVES_REGS(b
metasprite_t
struct metasprite_t metasprite_t
b
void b
Definition: gb.h:608
OLDCALL
#define OLDCALL
Definition: types.h:19
hardware.h
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:166
__current_metasprite
const void * __current_metasprite
metasprite_t::dtile
uint8_t dtile
Definition: metasprites.h:89
PRESERVES_REGS
#define PRESERVES_REGS(...)
Definition: types.h:29
c
void c
Definition: metasprites.h:113
__render_shadow_OAM
uint8_t __render_shadow_OAM