Drop the chunk palette; chunks are plain u16 tile arrays

The 64-entry per-chunk palette was a wire-format artifact and capped a chunk
at 64 distinct tiles. A Chunk is now Box<[u16; 1024]> with flags derived from
the id on lookup — the same layout a binary on-disk format would use.

Map path becomes the first CLI argument; assets/map_large is a generated
256×256 stress map (loads in ~0.5 ms release). The snapshot test takes
SNAPSHOT_MAP.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
irrlicht
2026-09-18 23:40:52 +02:00
co-authored by Claude Opus 5
parent 5a055c048d
commit 1d14076468
10 changed files with 317 additions and 104 deletions
+7 -3
View File
@@ -38,7 +38,7 @@ therefore shows up in the CSV as a large *negative* decimal when read as `i32`.
The loader parses each field as `i64`, reinterprets the low 32 bits as `u32`, and strips the
flip flags with `& 0x1FFF_FFFF`, leaving the bare tile id. **Flip orientation is discarded for
now** — flipped tiles render unflipped. Real flipping would need a flip-aware `blit_tile` plus
the flags carried through the chunk palette; deferred to the camera/sprite pass (09).
a flip flag next to the tile id in the chunk; deferred to the camera/sprite pass (09).
---
@@ -57,8 +57,12 @@ No `firstgid` subtraction: the authored ids already line up with `overworld.png`
## World assembly
`load_world` slices the map into 32×32 chunks via `Chunk::generate`, which builds each chunk's
6-bit palette automatically. The map's top-left tile sits at world (0, 0).
`load_world` slices the map into 32×32 chunks via `Chunk::generate`. A chunk is a plain
`[u16; 1024]` of tile ids; flags are derived from the id on lookup (`map::tile_flags`). That
array is also the natural on-disk layout should chunks ever be streamed from disk (RLE over
the `u16`s would do) — the CSV stays the interchange format for external tooling. The map's
top-left tile sits at world (0, 0). Loading a 256×256 map takes well under a millisecond in
release; the map path is the game's first CLI argument (`game assets/map_large`).
**Edge border:** a 30×30 map only fills part of chunk (0,0) (which spans tiles 0–31). Tiles
inside a loaded chunk but outside the authored map are emitted as an *invisible solid border*
+4 -2
View File
@@ -24,8 +24,10 @@ crate's `tick`/`set_action` interface is the seam a server could be wrapped arou
- [x] Pixel helpers: `set_pixel`, `extract`, `blit`, `blit_tile` in `game/src/game/pixelhelper.rs`
— signed `i32` offsets, clip against all four framebuffer edges, per-tile opacity mask
- [x] Input system: `GameAction`, `InputMap`, `InputState` in `game/src/input.rs` (over `pbio::Key`)
- [x] World model: `World` of 32×32 palette-compressed `Chunk`s (64-entry `TileDef` palette,
6-bit tile indices), entities indexed per chunk, `entities_in_viewport`
- [x] World model: `World` of 32×32 `Chunk`s (plain `[u16; 1024]` tile ids, flags derived
on lookup — the network-era 64-entry palette is gone), entities indexed per chunk,
`entities_in_viewport`. Map path is the first CLI argument; `assets/map_large` is a
generated 256×256 stress map
- [x] Map loader: Tiled-CSV parser in `sim/src/map.rs` (flip-flag masking, content-derived
dimensions), `load_world` slices it into chunks, invisible solid border at the map rim.
See `notes/07-map-loader.md`