aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demo/src/execute.ts5
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;
}
}
}
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.