Opt-in 9-slice panels — bordered boxes on a background layer. More...
#include <snes/types.h>Go to the source code of this file.
Classes | |
| struct | Panel |
| A 9-slice panel layer: one BG tilemap and the sheet to stamp from. More... | |
Functions | |
| void | panelClear (const Panel *p, u8 x, u8 y, u8 w, u8 h) |
| Blank a rectangle of the tilemap, leaving the rest alone. | |
| void | panelDraw (const Panel *p, u8 x, u8 y, u8 w, u8 h) |
Stamp a bordered box of w x h tiles at (x, y). | |
| void | panelFlush (const Panel *p) |
| Upload the tilemap to VRAM under forced blank. | |
| void | panelInit (const Panel *p) |
| Blank the whole tilemap. Call once before the first draw. | |
| void | panelPut (const Panel *p, u8 x, u8 y, u16 tile) |
| Put one tile of the sheet into the map, with the layer's palette and priority. | |
Opt-in 9-slice panels — bordered boxes on a background layer.
Every SNES RPG draws the same thing: a bordered box over the map, with text in it. So does every status bar. Both are a 9-slice panel — corners, edges and a fill stamped from a 3x3 tile sheet — and both were ~60 lines of stamping loop and priority wiring in each game that wanted one.
Blank a rectangle of the tilemap, leaving the rest alone.
The counterpart of panelDraw() for closing one box while others stay.
| p | The panel layer. |
| x | Left column (0-31). |
| y | Top row (0-31). |
| w | Width in tiles. |
| h | Height in tiles. |
Stamp a bordered box of w x h tiles at (x, y).
Coordinates and size are in tiles, in the 32x32 map. A box smaller than 2x2 has no interior and is ignored; anything crossing the map's edge is clipped.
Does not upload — call panelFlush() when the map is how you want it.
| p | The panel layer. |
| x | Left column (0-31). |
| y | Top row (0-31). |
| w | Width in tiles (>= 2). |
| h | Height in tiles (>= 2). |
| void panelFlush | ( | const Panel * | p | ) |
Upload the tilemap to VRAM under forced blank.
One 2 KB DMA covering every panel in the layer. Wraps itself in setScreenOff() / setScreenOn() because 2 KB does not reliably fit VBlank — see the file header.
| p | The panel layer. |
| void panelInit | ( | const Panel * | p | ) |
Blank the whole tilemap. Call once before the first draw.
Entry 0 is written everywhere, which shows the backdrop through the layer. It does not upload — pair it with panelFlush().
| p | The panel layer. |
Put one tile of the sheet into the map, with the layer's palette and priority.
For art that lives in the same sheet as the border — HUD icons, a cursor, a portrait frame. tile is a tile number, not a sheet coordinate.
| p | The panel layer. |
| x | Column (0-31). |
| y | Row (0-31). |
| tile | Tile number (absolute, not relative to base_tile). |