Opt-in asset bundle convention — package tiles + palette (+ optional tilemap) into a typed value, load it with one function call. More...
Go to the source code of this file.
Classes | |
| struct | BgAsset |
| A full background bundle: tileset + tilemap + map size. More... | |
| struct | GfxAsset |
| A tileset bundle: graphics + palette + color depth. More... | |
Macros | |
| #define | DECLARE_BG_ASSET(name, color_mode_, map_size_) |
| Declare a static const BgAsset from gfx4snes-style symbol pairs. | |
| #define | DECLARE_GFX_ASSET(name, color_mode_) |
| Declare a static const GfxAsset from gfx4snes-style symbol pairs. | |
Functions | |
| void | bgLoad (u8 bg, const BgAsset *asset, u8 palette_slot, u16 tiles_vram, u16 map_vram) |
| Load a full background bundle — typed-value variant of BG_LOAD. | |
| void | gfxLoad (u8 bg, const GfxAsset *asset, u8 palette_slot, u16 tiles_vram) |
| Load a tileset (tiles + palette) and configure a BG's tile graphics pointer — typed-value variant of GFX_LOAD. | |
Opt-in asset bundle convention — package tiles + palette (+ optional tilemap) into a typed value, load it with one function call.
One of the three "framework opt-ins" promised by PHILOSOPHY.md (alongside gameloop and scene). This module removes a recurring piece of SNES boilerplate: declaring six extern symbols (begin/end pairs for tiles, palette, tilemap), computing three sizes by subtraction at every call site, and threading them through an 8-parameter bgInitTileSet() followed by a separate dmaCopyVram() for the map.
DECLARE_BG_ASSET is constructor sugar — it expands to the six extern declarations and a static const BgAsset initialised from those symbols. Users who want to instantiate the struct manually can do so; the macro is a convenience, the struct is the contract.
The macros expect the symbol naming convention <name>_tiles, <name>_pal, <name>_map plus their _end siblings. The user chooses the prefix once in their data.asm.
The asset is a first-class value: pass it to a function, store an array of them as a level table indexed at runtime, swap assets at scene boundaries. Each callsite is one bgLoad/gfxLoad call, no positional-parameter shuffle.
| #define DECLARE_BG_ASSET | ( | name, | |
| color_mode_, | |||
| map_size_ ) |
Declare a static const BgAsset from gfx4snes-style symbol pairs.
Same convention as DECLARE_GFX_ASSET, plus <name>_map / <name>_map_end for the tilemap blob.
| #define DECLARE_GFX_ASSET | ( | name, | |
| color_mode_ ) |
Declare a static const GfxAsset from gfx4snes-style symbol pairs.
Expands to extern declarations for <name>_tiles/<name>_tiles_end and <name>_pal/<name>_pal_end, plus a static const GfxAsset populated with the right pointers and color mode.
Load a full background bundle — typed-value variant of BG_LOAD.
Composes gfxLoad() with bgSetMapPtr() and a dmaCopyVram() of the tilemap. After the call the BG is fully addressable; the caller still controls when to enable it on the screen.
Load a tileset (tiles + palette) and configure a BG's tile graphics pointer — typed-value variant of GFX_LOAD.
| bg | Background number 0-3. |
| asset | Bundle to load. Must be non-NULL. |
| palette_slot | Palette slot index (0-7 for 16-color, etc.). |
| tiles_vram | VRAM word address for the tile graphics (4 KB aligned). |