Posts Tagged emulator
Nestacy (NES Emulator)
History
Shortly after graduating (or perhaps at the end of my third year of undergrad) I started work on a NES emulator. It was a good testbed to test out all of the things that I had learnt.
The emulator would of course not have been possible without the immense amount of detail about the internals of the NES available online (I believe most of it is on this site someplace: http://nesdev.parodius.com/).
I started with creating an emulator for the 6502. Some of the results of the opcodes were a bit unclear, and I am sure that my emulator had a few bugs. I think there were some test programs to try out the emulator. The next component was the PPU, and it didn’t take long before I was able to get some crude graphics up. Of course, during this time I had to create a set of utilities to draw debug information for both the CPU and PPU (this became my first windowing toolkit: GWindows). There were still some bugs in the 6502 at that time, but there was a NES rom that tested all of the opcodes (and some of their peculiarities on certain page boundaries) and displayed the results visually. This allowed me to finalize the 6502 core. After that came adding some memory mappers for loading various ROMs. It wasn’t until later on that I added sound, support.
The emulator is still incomplete and doesn’t load all of the available ROMs. There was one bug, however, that I never was able to get rid of. It had to do with the sprite-1 detection and timing. The bug is visible in Super Mario Bro’s, where the sprite1 detect feature is used to switch name tables or something (the coin at the top). In the end it causes the scrolling of the top HUD to be offset incorrectly horizontally (like an erroneous VSync on a TV). I am happy to leave it as one of those bugs that I will never find.
The code is a bit of a mess so I didn’t post it. If someone is actually interested, I would be happy to provide it.
GWindows
The windowing toolkit was also a first for me at the time. There was support for numerous widgets, a file open dialog, and easily subclassable windows. I did end up using this windowing toolkit for other projects (at first the YUV capture system renderer) but never finalized the API.
Screenshots

