diff options
Diffstat (limited to 'src/lights/d3aa.ts')
| -rw-r--r-- | src/lights/d3aa.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lights/d3aa.ts b/src/lights/d3aa.ts index 21eea86..80bc134 100644 --- a/src/lights/d3aa.ts +++ b/src/lights/d3aa.ts @@ -173,16 +173,18 @@ export class D3AA { while (this.cpu.cycles < target) { this.cpu.tick(); + if (this.slpctrl.sleeping !== null) { + const sleepUntil = (this.cpu as any).nextClockEvent?.cycles ?? Infinity; + this.cpu.cycles = Math.min(target, sleepUntil); + continue; + } + 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 && this.cpu.nextInterrupt < 0) { - this.cpu.cycles = Math.min(this.slpctrl.sleepUntil, target); - } } } |
