jsbeeb 1.22.0 → 1.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![jsbeeb tests](https://github.com/mattgodbolt/jsbeeb/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/mattgodbolt/jsbeeb/actions/workflows/test-and-deploy.yml)
2
+ [![coverage](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fmattgodbolt%2Fjsbeeb%2Fbadges%2Fcoverage.json)](https://github.com/mattgodbolt/jsbeeb/actions/workflows/test-and-deploy.yml)
2
3
 
3
4
  # jsbeeb - JavaScript BBC Micro Emulator
4
5
 
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "name": "jsbeeb",
8
8
  "description": "Emulate a BBC Micro",
9
9
  "repository": "git@github.com:mattgodbolt/jsbeeb.git",
10
- "version": "1.22.0",
10
+ "version": "1.22.2",
11
11
  "//engines": "If you change the version of Node, it must also be updated at the top of the Dockerfile.",
12
12
  "engines": {
13
13
  "node": ">=24.15.0"
@@ -114,7 +114,8 @@
114
114
  "mirror-bbcdiscs:upload:blobs": "aws s3 sync .bbcdiscs-mirror/hfe s3://bbc.xania.org/archive/bbcdiscs/hfe/ --no-progress --exclude 'manifest.json' --delete --content-encoding br --cache-control 'public, max-age=31536000, immutable'",
115
115
  "mirror-bbcdiscs:upload:index": "aws s3 cp .bbcdiscs-mirror/hfe/manifest.json s3://bbc.xania.org/archive/bbcdiscs/hfe/manifest.json --cache-control 'public, max-age=300' && aws s3 cp .bbcdiscs-mirror/manifest.json s3://bbc.xania.org/archive/bbcdiscs/manifest.json --cache-control 'public, max-age=300'",
116
116
  "electron": "npm run build && ELECTRON_DISABLE_SANDBOX=1 electron .",
117
- "electron:build": "electron-builder"
117
+ "electron:build": "electron-builder",
118
+ "test:smoke": "npm run build && node tests/browser/smoke.js"
118
119
  },
119
120
  "lint-staged": {
120
121
  "*.js": [
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ /** Where the OS sits waiting for a keypress, per machine: the place to interrupt with a program. */
4
+ export function basicIdleAddr(model) {
5
+ return model.isMaster ? 0xe7e6 : 0xe581;
6
+ }
7
+
8
+ /**
9
+ * Pokes a tokenised BASIC program into memory at PAGE, and sets TOP and
10
+ * VARTOP after it, exactly as if it had just been typed.
11
+ */
12
+ export function installBasic(tokenised, { readByte, writeByte }) {
13
+ const page = readByte(0x18) << 8;
14
+ for (let i = 0; i < tokenised.length; ++i) {
15
+ writeByte(page + i, tokenised.charCodeAt(i));
16
+ }
17
+ // Set VARTOP (0x12/3) and TOP(0x02/3)
18
+ const end = page + tokenised.length;
19
+ const endLow = end & 0xff;
20
+ const endHigh = (end >>> 8) & 0xff;
21
+ writeByte(0x02, endLow);
22
+ writeByte(0x03, endHigh);
23
+ writeByte(0x12, endLow);
24
+ writeByte(0x13, endHigh);
25
+ }
package/src/dom-utils.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import { replaceOrAddExtension } from "./utils.js";
4
+
3
5
  // Minimal DOM helpers to replace jQuery usage.
4
6
 
5
7
  export function show(el) {
@@ -46,3 +48,9 @@ export function downloadBlob(blob, fileName) {
46
48
  a.remove();
47
49
  setTimeout(() => URL.revokeObjectURL(url), BlobUrlLifetimeMs);
48
50
  }
51
+
52
+ /** Save raw image bytes under the disc's name with the extension of the format they are in. */
53
+ export function downloadDriveData(data, name, extension) {
54
+ const blob = new Blob([data], { type: "application/octet-stream" });
55
+ downloadBlob(blob, replaceOrAddExtension(name, extension));
56
+ }