The new PPU

I have completed recoded the PPU, as well as made updates to other logic in preparation for the PPU changes. Although graphically, the games look a lot worse, they are actually a lot better now. Before, the PPU render code was about 250 lines, with lots of bit shifting and logic. Now it's about 12 lines of code, consisting mainly of updating the vram pointer. The reason the graphics are messed up is due mainly to timing issues. I've got a full day tomorrow (well later today technically) working on my new place, so I'm not sure how much I'll get done on Saturday; but next on the list is to get the sprite engine in -- as well as getting CPU and video clocks syncd properly, which should fix the rendering issues; at which point scrolling should also be supported inherently.

Here's what it looks like with the new PPU:

Update

I've been busy doing non-emulator stuff today, but I did get a bit done last night. First off, I re-coded the outer PPU logic to run the scanlines in the exact order specified in the docs I've been reading. Also, I am now using the address register (again, as the docs specify). However, I have two docs saying two different things about how to increment the values, so I'm going to have to figure out the true way to adjust the pointer through trial and error (once again proving that I need to write a doc on how everything works when I'm done). I've also added the logic to properly mirror memory locations for the name tables (depends on the properties cartridge itself). Right now I only coded for vertical and horizontal mirroring. As far as current progress goes, I can tell scrolling somewhat works; but most of the screens are garbage right now. Hopefully I can get my logic working and post some new screens soon.

Teardown Time

OK, it's time for me to finally tear down the PPU logic and build it back up from scratch the correct way. Before, I was calculating values and offsets to tables using C++ variables (seems obvious right?). Now, I am using processor registers just as the real NES would. This will not only speed up my emulation, but will also fix some problems, as games expect certain registers to be modified -- and by me not touching it, it's causing problems.

Wish me luck, this is going to be one of the hardest parts of the whole emulator!

It's time for timing

OK, now that the CPU is working good, I have gotten my hands on a handful of timer roms to check the order of things. I want this emulator to be as close to the real NES as possible, so it is my goal to be able to pass every one of these test roms if at all possible (they all claim to pass on real NES hardware). This means when I get back into writing my PPU, I'm going to have to pay close attention to the clock cycles and how they sync together. I already had to add a delay cycle count for interupts.

Anyway, here's a picture of nestress with a not-broken CPU:
Notet that the numbers above the PPU Test line ARE there when ran in other emulators as well. This screen looks (sans color) exactly as it should; a bit better than what it looked like a few days ago I say.

Finally

I have finally gotten all of the ops working properly. Most of them WERE good, but I had a bug in my BIT opcode which caused some of the evaluations to be weird. Anyway, here's the screenshot:


I still need to go ahead and add in support for the "undocumented" opcodes just so that I can be sure that the processor is working as advertised.

New Screenshots

Alright guys, I have replaced the SBC and ADC functions with inline assembler so that the processor can do the hard work for me (natively too). I've also fixed a few other "bugs". I call it "bugs", but it really deals with buggy documentation or mission information. This is one of the reasons why I'm going to write a full guide for everything when this is done. Even if you follow all of the documentation to the letter, your system will not be correct!

Anyway, here's the good stuff. Keep in mind that my bit2-3 color logic is still not working so the colors will be messed up:




CPU Updates

I spent most of the day doing stuff away from my computer, but I've made a lot of progress in passing these tests. Right now SBC seems to be the big holdup.