Eight-direction scrolling over a map of 1,433 distinct characters. More...
#include <snes.h>#include <snes/tilering.h>#include <snes/vramqueue.h>#include "res/archipelago.inc"Classes | |
| struct | Leg |
| One leg: where the camera goes, and how fast (pixels a frame on each axis). More... | |
Macros | |
| #define | CAM_MAX_X (archipelago_WIDTH * 8 - 256) |
| Camera limits: the map less one screen. | |
| #define | CAM_MAX_Y (archipelago_HEIGHT * 8 - 224) |
| Camera limits: the map less one screen (224 lines). | |
| #define | CHR_VRAM 0x0000 |
| The map (opensnes-tilering, from res/archipelago.png and its settings file). | |
| #define | LEGS (sizeof(course) / sizeof(course[0])) |
| Legs in the course. | |
| #define | MAP_VRAM 0x3000 |
| BG1 tilemap, 64x32 entries (4 KB), above the slots. | |
| #define | RING_SLOTS 640 |
| Slots in the ring: the worst screen (389) and room to keep characters for a return. | |
Functions | |
| static u16 | approach (u16 v, u16 target, u16 step) |
| Move v toward target by at most step. | |
| int | main (void) |
| Entry point — the archipelago, flown over. | |
| static u16 | scanline (void) |
| The scanline now, from the PPU's latched counter. | |
Variables | |
| u16 | camx |
| Camera position in map pixels. | |
| u16 | camy |
| FAR u16 | char_of [640] |
| The character of each slot. | |
| static const Leg | course [] |
| The course, from the bottom-left corner and back to it. | |
| u16 | leg |
| The leg being flown. | |
| u16 | manual |
| 1 while the D-pad drives the camera | |
| FAR u8 | refs [640] |
| Cells of the window showing each slot. | |
| TileRing | ring |
| The ring's state (plain RAM). | |
| FAR u16 | slot_of [archipelago_CHARS] |
| The slot of each map character. | |
| FAR u8 | staging [(((33)+(29)) *32)] |
| The frame's new characters, copied from ROM, sent by one or two DMAs. | |
| u16 | tr_cost_55 |
| u16 | tr_cost_7 |
| The worst frame the module predicts for the course's fastest legs (7 px, and 5 + 5). | |
| u16 | tr_direct |
| 1 = direct mode (no staging buffer); a test pokes it before main | |
| u16 | tr_frames |
| Frames of the first lap, and laps completed. | |
| u16 | tr_laps |
| u16 | tr_max_chars |
| Most characters one frame queued (first lap). | |
| u16 | tr_max_cost |
| Most vramQueueCost() before a flush, in bytes (first lap; x 8 = master cycles). | |
| u16 | tr_max_entries |
| Most queue entries one frame noted (first lap). | |
| u16 | tr_max_lines |
| The latest scanline a flush ended on, counted from the start of VBlank (line 225). | |
| u16 | tr_max_resident |
| Most slots in use at once (first lap). | |
| u16 | tr_refused |
| u16 | tr_starved |
| Characters that found no free slot, transfers the queue refused: 0 and 0. | |
| u16 | tr_total_chars |
| Characters loaded over the first lap. | |
| static const TileRingMap | world = archipelago_TILERING_MAP |
| What the converter wrote, in one structure. | |
Eight-direction scrolling over a map of 1,433 distinct characters.
An archipelago of 1280x896 pixels, 160x112 characters, drawn with 1,433 distinct 8x8 characters once mirrored copies are merged: more than the 1,024 a tilemap entry can name, so the whole set never fits VRAM. The screen never shows more than 389 at once (the converter measured every position), and the tilering module keeps a ring of 640 character slots in VRAM: as the camera moves it loads the characters of the column and the row that come into view, and frees the slots of those that leave.
The camera flies a fixed course on its own — up, across, down at a diagonal, at 3 to 7 pixels a frame — so that a test sees the same frames every time; the D-pad takes over (B held: fast), START gives the course back. The figures the course produced are kept in tr_* variables for the test (testing/manifests/scrolling_tile_ring*.toml, testing/tile_ring_budget.py).
The map is invented: devtools/art_assets/tile_ring.py draws it from a fixed seed.
| #define CAM_MAX_X (archipelago_WIDTH * 8 - 256) |
Camera limits: the map less one screen.
| #define CAM_MAX_Y (archipelago_HEIGHT * 8 - 224) |
Camera limits: the map less one screen (224 lines).
| #define CHR_VRAM 0x0000 |
The map (opensnes-tilering, from res/archipelago.png and its settings file).
BG1 characters: the ring's 640 slots, $0000-$27FF (20 KB)
| #define MAP_VRAM 0x3000 |
BG1 tilemap, 64x32 entries (4 KB), above the slots.
| #define RING_SLOTS 640 |
Slots in the ring: the worst screen (389) and room to keep characters for a return.
Move v toward target by at most step.
| v | Current value |
| target | Where it goes |
| step | Most it moves |
| int main | ( | void | ) |
Entry point — the archipelago, flown over.
|
static |
The scanline now, from the PPU's latched counter.
| u16 camx |
Camera position in map pixels.
| u16 camy |
|
static |
The course, from the bottom-left corner and back to it.
| u16 leg |
The leg being flown.
| u16 manual |
1 while the D-pad drives the camera
| TileRing ring |
The ring's state (plain RAM).
The frame's new characters, copied from ROM, sent by one or two DMAs.
| u16 tr_cost_55 |
| u16 tr_cost_7 |
The worst frame the module predicts for the course's fastest legs (7 px, and 5 + 5).
| u16 tr_direct |
1 = direct mode (no staging buffer); a test pokes it before main
| u16 tr_frames |
Frames of the first lap, and laps completed.
| u16 tr_laps |
| u16 tr_max_chars |
Most characters one frame queued (first lap).
| u16 tr_max_cost |
Most vramQueueCost() before a flush, in bytes (first lap; x 8 = master cycles).
| u16 tr_max_entries |
Most queue entries one frame noted (first lap).
| u16 tr_max_lines |
The latest scanline a flush ended on, counted from the start of VBlank (line 225).
| u16 tr_max_resident |
Most slots in use at once (first lap).
| u16 tr_refused |
| u16 tr_starved |
Characters that found no free slot, transfers the queue refused: 0 and 0.
| u16 tr_total_chars |
Characters loaded over the first lap.
|
static |
What the converter wrote, in one structure.