I've slowly added features to my 'fake' PPU. In fact, I'm by-passing the whole PPU idea entirely! This might not be accurate later, but it seems to work really well right now. I now have backgrounds and sprites and most of their associated features.
On top of this, I figured out a way to 'double buffer' my screen so that I can draw to one while it draws the other, then switch. At 70 FPS (my screen's refresh rate) the game seems to run at 100% speed. If I drop it to 35 FPS it's definitely too fast which is a good sign.
But, as you might see with the attached GIF, Mario isn't moving, Donkey Kong gets him every time! He wants to run, but cannot. I've also tried Mario Bros, and the Kuppas just fall right through the ground, as does Mario. Very strange behavior. I'm thinking one of my instructions isn't right. I've tried a few test roms, and I think they are saying my CMP function isn't right.
Remind me again, is CMP the same as SBC but without changing A? On NesDev.org they have two different 'formulas': one for CMP and one for SBC. That might be because of optimization purposes, but a good reminder would be nice
Thank you everyone! It seems this project just might work in the end!
Chad
Edit:
Here is the code I'm using for CMP and SBC.
Code: Select all
#define CPU_CMP { \
cpu_flag_c = (cpu_reg_a>=cpu_temp_memory); \
cpu_flag_z = (cpu_reg_a==cpu_temp_memory); \
cpu_temp_memory = ((cpu_reg_a-cpu_temp_memory)&0x00FF); \
cpu_flag_n = (cpu_temp_memory>>7); }
#define CPU_SBC { \
cpu_temp_result = cpu_reg_a-cpu_temp_memory+cpu_flag_c-0x01; \
cpu_flag_c = !(cpu_temp_result>0x8000); \
cpu_temp_result = (cpu_temp_result&0x00FF); \
cpu_flag_z = (cpu_temp_result==0x0000); \
cpu_flag_v = ((cpu_temp_result^cpu_reg_a)&(cpu_temp_result^(cpu_temp_memory^0xFF))&0x80); \
cpu_flag_n = (cpu_temp_result>>7); \
cpu_reg_a = cpu_temp_result; }