T-cycle accurate timing of the extra OAM interrupt. Fixes vblank_stat_intr-GS, related to
@@ -426,7 +426,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
GB_STATE(gb, display, 23);
GB_STATE(gb, display, 24);
GB_STATE(gb, display, 25);
-
+ GB_STATE(gb, display, 26);
}
if (!(gb->io_registers[GB_IO_LCDC] & 0x80)) {
@@ -743,25 +743,25 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
if (!gb->is_cgb) {
gb->ly_for_comparison = -1;
}
+ GB_SLEEP(gb, display, 26, 2);
if (gb->current_line == LINES) {
gb->oam_interrupt_line = gb->io_registers[GB_IO_STAT] & 0x20;
trigger_oam_interrupt(gb);
}
GB_STAT_update(gb);
gb->oam_interrupt_line = false;
- GB_SLEEP(gb, display, 12, 4);
+ GB_SLEEP(gb, display, 12, 2);
gb->ly_for_comparison = gb->current_line;
if (gb->current_line == LINES) {
/* Entering VBlank state triggers the OAM interrupt */
gb->oam_interrupt_line = gb->io_registers[GB_IO_STAT] & 0x20;
- trigger_oam_interrupt(gb);
- GB_STAT_update(gb);
- gb->oam_interrupt_line = false;
-
gb->io_registers[GB_IO_STAT] &= ~3;
gb->io_registers[GB_IO_STAT] |= 1;
gb->io_registers[GB_IO_IF] |= 1;
+ trigger_oam_interrupt(gb);
+ GB_STAT_update(gb);
+ gb->oam_interrupt_line = false;
if (gb->io_registers[GB_IO_STAT] & 0x20) {
gb->stat_interrupt_line = true;
