|
void | hide_sprites_range (uint8_t from, uint8_t to) |
|
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) |
|
uint8_t | move_metasprite (const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) |
|
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) |
|
uint8_t | move_metasprite_vflip (const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) |
|
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) |
|
uint8_t | move_metasprite_hflip (const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) |
|
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) |
|
uint8_t | move_metasprite_hvflip (const metasprite_t *metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) |
|
void | hide_metasprite (const metasprite_t *metasprite, uint8_t base_sprite) |
|
Metasprite support
A metasprite is a larger sprite made up from a collection of smaller individual hardware sprites. Different frames of the same metasprites can share tile data.
The api supports metasprites in both SPRITES_8x8 and SPRITES_8x16 mode. If 8x16 mode is used then the height of the metasprite must be a multiple of 16.
The origin (pivot) for the metasprite is not required to be in the upper left-hand corner as with regular hardware sprites.
Use the utility_png2asset tool to convert single or multiple frames of graphics into metasprite structured data for use with the ...metasprite...() functions.
Metasprites composed of variable numbers of sprites
When using png2asset, it's common for the output of different frames to be composed of different numbers of hardware sprites (since it's trying to create each frame as efficiently as possible). Due to that, it's good practice to clear out (hide) unused sprites in the shadow_OAM that have been set by previous frames.
#define MAX_HARDWARE_SPRITES
Definition: gb.h:1842
Metasprites and sprite properties (including cgb palette)
When the move_metasprite_*() functions are called they update all properties for the affected sprites in the Shadow OAM. This means any existing property flags set for a sprite (CGB palette, BG/WIN priority, Tile VRAM Bank) will get overwritten.
How to use sprite property flags with metasprites:
- Primary method: Use the
base_prop
parameter for the move_metasprite_*() functions.
- For more details about the properties on the Game Boy see: https://gbdev.io/pandocs/OAM.html#byte-3–attributesflags
- This can be left at zero for defaults
- Various
OAMF_*
flags can be used depending on the platform:
- OAMF_BANK0, OAMF_BANK1
- OAMF_CGB_PAL0, OAMF_CGB_PAL1, OAMF_CGB_PAL2, OAMF_CGB_PAL3, OAMF_CGB_PAL4, OAMF_CGB_PAL5, OAMF_CGB_PAL6, OAMF_CGB_PAL7,
- OAMF_PAL0, OAMF_PAL1,
- OAMF_PALMASK, OAMF_PRI, OAMF_XFLIP, OAMF_YFLIP
- Alternate method: The metasprite structures can have the property flags modified before compilation (such as with
-sp <props>
in the png2asset tool).
The following functions only support hardware sprite flipping on the Game Boy / Mega Duck and NES. For other consoles which do not have hardware sprite flipping see the cross-platform metasprite example for a workaround (with some performance penalty).
To test for hardware support see HARDWARE_SPRITE_CAN_FLIP_X and HARDWARE_SPRITE_CAN_FLIP_Y. Also see docs_consoles_supported_list for a brief summary of console capabilities.