Emulating A Fake Console

submited by
Style Pass
2024-04-16 14:00:19

I recently started on an emulator for the CHIP-8. I began the project in Go a few days ago, but switched to Odin because goroutines are too easy and I haven't done much work in Odin lately.

Disclaimer: This post is not a tutorial on building an emulator. Instead, consider it a brain dump. We'll take a look at how the CHIP-8 works, some implementation choices, and an undocumented Odin core package.

The information in this post and my understanding of the CHIP-8 are largely derived from this excellent guide by Tobias V. Langhoff. If you want to build your own, it's a great place to start. The repo for my version can be found here.

While the CHIP-8 never existed as hardware, for all intents and purposes we will be treating it as if it did. This means we'll be dealing with registers, a stack, memory, a display, instructions, etc.

Interestingly, it uses 16 bit opcodes that are interpreted as four nibbles. A great example of this is the drawing instruction DXYN. The entire opcode is 16 bits with the first 4 specifying the type of instruction (D). The second and third sets of 4 bits (X and Y) specify which of the V registers contain the coordinates at which to draw. The final nibble (N) specifies the height of the sprite in pixels.

Leave a Comment