Correctly implement INT 48h
drhelius opened this issue · 3 comments
drhelius commented
Interrupt INT 48h - LCD STAT
----------------------------
The STAT register (FF41) selects the conditions that will generate this
interrupt (expecting that interrupts are enabled via EI or RETI and that
IE.1 (FFFF.1) is set).
STAT.3 HBLANK (start of mode 0)
STAT.4 VBLANK (start of mode 1) (additional to INT 40)
STAT.5 OAM (start of mode 2 and mode 1)
STAT.6 LY=LYC (see info about LY=00)
If two STAT-condiditions come true at the same time only one INT 48 is
generated. This happens in combinations
LYC=01..90 and OAM at the same time (see info about LY=00)
LYC=90 and VBLANK at the same time
OAM and VBLANK at the same time
HBLANK and LYC=00 and LYC=91..99 are off-grid and cannot hit others.
Some STAT-conditions cause the following STAT-condition to be ignored:
Past VBLANK following LYC=91..99,00 is ignored
Past VBLANK following OAM (at 00) is ignored
Past LYC=00 at 99.2 following OAMs (at 00 and 01) are ignored
Past LYC=01..8F following OAM (at 02..90) is ignored
Past LYC=00..8F following HBLANK (at 00..8F) is ignored
Past LYC=8F following VBLANK is ignored
Past HBLANK following OAM is ignored
Past HBLANK at 8F following VBLANK is ignored
If the OAM condition occurs, everything following -is- recognized.
An ignored VBLANK condition means that INT 48h does not produce a V-Blank
interrupt, INT 40h is not affected and still produces V-Blank interrupts.
The last LY period (LY=99) is a shorter than normal LY periodes. It is followed
by the first LY period (LY=00) this period is longer than normal periodes.
LY value clks description
-------------------------------
LY=01..8F 456 at the same moment than OAM
LY=90 456 at the same moment than pseudo-OAM and VBLANK
LY=91..98 456 during vblank (similiar to LY=01..8F)
LY=99 ca.56 similiar to LY=91..98, but shorter
LY=00 ca.856 starts during vblank, then present until second OAM
Because of the pre-started long LY=00 period, LYC=00 occurs within vblank
period and before first OAM (where we would have expected it)
*EOF*
RokkumanX commented
Hi
For the layman what does this issue mean and what's the bug?
Thanks in advance!
drhelius commented
The lcdstat interrupt is not yet correctly implemented and some minor games crash or present issues.
RokkumanX commented
Thank you for the explanation, I really love this project and is really looking forward to all it's future improvements!
The code is very easy to work with also and I've made a couple of changes to more customize my needs and there were no problems using Visual Studio 2022 either.
Keep up the good work.