Nick Wilson

Home Projects Github Contact

Bayfield Emulator

A simplified Gameboy emulator


Running the Gameboy version of Tetris

Running Donkey Kong Land 2

Final project for CSC 350: Computer Architecture

As a final group project for a Computer Architecture course, three of us decided to write a Gameboy emulator. This presented a mix of work topics including a lot of research, CPU & GPU emulation, user input management, and a lot of debugging.

My area of focus was the graphics emulation. Nintendo used a variety of complicated and often under-documented tricks to try to squeeze more out of the Gameboy's anemic hardware. The Gameboy relied on virtual HBLANK and VBLANK periods to update sprites and background tiles. Mistakes with this timing early on caused subtle bugs that proved difficult to track down, due to games having a hard-coded expectation of how long certain operations took.

If I could point to one thing in this project I was most proud of, it would be the GPU's render function. I implemented a stateful GPU object and channeled the spirit of Duff's Device to allow the GPU to iterate any number of clock cycles, return for the CPU to run, and then when called again later, resume exactly where it left off. This allows precise and accurate timing for the GPU, and means that the virtual GPU is working on exactly what the game's code expects at any time.

As a group project

I was initially concerned about working on something of this scale collaboratively. It made sense, it was outside of the scope of what any one of us could have done in the provided time frame, but group projects, even at a university level, often turn out to be more effort than they're worth. Fortunately, once we got started it became clear that there were easy ways to split up the work to avoid duplicated work or to limit reliance on others' work.

I actually found that I enjoyed spending time working on my part and then having a look at the other contributors' work to see what they were doing. This allowed me to check that I was on track and that my work would be compatible with the rest of the project when I came time to piece it all together.

Final word

Ultimately, the first time I was able to play a game, I was overjoyed. There were still bugs, but I couldn't believe that we had produced a working product. I knew we would have something, but actually seeing it made all the 1 AM debugging sessions worth it.

For reference, for this project we were awarded an A+ (100%).

V1.1.0+

This project is still under active development! Check the Github page for the latest progress.