Mixed scrolling with fixed and auto-scrolling background layers. More...
Functions | |
| int | main (void) |
| Entry point – mixed scrolling with auto-scrolling BG1 and fixed BG2. | |
Variables | |
| s16 | scrX = 0 |
| BG1 tile data – repeating shader pattern (4bpp, tiles at VRAM $4000). | |
| s16 | scrY = 0 |
| BG1 vertical scroll offset (auto-incremented each frame). | |
Mixed scrolling with fixed and auto-scrolling background layers.
Layers two Mode 1 backgrounds: BG1 displays a repeating shader pattern that auto-scrolls diagonally each frame, while BG2 shows a static logo that remains fixed. Each layer uses its own tile set and palette slot in VRAM and CGRAM (BG1 tiles at $4000 with palette slot 1, BG2 tiles at $5000 with palette slot 0). The tilemaps are placed at non-overlapping VRAM addresses ($1800 for BG1, $1400 for BG2). This demonstrates how the SNES PPU composites multiple BG layers with independent scroll offsets, making it straightforward to combine static UI elements with animated backgrounds.
| int main | ( | void | ) |
Entry point – mixed scrolling with auto-scrolling BG1 and fixed BG2.
Loads two Mode 1 background layers into non-overlapping VRAM regions:
Each frame, BG1's scroll position is incremented diagonally by 1 pixel in both X and Y, causing the shader pattern to scroll continuously. BG2 has no scroll updates, so it remains fixed on screen. The SNES PPU composites both layers together, with BG2 (the logo) appearing on top of BG1 due to default priority ordering.
| s16 scrX = 0 |
BG1 tile data – repeating shader pattern (4bpp, tiles at VRAM $4000).
BG1 palette (16 colors loaded to CGRAM slot 1, offset 16).
BG1 tilemap (32x32 tile grid loaded to VRAM $1800).
BG2 tile data – static logo (4bpp, tiles at VRAM $5000).
BG2 palette (16 colors loaded to CGRAM slot 0, offset 0).
BG2 tilemap (32x32 tile grid loaded to VRAM $1400).
BG1 horizontal scroll offset (auto-incremented each frame).
| s16 scrY = 0 |
BG1 vertical scroll offset (auto-incremented each frame).