A large Tiled map scrolls as a Mario sprite moves left and right. The map engine streams only the visible tile columns to VRAM, so the map can be much wider than the screen. This is the stepping stone between "static background" and the full continuous_scroll example.
| Button | Action |
|---|---|
| LEFT | Move Mario left (sprite flips, map scrolls) |
| RIGHT | Move Mario right |
The map is too large to fit in VRAM. The map engine solves this:
The sprite's position in the map (xloc) is not its screen position. The screen position is xloc - x_pos, where x_pos is the camera's current offset exported by the map engine.
The sprite cycles through 4 frames (tiles 0, 2, 4, 6). Each 16x16 sprite uses 2 VRAM tiles (top-left + top-right), so frames are spaced by 2. Animation advances every other input frame for natural pacing.
| Module | Why it's here |
|---|---|
| console | consoleInit(), WaitForVBlank(), NMI handler setup |
| sprite | OAM buffer for the Mario sprite |
| dma | DMA transfers for tiles, palette, and map column streaming |
| input | padHeld() for continuous D-pad reading |
| background | BG layer and scroll register configuration |
| map | mapLoad(), mapUpdate(), mapVblank() — the streaming map engine |
Open map_scroll.sfc in Mesen2 and scroll with LEFT/RIGHT.