Mode 7 perspective with HDMA split-screen (F-Zero style). More...
Functions | |
| void | asm_setupHdmaPerspective (u16 sx, u16 sy) |
| Sky (Mode 3, BG2) tiles and 64x32 tilemap, from data.asm. Loaded with dmaCopyVram() to VRAM $5000 (tiles) and $4000 (map). | |
| int | main (void) |
| Entry point – F-Zero-style Mode 7 perspective with HDMA split-screen. | |
Variables | |
| u16 | pad0 |
| Mode 7 ground tilemap (128x128 entries, one byte per tile index). | |
| u16 | sx |
| u16 | sy |
Mode 7 perspective with HDMA split-screen (F-Zero style).
Creates an F-Zero-style pseudo-3D ground plane by combining two BG modes on a single screen using HDMA mid-frame register switching. The top portion (96 scanlines) displays a Mode 3 sky background, while the bottom portion (128 scanlines) renders a Mode 7 ground plane with per-scanline perspective scaling. Four HDMA channels cooperate each frame: one switches BGMODE from Mode 3 to Mode 7 at the split line, another toggles the main screen layer enable (BG2 for sky, BG1 for ground), and two more write per-scanline M7A and M7D values to create the perspective foreshortening effect where distant rows appear more compressed.
Sky (Mode 3, BG2) tiles and 64x32 tilemap, from data.asm. Loaded with dmaCopyVram() to VRAM $5000 (tiles) and $4000 (map).
Build and activate the 4-channel HDMA perspective split.
Configures four HDMA channels that cooperate each frame:
The perspective tables compress distant rows and expand near rows, creating the illusion of a 3D ground plane receding into the horizon. The scroll offsets (sx, sy) control the camera position on the Mode 7 ground.
| int main | ( | void | ) |
Entry point – F-Zero-style Mode 7 perspective with HDMA split-screen.
Sets up a dual-mode display: the top 96 scanlines render a Mode 3 sky background (BG2), while the bottom 128 scanlines render a Mode 7 ground plane (BG1) with per-scanline perspective scaling via HDMA. The D-pad scrolls the ground plane. HDMA tables are rebuilt every frame by the assembly helper to reflect the current scroll position.
| u16 pad0 |
Mode 7 ground tilemap (128x128 entries, one byte per tile index).
Mode 7 tilemaps are 128x128 bytes. Each byte is a tile index (0-255) referencing the 8bpp tile set. Loaded to VRAM via dmaCopyVramMode7() which handles the interleaved format (map in low bytes, tiles in high bytes).
Mode 7 ground tile pixel data (256 tiles, 64 bytes each = 16KB).
Each tile is 8x8 pixels at 8bpp (one byte per pixel, 64 bytes/tile). Written to the high bytes of VRAM words by dmaCopyVramMode7().
256-color palette for the ground plane (512 bytes). Current joypad button state
| u16 sx |
Mode 7 ground horizontal scroll offset (camera X)
| u16 sy |
Mode 7 ground vertical scroll offset (camera Y)