Mode 7 perspective with HDMA split-screen (F-Zero style) More...
#include <snes.h>Functions | |
| void | asm_loadSkyData (void) |
| Load sky background tiles and tilemap to VRAM via assembly DMA. | |
| void | asm_setupHdmaPerspective (u16 sx, u16 sy) |
| Build and activate the 4-channel HDMA perspective split. | |
| int | main (void) |
| Entry point – F-Zero-style Mode 7 perspective with HDMA split-screen. | |
Variables | |
| u8 | ground_map [] |
| Mode 7 ground tilemap (128x128 entries, one byte per tile index). | |
| u8 | ground_map_end [] |
| u8 | ground_pal [] |
| 256-color palette for the ground plane (512 bytes). | |
| u8 | ground_pal_end [] |
| u8 | ground_tiles [] |
| Mode 7 ground tile pixel data (256 tiles, 64 bytes each = 16KB). | |
| u8 | ground_tiles_end [] |
| u16 | pad0 |
| 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.
|
extern |
Load sky background tiles and tilemap to VRAM via assembly DMA.
Loads the Mode 3 sky image (tiles at VRAM $5000, tilemap at VRAM $4000). Uses assembly because the data may span multiple ROM banks (SUPERFREE sections), requiring correct bank byte handling that the C-level dmaCopyVram() cannot provide.
Must be called during forced blank.
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.
| sx | Horizontal scroll offset for the Mode 7 ground plane. |
| sy | Vertical scroll offset for the Mode 7 ground plane. |
| 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.
|
extern |
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).
| u8 ground_map_end[] |
|
extern |
256-color palette for the ground plane (512 bytes).
| u8 ground_pal_end[] |
|
extern |
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().
| u8 ground_tiles_end[] |
| u16 pad0 |
Current joypad button state
| u16 sx |
Mode 7 ground horizontal scroll offset (camera X)
| u16 sy |
Mode 7 ground vertical scroll offset (camera Y)