From 339613263c79716bff6e8d4dd6f1bb0ca3680733 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 18 Jun 2021 01:20:05 +0300 Subject: [PATCH] Fixed a bug that prevented STAT interrupt blocking from functioning correctly in the transition to VBlank while the OAM interrupt was disabled --- Core/display.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/display.c b/Core/display.c index b94ff26..a546127 100644 --- a/Core/display.c +++ b/Core/display.c @@ -1305,10 +1305,9 @@ abort_fetching_object: gb->io_registers[GB_IO_LY] = gb->current_line; gb->ly_for_comparison = -1; GB_SLEEP(gb, display, 26, 2); - if (gb->current_line == LINES) { - gb->mode_for_interrupt = 2; + if (gb->current_line == LINES && !gb->stat_interrupt_line && (gb->io_registers[GB_IO_STAT] & 0x20)) { + gb->io_registers[GB_IO_IF] |= 2; } - GB_STAT_update(gb); GB_SLEEP(gb, display, 12, 2); gb->ly_for_comparison = gb->current_line; @@ -1317,8 +1316,9 @@ abort_fetching_object: gb->io_registers[GB_IO_STAT] &= ~3; gb->io_registers[GB_IO_STAT] |= 1; gb->io_registers[GB_IO_IF] |= 1; - gb->mode_for_interrupt = 2; - GB_STAT_update(gb); + if (!gb->stat_interrupt_line && (gb->io_registers[GB_IO_STAT] & 0x20)) { + gb->io_registers[GB_IO_IF] |= 2; + } gb->mode_for_interrupt = 1; GB_STAT_update(gb);