Skip to content

Homemade Emulator

You'll write a CPU emulator that passes a published test suite, wrap a whole machine around it with video and keys, and run real software on it at the original speed.

About

Every emulator you've used so far was written by someone who read the CPU manual and did the work, and doing it yourself is how you find out how a machine really hangs together. You'll write a 6502, Z80 or 8080 core in any language, test every instruction against a public test suite until it passes, then add the memory map, video and keyboard of one real machine. The test suites are the thing nobody tells beginners about, and they turn a month of guessing into a week of fixing. The software you run on it is yours, public domain, or a system ROM its owner has released for emulation, which the Spectrum's is. Systems Programming's bytecode machine is a CPU you invented, and this one is a CPU that shipped.

At a glance

Per requirement
50 XP
Completion bonus
600 XP
Requirements
6
Takes
One season
Skill level
Advanced (years of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
With other people
Locked for now
Earn two more Rare badges in Retro Computing to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Implement the CPU's registers, flags and addressing modes, and run your first instruction. Start with a fetch-decode-execute loop and a handful of instructions, and print the registers after each step. Take a screenshot of a short trace with the program counter advancing. Photo
  2. 2
    Pass a published test suite for every documented instruction. The Klaus Dormann functional tests cover the 6502, zexall covers the Z80, and the per-instruction JSON tests from the ProcessorTests project cover both. Fix flags until they all pass, which is where most of the month goes. Take a screenshot of the suite reporting zero failures. Photo
  3. 3
    Add the memory map and I/O of one real machine. ROM, RAM, the video memory and the keyboard register at the addresses the real machine used, from its documentation. Take a photo of your drawn memory map with the matching code beside it. Photo
  4. 4
    Draw the screen and read the keyboard. Render the video memory to a window at the machine's resolution, and map your keyboard onto its matrix. Film typing on your emulator with characters appearing. Video
  5. 5
    Run real software at the original speed, with the frame rate the machine had. Throttle to the original clock and tick a 50 or 60 Hz frame interrupt, then run a program you have the right to run and compare it side by side with an established emulator. Film both running the same thing. Video
  6. 6
    Publish the source and have someone type a program into your emulator. A README that says how to build and run it, and a person who isn't you typing a ten-line program on it and running it. Take a screenshot of the repository and a photo of your tester at it. Photo