all repos — mgba @ 559c3212fd9ff931f55b46849dbd07570949b7b8

mGBA Game Boy Advance Emulator

LR35902: Fix core never exiting with certain event patterns
Jeffrey Pfau jeffrey@endrift.com
Tue, 27 Sep 2016 04:42:20 -0700
commit

559c3212fd9ff931f55b46849dbd07570949b7b8

parent

fc69cdce60f9aee4782e1b21d75fd7b6c2dfa19b

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

jump to
M CHANGESCHANGES

@@ -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.csrc/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); + } }