diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lights/d3aa.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lights/d3aa.ts b/src/lights/d3aa.ts index 9b8b0ba..29dc249 100644 --- a/src/lights/d3aa.ts +++ b/src/lights/d3aa.ts @@ -169,17 +169,20 @@ export class D3AA { /** Run the CPU for the given number of cycles */ step(cycles: number) { const target = this.cpu.cycles + cycles; + while (this.cpu.cycles < target) { + this.cpu.tick(); + const before = this.cpu.cycles; + this.slpctrl.sleepUntil = 0; avrInstruction(this.cpu); const mult = this.clkctrl.cycleMultiplier; if (mult > 1) { this.cpu.cycles += (this.cpu.cycles - before) * (mult - 1); } - if (this.slpctrl.sleepUntil > this.cpu.cycles) { + if (this.slpctrl.sleepUntil > this.cpu.cycles && this.cpu.nextInterrupt < 0) { this.cpu.cycles = Math.min(this.slpctrl.sleepUntil, target); } - this.cpu.tick(); } } |
