Fetch, decode, execute
The loop inside every processor: read two bytes at PC, cut them into nibbles, do what they say. Watch a countdown ROM run line by line, hit an instruction the emulator does not know, and teach it.
Open it in the simulatorBuild the classic first emulator in C++ on an ESP32-C3 handheld: memory, fetch-decode-execute, XOR sprites, keys, timers and a debugger, ending with an original game in 151 bytes.
0 of 7 done
7 lessons in 3 chapters, about 6 hours on a simulated ESP32-C3-DevKitM-1. Free, in your browser, every step checked by the simulator.
The loop inside every processor: read two bytes at PC, cut them into nibbles, do what they say. Watch a countdown ROM run line by line, hit an instruction the emulator does not know, and teach it.
Open it in the simulatorTwo timers that tick at 60 Hz: measure the delay timer to the millisecond, make the buzzer follow the sound timer, and edit the ROM for a longer beep.
Open it in the simulatorThe finished emulator runs Space Dodge, an original CHIP-8 game in 151 bytes: steer with the pad, dodge rocks, hear the beeps, and tune the game by editing its machine code.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
The machine's state, and the loop that runs it.
CHIP-8 is a computer that was only ever software. Build its 4 KB of memory, sixteen registers, program counter and font, load a ROM at 0x200, and read it back byte by byte.
0 of 5 steps
The loop inside every processor: read two bytes at PC, cut them into nibbles, do what they say. Watch a countdown ROM run line by line, hit an instruction the emulator does not know, and teach it.
0 of 5 steps
XOR sprites, a keypad on six buttons, and two timers at 60 Hz.
DXYN, the one drawing instruction: 8-pixel sprites from memory, drawn by XOR, with collisions in VF. Draw a rocket, erase it by drawing it again, label it with the font, and count the pixels.
0 of 5 steps
Sixteen CHIP-8 keys on a six-button pad: read the buttons each frame, spot new presses, and run the three key instructions, including FX0A, which stops the program until you press something.
0 of 4 steps
Two timers that tick at 60 Hz: measure the delay timer to the millisecond, make the buzzer follow the sound timer, and edit the ROM for a longer beep.
0 of 4 steps
A debugger to find a wrong byte, then a whole game.
A ROM should write 600D and writes BAD. Drive the built-in debugger from the serial monitor: step, disassemble, set a breakpoint, read the registers, find the wrong byte and fix it.
0 of 5 steps
The finished emulator runs Space Dodge, an original CHIP-8 game in 151 bytes: steer with the pad, dodge rocks, hear the beeps, and tune the game by editing its machine code.
0 of 5 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Write a CHIP-8 emulator are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated ESP32-C3-DevKitM-1 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 6 hours: 7 lessons in 3 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Fetch, decode, execute, Timers and sound and Boss: play a game.
With "The machine", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.