A CHIP-8 emulator written in C++17 with SDL2.
- Full CHIP-8 instruction set (35 opcodes)
- 64x32 monochrome display (scaled 10x)
- 16-key hex keypad input
- Delay and sound timers
- COSMAC VIP and CHIP-48/SUPER-CHIP quirk toggles
- Runtime debug trace
- Configurable CPU speed
- C++17 compiler (clang, gcc)
- CMake 3.20+
- SDL2
- just (optional, for build commands)
brew install sdl2 cmake justsudo apt install libsdl2-dev cmakejust build # debug build with sanitizers
just release # optimized release buildOr with plain CMake:
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --paralleljust br roms/Pong1P.ch8
# or
./build/chip8emu roms/Pong1P.ch8Usage: chip8emu <rom> [-d|--debug] [--chip48] [--cycles N]
| Flag | Description |
|---|---|
-d, --debug |
Enable CPU trace logging to stderr |
--chip48 |
Use CHIP-48/SUPER-CHIP quirks for shift and jump opcodes |
--cycles N |
CPU cycles per frame (default: 10) |
CHIP-8 uses a 16-key hex keypad (0-F), mapped to the QWERTY keyboard:
CHIP-8 QWERTY
1 2 3 C → 1 2 3 4
4 5 6 D → Q W E R
7 8 9 E → A S D F
A 0 B F → Z X C V
ESC— quit
| Component | Value |
|---|---|
| Memory | 4KB |
| Registers | 16x 8-bit (V0-VF), VF is flag |
| Index register | 12-bit (I) |
| Program counter | 16-bit, starts at 0x200 |
| Stack | 16 levels |
| Display | 64x32 monochrome |
| Keypad | 16 keys (0-F) |
| Timers | delay + sound, 60Hz |
| Fonts | 16 chars (0-F), 5 bytes each, loaded at 0x50 |
Some CHIP-8 instructions behave differently between the original COSMAC VIP interpreter and later CHIP-48/SUPER-CHIP variants:
| Opcode | COSMAC VIP (default) | CHIP-48/SUPER-CHIP (--chip48) |
|---|---|---|
8XY6 (SHR) |
Copy VY to VX, then shift VX right | Shift VX in place, ignore VY |
8XYE (SHL) |
Copy VY to VX, then shift VX left | Shift VX in place, ignore VY |
BNNN (JP) |
Jump to NNN + V0 | Jump to NNN + VX |
Use --chip48 for ROMs written for CHIP-48 or SUPER-CHIP.