From 7266186f4a564858cfcfd9045811f4f7f8805f6c Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 22 Feb 2019 18:49:23 -0800 Subject: [PATCH] GBA DMA: Fix DMA start/end timing --- CHANGES | 1 + src/gba/dma.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 2eb29fe71..ea2528ccc 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ Bugfixes: - Python: Fix crash when deleting files owned by library - Python: Make sure GB link object isn't GC'd before GB object - GBA DMA: Fix Display Start DMAs + - GBA DMA: Fix DMA start/end timing Misc: - GBA Video: Improve sprite cycle counting (fixes mgba.io/i/1274) diff --git a/src/gba/dma.c b/src/gba/dma.c index e6e96bc8d..dd5d493f8 100644 --- a/src/gba/dma.c +++ b/src/gba/dma.c @@ -237,9 +237,6 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) { gba->cpuBlocked = true; if (info->count == info->nextCount) { - if (sourceRegion < REGION_CART0 || destRegion < REGION_CART0) { - cycles += 2; - } if (width == 4) { cycles += memory->waitstatesNonseq32[sourceRegion] + memory->waitstatesNonseq32[destRegion]; } else { @@ -306,6 +303,9 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) { info->nextDest = dest; if (!wordsRemaining) { info->nextCount |= 0x80000000; + if (sourceRegion < REGION_CART0 || destRegion < REGION_CART0) { + info->when += 2; + } } GBADMAUpdate(gba); }