This example shows how to use maps created in the Tiled map editor with the OpenSNES map engine. A 224x30 tile level (1792x240 pixels) scrolls horizontally with the D-pad. Only the visible 32-tile window is in VRAM at any time — the map engine streams new columns as the camera moves.
Step 1. Design your level in Tiled (8x8 pixel tiles, any width/height up to 16384 tiles total). Set per-tile properties: attribute (collision), palette (0-7), priority (0-1).
Step 2. Export as .tmj (JSON format).
Step 3. Convert the tileset image with gfx4snes:
Step 4. Convert the Tiled map with tmx2snes:
Step 5. Include all binaries in data.asm and call mapLoad() in your game.
The SNES has limited VRAM — a 32x32 tilemap is only 2KB. A 224-tile-wide level won't fit. The map engine solves this by keeping the full level in ROM and streaming only the visible 32-tile window to VRAM:
The tilemap lives at VRAM $6800 with SC_64x32 layout — this is required by the map engine.
Each tile in the Tiled editor can have custom properties:
| Property | Tiled Field | SNES Effect |
|---|---|---|
| attribute | Hex string (e.g., "FF00") | Collision type: T_SOLID, T_LADDER, T_SPIKE, etc. |
| palette | Hex string (e.g., "1") | Palette bank (bits 10-12 of tilemap entry) |
| priority | Hex string (e.g., "1") | BG priority bit (bit 13 of tilemap entry) |
These are stored in .b16 (attributes) and .t16 (palette+priority) files by tmx2snes.
| Button | Action |
|---|---|
| LEFT | Scroll camera left |
| RIGHT | Scroll camera right |
| Module | Why it's here |
|---|---|
| console | consoleInit(), WaitForVBlank(), NMI handler setup |
| sprite | OAM buffer (required by NMI handler) |
| dma | DMA transfers for tiles, palette, and map column streaming |
| input | padHeld() for continuous D-pad reading |
| background | BG layer configuration and scroll registers |
| map | mapLoad(), mapUpdate(), mapVblank() — the streaming map engine |
Open tiled.sfc in Mesen2 and scroll with LEFT/RIGHT.
The map engine handles the rest — streaming, scrolling, collision lookups via mapGetMetaTilesProp().