LR35902: Fix LR35902Run

This commit is contained in:
Jeffrey Pfau 2016-09-27 21:31:49 -07:00
parent 82f503bc4e
commit 11486fea77
1 changed files with 5 additions and 7 deletions

View File

@ -156,8 +156,8 @@ void LR35902Tick(struct LR35902Core* cpu) {
} }
void LR35902Run(struct LR35902Core* cpu) { void LR35902Run(struct LR35902Core* cpu) {
bool running = 1; bool running = true;
while (running > 0 || cpu->executionState != LR35902_CORE_FETCH) { while (running || 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;
@ -165,7 +165,7 @@ void LR35902Run(struct LR35902Core* cpu) {
cpu->executionState += diff; cpu->executionState += diff;
cpu->irqh.processEvents(cpu); cpu->irqh.processEvents(cpu);
cpu->cycles += 2 - diff; cpu->cycles += 2 - diff;
running = -1; running = false;
} else { } else {
cpu->cycles += 2; cpu->cycles += 2;
} }
@ -173,10 +173,8 @@ 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) {
running = 0; cpu->irqh.processEvents(cpu);
running = false;
} }
} }
if (!running) {
cpu->irqh.processEvents(cpu);
}
} }