Hello everyone!
I'm new here, and I'm developing a NES emulator as a personal project/for fun.
It's getting to be quite accurate, but now I've hit a snag that I can't seem to overcome by myself.
No matter what I try, I can't pass the cpu_interrupts_v2 test #4. (IRQ and Sprite DMA test). It's always off by one instruction at some point.
I've tried fiddling with both Sprite DMA and frame IRQ timings, but to no avail.
So, how many CPU cycles do frame irq/sprite dma take?
- For frame IRQ, I'm counting 29833 cycles if $4017 is set to $00 at an even cycle, and 29834 if it's set at an odd cycle;
- For sprite DMA, I'm counting (after the initial 4 STA cycles), 514 cycles if $4014 is written at an even cycle, or 513 if $4014 is written at an odd cycle. If the IRQ triggers during sprite DMA, I delay it by one instruction;
Is this correct? I've tried many things to no avail, it always fails somewhere, so I must be doing something wrong.
With the timings I described above, this is the result I get:
Thanks in advance for all the help!
I'm new here, and I'm developing a NES emulator as a personal project/for fun.
It's getting to be quite accurate, but now I've hit a snag that I can't seem to overcome by myself.
No matter what I try, I can't pass the cpu_interrupts_v2 test #4. (IRQ and Sprite DMA test). It's always off by one instruction at some point.
I've tried fiddling with both Sprite DMA and frame IRQ timings, but to no avail.
So, how many CPU cycles do frame irq/sprite dma take?
- For frame IRQ, I'm counting 29833 cycles if $4017 is set to $00 at an even cycle, and 29834 if it's set at an odd cycle;
- For sprite DMA, I'm counting (after the initial 4 STA cycles), 514 cycles if $4014 is written at an even cycle, or 513 if $4014 is written at an odd cycle. If the IRQ triggers during sprite DMA, I delay it by one instruction;
Is this correct? I've tried many things to no avail, it always fails somewhere, so I must be doing something wrong.
With the timings I described above, this is the result I get:
Thanks in advance for all the help!