Game math & framework · a panel building block.
Every game has furniture: a status bar with hearts and a coin count, a dialog box that opens over the world and closes again. Both are the same primitive — a 9-slice panel, a bordered box stamped from a 3×3 tile sheet (four corners, four edges, one fill). Without a helper it's ~60 lines of stamping loop and priority wiring per box; the panel module is that loop, done once and correctly, so your game code just says draw a box here.
The single new idea: the panel module — several boxes, one layer, one upload. The HUD and the dialog live in the same tilemap on the same BG layer. panelDraw() stamps a box (picking corner/edge/fill by position); panelPut() drops a single sheet tile — a heart icon — into it; panelFlush() uploads the whole map. Opening the dialog is panelDraw + panelFlush; closing it is panelClear + panelFlush; and the HUD is untouched either way.
Two things worth internalising:
The sheet is res/boxes.png, twelve 2bpp tiles in an order the code relies on: 0 transparent, 1-9 the 9-slice in raster order (SHEET_BASE 1, stride 3), 10 and 11 the full and empty hearts. It is converted without reduction (no-reduce), so the tile numbers are the picture's, and loaded with one dmaCopyVram: the panel module writes the map, the converter's map is not used.
The panels are on BG3, Mode 1's 2bpp layer — the classic home of a HUD, cheap in VRAM (16 bytes a tile). Two things put it in front of the scene:
In Mode 1, BG3's priority-1 tiles are drawn in front of everything — sprites, BG1 and BG2 — only when the BGMODE bit is set; with it clear they sit behind BG1 and BG2 (anomie's register doc, the Mode 1 priority list). SELECT clears and sets the bit: the boxes drop behind the bar (and behind Kit and the raccoon) and come back in front of everything, while their tilemap does not change. A 2bpp palette has four colours (0 transparent) taken from CGRAM 0-31; the boxes use palette 4, CGRAM 16-19, which the scene (palette 0) leaves free — so the empty heart's outline reuses the box's line colour. (This lesson was the backgrounds/mode1_bg3_priority example.)
Probe oracles: hero_hp (0–5, hearts shown), dialog_shown (0/1) and bg3_high (0/1).
res/noodlebar.png (the noodle bar from above, Néo-Lumen backgrounds/noodlebar.png), res/boxes.png (the panel sheet) and res/residents.png (Kit and the raccoon, from above) are written by devtools/art_assets/build.py (indexed_scene, panel_sheet, panel_residents; CC0, assets/neo-lumen/README.md) and converted from the settings file beside each.
| Region | Content |
|---|---|
| $0000 | BG1 tiles: the bar, 823 tiles (4bpp) |
| $3800 | BG1 tilemap |
| $4000 | BG3 tiles: the panel sheet (2bpp) |
| $4400 | BG3 tilemap, uploaded by panelFlush() |
| $6000 | OBJ: Kit and the raccoon |
console, dma, background, panel, input, sprite
Uses the panel module in isolation. For a full game that combines it with text in the box (dialog lines, a numeric score), see demos/rpg.