An art project in software archaeology: the original 1984 Commodore 64 disk of The Castles of Dr. Creep (Ed Hobbs, Broderbund), pulled apart byte by byte and rebuilt in Zig. Disk image becomes 6502 assembly, then annotated assembly, then code that runs natively and in your browser.
Extract. A 1541 filesystem parser reads the 31 files off the disk: the 28 KB engine, a boot loader, a title bitmap, nine music files, and the level data and save files for each castle.
Disassemble. A recursive-descent tracer proves which bytes are code instead of guessing. Routines are named by cross-referencing Robert Crossfield's 2010 C++ reverse-engineering of the same binary.
Run, then lift. A C64 machine model in Zig (6502, VIC-II, SID, CIAs) runs the original engine. A lift table lets native Zig functions take over 6502 routines one at a time, each one testable against the original, until the whole engine is Zig.
Learned from the binary
The engine is a bytecode machine: castles are data files interpreted by per-object handlers for doors, keys, forcefields, mummies, matter transmitters, trapdoors, conveyors, Frankensteins, lightning machines and ray guns.
The game runs with every ROM banked out and drives sprites, input and music from its own raster interrupt.
The options menu opens on RUN/STOP, found the hard way when emulated joystick input kept "pressing" it forever.
The castle menu's order is simply the disk directory order.