Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly implement INT 48h #158

Open
drhelius opened this issue Dec 22, 2021 · 3 comments
Open

Correctly implement INT 48h #158

drhelius opened this issue Dec 22, 2021 · 3 comments
Labels

Comments

@drhelius
Copy link
Owner

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*
@drhelius drhelius added the bug label Dec 22, 2021
@RokkumanX
Copy link

Hi

For the layman what does this issue mean and what's the bug?

Thanks in advance!

@drhelius
Copy link
Owner Author

drhelius commented Dec 26, 2021

The lcdstat interrupt is not yet correctly implemented and some minor games crash or present issues.

@RokkumanX
Copy link

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.

@drhelius drhelius added this to Backlog Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants