Skip to content

morukele/Chip-8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chip-8 Interpreter

A fully functional Chip-8 interpreter written in Rust, demonstrating deep understanding of emulation, low-level systems programming, and graphics rendering.

Technically, it is an interpreter and not an emulator.

Key Achievements

  • Accurate CPU Emulation: Implemented all 35 Chip-8 opcodes with precise instruction decoding and execution logic
  • Memory Management: Designed and implemented a complete memory model (4KB RAM, stack, and registers) with proper address mapping
  • Graphics Rendering: Integrated SDL2 for pixel-perfect display rendering at configurable scales
  • Input Handling: Built a complete input system mapping hexadecimal keypad to AZERTY keyboard layouts
  • ROM Compatibility: Successfully runs multiple ROM files including IBM logo, test suites, and games (Space Invaders, Pong variants)

Technical Learning Outcomes

Through this project, I learnt about the following subjects:

  • Low-level systems programming: Understanding CPU instruction cycles, opcode, memory layout, and register operations
  • Rust systems programming: using Rust for systems programming and working with binary operations
  • Emulation architecture: Learning how interpreters decode and execute instructions, manage state, and handle timing
  • SDL2 integration: Graphics programming and real-time input handling in Rust

Project Demo

IBM Logo ROM

IBM Logo ROM displayed on Chip-8 interpreter

Test ROM - All Digits Passing

Test ROM displaying all digits correctly

Space Invaders Gameplay

Space Invaders ROM running on Chip-8 interpreter
Space Invaders in-game action

Simple Video Game

Simple video game running on the interpreter

Requirements

  • SDL2: Graphics and input library. Must be installed else program will not compile.
  • Rust: 1.56 or later

Usage

Clone the repository and navigate to the project directory:

git clone https://github.com/morukele/Chip-8
cd Chip-8

Running the Interpreter

cargo run -- -r ROM-NAME

This runs the interpreter with default settings and loads the specified CHIP-8 ROM file.

Command-line Options

  • -r, --rom: Name of CHIP-8 ROM file (include file extension) [default: 1-chip8-logo]
  • -s, --scale: Display scale factor [default: 10]
  • -h, --help: Print help information
  • -V, --version: Print version information

Example with Custom Settings

cargo run -- -r space_invaders.ch8 -s 15

AZERTY Keyboard Mapping

The Chip-8 was originally designed for AZERTY keyboards. This interpreter maps the 16-key hexadecimal keypad as follows:

Chip-8 Key AZERTY Key
1 &
2 é
3 "
C '
4 a
5 z
6 e
D r
7 q
8 s
9 d
E f
A w
0 x
B c
F v

Resources

About

An implementation of the Chip-8 emulator (interpreter) written in Rust.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages