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:
- Config 0: 8/16 — 16x16 metasprite (LARGE) + 8x8 metasprite (SMALL)
- Config 1: 8/32 — 32x32 metasprite (LARGE) + 8x8 metasprite (SMALL)
- Config 2: 16/32 — 32x32 metasprite (LARGE) + 16x16 metasprite (SMALL)
Ported from PVSnesLib DynamicEngineMetaSprite example.
- SNES Concepts
- Dynamic VRAM tile streaming for multi-tile sprite characters
- MetaspriteItem arrays defining sub-sprite layout
- OBJSEL size configuration (8/16, 8/32, 16/32)
- oambuffer[] state management for metasprite sub-sprites
- What to Observe
- Two sprite characters visible on screen
- D-PAD UP/DOWN switches between 3 OBJSEL configurations
- Menu cursor ">" indicates current selection
- Sprites change size when switching configurations
- Modules Used
- console, sprite, sprite_dynamic, sprite_dynamic_meta, sprite_lut, dma, background, text, input
- See also
- sprite.h
| static void drawSprites |
( |
void |
| ) |
|
Draw metasprites for the current OBJSEL configuration.
Render metasprites using oamDrawMeta() for the current size mode.
oamDrawMeta() 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).
< First tile of 16x16 sheet (192)
< First tile of 8x8 sheet (288)
< First tile of 32x32 sheet
< First tile of 8x8 sheet (288)
< First tile of 32x32 sheet
< First tile of 16x16 sheet (192)