diff --git a/CHANGES b/CHANGES index 67f87da77..bd67ace36 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 72d5e6c5c..9022ddf40 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 }