diff --git a/package-lock.json b/package-lock.json index 82303b1..7317f69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "glob": "^11.0.0", "html-webpack-partials-plugin": "^0.8.0", "jquery": "^3.7.1", - "jsbeeb": "github:mattgodbolt/jsbeeb#636f0b9e7668e2a1eaf45b7b1967ff9a045f66cc", + "jsbeeb": "github:mattgodbolt/jsbeeb#4e5f3666cbce0613bc9e7006d4aceddcb1095dc4", "monaco-editor": "^0.52.0", "promise": "^8.3.0", "resize-observer-polyfill": "^1.5.1", @@ -845,6 +845,15 @@ "node": ">= 8" } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -1566,8 +1575,7 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/array-flatten": { "version": "1.1.1", @@ -1734,6 +1742,29 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" }, + "node_modules/bootstrap": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.3.tgz", + "integrity": "sha512-8HLCdWgyoMguSO9o+aH+iuZ+aht+mzW0u3HIMzVu7Srrpv7EBBxTnrFlSCskwdY1+EOFQSm7uMJhNQHkdPcmjg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "peerDependencies": { + "@popperjs/core": "^2.11.8" + } + }, + "node_modules/bootswatch": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/bootswatch/-/bootswatch-5.3.3.tgz", + "integrity": "sha512-cJLhobnZsVCelU7zdH/L7wpcXAyUoTX4/5l2dWQ0JXgaVK80BdTQNU/ImWwoyIGBeyms4iQDAdNtOfPQZf0Atg==" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -4951,22 +4982,19 @@ }, "node_modules/jsbeeb": { "version": "0.0.7", - "resolved": "git+ssh://git@github.com/mattgodbolt/jsbeeb.git#636f0b9e7668e2a1eaf45b7b1967ff9a045f66cc", - "integrity": "sha512-2quLm10+jRv5R4tvlCtNh0YBic/eKjuh6cx6XGEjUbv2FcsVAZBUDhSxRrDyOsr7qb8gkyxFnnaabcB5FhoB/A==", + "resolved": "git+ssh://git@github.com/mattgodbolt/jsbeeb.git#4e5f3666cbce0613bc9e7006d4aceddcb1095dc4", + "integrity": "sha512-3AyntGgLLBMrq0QKFD6tscm/mijIfctpbTS/WB8OIBQKFGr5q9pJLjDGgzrTKBhWZKJfJcKJCDIgsMQ5cusTZQ==", "license": "GPL-3.0-or-later", "dependencies": { - "argparse": "^1.0.10" + "@popperjs/core": "^2.11.8", + "argparse": "^2.0.1", + "bootstrap": "^5.3.3", + "bootswatch": "^5.3.3", + "jquery": "^3.7.1", + "underscore": "^1.13.7" }, "engines": { - "node": "8" - } - }, - "node_modules/jsbeeb/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" + "node": "20" } }, "node_modules/jsdom": { @@ -8130,11 +8158,6 @@ "wbuf": "^1.7.3" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" - }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", diff --git a/package.json b/package.json index b1f9cdd..6a63aea 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "glob": "^11.0.0", "html-webpack-partials-plugin": "^0.8.0", "jquery": "^3.7.1", - "jsbeeb": "github:mattgodbolt/jsbeeb#636f0b9e7668e2a1eaf45b7b1967ff9a045f66cc", + "jsbeeb": "github:mattgodbolt/jsbeeb#4e5f3666cbce0613bc9e7006d4aceddcb1095dc4", "monaco-editor": "^0.52.0", "promise": "^8.3.0", "resize-observer-polyfill": "^1.5.1", diff --git a/src/emulator.js b/src/emulator.js index 6aebecd..fcd21ae 100644 --- a/src/emulator.js +++ b/src/emulator.js @@ -1,13 +1,13 @@ import _ from "underscore"; -import Cpu6502 from "jsbeeb/6502"; -import canvasLib from "jsbeeb/canvas"; -import Video from "jsbeeb/video"; -import Debugger from "jsbeeb/debug"; -import SoundChip from "jsbeeb/soundchip"; -import DdNoise from "jsbeeb/ddnoise"; -import models from "jsbeeb/models"; -import Cmos from "jsbeeb/cmos"; -import utils from "jsbeeb/utils"; +import {Cpu6502} from "jsbeeb/6502"; +import * as canvasLib from "jsbeeb/canvas"; +import {Video} from "jsbeeb/video"; +import {Debugger} from "jsbeeb/web/debug"; +import {FakeSoundChip} from "jsbeeb/soundchip"; +import {FakeDdNoise} from "jsbeeb/ddnoise"; +import * as models from "jsbeeb/models"; +import {Cmos} from "jsbeeb/cmos"; +import * as utils from "jsbeeb/utils"; import Promise from "promise"; import ResizeObserver from "resize-observer-polyfill"; import Snapshot from "snapshot"; @@ -49,6 +49,30 @@ class ScreenResizer { } } +class Emulator6502 extends Cpu6502 { + constructor(model, dbgr, video, soundChip, ddNoise, cmos, config) { + super( + model, + dbgr, + video, + soundChip, + ddNoise, + null, // Music5000 + cmos, + config, + null, // econet + ); + } + + execute(numCyclesToRun) { + // Patch to stop it resetting cycle count on execute. + // Number.MAX_SAFE_INTEGER should gives us plenty of headroom + this.halted = false; + this.targetCycles += numCyclesToRun; + return this.executeInternalFast(); + } +} + export class Emulator { constructor(root) { this.root = root; @@ -72,10 +96,10 @@ export class Emulator { window.theEmulator = this; - this.video = new Video.Video(Model.isMaster, this.canvas.fb32, _.bind(this.paint, this)); + this.video = new Video(Model.isMaster, this.canvas.fb32, _.bind(this.paint, this)); - this.soundChip = new SoundChip.FakeSoundChip(); - this.ddNoise = new DdNoise.FakeDdNoise(); + this.soundChip = new FakeSoundChip(); + this.ddNoise = new FakeDdNoise(); this.dbgr = new Debugger(this.video); const cmos = new Cmos({ @@ -90,7 +114,7 @@ export class Emulator { }, }); const config = {}; - this.cpu = new Cpu6502( + this.cpu = new Emulator6502( Model, this.dbgr, this.video, @@ -100,14 +124,6 @@ export class Emulator { config, ); - // Patch this version of JSbeeb to stop it reseting cycle count. - // Number.MAX_SAFE_INTEGER should gives us plenty of headroom - this.cpu.execute = function (numCyclesToRun) { - this.halted = false; - this.targetCycles += numCyclesToRun; - return this.executeInternalFast(); - }; - screen.mousemove(event => this.mouseMove(event)); screen.mouseleave(() => this.mouseLeave()); screen.keyup(event => this.keyUp(event)); @@ -158,6 +174,7 @@ export class Emulator { this.emuStatus.innerHTML += "."; if (this.emuStatus.innerHTML.length > 18) this.emuStatus.innerHTML = "Calling beebjit"; } + this.emuStatus.innerHTML = "Calling beebjit"; const counterInterval = setInterval(myCounter.bind(this), 200); const basic = btoa(tokenised).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); @@ -191,7 +208,6 @@ export class Emulator { async runProgram(tokenised) { if (!this.ready) return; - console.log(this.cpu.currentCycles); this.cpu.reset(true); const processor = this.cpu; await processor.execute(BotStartCycles); // match bbcmicrobot diff --git a/src/owlet.js b/src/owlet.js index b1c3c2a..0b6dc1f 100644 --- a/src/owlet.js +++ b/src/owlet.js @@ -10,7 +10,7 @@ import {Emulator} from "./emulator"; import Examples from "./examples.yaml"; import {expandCode, partialDetokenise} from "./tokens"; import {encode} from "base2048"; -import tokenise from "jsbeeb/basic-tokenise"; +import * as tokenise from "jsbeeb/basic-tokenise"; import "./owlet-editor.less"; import {getWarnings} from "./bbcbasic"; import {makeUEF} from "./UEF";