From e8c51b16b430bdcd0faaef50aa12c1d5937d7900 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 25 Sep 2016 16:21:43 -0700 Subject: [PATCH] GB: Fix invalid STOP behavior on Game Boy Color --- CHANGES | 1 + src/gb/gb.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index c5307cd0b..21b506249 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ Bugfixes: - GBA Savedata: Fix loading savestates with 512Mb Flash saves - Core: Fix importing save games as read-only - Util: Fix PNG identification on files too small to be a PNG + - GB: Fix invalid STOP behavior on Game Boy Color Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup diff --git a/src/gb/gb.c b/src/gb/gb.c index 154aa2dfe..545d64481 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -566,6 +566,12 @@ void GBStop(struct LR35902Core* cpu) { struct GB* gb = (struct GB*) cpu->master; if (cpu->bus) { mLOG(GB, GAME_ERROR, "Hit illegal stop at address %04X:%02X\n", cpu->pc, cpu->bus); + } + if (gb->memory.io[REG_KEY1] & 1) { + gb->doubleSpeed ^= 1; + gb->memory.io[REG_KEY1] &= 1; + gb->memory.io[REG_KEY1] |= gb->doubleSpeed << 7; + } else if (cpu->bus) { if (cpu->components && cpu->components[CPU_COMPONENT_DEBUGGER]) { struct mDebuggerEntryInfo info = { .address = cpu->pc - 1, @@ -576,10 +582,6 @@ void GBStop(struct LR35902Core* cpu) { // Hang forever gb->memory.ime = 0; cpu->pc -= 2; - } else if (gb->memory.io[REG_KEY1] & 1) { - gb->doubleSpeed ^= 1; - gb->memory.io[REG_KEY1] &= 1; - gb->memory.io[REG_KEY1] |= gb->doubleSpeed << 7; } // TODO: Actually stop }