diff --git a/CHANGES b/CHANGES index bd67ace36..29b97cf1c 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 9022ddf40..b049ea026 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 5596a0c50..66cd13ca4 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;