c64-ready 1.0.0 → 1.0.1
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/dist/assets/CHANGELOG-B12WeYEc.js +116 -0
- package/dist/assets/index-fUdEY2R7.js +610 -0
- package/dist/index.html +1 -1
- package/dist-ts/emulator/c64-emulator.d.ts +3 -0
- package/dist-ts/emulator/c64-emulator.d.ts.map +1 -1
- package/dist-ts/emulator/c64-emulator.js +36 -4
- package/dist-ts/emulator/c64-emulator.js.map +1 -1
- package/dist-ts/emulator/crt-info.d.ts +61 -0
- package/dist-ts/emulator/crt-info.d.ts.map +1 -0
- package/dist-ts/emulator/crt-info.js +190 -0
- package/dist-ts/emulator/crt-info.js.map +1 -0
- package/dist-ts/emulator/input.d.ts +96 -0
- package/dist-ts/emulator/input.d.ts.map +1 -1
- package/dist-ts/emulator/input.js +549 -4
- package/dist-ts/emulator/input.js.map +1 -1
- package/dist-ts/headless/c64-headless.d.ts +1 -0
- package/dist-ts/headless/c64-headless.d.ts.map +1 -1
- package/dist-ts/headless/c64-headless.js +5 -0
- package/dist-ts/headless/c64-headless.js.map +1 -1
- package/dist-ts/types/emulator.d.ts +2 -1
- package/dist-ts/types/emulator.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/emulator/c64-emulator.ts +34 -2
- package/src/emulator/crt-info.ts +35 -23
- package/src/headless/c64-headless.ts +5 -0
- package/src/headless/headless-cli.mjs +406 -229
- package/src/headless/input-server.mjs +397 -200
- package/src/headless/webrtc-server.mjs +168 -67
- package/src/main.ts +18 -4
- package/src/player/c64-player.ts +102 -36
- package/src/player/styles/ui-controller.css +90 -21
- package/src/player/ui-controller.ts +58 -11
- package/dist/assets/CHANGELOG-CPlXKLCV.js +0 -279
- package/dist/assets/index-Ckbi7gQo.js +0 -535
package/src/player/c64-player.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C64Emulator } from '../emulator/c64-emulator';
|
|
2
2
|
import { domKeyToC64Actions } from '../emulator/input';
|
|
3
|
-
import { parseCrtInfo } from '../emulator/crt-info';
|
|
3
|
+
import { getUnsupportedCrtReason, parseCrtInfo } from '../emulator/crt-info';
|
|
4
4
|
import type { GameLoadOptions } from '../types';
|
|
5
5
|
import type { JoystickPort } from '../emulator/constants';
|
|
6
6
|
import type { InputMode } from '../emulator/input';
|
|
@@ -22,6 +22,7 @@ export interface C64PlayerOptions {
|
|
|
22
22
|
export class C64Player {
|
|
23
23
|
private emulator: C64Emulator | null = null;
|
|
24
24
|
private inputHandler: InputHandler | null = null;
|
|
25
|
+
private disableCrtPreloadChecks: boolean = false;
|
|
25
26
|
readonly audio = new AudioEngine();
|
|
26
27
|
private readonly options: Required<Pick<C64PlayerOptions, 'wasmUrl' | 'gameUrl' | 'gameType'>> &
|
|
27
28
|
C64PlayerOptions;
|
|
@@ -35,10 +36,8 @@ export class C64Player {
|
|
|
35
36
|
|
|
36
37
|
onProgress?.(10, 'INITIALISING WASM...');
|
|
37
38
|
this.emulator = await C64Emulator.load(wasmUrl);
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
this.inputHandler.attach();
|
|
41
|
-
renderer.attachTo(this.emulator);
|
|
39
|
+
this.emulator.setCrtPreloadChecksEnabled(!this.disableCrtPreloadChecks);
|
|
40
|
+
this.attachInputAndRenderer(this.emulator, renderer);
|
|
42
41
|
|
|
43
42
|
if (gameUrl && gameUrl !== 'null') {
|
|
44
43
|
await this.loadGame(gameUrl, gameType, onProgress);
|
|
@@ -60,7 +59,6 @@ export class C64Player {
|
|
|
60
59
|
*/
|
|
61
60
|
private initAudio(): void {
|
|
62
61
|
if (!this.emulator) return;
|
|
63
|
-
const emulator = this.emulator;
|
|
64
62
|
|
|
65
63
|
// Notify the UI whenever audio state changes
|
|
66
64
|
this.audio.onStateChange = (state) => {
|
|
@@ -69,11 +67,12 @@ export class C64Player {
|
|
|
69
67
|
|
|
70
68
|
// Fire-and-forget init
|
|
71
69
|
this.audio.init().then((autoplayOk) => {
|
|
70
|
+
if (!this.emulator) return;
|
|
72
71
|
// Tell the SID what sample rate we're using (matches AudioContext)
|
|
73
|
-
emulator.setSampleRate(this.audio.sampleRate);
|
|
72
|
+
this.emulator.setSampleRate(this.audio.sampleRate);
|
|
74
73
|
|
|
75
74
|
// Give the engine a reader that snapshots the SID circular buffer
|
|
76
|
-
this.audio.setSidBufferReader(() => emulator
|
|
75
|
+
this.audio.setSidBufferReader(() => this.emulator?.getSidBuffer() ?? null);
|
|
77
76
|
|
|
78
77
|
if (!autoplayOk) {
|
|
79
78
|
window.dispatchEvent(new CustomEvent('c64-audio-suspended'));
|
|
@@ -123,22 +122,13 @@ export class C64Player {
|
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(type)}...`);
|
|
126
|
-
// Basic validation for cartridge files — some malformed .crt files can
|
|
127
|
-
// silently fail inside the WASM loader; catch common format problems here
|
|
128
|
-
if (type === 'crt' && !isValidCRT(data)) {
|
|
129
|
-
onProgress?.(0, 'INVALID CRT');
|
|
130
|
-
const err = new Error('Invalid CRT file format');
|
|
131
|
-
console.error(err);
|
|
132
|
-
throw err;
|
|
133
|
-
}
|
|
134
|
-
if (type === 'crt') {
|
|
135
|
-
const filename = url.split('/').pop() ?? url;
|
|
136
|
-
const info = parseCrtInfo(data, filename);
|
|
137
|
-
if (info) console.log(info.line);
|
|
138
|
-
}
|
|
139
125
|
this.assertSnapshotFormatSupported(data, type, url);
|
|
140
126
|
this.emitSnapshotLoadInfo(type, url);
|
|
141
127
|
try {
|
|
128
|
+
if (type === 'crt') {
|
|
129
|
+
const filename = url.split('/').pop() ?? url;
|
|
130
|
+
this.handleCrtPreloadChecks(data, filename, onProgress);
|
|
131
|
+
}
|
|
142
132
|
this.emulator.loadGame({ type, data });
|
|
143
133
|
if (type === 'prg') {
|
|
144
134
|
await this.autoRunPrgIfRunning();
|
|
@@ -151,7 +141,9 @@ export class C64Player {
|
|
|
151
141
|
console.error('Failed to insert cartridge or load game:', err);
|
|
152
142
|
// Surface a global event so UI can react if needed
|
|
153
143
|
window.dispatchEvent(
|
|
154
|
-
new CustomEvent('c64-load-error', {
|
|
144
|
+
new CustomEvent('c64-load-error', {
|
|
145
|
+
detail: { error: err instanceof Error ? err.message : String(err), url, type },
|
|
146
|
+
}),
|
|
155
147
|
);
|
|
156
148
|
throw err;
|
|
157
149
|
}
|
|
@@ -167,19 +159,12 @@ export class C64Player {
|
|
|
167
159
|
const ab = await file.arrayBuffer();
|
|
168
160
|
const data = new Uint8Array(ab);
|
|
169
161
|
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(resolvedType)}...`);
|
|
170
|
-
if (resolvedType === 'crt' && !isValidCRT(data)) {
|
|
171
|
-
onProgress?.(0, 'INVALID CRT');
|
|
172
|
-
const err = new Error('Invalid CRT file format');
|
|
173
|
-
console.error(err);
|
|
174
|
-
throw err;
|
|
175
|
-
}
|
|
176
|
-
if (resolvedType === 'crt') {
|
|
177
|
-
const info = parseCrtInfo(data, file.name);
|
|
178
|
-
if (info) console.log(info.line);
|
|
179
|
-
}
|
|
180
162
|
this.assertSnapshotFormatSupported(data, resolvedType, file.name);
|
|
181
163
|
this.emitSnapshotLoadInfo(resolvedType, file.name);
|
|
182
164
|
try {
|
|
165
|
+
if (resolvedType === 'crt') {
|
|
166
|
+
this.handleCrtPreloadChecks(data, file.name, onProgress);
|
|
167
|
+
}
|
|
183
168
|
this.emulator.loadGame({ type: resolvedType, data });
|
|
184
169
|
if (resolvedType === 'prg') {
|
|
185
170
|
await this.autoRunPrgIfRunning();
|
|
@@ -193,7 +178,11 @@ export class C64Player {
|
|
|
193
178
|
console.error('Failed to insert cartridge from file:', err);
|
|
194
179
|
window.dispatchEvent(
|
|
195
180
|
new CustomEvent('c64-load-error', {
|
|
196
|
-
detail: {
|
|
181
|
+
detail: {
|
|
182
|
+
error: err instanceof Error ? err.message : String(err),
|
|
183
|
+
file: file.name,
|
|
184
|
+
type: resolvedType,
|
|
185
|
+
},
|
|
197
186
|
}),
|
|
198
187
|
);
|
|
199
188
|
throw err;
|
|
@@ -247,6 +236,22 @@ export class C64Player {
|
|
|
247
236
|
}
|
|
248
237
|
}
|
|
249
238
|
|
|
239
|
+
async reboot(): Promise<void> {
|
|
240
|
+
if (!this.emulator) return;
|
|
241
|
+
try {
|
|
242
|
+
await this.emulator.reboot();
|
|
243
|
+
this.attachInputAndRenderer(this.emulator, this.options.renderer);
|
|
244
|
+
this.emulator.start();
|
|
245
|
+
this.emulator.setSampleRate(this.audio.sampleRate);
|
|
246
|
+
this.audio.setSidBufferReader(() => this.emulator?.getSidBuffer() ?? null);
|
|
247
|
+
window.dispatchEvent(new CustomEvent('c64-reboot', { detail: {} }));
|
|
248
|
+
window.dispatchEvent(new CustomEvent('c64-close-menu'));
|
|
249
|
+
} catch (e) {
|
|
250
|
+
console.error('Failed to reboot emulator:', e);
|
|
251
|
+
throw e;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
250
255
|
/**
|
|
251
256
|
* Change which joystick port keyboard events map to (1 or 2).
|
|
252
257
|
* Delegates to the InputHandler created during start().
|
|
@@ -266,6 +271,11 @@ export class C64Player {
|
|
|
266
271
|
this.inputHandler?.setInputMode(mode);
|
|
267
272
|
}
|
|
268
273
|
|
|
274
|
+
setCrtPreloadChecksDisabled(disabled: boolean): void {
|
|
275
|
+
this.disableCrtPreloadChecks = disabled;
|
|
276
|
+
this.emulator?.setCrtPreloadChecksEnabled(!disabled);
|
|
277
|
+
}
|
|
278
|
+
|
|
269
279
|
private async autoRunPrgIfRunning(): Promise<void> {
|
|
270
280
|
if (!this.emulator || !this.emulator.isRunning()) return;
|
|
271
281
|
await waitMs(220);
|
|
@@ -329,11 +339,67 @@ export class C64Player {
|
|
|
329
339
|
);
|
|
330
340
|
throw err;
|
|
331
341
|
}
|
|
342
|
+
|
|
343
|
+
private attachInputAndRenderer(emulator: C64Emulator, renderer: CanvasRenderer): void {
|
|
344
|
+
this.inputHandler?.detach();
|
|
345
|
+
this.inputHandler = new InputHandler(emulator);
|
|
346
|
+
this.inputHandler.attach();
|
|
347
|
+
renderer.attachTo(emulator);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
private handleCrtPreloadChecks(
|
|
351
|
+
data: Uint8Array,
|
|
352
|
+
source: string,
|
|
353
|
+
onProgress?: ProgressCallback,
|
|
354
|
+
): void {
|
|
355
|
+
if (!this.disableCrtPreloadChecks) {
|
|
356
|
+
validateCrtSupportOrThrow(data, source, onProgress);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const info = parseCrtInfo(data, source);
|
|
361
|
+
if (!info) return;
|
|
362
|
+
|
|
363
|
+
console.log(info.line);
|
|
364
|
+
const unsupportedReason = getUnsupportedCrtReason(info);
|
|
365
|
+
if (!unsupportedReason) return;
|
|
366
|
+
|
|
367
|
+
onProgress?.(90, 'UNSAFE CRT LOAD');
|
|
368
|
+
const message =
|
|
369
|
+
'Preload checks are disabled. This cartridge is normally flagged as incompatible and may hang the emulator.';
|
|
370
|
+
console.warn(`${unsupportedReason} Proceeding because preload checks are disabled.`);
|
|
371
|
+
window.dispatchEvent(
|
|
372
|
+
new CustomEvent('c64-load-info', {
|
|
373
|
+
detail: {
|
|
374
|
+
mode: 'warning',
|
|
375
|
+
source,
|
|
376
|
+
message,
|
|
377
|
+
},
|
|
378
|
+
}),
|
|
379
|
+
);
|
|
380
|
+
}
|
|
332
381
|
}
|
|
333
382
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
383
|
+
function validateCrtSupportOrThrow(
|
|
384
|
+
data: Uint8Array,
|
|
385
|
+
source: string,
|
|
386
|
+
onProgress?: ProgressCallback,
|
|
387
|
+
): void {
|
|
388
|
+
const info = parseCrtInfo(data, source);
|
|
389
|
+
if (!info) {
|
|
390
|
+
onProgress?.(0, 'INVALID CRT');
|
|
391
|
+
const err = new Error('Invalid CRT file format');
|
|
392
|
+
console.error(err);
|
|
393
|
+
throw err;
|
|
394
|
+
}
|
|
395
|
+
console.log(info.line);
|
|
396
|
+
const unsupportedReason = getUnsupportedCrtReason(info);
|
|
397
|
+
if (unsupportedReason) {
|
|
398
|
+
onProgress?.(0, 'UNSUPPORTED CRT');
|
|
399
|
+
const err = new Error(unsupportedReason);
|
|
400
|
+
console.error(err);
|
|
401
|
+
throw err;
|
|
402
|
+
}
|
|
337
403
|
}
|
|
338
404
|
|
|
339
405
|
function formatLoadProgressLabel(type: GameLoadOptions['type']): string {
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
display: flex;
|
|
18
18
|
align-items: center;
|
|
19
19
|
justify-content: center;
|
|
20
|
-
transition:
|
|
20
|
+
transition:
|
|
21
|
+
border-color 0.2s,
|
|
22
|
+
color 0.2s;
|
|
21
23
|
z-index: 1000;
|
|
22
24
|
}
|
|
23
25
|
.c64-help-btn:hover {
|
|
@@ -155,7 +157,10 @@
|
|
|
155
157
|
align-items: center;
|
|
156
158
|
justify-content: center;
|
|
157
159
|
z-index: 1010;
|
|
158
|
-
transition:
|
|
160
|
+
transition:
|
|
161
|
+
border-color 0.2s,
|
|
162
|
+
color 0.2s,
|
|
163
|
+
opacity 0.3s;
|
|
159
164
|
animation: c64-unmute-pulse 2s ease-in-out infinite;
|
|
160
165
|
}
|
|
161
166
|
.c64-unmute-btn:hover {
|
|
@@ -167,8 +172,13 @@
|
|
|
167
172
|
pointer-events: none;
|
|
168
173
|
}
|
|
169
174
|
@keyframes c64-unmute-pulse {
|
|
170
|
-
0%,
|
|
171
|
-
|
|
175
|
+
0%,
|
|
176
|
+
100% {
|
|
177
|
+
transform: scale(1);
|
|
178
|
+
}
|
|
179
|
+
50% {
|
|
180
|
+
transform: scale(1.05);
|
|
181
|
+
}
|
|
172
182
|
}
|
|
173
183
|
.c64-audio-section {
|
|
174
184
|
margin-top: 16px;
|
|
@@ -199,8 +209,12 @@
|
|
|
199
209
|
justify-content: center;
|
|
200
210
|
flex-shrink: 0;
|
|
201
211
|
}
|
|
202
|
-
.c64-mute-btn:hover {
|
|
203
|
-
|
|
212
|
+
.c64-mute-btn:hover {
|
|
213
|
+
border-color: #7b71d5;
|
|
214
|
+
}
|
|
215
|
+
.c64-mute-btn.muted {
|
|
216
|
+
color: #f44;
|
|
217
|
+
}
|
|
204
218
|
.c64-volume-slider {
|
|
205
219
|
flex: 1;
|
|
206
220
|
-webkit-appearance: none;
|
|
@@ -255,7 +269,7 @@
|
|
|
255
269
|
.c64-menu-overlay {
|
|
256
270
|
position: fixed;
|
|
257
271
|
inset: 0;
|
|
258
|
-
background: rgba(0,0,0,0.5);
|
|
272
|
+
background: rgba(0, 0, 0, 0.5);
|
|
259
273
|
display: flex;
|
|
260
274
|
align-items: flex-start;
|
|
261
275
|
justify-content: flex-start;
|
|
@@ -265,7 +279,10 @@
|
|
|
265
279
|
opacity: 0;
|
|
266
280
|
transition: opacity 0.2s ease;
|
|
267
281
|
}
|
|
268
|
-
.c64-menu-overlay.visible {
|
|
282
|
+
.c64-menu-overlay.visible {
|
|
283
|
+
opacity: 1;
|
|
284
|
+
pointer-events: auto;
|
|
285
|
+
}
|
|
269
286
|
.c64-menu-panel {
|
|
270
287
|
background: #0f0f1a;
|
|
271
288
|
border: 2px solid #333;
|
|
@@ -275,8 +292,18 @@
|
|
|
275
292
|
color: #ddd;
|
|
276
293
|
font-family: monospace;
|
|
277
294
|
}
|
|
278
|
-
.c64-menu-header {
|
|
279
|
-
|
|
295
|
+
.c64-menu-header {
|
|
296
|
+
display: flex;
|
|
297
|
+
align-items: center;
|
|
298
|
+
justify-content: space-between;
|
|
299
|
+
}
|
|
300
|
+
.c64-menu-close {
|
|
301
|
+
background: none;
|
|
302
|
+
border: none;
|
|
303
|
+
color: #888;
|
|
304
|
+
font-size: 20px;
|
|
305
|
+
cursor: pointer;
|
|
306
|
+
}
|
|
280
307
|
.c64-settings-tabs {
|
|
281
308
|
display: flex;
|
|
282
309
|
gap: 8px;
|
|
@@ -351,22 +378,49 @@
|
|
|
351
378
|
margin-top: 12px;
|
|
352
379
|
text-align: center;
|
|
353
380
|
color: #aaa;
|
|
354
|
-
background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
|
|
381
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent);
|
|
355
382
|
}
|
|
356
383
|
.c64-dragarea button {
|
|
357
384
|
margin-left: 6px;
|
|
358
385
|
}
|
|
359
|
-
.c64-dragarea.dragover {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
.c64-cart-
|
|
364
|
-
|
|
386
|
+
.c64-dragarea.dragover {
|
|
387
|
+
border-color: #7b71d5;
|
|
388
|
+
color: #fff;
|
|
389
|
+
}
|
|
390
|
+
.c64-cart-preview {
|
|
391
|
+
display: flex;
|
|
392
|
+
gap: 12px;
|
|
393
|
+
align-items: center;
|
|
394
|
+
margin-top: 12px;
|
|
395
|
+
}
|
|
396
|
+
.c64-cart-icon {
|
|
397
|
+
width: 56px;
|
|
398
|
+
height: 40px;
|
|
399
|
+
background: #222;
|
|
400
|
+
border: 1px solid #333;
|
|
401
|
+
display: flex;
|
|
402
|
+
align-items: center;
|
|
403
|
+
justify-content: center;
|
|
404
|
+
border-radius: 4px;
|
|
405
|
+
}
|
|
406
|
+
.c64-cart-filename {
|
|
407
|
+
font-size: 13px;
|
|
408
|
+
color: #ccc;
|
|
409
|
+
word-break: break-all;
|
|
410
|
+
}
|
|
411
|
+
.c64-cart-type {
|
|
412
|
+
font-size: 11px;
|
|
413
|
+
color: #888;
|
|
414
|
+
margin-top: 2px;
|
|
415
|
+
}
|
|
416
|
+
.c64-file-input {
|
|
417
|
+
display: none;
|
|
418
|
+
}
|
|
365
419
|
.c64-menu-actions {
|
|
366
|
-
margin-top:12px;
|
|
367
|
-
display:flex;
|
|
420
|
+
margin-top: 12px;
|
|
421
|
+
display: flex;
|
|
368
422
|
flex-wrap: wrap;
|
|
369
|
-
gap:8px;
|
|
423
|
+
gap: 8px;
|
|
370
424
|
}
|
|
371
425
|
.c64-system-actions {
|
|
372
426
|
margin-top: 4px;
|
|
@@ -374,4 +428,19 @@
|
|
|
374
428
|
gap: 8px;
|
|
375
429
|
flex-wrap: wrap;
|
|
376
430
|
}
|
|
377
|
-
.c64-
|
|
431
|
+
.c64-checkbox-row {
|
|
432
|
+
margin-top: 10px;
|
|
433
|
+
display: inline-flex;
|
|
434
|
+
gap: 8px;
|
|
435
|
+
align-items: center;
|
|
436
|
+
color: #ccc;
|
|
437
|
+
font-size: 13px;
|
|
438
|
+
}
|
|
439
|
+
.c64-btn {
|
|
440
|
+
background: #222;
|
|
441
|
+
border: 1px solid #444;
|
|
442
|
+
color: #ddd;
|
|
443
|
+
padding: 6px 10px;
|
|
444
|
+
border-radius: 4px;
|
|
445
|
+
cursor: pointer;
|
|
446
|
+
}
|
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
type LoadTypeSelection,
|
|
38
38
|
} from './load-formats';
|
|
39
39
|
|
|
40
|
+
const CRT_PRELOAD_CHECKS_STORAGE_KEY = 'c64-disable-crt-preload-checks';
|
|
41
|
+
|
|
40
42
|
export default class UIController {
|
|
41
43
|
private helpOverlay: HTMLElement | null = null;
|
|
42
44
|
private settingsOverlay: HTMLElement | null = null;
|
|
@@ -284,7 +286,13 @@ export default class UIController {
|
|
|
284
286
|
<div class="c64-system-actions">
|
|
285
287
|
<button class="c64-btn" id="c64-detach-btn">Detach Cartridge</button>
|
|
286
288
|
<button class="c64-btn" id="c64-reset-btn">Hard Reset</button>
|
|
289
|
+
<button class="c64-btn" id="c64-reboot-btn">Reboot Emulator</button>
|
|
287
290
|
</div>
|
|
291
|
+
<label class="c64-checkbox-row" for="c64-disable-crt-preload-checks">
|
|
292
|
+
<input type="checkbox" id="c64-disable-crt-preload-checks" />
|
|
293
|
+
Disable crt preload checks
|
|
294
|
+
</label>
|
|
295
|
+
<div class="c64-section-hint">Allows any .crt file and skips compatibility prechecks.</div>
|
|
288
296
|
</section>
|
|
289
297
|
</div>
|
|
290
298
|
</div>
|
|
@@ -298,10 +306,10 @@ export default class UIController {
|
|
|
298
306
|
// The settings overlay is the overlay we just created
|
|
299
307
|
this.settingsOverlay = overlay;
|
|
300
308
|
|
|
301
|
-
const tabButtons = panel.querySelectorAll(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
) as NodeListOf<HTMLElement>;
|
|
309
|
+
const tabButtons = panel.querySelectorAll(
|
|
310
|
+
'[data-settings-tab]',
|
|
311
|
+
) as NodeListOf<HTMLButtonElement>;
|
|
312
|
+
const sectionEls = panel.querySelectorAll('[data-settings-section]') as NodeListOf<HTMLElement>;
|
|
305
313
|
|
|
306
314
|
const activateSection = (sectionId: string) => {
|
|
307
315
|
tabButtons.forEach((tab) => {
|
|
@@ -409,12 +417,11 @@ export default class UIController {
|
|
|
409
417
|
};
|
|
410
418
|
|
|
411
419
|
const parseManifest = (raw: unknown): ToolItem[] => {
|
|
412
|
-
const entries: unknown[] =
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
: [];
|
|
420
|
+
const entries: unknown[] = Array.isArray(raw)
|
|
421
|
+
? raw
|
|
422
|
+
: raw && typeof raw === 'object' && Array.isArray((raw as { tools?: unknown[] }).tools)
|
|
423
|
+
? (raw as { tools: unknown[] }).tools
|
|
424
|
+
: [];
|
|
418
425
|
|
|
419
426
|
return entries
|
|
420
427
|
.map((entry) => {
|
|
@@ -433,7 +440,10 @@ export default class UIController {
|
|
|
433
440
|
.map((part) => encodeURIComponent(part))
|
|
434
441
|
.join('/');
|
|
435
442
|
const normalizedPath = encodedPath.replace(/^\/+/, '');
|
|
436
|
-
const url = `${import.meta.env.BASE_URL}tools/${normalizedPath}`.replace(
|
|
443
|
+
const url = `${import.meta.env.BASE_URL}tools/${normalizedPath}`.replace(
|
|
444
|
+
/([^:]\/)\/+/,
|
|
445
|
+
'$1',
|
|
446
|
+
);
|
|
437
447
|
return { name: filename, url, type } satisfies ToolItem;
|
|
438
448
|
})
|
|
439
449
|
.filter((v): v is ToolItem => !!v);
|
|
@@ -472,6 +482,22 @@ export default class UIController {
|
|
|
472
482
|
// Detach cartridge / hard reset controls
|
|
473
483
|
const detachBtn = section?.querySelector('#c64-detach-btn') as HTMLButtonElement | null;
|
|
474
484
|
const resetBtn = section?.querySelector('#c64-reset-btn') as HTMLButtonElement | null;
|
|
485
|
+
const rebootBtn = section?.querySelector('#c64-reboot-btn') as HTMLButtonElement | null;
|
|
486
|
+
const disableChecksToggle = section?.querySelector(
|
|
487
|
+
'#c64-disable-crt-preload-checks',
|
|
488
|
+
) as HTMLInputElement | null;
|
|
489
|
+
|
|
490
|
+
const disableCrtPreloadChecks =
|
|
491
|
+
window.localStorage.getItem(CRT_PRELOAD_CHECKS_STORAGE_KEY) === '1';
|
|
492
|
+
this.player?.setCrtPreloadChecksDisabled(disableCrtPreloadChecks);
|
|
493
|
+
if (disableChecksToggle) {
|
|
494
|
+
disableChecksToggle.checked = disableCrtPreloadChecks;
|
|
495
|
+
disableChecksToggle.addEventListener('change', () => {
|
|
496
|
+
const disabled = disableChecksToggle.checked;
|
|
497
|
+
window.localStorage.setItem(CRT_PRELOAD_CHECKS_STORAGE_KEY, disabled ? '1' : '0');
|
|
498
|
+
this.player?.setCrtPreloadChecksDisabled(disabled);
|
|
499
|
+
});
|
|
500
|
+
}
|
|
475
501
|
if (detachBtn) {
|
|
476
502
|
detachBtn.addEventListener('click', () => {
|
|
477
503
|
if (!this.player) return;
|
|
@@ -495,6 +521,27 @@ export default class UIController {
|
|
|
495
521
|
}
|
|
496
522
|
});
|
|
497
523
|
}
|
|
524
|
+
if (rebootBtn) {
|
|
525
|
+
rebootBtn.addEventListener('click', async () => {
|
|
526
|
+
if (!this.player) return;
|
|
527
|
+
if (!confirm('Perform full reboot? This re-instantiates the emulator with no game loaded.'))
|
|
528
|
+
return;
|
|
529
|
+
const statusEl = document.getElementById('status');
|
|
530
|
+
if (statusEl) {
|
|
531
|
+
statusEl.textContent = 'Rebooting emulator...';
|
|
532
|
+
}
|
|
533
|
+
try {
|
|
534
|
+
await this.player.reboot();
|
|
535
|
+
if (statusEl) {
|
|
536
|
+
statusEl.textContent = 'Emulator rebooted (no game loaded)';
|
|
537
|
+
}
|
|
538
|
+
} catch (err) {
|
|
539
|
+
if (statusEl) {
|
|
540
|
+
statusEl.textContent = `Reboot failed: ${String((err as Error)?.message ?? err)}`;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
498
545
|
|
|
499
546
|
// ── Audio section ─────────────────────────────────────────────────────
|
|
500
547
|
const audioContainer = panel.querySelector('#c64-audio-section-anchor') as HTMLElement;
|