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.
- SNES Concepts
- Independent per-layer scroll registers (BG1 scrolls, BG2 stays fixed)
- Multiple tile sets sharing VRAM without overlap
- Separate palette slots per layer via gfx4snes
-e flag
- Mode 1 dual-layer compositing (BG1 behind BG2)
- What to Observe
- The shader pattern (BG1) scrolls diagonally and wraps seamlessly
- The logo (BG2) remains stationary in the center
- Both layers composite together with proper priority ordering
- Modules Used
- console, sprite, dma, background
- See also
- background.h, dma.h, video.h
Entry point – mixed scrolling with auto-scrolling BG1 and fixed BG2.
Loads two Mode 1 background layers into non-overlapping VRAM regions:
- BG1: shader pattern (tiles at $4000, tilemap at $1800, palette slot 1)
- BG2: static logo (tiles at $5000, tilemap at $1400, palette slot 0)
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.
- Note
- The extern declarations use scalar syntax (not array) because the data symbols are defined in assembly as labels. Address-of (
&) is used to obtain their pointers for DMA operations.
- Returns
- Does not return (infinite loop).