summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'index.html')
-rw-r--r--index.html16
1 files changed, 12 insertions, 4 deletions
diff --git a/index.html b/index.html
index b6cf570..34bfe8e 100644
--- a/index.html
+++ b/index.html
@@ -546,15 +546,23 @@ function updateEeprom(eepromData) {
prevEeprom.set(eepromData);
}
-// ---- RAF polling loop ----
function poll() {
requestAnimationFrame(poll);
if (!sim) return;
// catch up simulator
- const dt = Date.now() - t0;
- const cycles = CPU_FREQ / 1000 * dt;
- sim.step(cycles - sim.getState().cycles);
+ const tt = 1000 * sim.getState().cycles / CPU_FREQ;
+ let dt = Date.now() - t0 - tt;
+
+ if (dt < 0 || dt > 100) {
+ // handle backwards/forward time jumps to avoid freezing the sim or blocking the UI by simulating too much
+ const dt2 = Math.max(0, Math.min(100, dt));
+ console.log("timp jump", dt, dt2);
+ t0 += dt - dt2;
+ dt = dt2;
+ }
+
+ sim.step(Math.round(dt * CPU_FREQ / 1000));
// Read state from emulator
const st = sim.getState();
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.