diff --git a/Core/display.c b/Core/display.c index a546127..8ebe803 100644 --- a/Core/display.c +++ b/Core/display.c @@ -854,7 +854,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) GB_STATE(gb, display, 21); GB_STATE(gb, display, 22); GB_STATE(gb, display, 23); - // GB_STATE(gb, display, 24); + GB_STATE(gb, display, 24); GB_STATE(gb, display, 25); GB_STATE(gb, display, 26); GB_STATE(gb, display, 27); @@ -1287,7 +1287,9 @@ abort_fetching_object: gb->wy_triggered = true; } GB_SLEEP(gb, display, 31, 2); - gb->mode_for_interrupt = 2; + if (gb->current_line != LINES - 1) { + gb->mode_for_interrupt = 2; + } // Todo: unverified timing gb->current_lcd_line++; @@ -1310,7 +1312,9 @@ abort_fetching_object: } GB_SLEEP(gb, display, 12, 2); gb->ly_for_comparison = gb->current_line; - + GB_STAT_update(gb); + GB_SLEEP(gb, display, 24, 1); + if (gb->current_line == LINES) { /* Entering VBlank state triggers the OAM interrupt */ gb->io_registers[GB_IO_STAT] &= ~3; @@ -1350,8 +1354,7 @@ abort_fetching_object: } } - GB_STAT_update(gb); - GB_SLEEP(gb, display, 13, LINE_LENGTH - 4); + GB_SLEEP(gb, display, 13, LINE_LENGTH - 5); } /* TODO: Verified on SGB2 and CGB-E. Actual interrupt timings not tested. */