all repos — mgba @ aa0f988daa2319272e3d6816b75ebf66896c6f32

mGBA Game Boy Advance Emulator

GB, GBA: Fix interrupted cores from restarting early
Vicki Pfau vi@endrift.com
Sun, 24 Jun 2018 16:26:47 -0700
commit

aa0f988daa2319272e3d6816b75ebf66896c6f32

parent

e78333611d8d72394d5fd68539c0a0a8e2ffe45f

2 files changed, 8 insertions(+), 9 deletions(-)

jump to
M src/gb/gb.csrc/gb/gb.c

@@ -644,17 +644,17 @@ nextEvent = mTimingTick(&gb->timing, nextEvent);

} while (gb->cpuBlocked); cpu->nextEvent = nextEvent; - if (gb->earlyExit) { - gb->earlyExit = false; - break; - } if (cpu->halted) { cpu->cycles = cpu->nextEvent; if (!gb->memory.ie || !gb->memory.ime) { break; } } + if (gb->earlyExit) { + break; + } } while (cpu->cycles >= cpu->nextEvent); + gb->earlyExit = false; } void GBSetInterrupts(struct LR35902Core* cpu, bool enable) {
M src/gba/gba.csrc/gba/gba.c

@@ -264,11 +264,6 @@ nextEvent = mTimingTick(&gba->timing, nextEvent + cycles);

} while (gba->cpuBlocked); cpu->nextEvent = nextEvent; - - if (gba->earlyExit) { - gba->earlyExit = false; - break; - } if (cpu->halted) { cpu->cycles = nextEvent; if (!gba->memory.io[REG_IME >> 1] || !gba->memory.io[REG_IE >> 1]) {

@@ -280,7 +275,11 @@ else if (nextEvent < 0) {

mLOG(GBA, FATAL, "Negative cycles will pass: %i", nextEvent); } #endif + if (gba->earlyExit) { + break; + } } + gba->earlyExit = false; #ifndef NDEBUG if (gba->cpuBlocked) { mLOG(GBA, FATAL, "CPU is blocked!");