Expand description
Importing PICO-8 cartridge assets.
Pixel8 is a loving homage to PICO-8: it borrows the very same 16-color palette, the same eight chip-tune waveforms and per-step effects, and the same 128x128 sprite sheet and 16-wide sprite layout. That overlap means a PICO-8 cart’s assets — graphics, sprite flags, map, sound effects and music — transfer into a Pixel8 project almost one-to-one. This module does exactly that.
Only the assets are imported. PICO-8 games are written in Lua and Pixel8
games in Rust, so the cart’s code is ignored entirely: the new project
gets a stub src/lib.rs to build against, and the game logic is yours to
write in Rust against the imported art and audio.
Two input formats are understood:
.p8— the plain-text cartridge: labelled__gfx__,__gff__,__label__,__map__,__sfx__and__music__sections of hex (the__lua__section is skipped)..p8.png— the PNG cartridge: the game’s 32 KiB ROM hidden two bits at a time in the low bits of each pixel’s A/R/G/B channels. The image is decoded, the ROM reassembled, and the same fixed memory map PICO-8 uses (0x0000gfx,0x2000map,0x3000flags,0x3100music,0x3200sfx) is read out.
Structs§
- Placement
- Where one kind’s appended items landed in the destination.
- Report
- The outcome of an append: where each kind landed, plus any warnings (e.g. references left pointing at slots that were not part of the selection).
- Selection
- Which source assets to append into a destination cart. Indices are the source PICO-8 cart’s own indices (sprite 0..256, SFX/music 0..64).
Constants§
- IMPORT_
TEMPLATE - Stub
src/lib.rsscaffolded for an imported cart. The assets are real; the game logic is the user’s to write in Rust.
Functions§
- append_
pico8_ assets - Append the selected
srcassets intodest, afterdest’s last used slot of each kind. Imported audio cross-references (music channels and SFX custom-instrument notes) are remapped to the slots their targets landed in; references to slots that were not selected are left as-is and reported as warnings.destis only mutated on success (a capacity or validation error leaves it untouched). - default_
dir_ name - Default project directory name to import a cart into when none is given:
the cart’s name with its suffixes peeled off (
airwolf.p8->airwolf), falling back toimported. - import_
project - Create a new Pixel8 project from a PICO-8 cart’s assets.
- parse_
bytes - Read a PICO-8 cart’s assets from raw bytes, auto-detecting the format.
- parse_
clipboard - Decode a PICO-8 editor clipboard string. Recognises
[gfx]and[sfx]blobs; anything else is an error. - parse_
file - Read a PICO-8 cart’s assets from a file, auto-detecting
.p8text vs.p8.png.