All paths

Write a CHIP-8 emulator

Build 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.

ESP32-C3-DevKitM-1Free7 lessons6 h3 chapters2,340 XPCoding · Advanced+250 XP

0 of 7 done

What you will build

3 projects, built step by step

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.

Chapter 1 project

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 simulator
Chapter 2 project

Timers and sound

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.

Open it in the simulator
Chapter 3 project

Boss: play a game

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.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

The processor

The machine's state, and the loop that runs it.

  1. Open250 XP

    The machine

    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

  2. ProjectLocked500 XP

    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.

    0 of 5 steps

5 questions, graded as you go.
Chapter 2

Screen, keys and sound

XOR sprites, a keypad on six buttons, and two timers at 60 Hz.

  1. Locked250 XP

    Display

    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

  2. Locked212 XP

    Keypad

    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

  3. ProjectLocked424 XP

    Timers and sound

    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

5 questions, graded as you go.
Chapter 3

Debug and play

A debugger to find a wrong byte, then a whole game.

  1. Locked250 XP

    Debugging ROMs

    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

  2. ProjectLocked454 XP

    Boss: play a game

    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

4 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

The processor

  1. The machineCHIP-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.
  2. Fetch, decode, executeThe 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.
Chapter 2

Screen, keys and sound

  1. DisplayDXYN, 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.
  2. KeypadSixteen 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.
  3. Timers and soundTwo 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.
Chapter 3

Debug and play

  1. Debugging ROMsA 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.
  2. Boss: play a gameThe 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.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Write a CHIP-8 emulator

Is Write a CHIP-8 emulator free?

Yes. 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.

Do I need a real ESP32-C3-DevKitM-1?

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.

How long does Write a CHIP-8 emulator take?

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.

What will I build?

Each chapter ends in a project that puts it together: Fetch, decode, execute, Timers and sound and Boss: play a game.

Where do I start?

With "The machine", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.