From dbd04f09e868a597d6cb79ec5fd5a972df4a8410 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 25 Feb 2017 15:42:26 +0200 Subject: [PATCH] HBlank HDMA should start instantly when starting during HBlank. Fixes 3-D Ultra Pinball. --- Core/memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/memory.c b/Core/memory.c index a13b374..32a19aa 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -577,6 +577,10 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) } gb->hdma_on = (value & 0x80) == 0; gb->hdma_on_hblank = (value & 0x80) != 0; + if (gb->hdma_on_hblank && (gb->io_registers[GB_IO_STAT] & 3) == 0) { + gb->hdma_on = true; + gb->hdma_cycles = 0; + } gb->io_registers[GB_IO_HDMA5] = value; gb->hdma_steps_left = (gb->io_registers[GB_IO_HDMA5] & 0x7F) + 1; /* Todo: Verify this. Gambatte's DMA tests require this. */