Fix a regression while emulating object size change during fetch

This commit is contained in:
Lior Halphon 2022-05-04 00:23:55 +03:00
parent bef1529bb2
commit 36e2896ec7

View File

@ -1656,11 +1656,8 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force)
advance_fetcher_state_machine(gb, &cycles); advance_fetcher_state_machine(gb, &cycles);
dma_sync(gb, &cycles); dma_sync(gb, &cycles);
gb->object_low_line_address = get_object_line_address(gb, gb->mode2_y_bus = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 2);
gb->objects_y[gb->n_visible_objs - 1], 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->cycles_for_line += 2;
GB_SLEEP(gb, display, 20, 2); GB_SLEEP(gb, display, 20, 2);
@ -1670,6 +1667,10 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force)
/* TODO: timing not verified */ /* TODO: timing not verified */
dma_sync(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,
gb->object_flags);
gb->object_tile_data[0] = vram_read(gb, gb->object_low_line_address); gb->object_tile_data[0] = vram_read(gb, gb->object_low_line_address);
@ -1679,15 +1680,17 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force)
goto abort_fetching_object; 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->during_object_fetch = false;
gb->cycles_for_line++; gb->cycles_for_line++;
GB_SLEEP(gb, display, 40, 1); 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; uint8_t palette = (gb->object_flags & 0x10) ? 1 : 0;
if (gb->cgb_mode) { if (gb->cgb_mode) {