/chip8

Primary LanguageRust

A Chip8 emulator written in Rust!

Setup

This assumes you have cargo installed. Also, you will need to install sdl2 - see here for install instructions.

Usage: cargo run /path/to/file

Download ya some games!

Chip8 Games

Implementation notes:

I primarily used the "Cowgod's Chip 8 Specification". I found this specification to be quite good but there were a few things that I misinterpreted that cost me a bit of time and, for those who might be reading this in the future, I will mention those things below.

2nnn - CALL addr
Call subroutine at nnn.

The interpreter increments the stack pointer, then puts the current PC on the top of the stack. The PC is then set to nnn.

I found this to be a little confusing as I think what actually needs to happen is that you put the current PC on top of the stack and then increment the stack pointer. Finally, set the PC to nnn. The way this reads is that you would first increment the stack pointer which is not right.

00EE - RET
Return from a subroutine.

The interpreter sets the program counter to the address at the top of the stack, then subtracts 1 from the stack pointer.

Similar to point 1, I misintrepreted the order here. What should happen is that you decrement the stack pointer and then set the program counter to the top of the stack.

Both points 1 and 2 make when you think about what a CALL and RETURN statement should do given a program counter and a stack but I still messed this up the first time.

In general, be careful when adding u8s (ie make sure you account for potential overflows).

Sources: