Dynamic metasprite engine demo — multi-tile characters with VRAM streaming. More...
#include <snes.h>#include "res/spritehero32.inc"#include "res/spritehero16.inc"#include "res/spritehero8.inc"Functions | |
| void | changeObjSize (void) |
| Reinitialize sprite engine and upload all tiles during force blank. | |
| void | drawSprites (void) |
| Draw metasprites for the current OBJSEL configuration. | |
| void | drawText (void) |
| Draw the configuration menu text. | |
| int | main (void) |
| Entry point. | |
Variables | |
| static const MetaspriteItem | hero16_frame0 [] |
| 16x16 metasprite: 32x48 character (2x3 grid of 16x16) | |
| static const MetaspriteItem | hero32_frame0 [] |
| 32x32 metasprite: 64x64 character (2x2 grid of 32x32) | |
| static const MetaspriteItem | hero8_frame0 [] |
| 8x8 metasprite: 16x16 character (2x2 grid of 8x8) | |
| u16 | pad0 |
| u16 | selectedItem |
Dynamic metasprite engine demo — multi-tile characters with VRAM streaming.
Demonstrates oamMetaDrawDyn(..., size_class): multi-tile sprite characters where each sub-sprite's tiles are streamed to VRAM on demand (dynamic sprite engine). The size_class parameter selects whether the metasprite uses the small or large half of the configured size pair. Three OBJSEL configurations are selectable via D-PAD:
Ported from PVSnesLib DynamicEngineMetaSprite example.
| void changeObjSize | ( | void | ) |
Reinitialize sprite engine and upload all tiles during force blank.
Uses force blank for a glitch-free OBJSEL switch. The current configuration can enqueue >7 entries (config 2 hits 10), and the NMI auto-flush hook drains 7 per VBlank, so oamDynamicDrainQueue loops WaitForVBlank() until the queue is empty before we release force blank. NMI suppresses the end-frame "hide stale sprites" path during the drain so the just-queued sprites are not pushed off-screen.
| void drawSprites | ( | void | ) |
Draw metasprites for the current OBJSEL configuration.
Render metasprites using oamDrawMetasprite() for the current size mode.
oamDrawMetasprite() reads metasprite frame data (tile offsets + positions) and populates multiple OAM entries to compose a large character from smaller hardware sprite pieces. It returns the next available OAM ID, allowing multiple metasprites to be drawn without ID conflicts.
Each size mode uses a different combination of LARGE and SMALL sprites to render two characters: one larger (left) and one smaller (right).
| void drawText | ( | void | ) |
Draw the configuration menu text.
| int main | ( | void | ) |
Entry point.
|
static |
16x16 metasprite: 32x48 character (2x3 grid of 16x16)
|
static |
32x32 metasprite: 64x64 character (2x2 grid of 32x32)
|
static |
8x8 metasprite: 16x16 character (2x2 grid of 8x8)
| u16 pad0 |
| u16 selectedItem |