From 36e2896ec775cdf19f04e64d0fd7ba27a7535a01 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 4 May 2022 00:23:55 +0300 Subject: [PATCH] Fix a regression while emulating object size change during fetch --- Core/display.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Core/display.c b/Core/display.c index ecdc5db..82b2a45 100644 --- a/Core/display.c +++ b/Core/display.c @@ -1656,12 +1656,9 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force) advance_fetcher_state_machine(gb, &cycles); dma_sync(gb, &cycles); - gb->object_low_line_address = get_object_line_address(gb, - gb->objects_y[gb->n_visible_objs - 1], - gb->mode2_y_bus = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 2), - gb->object_flags = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 3) - ); - + gb->mode2_y_bus = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 2); + gb->object_flags = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 3); + gb->cycles_for_line += 2; GB_SLEEP(gb, display, 20, 2); if (gb->object_fetch_aborted) { @@ -1670,6 +1667,10 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force) /* TODO: timing not verified */ dma_sync(gb, &cycles); + gb->object_low_line_address = get_object_line_address(gb, + gb->objects_y[gb->n_visible_objs - 1], + gb->mode2_y_bus, + gb->object_flags); gb->object_tile_data[0] = vram_read(gb, gb->object_low_line_address); @@ -1679,14 +1680,16 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force) goto abort_fetching_object; } - /* TODO: timing not verified */ - dma_sync(gb, &cycles); - gb->object_tile_data[1] = vram_read(gb, gb->object_low_line_address + 1); - - gb->during_object_fetch = false; gb->cycles_for_line++; GB_SLEEP(gb, display, 40, 1); + + /* TODO: timing not verified */ + dma_sync(gb, &cycles); + gb->object_tile_data[1] = vram_read(gb, get_object_line_address(gb, + gb->objects_y[gb->n_visible_objs - 1], + gb->mode2_y_bus, + gb->object_flags) + 1); uint8_t palette = (gb->object_flags & 0x10) ? 1 : 0;