Rotating Mode 7 perspective — full matrix driven by 4 HDMA channels.
Port of krom (Peter Lemon)'s Mode7 Perspective demo (PeterLemon/SNES, PPU/Mode7/Perspective). Four HDMA channels each feed one Mode 7 matrix register per scanline (M7A/M7B/M7C/M7D from cos, sin, -sin, cos tables), so the ground plane is BOTH perspective-projected (each line scaled by 20480/y) AND rotated (48 angle steps) — the full affine matrix per line, where graphics/backgrounds/mode7_perspective drives only the two diagonal terms (no rotation).
Rotating means the whole matrix changes per angle: the demo precomputes 48 tables per trig function (krom's exact tables, extracted verbatim; entry(a,y) = trig(2*PI*a/48) * 20480 / y in 8.8 fixed point) and repoints all four HDMA channels each frame.
- SNES Concepts
- Per-scanline Mode 7 matrix writes (perspective + rotation combined)
- 4-channel HDMA coordination on one register family
- HDMA table repointing as a zero-copy animation primitive
- Mode 7 interleaved VRAM (dmaCopyVramMode7)
- What to Observe
- A kart-style track receding to the horizon. D-pad moves over the plane, L/R rotate the world in 7.5-degree steps, Y/A nudge the pivot on X, X/B nudge it on Y (krom's control map).
- Modules Used
- console, dma, background, hdma, input, mode7
- See also
- https://github.com/PeterLemon/SNES — original demo & tables
-
devtools/m7ptables.py — table extraction + math verification
| void repointTables |
( |
void | | ) |
|
|
static |
Point all four matrix channels at the current angle's tables.
cos feeds both diagonal terms (M7A, M7D), sin/-sin the off-diagonal pair (M7B, M7C) — a standard rotation matrix, perspective-scaled per line inside the tables themselves. hdmaSetup() re-arms the channel and reads the bank from the far pointer, so repointing is just four calls.