oRBIT2002 wrote:
I can't run any of his tests almost cause I get something like "basic frame timing wrong" or similar and I bet it's because of the problem mentioned.
Yeah that's a problem. Have you tried nestest.nes? Perhaps there's a weird CPU bug in your emu causing this to happen in these test ROMs.
Maybe it's not that you're not setting the flag, but rather you're clearing it too soon. From a quick glance at the source, this test ROM seems to just wait a moderately long time for the flag to set, then checks it once (as opposed to most commercial games which poll it constantly). Perhaps your emu is setting it and clearing it before the ROM checks it? If you're automatically clearing the flag at any time other than a $2002 read, try removing that and see if you get past that error -- that'll give you a better idea of what might be causing the problem (note: this is not a solution! You
are supposed to automatically clear the flag at a certain time -- I'm only recommending this for diagnostic purposes)
But it's really hard for me to speculate what the problem could be. The best way to go about solving this problem would be to dump a trace log of your emu running this log and have it display information relevant to the problem (timestamps, $2002 status, etc). This will help you see where the ROM is going wrong, and will give you a better idea of what it's expecting (so you can know what needs to be done to fix the problem).
Believe me, if you put a tracer in your emu, it's an unbelievably valuable debugging tool. This won't be the last time you'll have a use for it.
Quote:
When does the test expects this bit? I mean, on which scanline does it run the test (if everything should work properly of course)? Scanline 241 when the vblank occurs?
EDIT -- oh whoops, I totally misunderstood what you were asking before
*checks*
edit again:
from the source:
Code:
jsr wait_vbl
ldy #25 ; 29800 delay
lda #237
jsr delay_ya8
lda #2;) VBL flag isn't being set
lda $2002
and #$80
jsr error_if_eq
So the test is:
- waiting for VBlank (probably by polling $2002? oddly I couldn't find a 'wait_vbl' label in the source anywhere)
- doing nothing for about 29800 CPU cycles (roughly 1 frame)
- checking VBlank flag once and erroring if it's not set
A full NTSC frame is roughly 29780.667 CPU cycles:
341 PPU cycles per scanline
* 262 scanlines per frame
= 89342 PPU cycles per frame
/ 3 PPU cycles per CPU cycle
= 29780.667
so if the ROM is waiting 29800 cycles, it is checking the flag roughly 20 cycles into VBlank (so almost a fourth of the way through the very first scanline of VBlank)