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.
cargo run filename, where
filename is a file in the
Implemented in chip8.rs.
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.
load_rom function reads and copies a ROM file and in-memory, starting at the program base pointer, at
Each instruction is implemented in its own function in that same file.
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,
display_sfml.rs for our implementation.
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.
- Assembler/disassembler (from/to Chipper).