Prince of Persia Apple II: Modern Port Experiments
Two experiments on Jordan Mechner's 6502 source for Prince of Persia. A transpiler that turns the animation bytecode into a Rust crate, and a wave function collapse generator for new levels.

Two independent experiments on the Apple II source code for Prince of Persia that Jordan Mechner released in 2012.
6502 assembly to Rust
The animation system in Prince of Persia is a bytecode virtual machine. Mechner wrote a 15-opcode instruction set (goto, act, chx, chy, setfall, die, and so on) and encoded every character state as a short program in it. There are 114 of those programs, 1,525 instructions in all.
A Python pipeline fetches the original .S files, parses the Merlin assembler syntax (two-line jumps, several instructions packed into one db line, labels sharing a line with data, dead do 0 blocks, constant expressions) and emits a Rust crate, pop-engine. The VM and its programs survive intact as a flat array, with zero unresolved jump targets. A handwritten interpreter steps it one frame at a time.
Since then the crate has grown level loading, floor and barrier collision, and a decoder for the delta-RLE compressed double hi-res sprite files. The cover is the result: all 241 frames in one atlas. A small example drives the Prince around a real level with the keyboard.
Wave function collapse levels
The second experiment learns the tile grammar of all 15 original levels (47 tile types, 479 horizontal and 293 vertical adjacency pairs) and generates new rooms with lowest-entropy-first WFC, restarting on contradiction. The output is a valid 2,304-byte level file in the original’s format.
python3 -m transpiler.main
python3 -m wfc.generate --rooms 6 --seed 1989
cargo run --example render --manifest-path pop-engine/Cargo.toml -- .level-cache/LEVEL1