Skip to content
A CHIP-8 emulator in Rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
res
roms
src
.gitignore
Cargo.toml
README.md
invaders.gif

README.md

chip8

A complete CHIP-8 emulator in Rust, which runs most ROMS you can find in the wild. It keeps the CPU at 500 Hz, and draws onto the screen at 60 Hz.

A demonstration GIF of the emulator running invaders.

Running

Execute cargo run filename, where filename is a file in the roms directory.

CPU

Implemented in chip8.rs. The cycle function is where most things happen: two bytes are fetched from the program counter, timers are delayed if necessary (at 60 Hz as per spec), and the CPU branches depending on the instruction fetched.

The load_rom function reads and copies a ROM file and in-memory, starting at the program base pointer, at 0x200.

Each instruction is implemented in its own function in that same file.

Display

The CPU writes onto a 64x32 array that represents video memory. A display implementation must read from this array and upscale the source to get something visualizable. This project provides an SFML-based implementation; take a look at display.rs for the Display trait definition, and display_sfml.rs for our implementation.

Sound

The CHIP-8 specification requires a single 'beep' sound, which plays as long as the sound timer is not zero. We generate 0.5 seconds of a pure sine wave, which is a bid ad-hoc, but has worked well so far.

Roms

The roms folder contains a collection of ROMS from this project: all credits due to the respective authors.

Todo

  • Debugger.
  • Assembler/disassembler (from/to Chipper).
You can’t perform that action at this time.