A CHIP-8 emulator written in Python with pygame for graphics and input.
- Complete CHIP-8 instruction set (35 opcodes)
- 64x32 monochrome display with configurable scale
- 16-key hexadecimal keypad input
- Sound timer with beep
- Debug mode with CPU state dump
- Python 3.10+
- pygame
- numpy
# Install dependencies
pip install -r requirements.txtpython main.py <rom_file>
# Examples
python main.py roms/PONG.ch8
python main.py roms/TETRIS.ch8| Key | Action |
|---|---|
| ESC | Quit |
| P | Pause/Resume |
| R | Reset |
| D | Dump CPU state (debug) |
CHIP-8 Keypad Keyboard
+---+---+---+---+ +---+---+---+---+
| 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 |
+---+---+---+---+ +---+---+---+---+
RustC8/
├── main.py # Entry point with pygame loop
├── chip8/
│ ├── __init__.py
│ ├── cpu.py # Main emulator class with opcode execution
│ ├── display.py # 64x32 display buffer
│ └── keypad.py # 16-key input handling
├── roms/ # Place ROM files here
├── requirements.txt
└── README.md
| Component | Specification |
|---|---|
| Memory | 4KB (4096 bytes) |
| Display | 64×32 pixels, monochrome |
| Registers | 16 × 8-bit (V0-VF) |
| Index Register | 16-bit (I) |
| Program Counter | 16-bit (PC) |
| Stack | 16 levels |
| Timers | 2 × 8-bit (delay, sound) at 60Hz |
| Keypad | 16 keys (0-9, A-F) |
You can adjust emulation settings in main.py:
SCALE = 15 # Pixel scale (15 = 960×480 window)
CYCLES_PER_FRAME = 10 # CPU cycles per frame (adjust for game speed)
FPS = 60 # Target framerate
FG_COLOR = (0, 255, 128) # Pixel color (default: green)For testing your emulator, use these recommended test ROMs:
- IBM Logo - Displays the IBM logo (tests basic drawing)
- Chip8 Test Suite - Comprehensive opcode tests
- BC_test - Another opcode test ROM
MIT License