- When I wrote my CPU core, I used a single reference that 1 CPU clock equals to 3 PPU clocks. By reading the CPU opcodes reference, it seems clear enough that if a certain instruction (example) uses 1 cycle to fetch the opcode, another for the immediate byte and another for reading memory, so the PPU would execute 3 cycles per CPU cycle. By the way, the last CPU test ROMs fail and nobody could make my question answered... I knew the "half" CPU cycle thing, but what about the PPU itself? An hypotetical example (sorry for those ones that dislike pasting any code):
The following block gives me an error of +1 CPU cycle. I wonder why...
Code:
//this is pseudo-code
opcode = readmem(cpu->PC); ppu_clock(3);
byte = readmem(cpu->PC); ppu_clock(3);
cpu->A = readmem(byte);
ppu_clock(3); //executes 3 PPU cycles
opcode = readmem(cpu->PC); ppu_clock(3);
byte = readmem(cpu->PC); ppu_clock(3);
cpu->A = readmem(byte);
ppu_clock(3); //executes 3 PPU cycles
The following block gives me an error of +1 CPU cycle. I wonder why...