From 35be6c121b93ef43c9249b8497121d1eb18c1d0c Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 6 Jun 2020 17:57:26 -0700 Subject: [PATCH] GB: Fix HALT bug --- src/gb/core.c | 4 ++-- src/gb/gb.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gb/core.c b/src/gb/core.c index 41290e84e..7ee5828dd 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -1082,9 +1082,9 @@ static void _GBVLPReset(struct mCore* core) { GBVideoProxyRendererShim(&gb->video, &gbcore->proxyRenderer); // Make sure CPU loop never spins - GBHalt(gb->cpu); gb->memory.ie = 0; gb->memory.ime = false; + GBHalt(gb->cpu); } static bool _GBVLPLoadROM(struct mCore* core, struct VFile* vf) { @@ -1115,9 +1115,9 @@ static bool _GBVLPLoadState(struct mCore* core, const void* buffer) { GBAudioReset(&gb->audio); // Make sure CPU loop never spins - GBHalt(gb->cpu); gb->memory.ie = 0; gb->memory.ime = false; + GBHalt(gb->cpu); return true; } diff --git a/src/gb/gb.c b/src/gb/gb.c index fda3f214a..ff73614eb 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -749,7 +749,7 @@ void GBHalt(struct SM83Core* cpu) { if (!(gb->memory.ie & gb->memory.io[REG_IF] & 0x1F)) { cpu->cycles = cpu->nextEvent; cpu->halted = true; - } else { + } else if (!gb->memory.ime) { mLOG(GB, GAME_ERROR, "HALT bug"); cpu->executionState = SM83_CORE_HALT_BUG; }