LR35902: Fix core never exiting with certain event patterns
Jeffrey Pfau jeffrey@endrift.com
Tue, 27 Sep 2016 04:42:20 -0700
2 files changed,
9 insertions(+),
3 deletions(-)
M
CHANGES
→
CHANGES
@@ -22,6 +22,7 @@ - GBA Hardware: Improve Game Boy Player rumble behavior
- GB: Initialize audio properly - GB MBC: Fix RTC access when no save file is loaded - GB: Properly clear KEY1 bit 0 when switching speeds + - LR35902: Fix core never exiting with certain event patterns Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup
M
src/lr35902/lr35902.c
→
src/lr35902/lr35902.c
@@ -156,13 +156,16 @@ }
} void LR35902Run(struct LR35902Core* cpu) { - while (true) { + bool running = 1; + while (running > 0 || cpu->executionState != LR35902_CORE_FETCH) { _LR35902Step(cpu); if (cpu->cycles + 2 >= cpu->nextEvent) { int32_t diff = cpu->nextEvent - cpu->cycles; cpu->cycles = cpu->nextEvent; + cpu->executionState += diff; cpu->irqh.processEvents(cpu); cpu->cycles += 2 - diff; + running = -1; } else { cpu->cycles += 2; }@@ -170,8 +173,10 @@ cpu->executionState = LR35902_CORE_FETCH;
cpu->instruction(cpu); ++cpu->cycles; if (cpu->cycles >= cpu->nextEvent) { - break; + running = 0; } } - cpu->irqh.processEvents(cpu); + if (!running) { + cpu->irqh.processEvents(cpu); + } }