6502 XXX-TREME
on

Since the dawn of time I have been interested in making an emulator for some sort of old console, and this week I finally started giving it a shot. The system I picked to work with was the NES, I figured it would be one of the more documented systems with low performance requirements which is pretty important because I hate optimizing my code and am using C# which can be a bit slow compared to lower level languages. Yesterday I finished the first part of this grand project a 6502 CPU emulator. The 6502 was a widely used processor back in the day used in the C64, Atari 2600, Apple I & Apple II, and of course the NES. This meant there was pleennnty of documentation for me to refer to although many systems had slightly different implementations of the CPU with some differing features their docs were still extremely useful. There are around 55 different operations the CPU can perform and like a gazillion addressing types for each one do making this CPU involved a ton of typing though it was quite straight forward for the most part. Actually coding the majority of the opcodes didn't take too long but debugging them to behave with all the subtle nuances and finding out what some obscure NES opcodes actually did seemed to take years. To assist with debugging I found a NES ROM called nestest.nes and a log from a fully function emulator running nestest.nes to compare against. Nestest.nes is an excellent tool that doesn't require video output to work, it runs through most operations the NES needs to support and the edge cases for using them to make sure your CPU can handle everything. But now my 6502 emulator passes nestest.nes so I consider this portion of my grand project pretty much complete, though the CPU cycle counting I'm doing needs a little fine tuning and I wouldn't mind polishing up some code.

Mass6502

My emulator's log in all its glory

It is pretty hard for me to measure the mhz of my emulator at the moment but I think I am crushing the 1.79mhz the NES required. Next I plan to implement the NES PPU so I can get some sort of graphics output from this beast though I am dreading working on it as it seems far more intricate then the CPU. After that I just need controller support and some support for loading the large variety of differing ROM types and hopefully I'll be able to start testing it against actual games instead of test ROMs.