varunshenoy / rusty-chip8

A CHIP-8 emulator written in Rust ๐Ÿฆ€

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Rusty CHIP-8 Emulator

tetris in chip8

CHIP-8 is an interpreted programming language, developed by Joseph Weisbecker. It was initially used on the COSMAC VIP and Telmac 1800 8-bit microcomputers in the mid-1970s. CHIP-8 programs are run on a CHIP-8 virtual machine.

โ€” Wikipedia on CHIP-8

I first wanted to build a GBA emulator, since I've grown up on those (Pokemon ROM hacks made up my childhood), but it seemed like a lot for a first time emulator. Honestly, implementing every single instruction would have taken forever. I'm also new to Rust, so building a CHIP-8 emulator is a good place to start. Overall, this is a fantastic systems project to learn a new language and have something to show at the end of it all.

I primarily tested this emulator on TETRIS and PONG. Note that it seems like the key debouncer within minifb is not the best, so sometimes keys may not be received properly. This is a first time Rust and "building an emulator" project I've done, so expect some quirks. The TEST ROM (listed below) was also used in debugging the emulator.

Some interesting extensions would be to build an interactive debugger (which would involve the user being able to step through opcode instructions and visually look under the hood to examine registers and the stack) and replacing minifb with sdl2 for better abstractions and proper device periphery separation.

๐ŸŽฎ Advice for Building a Emulator

Instead of writing the emulator and testing it afterwards (as I did in this project), it is best to initially write a minimal amount of code. First, load a ROM. When the interpreter gets to an unimplemented opcode, crash/panic and print the opcode. At that point, write the code to parse the opcode and make sure it gets appropriately handled. This build-test loop chunks this larger project into much smaller pieces and makes sure every opcode gets the attention it needs.

๐Ÿ•น Resources Used:

About

A CHIP-8 emulator written in Rust ๐Ÿฆ€


Languages

Language:Rust 100.0%