A lightweight and accurate CHIP-8 emulator written in C++ using SDL2 for graphics, input, and audio. Experience classic 8-bit games like Pong, Space Invaders, Tetris, and more!
chip8-emulator/
├── .git/ # Git version control directory
├── src/ # Source code (.cpp and .h files)
│ └── chip8.cpp # Main code
├── roms/ # Place your .ch8 ROM files here
├── build/ # Build output (created by CMake)
├── .gitignore # Git ignore file for C++
├── CMakeLists.txt # CMake build configuration
├── LICENSE # MIT License
└── README.md # Project documentation
sudo pacman -Syu base-devel cmake sdl2 pulseaudio# 1. Clone the repository
git clone https://github.com/Pratyush-gg/chip8-emulator.git
cd chip8-emulator
# 2. Create and enter build directory
mkdir build && cd build
# 3. Configure with CMake
cmake ..
# 4. Build the project
makeThis will create the executable: build/chip8_emu
ROM files from roms/ will automatically be copied to build/roms/ during the build process.
# Basic usage
./chip8_emu roms/Pong.ch8The CHIP-8 system has a 16-key hexadecimal keypad. The mapping is:
| CHIP-8 Key | Keyboard Key | CHIP-8 Key | Keyboard Key | |
|---|---|---|---|---|
1 |
1 |
2 |
2 |
|
3 |
3 |
C |
4 |
|
4 |
Q |
5 |
W |
|
6 |
E |
D |
R |
|
7 |
A |
8 |
S |
|
9 |
D |
E |
F |
|
A |
Z |
0 |
X |
|
B |
C |
F |
V |
Popular CHIP-8 games you can find online:
- Pong - Classic two-player paddle game
- Space Invaders - Shoot the descending aliens
- Tetris - Falling block puzzle game etc.
- Memory: 4KB RAM (0x000-0xFFF)
- Display: 64x32 monochrome pixels
- Registers: 16 8-bit general purpose (V0-VF)
- Stack: 16 levels for subroutines
- Timers: 60Hz delay and sound timers
- Input: 16-key hexadecimal keypad
- Font Set: Built-in 16 character font (0-F)
Build fails with SDL2 not found
# Make sure SDL2 development libraries are installed
sudo apt install libsdl2-dev # Ubuntu/Debian
sudo pacman -S sdl2 # Arch Linux- CHIP-8 Wikipedia
- Cowgod's CHIP-8 Technical Reference
- A high-level guide to making a CHIP-8 emulator
- Building a CHIP-8 Emulator [C++]
- SDL2 Documentation
If you enjoy this emulator, please give it a ⭐ on GitHub!