From 59e61c31ea4f7daef3692a890f8702b7494df683 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 25 Sep 2016 16:48:41 -0700 Subject: [PATCH] GB, GBA: Fix emulator hardlocking when halting with IRQs off --- CHANGES | 1 + src/gb/gb.c | 3 +++ src/gba/gba.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 21b506249..c89446be9 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ Bugfixes: - 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 + - GB, GBA: Fix emulator hardlocking when halting with IRQs off Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup diff --git a/src/gb/gb.c b/src/gb/gb.c index 545d64481..59000fd4b 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -537,6 +537,9 @@ void GBProcessEvents(struct LR35902Core* cpu) { if (cpu->halted) { cpu->cycles = cpu->nextEvent; + if (!gb->memory.ie || !gb->memory.ime) { + break; + } } } while (cpu->cycles >= cpu->nextEvent); } diff --git a/src/gba/gba.c b/src/gba/gba.c index a39ba72cd..e0ebad00c 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -287,6 +287,9 @@ static void GBAProcessEvents(struct ARMCore* cpu) { if (cpu->halted) { cpu->cycles = cpu->nextEvent; + if (!gba->memory.io[REG_IME >> 1] || !gba->memory.io[REG_IE >> 1]) { + break; + } } if (nextEvent == 0) { break;