From 91491e704e21343f8d7a908d1a8119cafecd6de2 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 24 Apr 2017 13:14:31 -0700 Subject: [PATCH] GB, GBA Core: Ensure the core is halted even if a state is not loaded --- src/gb/core.c | 5 +++++ src/gba/core.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/gb/core.c b/src/gb/core.c index 97b48e7da..0bcc2aa9d 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -792,6 +792,11 @@ static void _GBVLPReset(struct mCore* core) { LR35902Reset(core->cpu); mVideoLogContextRewind(gbcore->logContext, core); GBVideoProxyRendererShim(&gb->video, &gbcore->proxyRenderer); + + // Make sure CPU loop never spins + GBHalt(gb->cpu); + gb->memory.ie = 0; + gb->memory.ime = false; } static bool _GBVLPLoadROM(struct mCore* core, struct VFile* vf) { diff --git a/src/gba/core.c b/src/gba/core.c index 4558ccd77..dc764d6e7 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -811,6 +811,11 @@ static void _GBAVLPReset(struct mCore* core) { ARMReset(core->cpu); mVideoLogContextRewind(gbacore->logContext, core); GBAVideoProxyRendererShim(&gba->video, &gbacore->proxyRenderer); + + // Make sure CPU loop never spins + GBAHalt(gba); + gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IME, 0, NULL); + gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IE, 0, NULL); } static bool _GBAVLPLoadROM(struct mCore* core, struct VFile* vf) {