Expand description
The PNG cartridge format.
A Pixel8 cart is a real PNG image — the picture is the cartridge, complete with label art — with the game embedded in a private ancillary chunk. Any image viewer shows the cart; Pixel8 plays it.
Chunk layout (see docs/CART_FORMAT.md for the full story):
PNG signature
IHDR, IDAT*, ... # ordinary PNG image: the cart label art
pxRt # Pixel8 payload chunk:
"PIXEL8" # magic
u16 LE version # cartridge format version (currently 1)
deflate( json( Cart ) )
IENDCart always carries the compiled game.wasm and the full
asset bundle; carts exported as editable also carry the Rust source.
Structs§
- Cart
- Everything inside a cartridge.
Constants§
- CART_
VERSION - Current cartridge format version. Bump (and reject older carts with a clear message) once carts are published; until then format changes are free.
- LABEL_H
- LABEL_W
- Cart image dimensions.
- MAX_
WASM_ SIZE - Hard cap on a cart’s compiled wasm module: 128 K, shared with the memory and fuel limits. Keeps carts small and shareable and rations dependency bloat. Enforced on both save and load.
- MEMORY_
CAP - Hard cap on a cart’s initial linear memory: 128 K, enforced at load (see
vm.rs). Numerically equalsMAX_WASM_SIZEbut is a distinct limit. - WASM_
PAGE_ SIZE - One wasm linear-memory page: 64 KiB.
Functions§
- decode
- Decode and validate a cart from PNG bytes.
- default_
label - The built-in default label used when no screenshot was captured.
- encode
- Encode a cart into PNG bytes.
- encode_
screen_ png - Encode the virtual screen as a standalone PNG (for screenshots and
docs).
scaleis an integer zoom factor. - initial_
memory_ bytes - The initial linear memory a cart commits at instantiation, in bytes,
read from the wasm’s exported
memoryminimum.Nonewhen the wasm cannot be parsed or declares no exportedmemory. - is_cart
- Cheap check: is this PNG a Pixel8 cart? Scans chunk headers for
pxRtwithout decompressing anything — used by cart pickers to filter directories quickly. - load_
png - Load and validate a cart from a PNG file.
- save_
png - Save a cart as a PNG file with label art.