A simple, from scratch implementation of the CHIP-8 virtual machine, written in C with SDL2 for graphics and input.
CHIP-8 is a virtual machine, created in the mid-1970s by Joseph Weisbecker to make it easier to write games for early microcomputers such as the COSMAC VIP.
CHIP-8 programs were small, simple, and portable. Many classic games like Pong, Breakout, and Space Invaders were written for CHIP-8.
- Memory: 4096 bytes (4 KB)
- Program start address:
0x200 - Registers:
- 16 general-purpose 8-bit registers (
V0–VF) VFis also used as a flag register
- 16 general-purpose 8-bit registers (
- Index register:
I(16-bit) - Program counter:
PC - Stack: used for subroutine calls
- Display: 64 × 32 monochrome pixels
- Timers:
- Delay timer
- Sound timer
Original CHIP-8 keypad: Mapped keyboard keys:
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
This project depends on:
- SDL2 — for window creation, rendering, and keyboard input
brew install sdl2Verify installation:
which sdl2-configFrom the project root:
makeThis will produce an executable named:
chip8Run the emulator from the terminal and pass a CHIP-8 ROM:
./chip8 path/to/rom.ch8Example:
./chip8 roms/PONG.ch8- Implement the CHIP-8 instruction set faithfully
- Keep the codebase simple and readable
- Make all machine state explicit
This project is intentionally written in plain C, without object systems or heavy abstractions, to keep the machine model visible.
- Implement audio output (beep when sound timer > 0)
- Improve timing accuracy
- Cowgod’s CHIP-8 Technical Reference