diff --git a/src/gb/memory.c b/src/gb/memory.c index 0f6365ef3..85820f90e 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -340,7 +340,11 @@ void _GBMemoryHDMAService(struct GB* gb) { if (gb->memory.hdmaRemaining) { gb->memory.hdmaNext += 2; } else { - gb->memory.io[REG_HDMA5] |= 0x80; + if (gb->memory.isHdma) { + --gb->memory.io[REG_HDMA5]; + } else { + gb->memory.io[REG_HDMA5] |= 0x80; + } } } diff --git a/src/gb/video.c b/src/gb/video.c index 9a97c3407..d91303bf7 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -178,6 +178,10 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) { video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); GBUpdateIRQs(video->p); } + 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->memory.hdmaNext = video->p->cpu->cycles; + } break; } video->stat = GBRegisterSTATSetMode(video->stat, video->mode);