Tiled map editor integration with the map scrolling engine.
Demonstrates how to use maps created in the Tiled editor (https://www.mapeditor.org/) with the OpenSNES map engine. The map is a large 224x30 tile level (1792x240 pixels) stored in ROM. The map engine streams the visible 32-tile window into VRAM as the camera scrolls, so only the on-screen portion uses VRAM at any time.
The Tiled workflow:
- Design your level in Tiled (paint tiles, set collision properties)
- Export as .tmj (JSON) or .tmx (XML)
- Convert with tmxconv to .m16 (tilemap) + .t16 (tile defs) + .b16 (attributes)
- Convert tileset PNG with gfx4snes to .pic + .pal
- Include all binaries in data.asm
This example uses pre-converted binaries. The original Tiled source file (maplevel01.tmj) is included in res/ for reference.
Ported from PVSnesLib "tiled" example by alekmaul.
- SNES Concepts
- Map engine: mapLoad() / mapUpdate() / mapUpdateCamera() / mapVblank()
- Streaming tilemap: only 32 visible columns are in VRAM at any time
- SC_64x32 tilemap layout at VRAM $6800 (required by map engine)
- Tile data at VRAM $2000 (4bpp, 16-color)
- Horizontal camera scrolling with pixel-level precision
- VBlank DMA for tilemap updates (mapVblank)
- What to Observe
- Press LEFT/RIGHT on D-pad to scroll through the level
- The background scrolls smoothly at 1 pixel per frame
- Notice the level is much wider than the screen (1792px vs 256px)
- The tileset uses platformer-style tiles (platforms, ladders, walls)
- Modules Used
- console, sprite, dma, input, background, map
- See also
- map.h, background.h, input.h, dma.h