3.6 KiB
| id | ticket | title | status | created | resolved | decision | tags | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AGD-0004 | tilemap-and-metatile-runtime-binary-layout | Tilemap and Metatile Runtime Binary Layout | open | 2026-03-26 |
|
Pain
The repository has conceptual alignment around map responsibility split and active-window residency, but still lacks a closed runtime binary contract for handheld maps.
Without a canonical decision:
- packer cannot close the output specification for map artifacts;
- runtime lacks one stable reading baseline;
- Studio cannot align authoring and preview schemas with one binary target.
Context
Legacy source: docs/packer/agendas/Tilemap and Metatile Runtime Binary Layout Agenda.md
Domain owner: docs/packer
Cross-domain impact:
docs/vm-archdocs/studiodocs/compiler/pbs
Current discussion premises retained from source:
- visual and collision concerns should remain separated;
- map cells should not duplicate large metadata per tile;
- only a
3x3active window of maps should remain resident in memory; - a
64 KiBtarget budget per map bank has been discussed; map bankandtileset bankdo not need identical size rules.
Open Questions
- Is
collisionIdwith5bits (32classes) sufficient for expected projects? - Should
flag0be reserved for fast trigger semantics or contextual visual variation? - Which optional chunks belong in
V1, and which should wait for a later version? - Must
map bankstay strictly at64 KiB, or should capacity be variable with explicit metadata? - What compression policy should the packer adopt by default for the stream?
Options
Option A - u8 cells with auxiliary tables
- Approach: Store only one
metatileIdper cell and derive collision/flags from side tables. - Pro: Smallest RAM and I/O footprint.
- Con: Pushes too much semantic meaning into external lookup tables.
- Maintainability: Medium.
Option B - u16 bit-packed cells
- Approach: Use
16bits per cell, with a compact split such asvisualId,collisionId, andflag0. - Pro: Balances compactness, deterministic decoding, and enough expressivity for many handheld cases.
- Con: Leaves less room for inline per-cell growth than
u32. - Maintainability: Strong.
Option C - u32 cells
- Approach: Use larger cells to keep more event/flag space inline.
- Pro: Highest flexibility for per-cell triggers and future expansion.
- Con: Doubles memory cost versus
u16without current evidence that it is needed. - Maintainability: Weak for the current budget target.
Discussion
The retained source already converged toward u16 as the best baseline.
The suggested runtime shape is:
- fixed map header;
- contiguous cell stream;
- optional future-proof chunks.
The proposed U16_PACKED_V1 split keeps visual and collision references compact while preserving predictable memory usage and straightforward streaming behavior for a handheld target.
Resolution
Recommended direction: adopt Option B as the baseline.
Imported retained recommendation:
- authorship stays JSON-oriented around compact ids;
- build output packs deterministically into
U16_PACKED_V1; - runtime active-window budget remains explicit;
- any move to
u32should happen only through a later versioned encoding with evidence of need.
Next step suggestion: convert this agenda into a decision that closes U16_PACKED_V1, propagation to docs/vm-arch, Studio editing schema alignment, and implementation planning for roundtrip tests.