Skip to main content

Building a NES emulator

·

One year ago, on May 25, 2024, I made the first commit of what would become NESd, my NES emulator.

Today, it supports 2.480 games, and runs on macOS (x64 and arm64), Linux (x64 and arm64), Windows, and Android. There is still lots to be done, but I got further than I ever thought I would. It is the personal project that I am most proud of, and I want to share the story of how it came to be.

Early last year, I discovered Modern Vintage Gamer (MVG) on YouTube and started binging his videos. MVG makes videos on retro gaming and emulation. He has been active in the emulation scene for a long time, and has ported many emulators to other platforms, mainly the original Xbox.

In one of his videos, he told the story about how his channel landed him a job in game development. He was recruited by a game studio to port a Game Boy Color game to the Nintendo Switch. There are different ways of porting a game to a different platform, and one of the most common ways for retro games is to use an emulator and ship the original ROM with it.

What caught my attention in MVG’s story was this: Instead of using the code of an existing Game Boy emulator, he wrote a new one From scratch. Within a few days he had a basic working emulator.

This story inspired me. With my passion for programming and experience with emulation, surely I could also write an emulator? I had attempted to write an emulator as a teen and later in college, but never got very far. My skills just weren’t there yet. I had only managed to follow a tutorial on CHIP-8 and was overwhelmed by the complexity of other retro systems. With many more years of programming experience under my belt, and actual professional experience, I decided to try it once again.

But which system should I target? I decided to start with the NES, the Nintendo Entertainment System. Since it is a relatively early console, I figured it would be a simple system, and at least somewhat easy to emulate. I ended up being wrong, but it was still easier to emulate than later consoles.

I started researching the NES and its hardware, and luckily found lots of freely accessible documentation on it. Over the next few weeks, I spent most of my free time researching, programming, getting stuck, and eventually overcoming each hurdle. I quickly realized that it was not as simple as I had hoped, but I kept going.

Within a few weeks I had a basic emulator that supported quite a few games and could emulate the CPU, graphics, and audio. Since then, I have spent many hours on my emulator, adding features, fixing bugs, and optimizing the code. There’s still lots to do, but I am extremely proud of what I have accomplished so far.

Introducing: NESd #

Go check out NESd on GitHub. It is one of many NES emulators, but this one is mine.

Any feedback, bug reports, or feature requests are welcome!

Shout-outs #

This project would not have been possible without the resources provided by many dedicated people:

  • The Nesdev Wiki is a treasure trove of information on the NES hardware and its behavior.
  • The Nesdev Forums features many in-depth discussions on hardware behaviors and emulation techniques.
  • The Mesen emulator by SourMesen is by far my favorite “reference” implementation, showing me how some features could be implemented when I was stuck.