diff options
Diffstat (limited to '')
| -rw-r--r-- | demo/src/execute.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/demo/src/execute.ts b/demo/src/execute.ts index 3a2f162..7b6cae0 100644 --- a/demo/src/execute.ts +++ b/demo/src/execute.ts @@ -39,16 +39,19 @@ export class AVRRunner { async execute(callback: (cpu: CPU) => void) { this.stopped = false; + const workUnitCycles = 500000; + let nextTick = this.cpu.cycles + workUnitCycles; for (;;) { avrInstruction(this.cpu); this.timer.tick(); this.usart.tick(); - if (this.cpu.cycles % 500000 === 0) { + if (this.cpu.cycles >= nextTick) { callback(this.cpu); await new Promise((resolve) => setTimeout(resolve, 0)); if (this.stopped) { break; } + nextTick += workUnitCycles; } } } |
