Just a GL 7F28 CHIP-8 emulator written in Rust πΎ
Chip-8 is a virtual machine and easy-to-use interpreted programming language from the late 70's. Typically, the roms are in a compiled form - which is what this emulator executes. Since it wasn't accompanied by dedicated hardware, there are specifications on all the components a Chip-8 implementation should have.
This project was made after i had Computer Architecture and Organization classes, a pretty cool subject that made me want to get my hands dirty with emulation.
With this in mind, if you're curious about those topics take a look at this repo's resources! It's more hands-on approach, but there is definitely something to be learned, like how a computer executes instructions, branches execution, and more.
Also, the code is thoroughly commented, and should be easy to follow if you're familiar with rust.
The only caveat is the fb.glutin_handle_basic_input
function, at the end of main
, which is heavy library
code - input
is just a recap of a frame's input events from OpenGL.
Here are some specs of my Chip-8 implementation:
- 500 Hz Clock
- 4Kb of RAM memory (512 bytes reserved to the Virtual Machine)
- 64x32 display (resizeable with OpenGl)
- 16 8-bit data registers, plus some other special ones
- 60Hz playback rate
You'll need
cargo
andlibsdl2-dev
to build rusty-8.
cargo install --branch main --git https://github.com/gabrielvictorcf/rusty-8 rusty-8
You can git clone https://github.com/gabrielvictorcf/rusty-8.git
to get the roms, or just
go to roms
and download them individually. Then, all that's left is to:
rusty-8 <rom_path> # opens the emulator and executes given rom!
Some games might be buggy - this is unrelated to the emulator itself, and depends more on how the game was programmed. Also, if you find the window a bit large, it's resizeable.
Chip-8's original keyboard and this emulator's keyboards are as follows:
Original Rusty-8
βββββ¦ββββ¦ββββ¦ββββ βββββ¦ββββ¦ββββ¦ββββ
β 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 β
βββββ©ββββ©ββββ©ββββ βββββ©ββββ©ββββ©ββββ
There are also some additional emulator/window controls:
- Window close -
Esc
orCtrl+W
- Emulator reset -
Ctrl+R
All of these are amazing, free, resources that make learning/implementing Chip-8 quite a pleasure. Big thanks to all of these creators!
- Matt Mikolay's Chip-8 Technical Reference
- Cowgod's Chip-8 Technical Reference
- Test rom
- Game roms
More game roms shouldn't be hard to find around the internet.
This was built using some nice crates, so thanks to their creators as well.
All code in this repository is licensed under the MIT License, and thus is of free use.