diff options
| author | Apexo | 2026-04-02 21:09:27 +0200 |
|---|---|---|
| committer | Apexo | 2026-04-02 21:09:29 +0200 |
| commit | fe0b1c4bdccec7e10c1a43b3eb0a0c26d9b7fec4 (patch) | |
| tree | 2515dc822132a2a81d707db1d5b1b50439c3d4e5 /src/lights/d3aa.ts | |
| parent | SLPCTRL: clear sleep state on interrupt (diff) | |
| download | anduril-sim-fe0b1c4bdccec7e10c1a43b3eb0a0c26d9b7fec4.tar.gz anduril-sim-fe0b1c4bdccec7e10c1a43b3eb0a0c26d9b7fec4.tar.bz2 anduril-sim-fe0b1c4bdccec7e10c1a43b3eb0a0c26d9b7fec4.zip | |
move sleepUntil handling to main loop
This should fix the issue of wakups that are triggered when the step()
functions has reached its target cycle.
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); - } } } |
