diff options
Diffstat (limited to 'bedrock.js')
-rw-r--r-- | bedrock.js | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,7 +1,7 @@ "use strict"; let systemName = "bedrock-js"; -let systemVersion = "1.0.0"; +let systemVersion = "1.0.1"; let systemAuthors = "Ben Bridle"; let initialScreenScale = 2; @@ -91,6 +91,7 @@ function upgradeToEmulator(element) { let options = { scale, controls: 'controls' in attr, + nocursor: 'nocursor' in attr, autoplay: true, }; let url = URL.parse(attr.src.value, window.location.href); @@ -540,6 +541,7 @@ function EmulatorElement(options) { if (options && !options.controls) emulator.hideMenuBar(); if (options && options.autoplay) emulator.runProgram(); + if (options && options.nocursor) canvas.style.cursor = 'none'; return emulator; } @@ -1118,6 +1120,7 @@ function Bedrock(e) { this.paused = true; // true when program is paused for the user. this.asleep = false; // true when program is waiting for input. this.halted = false; // true when program has halted. + this.frameLag = 0; // time since runLoop started } // Reset the emulator and load in a new program. @@ -1194,6 +1197,7 @@ function Bedrock(e) { let image = new ImageData(scr.pixels, scr.width, scr.height); scr.ctx.putImageData(image, 0, 0, scr.dx0, scr.dy0, scr.dx1, scr.dy1); scr.unmark(); + this.frameLag = performance.now(); } } @@ -1212,12 +1216,16 @@ function Bedrock(e) { default: // NORMAL } this.update(); + // Force a render if the frame has been running for >500ms. + if (performance.now() - this.frameLag > 500) { + this.render(); } setTimeout(this.runLoop.bind(this), 0); } } } this.sleepLoop = () => { + this.frameLag = performance.now(); if (!this.halted) { if (!this.asleep) { setTimeout(this.runLoop.bind(this), 0); @@ -2143,6 +2151,9 @@ function StreamDevice(br) { default: return; } } + this.wake = function() { + return false; + } } @@ -2171,6 +2182,9 @@ function ClipboardDevice(br) { default: return; } } + this.wake = function() { + return false; + } this.readEntry = function(v) { this.readQueue = []; |