Skip to content

ssakash/RustC8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CHIP-8 Emulator

A CHIP-8 emulator written in Python with pygame for graphics and input.

Features

  • 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

Requirements

  • Python 3.10+
  • pygame
  • numpy

Installation

# Install dependencies
pip install -r requirements.txt

Usage

python main.py <rom_file>

# Examples
python main.py roms/PONG.ch8
python main.py roms/TETRIS.ch8

Controls

Emulator Controls

Key Action
ESC Quit
P Pause/Resume
R Reset
D Dump CPU state (debug)

CHIP-8 Keypad Mapping

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 |
+---+---+---+---+   +---+---+---+---+

Project Structure

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

CHIP-8 Specifications

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)

Configuration

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)

Test ROMs

For testing your emulator, use these recommended test ROMs:

  1. IBM Logo - Displays the IBM logo (tests basic drawing)
  2. Chip8 Test Suite - Comprehensive opcode tests
  3. BC_test - Another opcode test ROM

License

MIT License

About

CHIP-8 emulator written in Python to help beginners make thier emulator.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages