mirror of https://github.com/mgba-emu/mgba.git
LR35902: Fix core never exiting with certain event patterns
This commit is contained in:
parent
fc69cdce60
commit
559c3212fd
1
CHANGES
1
CHANGES
|
@ -22,6 +22,7 @@ Bugfixes:
|
||||||
- GB: Initialize audio properly
|
- GB: Initialize audio properly
|
||||||
- GB MBC: Fix RTC access when no save file is loaded
|
- GB MBC: Fix RTC access when no save file is loaded
|
||||||
- GB: Properly clear KEY1 bit 0 when switching speeds
|
- GB: Properly clear KEY1 bit 0 when switching speeds
|
||||||
|
- LR35902: Fix core never exiting with certain event patterns
|
||||||
Misc:
|
Misc:
|
||||||
- All: Only update version info if needed
|
- All: Only update version info if needed
|
||||||
- FFmpeg: Encoding cleanup
|
- FFmpeg: Encoding cleanup
|
||||||
|
|
|
@ -156,13 +156,16 @@ void LR35902Tick(struct LR35902Core* cpu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LR35902Run(struct LR35902Core* cpu) {
|
void LR35902Run(struct LR35902Core* cpu) {
|
||||||
while (true) {
|
bool running = 1;
|
||||||
|
while (running > 0 || cpu->executionState != LR35902_CORE_FETCH) {
|
||||||
_LR35902Step(cpu);
|
_LR35902Step(cpu);
|
||||||
if (cpu->cycles + 2 >= cpu->nextEvent) {
|
if (cpu->cycles + 2 >= cpu->nextEvent) {
|
||||||
int32_t diff = cpu->nextEvent - cpu->cycles;
|
int32_t diff = cpu->nextEvent - cpu->cycles;
|
||||||
cpu->cycles = cpu->nextEvent;
|
cpu->cycles = cpu->nextEvent;
|
||||||
|
cpu->executionState += diff;
|
||||||
cpu->irqh.processEvents(cpu);
|
cpu->irqh.processEvents(cpu);
|
||||||
cpu->cycles += 2 - diff;
|
cpu->cycles += 2 - diff;
|
||||||
|
running = -1;
|
||||||
} else {
|
} else {
|
||||||
cpu->cycles += 2;
|
cpu->cycles += 2;
|
||||||
}
|
}
|
||||||
|
@ -170,8 +173,10 @@ void LR35902Run(struct LR35902Core* cpu) {
|
||||||
cpu->instruction(cpu);
|
cpu->instruction(cpu);
|
||||||
++cpu->cycles;
|
++cpu->cycles;
|
||||||
if (cpu->cycles >= cpu->nextEvent) {
|
if (cpu->cycles >= cpu->nextEvent) {
|
||||||
break;
|
running = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!running) {
|
||||||
cpu->irqh.processEvents(cpu);
|
cpu->irqh.processEvents(cpu);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue