Sunday, September 26, 2010

I've been able to get a lot of work done on the CPU. I'm not an assembly programmer. All of the programming I've ever done has been from a high language level, so it's interesting to see the actual instructions that the CPU offers. I've been able to spend the last few weeks implementing the instruction set. I've tried to be rigorous in testing, but the CPU itself isn't really all that functional. It only makes sense in context and right now I know nothing about that context. I've become pretty familiar with the 6502 instruction set, but know very little about how it's actually programmed. I have no idea how it actually places graphics on the screen or plays sound. I assume it involves placing information at some point in memory since that's pretty much all that the CPU instruction set does. I'm looking forward to implementing the screen and the PPU. That ought to be pretty interesting. Once I've done that I ought to be able to get the CPU to actually do something and will hopefully be able to start debugging. Right now I'm emulating the CPU, but have not started emulating the entire system.

Monday, September 6, 2010

Since I last posted I've done a bit of work. I released the current version of the code as of last week some time via Google Code. This is located here. I'll probably release on there once a week or so. Of course, it doesn't do anything really just yet, so there's very little reason to look at it, but it's there.

So far as the emulator goes, I'm starting to realize how huge of a project this is. I'm working exclusively on the CPU. The main function of the CPU is to do manipulations on values in memory, so getting memory to function properly has been a pretty big project lately. Right now I'm focusing mainly on the program memory, which is held in basically the last half of the total memory that the NES has. I really need to get the front half working.

That said, I've begun a small amount of work on the CPU itself. I've only written one of the 50 or so commands that the 6502 supports. I started with AND. I started alphabetically and skipped ADD because ADD is actually pretty complicated. AND was a much nicer starting point. I need to take a look at the flags. I don't understand all of them very well. The 6502 supports 13 different memory addressing modes. I've implemented something like the first two addressing modes.

The problem I'm having so far is that I need to find some means of writing test cases for the CPU based on the way the CPU really functions. I can write test cases, but these test cases will be based on my understanding of the CPU, which is limited. Testing of the CPU is going to need to be pretty thorough.

I've found a couple of documents pretty useful:
http://nesdev.parodius.com/6502guid.txt
http://nesdev.parodius.com/6502jsm.zip
They both describe the available instructions. 6502guid.txt was really helpful in understanding the memory addressing modes.