all repos — mgba @ 7df5b67a71d4406d1261510ae6296e879db33c39

mGBA Game Boy Advance Emulator

GBA DMA: Only update DMA scheduling if needed
Vicki Pfau vi@endrift.com
Fri, 21 Aug 2020 02:41:03 -0700
commit

7df5b67a71d4406d1261510ae6296e879db33c39

parent

5c58186f03fb053038ee804b44051f21623ec62c

1 files changed, 10 insertions(+), 2 deletions(-)

jump to
M src/gba/dma.csrc/gba/dma.c

@@ -134,29 +134,37 @@

void GBADMARunHblank(struct GBA* gba, int32_t cycles) { struct GBAMemory* memory = &gba->memory; struct GBADMA* dma; + bool found = false; int i; for (i = 0; i < 4; ++i) { dma = &memory->dma[i]; if (GBADMARegisterIsEnable(dma->reg) && GBADMARegisterGetTiming(dma->reg) == GBA_DMA_TIMING_HBLANK && !dma->nextCount) { dma->when = mTimingCurrentTime(&gba->timing) + 3 + cycles; dma->nextCount = dma->count; + found = true; } } - GBADMAUpdate(gba); + if (found) { + GBADMAUpdate(gba); + } } void GBADMARunVblank(struct GBA* gba, int32_t cycles) { struct GBAMemory* memory = &gba->memory; struct GBADMA* dma; + bool found = false; int i; for (i = 0; i < 4; ++i) { dma = &memory->dma[i]; if (GBADMARegisterIsEnable(dma->reg) && GBADMARegisterGetTiming(dma->reg) == GBA_DMA_TIMING_VBLANK && !dma->nextCount) { dma->when = mTimingCurrentTime(&gba->timing) + 3 + cycles; dma->nextCount = dma->count; + found = true; } } - GBADMAUpdate(gba); + if (found) { + GBADMAUpdate(gba); + } } void GBADMARunDisplayStart(struct GBA* gba, int32_t cycles) {