jsbeeb 1.10.0 → 1.12.0
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 +1 -1
- package/package.json +2 -7
- package/src/6502.js +8 -1
- package/src/app/app.js +1 -1
- package/src/app/electron.js +8 -8
- package/src/bem-snapshot.js +7 -218
- package/src/config.js +79 -62
- package/src/dom-utils.js +32 -0
- package/src/google-drive.js +3 -4
- package/src/keyboard.js +17 -14
- package/src/main.js +267 -235
- package/src/models.js +4 -4
- package/src/snapshot-helpers.js +208 -0
- package/src/snapshot.js +9 -18
- package/src/sth.js +1 -1
- package/src/tapes.js +2 -2
- package/src/uef-snapshot.js +402 -0
- package/src/utils.js +146 -15
- package/src/web/audio-handler.js +41 -25
- package/src/web/debug.js +100 -71
package/src/google-drive.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import * as utils from "./utils.js";
|
|
3
|
+
import { debounce, uint8ArrayToString } from "./utils.js";
|
|
5
4
|
import { discFor } from "./fdc.js";
|
|
6
5
|
|
|
7
6
|
const MIME_TYPE = "application/vnd.jsbeeb.disc-image";
|
|
@@ -112,7 +111,7 @@ export class GoogleDriveLoader {
|
|
|
112
111
|
const metadata = { name, mimeType: MIME_TYPE };
|
|
113
112
|
if (!idOrNone) metadata.parents = [this.parentFolderId];
|
|
114
113
|
|
|
115
|
-
const base64Data = btoa(
|
|
114
|
+
const base64Data = btoa(uint8ArrayToString(data));
|
|
116
115
|
const multipartRequestBody =
|
|
117
116
|
`${delimiter}Content-Type: application/json\r\n\r\n` +
|
|
118
117
|
`${JSON.stringify(metadata)}${delimiter}` +
|
|
@@ -141,7 +140,7 @@ export class GoogleDriveLoader {
|
|
|
141
140
|
const id = meta.id;
|
|
142
141
|
if (meta.capabilities.canEdit) {
|
|
143
142
|
console.log("Making editable disc");
|
|
144
|
-
flusher =
|
|
143
|
+
flusher = debounce(async (changedData) => {
|
|
145
144
|
console.log("Data changed...");
|
|
146
145
|
await this.saveFile(name, changedData, id);
|
|
147
146
|
console.log("Saved ok");
|
package/src/keyboard.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import * as utils from "./utils.js";
|
|
3
|
-
import EventEmitter from "event-emitter-es6";
|
|
4
3
|
|
|
5
4
|
const isMac = typeof window !== "undefined" && /^Mac/i.test(window.navigator?.platform || "");
|
|
6
5
|
|
|
@@ -15,7 +14,7 @@ const isMac = typeof window !== "undefined" && /^Mac/i.test(window.navigator?.pl
|
|
|
15
14
|
/**
|
|
16
15
|
* Keyboard class that handles all keyboard related functionality
|
|
17
16
|
*/
|
|
18
|
-
export class Keyboard extends
|
|
17
|
+
export class Keyboard extends EventTarget {
|
|
19
18
|
/**
|
|
20
19
|
* Create a new Keyboard instance with specified configuration
|
|
21
20
|
* @param {KeyboardConfig} config - The configuration object
|
|
@@ -182,7 +181,7 @@ export class Keyboard extends EventEmitter {
|
|
|
182
181
|
// Handle debugger 'g' key press
|
|
183
182
|
if (this.dbgr.enabled() && code === LOWERCASE_G) {
|
|
184
183
|
this.dbgr.hide();
|
|
185
|
-
this.
|
|
184
|
+
this.dispatchEvent(new Event("resume"));
|
|
186
185
|
return;
|
|
187
186
|
}
|
|
188
187
|
|
|
@@ -193,7 +192,7 @@ export class Keyboard extends EventEmitter {
|
|
|
193
192
|
return;
|
|
194
193
|
} else if (code === LOWERCASE_N) {
|
|
195
194
|
this.requestStep();
|
|
196
|
-
this.
|
|
195
|
+
this.dispatchEvent(new Event("resume"));
|
|
197
196
|
return;
|
|
198
197
|
}
|
|
199
198
|
}
|
|
@@ -247,7 +246,7 @@ export class Keyboard extends EventEmitter {
|
|
|
247
246
|
*/
|
|
248
247
|
_handleSpecialKeys(code) {
|
|
249
248
|
if (code === utils.keyCodes.F12 || code === utils.keyCodes.BREAK) {
|
|
250
|
-
this.
|
|
249
|
+
this.dispatchEvent(new CustomEvent("break", { detail: true }));
|
|
251
250
|
this.processor.setReset(true);
|
|
252
251
|
return true;
|
|
253
252
|
} else if (isMac && code === utils.keyCodes.CAPSLOCK) {
|
|
@@ -278,7 +277,7 @@ export class Keyboard extends EventEmitter {
|
|
|
278
277
|
|
|
279
278
|
// Handle special key cases
|
|
280
279
|
if (code === utils.keyCodes.F12 || code === utils.keyCodes.BREAK) {
|
|
281
|
-
this.
|
|
280
|
+
this.dispatchEvent(new CustomEvent("break", { detail: false }));
|
|
282
281
|
this.processor.setReset(false);
|
|
283
282
|
return;
|
|
284
283
|
} else if (isMac && code === utils.keyCodes.CAPSLOCK) {
|
|
@@ -308,14 +307,18 @@ export class Keyboard extends EventEmitter {
|
|
|
308
307
|
setTimeout(() => this.processor.sysvia.keyUp(utils.keyCodes.CAPSLOCK), CAPS_LOCK_DELAY);
|
|
309
308
|
|
|
310
309
|
if (isMac && window.localStorage && !window.localStorage.getItem("warnedAboutRubbishMacs")) {
|
|
311
|
-
this.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
this.dispatchEvent(
|
|
311
|
+
new CustomEvent("showError", {
|
|
312
|
+
detail: {
|
|
313
|
+
context: "handling caps lock on Mac OS X",
|
|
314
|
+
error: `Mac OS X does not generate key up events for caps lock presses.
|
|
315
|
+
jsbeeb can only simulate a 'tap' of the caps lock key. This means it doesn't work well for games
|
|
316
|
+
that use caps lock for left or fire, as we can't tell if it's being held down. If you need to play
|
|
316
317
|
such a game, please see the documentation about remapping keys.
|
|
317
318
|
Close this window to continue (you won't see this error again)`,
|
|
318
|
-
|
|
319
|
+
},
|
|
320
|
+
}),
|
|
321
|
+
);
|
|
319
322
|
window.localStorage.setItem("warnedAboutRubbishMacs", "true");
|
|
320
323
|
}
|
|
321
324
|
}
|
|
@@ -437,7 +440,7 @@ export class Keyboard extends EventEmitter {
|
|
|
437
440
|
*/
|
|
438
441
|
pauseEmulation() {
|
|
439
442
|
this.pauseEmu = true;
|
|
440
|
-
this.
|
|
443
|
+
this.dispatchEvent(new Event("pause"));
|
|
441
444
|
}
|
|
442
445
|
|
|
443
446
|
/**
|
|
@@ -445,6 +448,6 @@ export class Keyboard extends EventEmitter {
|
|
|
445
448
|
*/
|
|
446
449
|
resumeEmulation() {
|
|
447
450
|
this.pauseEmu = false;
|
|
448
|
-
this.
|
|
451
|
+
this.dispatchEvent(new Event("resume"));
|
|
449
452
|
}
|
|
450
453
|
}
|