Skip to content

Commit da4da23

Browse files
author
nils
committed
Document MPX asset pack format
1 parent 50b3397 commit da4da23

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,51 @@ python tools\minipixels.py package
248248

249249
The Python CLI validates project JSON, reads 8-bit RGB/RGBA image assets at build time, writes a deterministic MiniPixels asset container (`assets.mpx`), generates deterministic MiniLang asset modules, emits SpriteSheet helper factories for assets with `sheet` metadata, includes runtime assets such as `type: "audio"` or `type: "file"` in the pack, generates `generated.levels` from MiniPixels or Tiled JSON when `levels.path` is present, writes `asset-report.json`, and invokes the regular MiniLang compiler. Image payloads inside `assets.mpx` are PNG-encoded in the MiniPixels runtime profile and decoded by MiniLang code through `mp.loadPngFromPack(...)`. Audio payloads can be loaded as bytes and played directly from memory through WinMM `SND_MEMORY` clips, so example builds no longer need loose WAV files next to the executable. The native MiniLang CLI can already validate manifests and generate importable modules for `procedural` sprites and MiniPixels `levels.json`.
250250

251+
## MPX Asset Pack Format
252+
253+
`assets.mpx` is MiniPixels' deterministic runtime asset container. It is intentionally simple: a fixed header, a compact entry table, and contiguous payload bytes.
254+
255+
All multi-byte integers are unsigned little-endian values.
256+
257+
```text
258+
offset size field
259+
0 4 magic bytes: "MPX1"
260+
4 4 entry count: u32
261+
8 variable entry table
262+
... variable payload bytes
263+
```
264+
265+
Each entry table record is:
266+
267+
```text
268+
size field
269+
2 asset id byte length: u16
270+
N asset id as UTF-8 bytes, no terminator
271+
1 kind: u8
272+
1 flags: u8, currently 0
273+
4 payload offset from start of file: u32
274+
4 payload size in bytes: u32
275+
```
276+
277+
Current `kind` values:
278+
279+
| Kind | Asset type | Payload |
280+
| --- | --- | --- |
281+
| `1` | `image` | MiniPixels PNG-profile bytes |
282+
| `2` | `audio` | Original audio file bytes, usually WAV |
283+
| `3` | `file` | Original file bytes |
284+
285+
Image assets are transcoded by the Python CLI into the MiniPixels PNG profile before they are written to the pack. That profile is deliberately narrow so the MiniLang runtime decoder stays small: 8-bit RGBA, PNG filter type `0`, non-interlaced, and a zlib stream made of stored Deflate blocks. Audio and file assets are stored byte-for-byte.
286+
287+
Runtime APIs:
288+
289+
```ml
290+
pack = mp.openAssetPack("assets.mpx")
291+
img = mp.loadPngFromPack(pack, "player")
292+
raw = mp.loadBytesFromPack(pack, "coin_sfx")
293+
kind = mp.assetKindFromPack(pack, "coin_sfx")
294+
```
295+
251296
## Mini Code Examples
252297

253298
Text:

0 commit comments

Comments
 (0)