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 __current_base_prop;
extern uint8_t __render_shadow_OAM;
static uint8_t __move_metasprite(uint8_t id, uint16_t yx);
static uint8_t __move_metasprite_flipx(uint8_t id, uint16_t yx);
static uint8_t __move_metasprite_flipy(uint8_t id, uint16_t yx);
static uint8_t __move_metasprite_flipxy(uint8_t id, uint16_t yx);
static uint8_t __move_metasprite_vflip(uint8_t id, uint16_t yx);
static uint8_t __move_metasprite_hflip(uint8_t id, uint16_t yx);
static uint8_t __move_metasprite_hvflip(uint8_t id, uint16_t yx);
static void __hide_metasprite(uint8_t id);
void hide_sprites_range(uint8_t from, uint8_t to);
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) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
__current_base_prop = base_prop;
return __move_metasprite(base_sprite, (y << 8) | (uint8_t)x);
}
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;
__current_base_prop = 0;
return __move_metasprite(base_sprite, (y << 8) | (uint8_t)x);
}
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) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
__current_base_prop = base_prop;
return __move_metasprite_flipx(base_sprite, (y << 8) | (uint8_t)(x - 8u));
}
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;
__current_base_prop = 0;
return __move_metasprite_vflip(base_sprite, (y << 8) | (uint8_t)(x - 8u));
}
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) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
__current_base_prop = base_prop;
return __move_metasprite_flipy(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | x);
}
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;
__current_base_prop = 0;
return __move_metasprite_hflip(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | x);
}
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) {
__current_metasprite = metasprite;
__current_base_tile = base_tile;
__current_base_prop = base_prop;
return __move_metasprite_flipxy(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | (uint8_t)(x - 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;
__current_base_prop = 0;
return __move_metasprite_hvflip(base_sprite, ((y - ((LCDC_REG & LCDCF_OBJ16) ? 16u : 8u)) << 8) | (uint8_t)(x - 8));
}
inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
__current_metasprite = metasprite;
__hide_metasprite(base_sprite);
}
#endif
hardware.h
LCDCF_OBJ16
#define LCDCF_OBJ16
Definition: hardware.h:247
LCDC_REG
__REG LCDC_REG
Definition: hardware.h:182
__current_base_prop
uint8_t __current_base_prop
__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
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:249
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:289
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:208
stdint.h
int8_t
signed char int8_t
Definition: stdint.h:43
uint16_t
unsigned short int uint16_t
Definition: stdint.h:52
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
metasprite_t::props
uint8_t props
Definition: metasprites.h:105