nesdev.com
http://forums.nesdev.com/

Timing of LYC==0
http://forums.nesdev.com/viewtopic.php?f=20&t=14581
Page 1 of 1

Author:  dalton [ Tue Jul 26, 2016 4:05 am ]
Post subject:  Timing of LYC==0

Hi,

does anyone know whether the horizontal timing of the LYC interrupt at Y==0 is different to other rows?

It seems the timing, (the number of cycles before the row graphics is shown) is consistent for all rows but the first. At Y==0 the interrupt seems to occur somewhat earlier.

Cheers

Author:  DarkMoe [ Tue Jul 26, 2016 6:39 am ]
Post subject:  Re: Timing of LYC==0

I guess nobody truly knows,

What I've seen implemented in some emulators is that ly = 0 when the LCD is just turned on has 456 cycles and when it hits VBLANK, ly = 0 has that double timing behaviour (456 * 2).

I have it like that on my emu, but my interrupt code is a mess. Not really sure if theres a demo or game that relies on that specific quirck

Author:  dalton [ Wed Jul 27, 2016 2:34 am ]
Post subject:  Re: Timing of LYC==0

Thanks!

It seems LYC==0 is early by a time corresponding to about one scanline, compared to the other LYC interrupts.
This loop in the beginning of the interrupt at row zero puts it into phase:
Code:
        ld a,56
loop:
        dec a
        jr nz,loop


(cgb double speed)

Author:  tepples [ Wed Jul 27, 2016 4:54 am ]
Post subject:  Re: Timing of LYC==0

Having it be zero during the equivalent of a "pre-render" line would make sense in a way to me.

Author:  binji [ Thu Aug 04, 2016 11:00 am ]
Post subject:  Re: Timing of LYC==0

Wilbert Pol's fork of mooneye-gb has some tests for LY=0. If these are correct, the behavior is that LY=153 lasts for just 4 cycles, then becomes LY=0, even though the mode is still VBLANK. So LY=0 actually lasts for 452 + 456 cycles. But it looks like the LY=LYC interrupt for LY=0 doesn't fire exactly when LY becomes 0, but after a 4-cycle delay. Another interesting case that is likely related: it seems that if you write 153 to LYC on the cycle when LY becomes 0, the STAT interrupt will fire.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/