A feature-complete Chip-8 interpreter written in C++11, using SDL2 for rendering and input handling. This emulator runs standard Chip-8 ROMs (games/programs).
- Full Opcode Support: Implements the standard Chip-8 instruction set.
- Scalable Graphics: Resizable window with configurable scale factor.
- Configurable Speed: Adjustable CPU cycle delay to control emulation speed.
- Cross-Platform: Runs on Linux, Windows, and macOS (requires SDL2).
- Keyboard Input: Maps modern keyboards to the hex keypad.
To build this project, you need:
- C++ Compiler (GCC, Clang, or MSVC) supporting C++11.
- CMake (Version 3.14 or higher).
- SDL2 Library (Development headers).
sudo dnf install gcc-c++ cmake make SDL2-develsudo apt-get install build-essential cmake libsdl2-dev-
Clone or download this repository.
-
Open a terminal in the project folder.
-
Run the following commands:
# Create a build directory
mkdir build
cd build
# Generate the Makefile
cmake ..
# Compile the executable
makeRun the emulator from the command line. You must provide three arguments:
./chip8 <Scale> <Delay> <ROM_Path>-
Scale: Integer. Multiplies the original 64x32 resolution. (Recommended: 10 to 20).
-
Delay: Integer. Milliseconds to wait between CPU cycles. Lower is faster. (Recommended: 1 to 4).
-
ROM_Path: Path to a valid .ch8 or .rom file.
To play Pong with 15x scale and 3ms delay:
./chip8 15 3 ../roms/PONGThe original Chip-8 used a 16-key hexadecimal keypad (0-F). This emulator maps them to the left side of your QWERTY keyboard:
| Chip-8 Key | Keyboard Key | Action (Standard Games) |
|---|---|---|
| 1 | 1 | |
| 2 | 2 | |
| 3 | 3 | |
| C | 4 | Player 2 Up (Pong) |
| 4 | Q | Player 1 Up (Pong) |
| 5 | W | |
| 6 | E | |
| D | R | Player 2 Down (Pong) |
| 7 | A | Player 1 Down (Pong) |
| 8 | S | |
| 9 | D | |
| E | F | |
| A | Z | |
| 0 | X | |
| B | C | |
| F | V |
- ESC: Exit the emulator.
-
Source/Chip8.cpp/hpp: Core CPU logic, memory, and opcode implementation. -
Source/Platform.cpp/hpp: Handles graphics (SDL2) and input events. -
Source/Main.cpp: Entry point, main loop, and argument parsing. -
CMakeLists.txt: Build configuration.
-
"Segmentation Fault": Usually happens if the ROM path is incorrect. Double-check that the file exists and the path is right relative to where you are running the terminal command.
-
Game is too fast/slow: Adjust the second argument (Delay). Increase the number to slow it down, decrease it to speed it up.
A big thanks to Austin Morlan and his blog
