rustic_chip is a CHIP-8 emulator written in Rust. It uses SDL2 for video/input and Rodio for audio, and it supports loading and running CHIP-8 ROMs from the command line.
- CHIP-8 CPU core with opcode decoding and execution
- 64x32 monochrome framebuffer
- SDL2 window rendering
- Keyboard input mapped to the CHIP-8 keypad
- Basic beep sound support through Rodio
- Fontset loaded into memory at startup
- Rust toolchain with Cargo
SDL2 needs the native development libraries installed on your system.
On Debian or Ubuntu:
sudo apt update
sudo apt install libsdl2-devOn Fedora:
sudo dnf install SDL2-develOn Arch Linux:
sudo pacman -S sdl2cargo buildFor a faster optimized binary:
cargo build --releaseThe emulator expects a CHIP-8 ROM path as the first argument.
cargo run -- "/path/to/your/rom.ch8"If you already built the binary:
./target/debug/rustic_chip "/path/to/your/rom.ch8"If the ROM path contains spaces or brackets, keep it quoted.
This repository does not include ROM files. You can get CHIP-8 ROMs from:
https://github.com/kripod/chip8-roms/tree/master
The keypad uses a standard CHIP-8 layout:
CHIP-8 keypad Keyboard mapping
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
Additional keys:
Escapeexits the emulator
src/
main.rs
display/
display.rs
mod.rs
internals/
audio.rs
chip8.rs
constants.rs
mod.rs
opcodes.rs
This contains the main emulator state:
- memory
- registers
- index register
- program counter
- video buffer
- stack
- timers
- keypad state
It also handles:
- loading ROMs
- advancing CPU cycles
- mapping SDL keyboard input into the CHIP-8 keypad
This file contains:
- opcode enum definitions
- opcode decoding
- opcode execution logic
This file handles:
- creating the SDL2 window
- uploading the CHIP-8 framebuffer to a streaming texture
- presenting frames on screen
The current loop in src/main.rs does the following:
- Reads the ROM path from the command line
- Creates a
Chip8instance - Loads the ROM into memory
- Creates the SDL2 display
- Polls SDL events
- Executes multiple CPU cycles per frame
- Presents the framebuffer
- Sleeps briefly to keep the loop close to 60 Hz
