From 804b9bec63a16d8f94068bcc1fb5c1f30e4e9f34 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 10 Feb 2020 00:21:33 +0200 Subject: [PATCH] Fixed a bug where HDMA begins in the middle of an instruction while cycles are pending to be flushed. Fixes #230 --- Core/sm83_cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/sm83_cpu.c b/Core/sm83_cpu.c index 0009a69..c9da208 100644 --- a/Core/sm83_cpu.c +++ b/Core/sm83_cpu.c @@ -1512,10 +1512,11 @@ void GB_cpu_run(GB_gameboy_t *gb) opcodes[gb->last_opcode_read](gb, gb->last_opcode_read); } + flush_pending_cycles(gb); + if (gb->hdma_starting) { gb->hdma_starting = false; gb->hdma_on = true; gb->hdma_cycles = -8; } - flush_pending_cycles(gb); }