-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GB] Fix LYC-STAT IRQ timing & VBlank scanline handling
- Loading branch information
Showing
1 changed file
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c878372
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a pretty decent fix. LYC-STAT IRQs for Line 0 are actually triggered during VBlank. It seems that Line 153 is technically Line 0. At that time the LCD has reached the top scanline, but it waits 456 cycles (the time it takes to process an entire scanline) before exiting VBlank.
So, that is to say, the timings were off. LYC-STAT IRQs for Line 0 get a sort of head-start before the LCD enters Mode 2 (OAM processing) and before VRAM becomes inaccessible. Several commercial games demonstrate this behavior such as Tomb Raider and Aladdin on the GBC, and Kirby's Dreamland 2 on the DMG (1st scanline of Rick's head didn't work because of this). Others probably rely on this behavior.
Once again, these kind of things are explained absolutely nowhere (maybe in the source code of other emus? certainly not in more formal documentation).