From 3133687e6820d98581855010ae772473666d2643 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sun, 16 Jan 2022 00:50:08 +0200 Subject: [PATCH] Potential logic bug fixes --- Core/display.c | 1 + Core/memory.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/display.c b/Core/display.c index de84999..1b90ddb 100644 --- a/Core/display.c +++ b/Core/display.c @@ -1613,6 +1613,7 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force) if (unlikely(GB_is_dma_active(gb))) { unsigned offset = cycles - gb->display_cycles; // Time passed in 8MHz ticks + cycles = gb->display_cycles; if (offset) { if (!gb->cgb_double_speed) { offset >>= 1; // Convert to T-cycles diff --git a/Core/memory.c b/Core/memory.c index 8409490..572eae3 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -292,7 +292,11 @@ static uint8_t read_mbc_rom(GB_gameboy_t *gb, uint16_t addr) static uint8_t read_vram(GB_gameboy_t *gb, uint16_t addr) { - GB_display_sync(gb); + if (!GB_is_dma_active(gb)) { + /* Prevent syncing from a DMA read. Batching doesn't happen during DMA anyway. */ + GB_display_sync(gb); + } + if (unlikely(gb->vram_read_blocked)) { return 0xFF; }