diff --git a/CHANGES b/CHANGES index 970a83ae5..bbca29273 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ Bugfixes: - Qt: Fix timezone issues with time overrides - Qt: Fix sprite export pausing game indefinitely (fixes mgba.io/i/841) - GB Video: Fix potential hang when ending mode 0 + - GB Memory: Fix HDMA count starting in mode 0 (fixes mgba.io/i/855) Misc: - Qt: Don't rebuild library view if style hasn't changed - SDL: Fix 2.0.5 build on macOS under some circumstances diff --git a/src/gb/memory.c b/src/gb/memory.c index e593d6b23..21c9e17a3 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -464,10 +464,13 @@ void GBMemoryWriteHDMA5(struct GB* gb, uint8_t value) { bool wasHdma = gb->memory.isHdma; gb->memory.isHdma = value & 0x80; if ((!wasHdma && !gb->memory.isHdma) || gb->video.mode == 0) { - gb->memory.hdmaRemaining = ((value & 0x7F) + 1) * 0x10; + if (gb->memory.isHdma) { + gb->memory.hdmaRemaining = 0x10; + } else { + gb->memory.hdmaRemaining = ((value & 0x7F) + 1) * 0x10; + } gb->cpuBlocked = true; mTimingSchedule(&gb->timing, &gb->memory.hdmaEvent, 0); - gb->cpu->nextEvent = gb->cpu->cycles; } } diff --git a/src/gb/video.c b/src/gb/video.c index 6fda8c5e4..49bbff1f8 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -231,6 +231,7 @@ void _endMode3(struct mTiming* timing, void* context, uint32_t cyclesLate) { GBVideoProcessDots(video); if (video->ly < GB_VIDEO_VERTICAL_PIXELS && video->p->memory.isHdma && video->p->memory.io[REG_HDMA5] != 0xFF) { video->p->memory.hdmaRemaining = 0x10; + video->p->cpuBlocked = true; mTimingDeschedule(timing, &video->p->memory.hdmaEvent); mTimingSchedule(timing, &video->p->memory.hdmaEvent, 0); }