From a260b4cf91649498b32e3d10a06117175c9cb75f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 20 Feb 2016 13:57:16 -0800 Subject: [PATCH] GB Memory: Clearing the HDMA bit disabled HDMA --- src/gb/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gb/memory.c b/src/gb/memory.c index 6fe4144cc..1e7ccaabd 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -322,8 +322,9 @@ void GBMemoryWriteHDMA5(struct GB* gb, uint8_t value) { } gb->memory.hdmaDest &= 0x1FF0; gb->memory.hdmaDest |= 0x8000; + bool wasHdma = gb->memory.isHdma; gb->memory.isHdma = value & 0x80; - if (!gb->memory.isHdma) { + if (!wasHdma && !gb->memory.isHdma) { gb->memory.hdmaRemaining = ((value & 0x7F) + 1) * 0x10; gb->memory.hdmaNext = gb->cpu->cycles; gb->cpu->nextEvent = gb->cpu->cycles;