The Castles of

Dr. Creep taken apart and rebuilt in Zig

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.

A castle room drawn by the tutorial's game: a doorway and a doorbell

Read the tutorial

Build your own Dr. Creep from an empty file, in Zig, for the Comet 64: an imaginary 1984 home computer with 64 KB of memory, 8 sprites and a 50 Hz screen. Every chapter ends with the game, as it stands, running right on the page.

Start with the prologue →
A title screen in the style of The Castles of Dr. Creep

Play Dr. Creep

The original game, unmodified, running on this project's from-scratch C64 emulation core compiled to WebAssembly. The game data is copyrighted, so you bring your own disk image; it never leaves your browser.

Power on →

How it works

  1. 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.
  2. 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.
  3. 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