all repos — mgba @ 60a2f49cda145235f298cc2e87fd924a323dc567

mGBA Game Boy Advance Emulator

GB: Improve stepping timing accuracy
Vicki Pfau vi@endrift.com
Mon, 13 Nov 2017 23:27:05 -0800
commit

60a2f49cda145235f298cc2e87fd924a323dc567

parent

5d9e4d217a273bec4dfdddafdea85e25eda7a45f

1 files changed, 5 insertions(+), 5 deletions(-)

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

@@ -137,22 +137,22 @@ }

} void LR35902Tick(struct LR35902Core* cpu) { + if (cpu->cycles >= cpu->nextEvent) { + cpu->irqh.processEvents(cpu); + } _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; + cpu->cycles += LR35902_CORE_EXECUTE - cpu->executionState; } else { cpu->cycles += 2; } cpu->executionState = LR35902_CORE_FETCH; cpu->instruction(cpu); ++cpu->cycles; - if (cpu->cycles >= cpu->nextEvent) { - cpu->irqh.processEvents(cpu); - } } void LR35902Run(struct LR35902Core* cpu) {

@@ -168,7 +168,7 @@ int32_t diff = cpu->nextEvent - cpu->cycles;

cpu->cycles = cpu->nextEvent; cpu->executionState += diff; cpu->irqh.processEvents(cpu); - cpu->cycles += 2 - diff; + cpu->cycles += LR35902_CORE_EXECUTE - cpu->executionState; running = false; } else { cpu->cycles += 2;