From ea2f32b255aa1a31abab207f824c72a6f6d20639 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 21 Feb 2020 21:44:44 +0200 Subject: [PATCH] The fetcher state machine advances even while handling an object --- Core/display.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Core/display.c b/Core/display.c index c79e8bd..13bd955 100644 --- a/Core/display.c +++ b/Core/display.c @@ -761,6 +761,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) GB_STATE(gb, display, 38); GB_STATE(gb, display, 39); GB_STATE(gb, display, 40); + GB_STATE(gb, display, 41); } @@ -956,8 +957,16 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) } } - gb->cycles_for_line += 4; - GB_SLEEP(gb, display, 20, 4); + advance_fetcher_state_machine(gb); + gb->cycles_for_line++; + GB_SLEEP(gb, display, 41, 1); + if (gb->object_fetch_aborted) { + goto abort_fetching_object; + } + advance_fetcher_state_machine(gb); + + gb->cycles_for_line += 3; + GB_SLEEP(gb, display, 20, 3); if (gb->object_fetch_aborted) { goto abort_fetching_object; }