c64-ready 2.1.1 → 2.4.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/bin/admin.mjs +0 -0
- package/bin/headless.mjs +1 -0
- package/dist/assets/index-Dxuihfdi.js +177 -0
- package/dist/index.html +1 -1
- package/dist-ts/emulator/c64-emulator.d.ts +1 -1
- package/dist-ts/emulator/c64-emulator.d.ts.map +1 -1
- package/dist-ts/emulator/c64-emulator.js +1 -0
- package/dist-ts/emulator/c64-emulator.js.map +1 -1
- package/dist-ts/emulator/c64-wasm.d.ts +4 -4
- package/dist-ts/emulator/c64-wasm.d.ts.map +1 -1
- package/dist-ts/emulator/c64-wasm.js.map +1 -1
- package/dist-ts/emulator/input.d.ts +9 -2
- package/dist-ts/emulator/input.d.ts.map +1 -1
- package/dist-ts/emulator/input.js +40 -10
- package/dist-ts/emulator/input.js.map +1 -1
- package/dist-ts/player/audio-engine.d.ts.map +1 -1
- package/dist-ts/player/audio-engine.js +4 -0
- package/dist-ts/player/audio-engine.js.map +1 -1
- package/dist-ts/player/c64-player.d.ts +8 -1
- package/dist-ts/player/c64-player.d.ts.map +1 -1
- package/dist-ts/player/c64-player.js +71 -4
- package/dist-ts/player/c64-player.js.map +1 -1
- package/dist-ts/player/index.d.ts +1 -1
- package/dist-ts/player/index.d.ts.map +1 -1
- package/dist-ts/player/input-handler.d.ts +4 -1
- package/dist-ts/player/input-handler.d.ts.map +1 -1
- package/dist-ts/player/input-handler.js +10 -11
- package/dist-ts/player/input-handler.js.map +1 -1
- package/dist-ts/player/load-formats.js +1 -1
- package/dist-ts/player/load-formats.js.map +1 -1
- package/dist-ts/player/ui-controller.d.ts.map +1 -1
- package/dist-ts/player/ui-controller.js +8 -1
- package/dist-ts/player/ui-controller.js.map +1 -1
- package/package.json +1 -1
- package/src/emulator/c64-emulator.ts +2 -1
- package/src/emulator/c64-wasm.ts +4 -4
- package/src/emulator/input.ts +50 -16
- package/src/headless/c64-key-map.mjs +357 -165
- package/src/headless/c64-wasm.mjs +2 -2
- package/src/headless/ffmpeg-runner.mjs +214 -75
- package/src/headless/headless-cli.d.ts +1 -1
- package/src/headless/headless-cli.mjs +137 -19
- package/src/headless/headless-cli.mjs.d.ts +1 -1
- package/src/headless/input-server.mjs +511 -67
- package/src/headless/webrtc-encoder.mjs +49 -25
- package/src/headless/webrtc-server.mjs +21 -20
- package/src/main.ts +3 -2
- package/src/player/audio-engine.ts +4 -0
- package/src/player/c64-player.ts +70 -7
- package/src/player/index.ts +8 -1
- package/src/player/input-handler.ts +13 -12
- package/src/player/load-formats.ts +1 -1
- package/src/player/styles/canvas-renderer.css +10 -5
- package/src/player/ui-controller.ts +25 -14
- package/dist/assets/index-Bk-mEPYS.js +0 -169
- package/dist-ts/emulator/memory.d.ts +0 -2
- package/dist-ts/emulator/memory.d.ts.map +0 -1
- package/dist-ts/emulator/memory.js +0 -9
- package/dist-ts/emulator/memory.js.map +0 -1
- package/src/emulator/memory.ts +0 -9
|
@@ -18,7 +18,10 @@ import wrtc from '@roamhq/wrtc';
|
|
|
18
18
|
const { RTCVideoSource, RTCAudioSource, rgbaToI420 } = wrtc.nonstandard;
|
|
19
19
|
|
|
20
20
|
const nowMonoMs = () => {
|
|
21
|
-
if (
|
|
21
|
+
if (
|
|
22
|
+
typeof globalThis.performance !== 'undefined' &&
|
|
23
|
+
typeof globalThis.performance.now === 'function'
|
|
24
|
+
) {
|
|
22
25
|
return globalThis.performance.now();
|
|
23
26
|
}
|
|
24
27
|
return Date.now();
|
|
@@ -50,29 +53,29 @@ export class WebRTCEncoder {
|
|
|
50
53
|
// ~1300ms *behind* the audio clock after every cart load. The browser's
|
|
51
54
|
// AV sync logic then delayed video rendering until the audio clock "caught
|
|
52
55
|
// up", creating the observed ~1–30s of perceived input lag.
|
|
53
|
-
_videoOriginMs = 0;
|
|
56
|
+
_videoOriginMs = 0; // set in init() to nowMonoMs()
|
|
54
57
|
_videoFrameDurationUs = 0; // microseconds per frame, set in setFps() (kept for compatibility)
|
|
55
58
|
|
|
56
59
|
// RTCAudioSource.onData() requires exactly (sampleRate / 100) samples per call —
|
|
57
60
|
// that is one 10 ms WebRTC audio processing frame. At 44100 Hz that is 441 samples.
|
|
58
61
|
// The SID buffer is 4096 samples, so we queue incoming audio and drain it in
|
|
59
62
|
// 441-sample chunks.
|
|
60
|
-
_audioChunkSize = 441;
|
|
63
|
+
_audioChunkSize = 441; // recalculated in init()
|
|
61
64
|
// Pre-allocated audio ring buffer — large enough to hold several SID pulls
|
|
62
65
|
// without allocation. Using a ring avoids per-frame Float32Array allocs
|
|
63
66
|
// (which caused GC pauses and audio stuttering at 50fps).
|
|
64
|
-
_audioRing = null;
|
|
67
|
+
_audioRing = null; // Float32Array, allocated in init()
|
|
65
68
|
_audioRingSize = 0;
|
|
66
69
|
_audioRingWrite = 0;
|
|
67
70
|
_audioRingRead = 0;
|
|
68
71
|
_audioRingCount = 0;
|
|
69
|
-
_audioInt16 = null;
|
|
72
|
+
_audioInt16 = null; // Int16Array(chunkSize), allocated in init()
|
|
70
73
|
// Pre-allocated staging buffers — reused every frame to avoid GC pressure.
|
|
71
74
|
// rgbaToI420() validates data.byteLength === width*height*4, so we cannot
|
|
72
75
|
// pass a subarray of the WASM heap (whose byteLength = full heap size).
|
|
73
76
|
// Copying into _rgbaBuf each frame is one memcpy (~417 KB) — negligible.
|
|
74
|
-
_rgbaBuf = null;
|
|
75
|
-
_i420Buf = null;
|
|
77
|
+
_rgbaBuf = null; // Uint8ClampedArray(width*height*4)
|
|
78
|
+
_i420Buf = null; // Uint8ClampedArray(width*height * 3/2)
|
|
76
79
|
|
|
77
80
|
/**
|
|
78
81
|
* @param {{ width?: number, height?: number, sampleRate?: number }} opts
|
|
@@ -84,12 +87,12 @@ export class WebRTCEncoder {
|
|
|
84
87
|
this._audioChunkSize = Math.floor(sampleRate / 100); // 441 @ 44100, 480 @ 48000
|
|
85
88
|
// Audio ring: large enough for 8× the SID pull size (8×4096 = 32768 samples)
|
|
86
89
|
// so even bursts after a cart load never overflow.
|
|
87
|
-
this._audioRingSize
|
|
88
|
-
this._audioRing
|
|
90
|
+
this._audioRingSize = 4096 * 8;
|
|
91
|
+
this._audioRing = new Float32Array(this._audioRingSize);
|
|
89
92
|
this._audioRingWrite = 0;
|
|
90
|
-
this._audioRingRead
|
|
93
|
+
this._audioRingRead = 0;
|
|
91
94
|
this._audioRingCount = 0;
|
|
92
|
-
this._audioInt16
|
|
95
|
+
this._audioInt16 = new Int16Array(this._audioChunkSize);
|
|
93
96
|
this._videoOriginMs = nowMonoMs();
|
|
94
97
|
|
|
95
98
|
// Staging buffers with exact byte sizes that rgbaToI420 expects
|
|
@@ -141,7 +144,7 @@ export class WebRTCEncoder {
|
|
|
141
144
|
*/
|
|
142
145
|
pushSilenceForGap(gapMs) {
|
|
143
146
|
if (!this.audioSource || gapMs <= 0) return;
|
|
144
|
-
const chunkSize
|
|
147
|
+
const chunkSize = this._audioChunkSize; // 441 @ 44100 Hz
|
|
145
148
|
const sampleRate = this._sampleRate;
|
|
146
149
|
// Number of silence samples needed to cover the gap
|
|
147
150
|
const totalSamples = Math.round((gapMs / 1000) * sampleRate);
|
|
@@ -152,16 +155,36 @@ export class WebRTCEncoder {
|
|
|
152
155
|
let pushed = 0;
|
|
153
156
|
while (pushed + chunkSize <= totalSamples) {
|
|
154
157
|
this.audioSource.onData({
|
|
155
|
-
samples:
|
|
156
|
-
sampleRate:
|
|
157
|
-
bitsPerSample:
|
|
158
|
-
channelCount:
|
|
158
|
+
samples: int16,
|
|
159
|
+
sampleRate: sampleRate,
|
|
160
|
+
bitsPerSample: 16,
|
|
161
|
+
channelCount: 1,
|
|
159
162
|
numberOfFrames: chunkSize,
|
|
160
163
|
});
|
|
161
164
|
pushed += chunkSize;
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Push a small amount of silence so newly-created audio tracks have data
|
|
170
|
+
* before the main emulation loop delivers the first SID frame.
|
|
171
|
+
* @param {number} chunks Number of 10 ms audio chunks to push.
|
|
172
|
+
*/
|
|
173
|
+
primeAudio(chunks = 1) {
|
|
174
|
+
if (!this.audioSource || chunks <= 0) return;
|
|
175
|
+
const chunkSize = this._audioChunkSize;
|
|
176
|
+
this._audioInt16.fill(0);
|
|
177
|
+
for (let i = 0; i < chunks; i++) {
|
|
178
|
+
this.audioSource.onData({
|
|
179
|
+
samples: this._audioInt16,
|
|
180
|
+
sampleRate: this._sampleRate,
|
|
181
|
+
bitsPerSample: 16,
|
|
182
|
+
channelCount: 1,
|
|
183
|
+
numberOfFrames: chunkSize,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
165
188
|
/**
|
|
166
189
|
* Set the frame rate used to compute video timestamps.
|
|
167
190
|
* Must be called after init() if the fps differs from the default 50.
|
|
@@ -185,10 +208,7 @@ export class WebRTCEncoder {
|
|
|
185
208
|
// This is necessary because rgbaToI420 checks data.byteLength strictly.
|
|
186
209
|
this._rgbaBuf.set(rgbaData.subarray(0, width * height * 4));
|
|
187
210
|
|
|
188
|
-
rgbaToI420(
|
|
189
|
-
{ width, height, data: this._rgbaBuf },
|
|
190
|
-
{ width, height, data: this._i420Buf },
|
|
191
|
-
);
|
|
211
|
+
rgbaToI420({ width, height, data: this._rgbaBuf }, { width, height, data: this._i420Buf });
|
|
192
212
|
|
|
193
213
|
// Drive timestamp from wall clock (microseconds elapsed since init()).
|
|
194
214
|
// After any gap (e.g. the ~1300ms c64_loadCartridge blockage) the timestamp
|
|
@@ -212,9 +232,9 @@ export class WebRTCEncoder {
|
|
|
212
232
|
* @param {Float32Array} f32samples - SID output, sampleRate Hz mono
|
|
213
233
|
*/
|
|
214
234
|
pushAudioFrame(f32samples) {
|
|
215
|
-
const chunkSize
|
|
216
|
-
const ringSize
|
|
217
|
-
const ring
|
|
235
|
+
const chunkSize = this._audioChunkSize;
|
|
236
|
+
const ringSize = this._audioRingSize;
|
|
237
|
+
const ring = this._audioRing;
|
|
218
238
|
|
|
219
239
|
// Write incoming samples into the ring (wrap-around, drop on overflow)
|
|
220
240
|
for (let i = 0; i < f32samples.length; i++) {
|
|
@@ -246,6 +266,10 @@ export class WebRTCEncoder {
|
|
|
246
266
|
}
|
|
247
267
|
}
|
|
248
268
|
|
|
249
|
-
get width() {
|
|
250
|
-
|
|
269
|
+
get width() {
|
|
270
|
+
return this._width;
|
|
271
|
+
}
|
|
272
|
+
get height() {
|
|
273
|
+
return this._height;
|
|
274
|
+
}
|
|
251
275
|
}
|
|
@@ -51,10 +51,7 @@ function buildTimedTurnCredentials({
|
|
|
51
51
|
const safeLabel = String(usernameLabel ?? '').trim() || 'c64live';
|
|
52
52
|
const expiresAt = Math.floor(nowSeconds) + normalizeTurnTtlSeconds(ttlSeconds);
|
|
53
53
|
const username = `${expiresAt}:${safeLabel}`;
|
|
54
|
-
const credential = crypto
|
|
55
|
-
.createHmac('sha1', safeSecret)
|
|
56
|
-
.update(username)
|
|
57
|
-
.digest('base64');
|
|
54
|
+
const credential = crypto.createHmac('sha1', safeSecret).update(username).digest('base64');
|
|
58
55
|
|
|
59
56
|
return { username, credential };
|
|
60
57
|
}
|
|
@@ -116,11 +113,12 @@ function buildIceServers({
|
|
|
116
113
|
if (verbose) {
|
|
117
114
|
const stunCount = stunUrls.length;
|
|
118
115
|
const turnCount = turnUrls.length;
|
|
119
|
-
const turnMode =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
const turnMode =
|
|
117
|
+
turnUrls.length > 0 && turnSecret
|
|
118
|
+
? 'timed'
|
|
119
|
+
: turnUrls.length > 0 && turnUsername && turnPassword
|
|
120
|
+
? 'static'
|
|
121
|
+
: 'disabled';
|
|
124
122
|
console.error(
|
|
125
123
|
`[webrtc] ICE config stunUrls=${stunCount} turnUrls=${turnCount} turnMode=${turnMode}`,
|
|
126
124
|
);
|
|
@@ -177,16 +175,17 @@ export function createWebRTCServer({
|
|
|
177
175
|
onPeerConnected,
|
|
178
176
|
onDataChannelInput,
|
|
179
177
|
} = {}) {
|
|
180
|
-
const buildRuntimeIceServers = () =>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
178
|
+
const buildRuntimeIceServers = () =>
|
|
179
|
+
buildIceServers({
|
|
180
|
+
iceStunUrls,
|
|
181
|
+
iceTurnUrls,
|
|
182
|
+
iceTurnSecret,
|
|
183
|
+
iceTurnTtlSeconds,
|
|
184
|
+
iceTurnUsernameLabel,
|
|
185
|
+
iceTurnUsername,
|
|
186
|
+
iceTurnPassword,
|
|
187
|
+
verbose,
|
|
188
|
+
});
|
|
190
189
|
|
|
191
190
|
const iceServers = buildRuntimeIceServers();
|
|
192
191
|
|
|
@@ -533,7 +532,9 @@ export function createWebRTCServer({
|
|
|
533
532
|
if (req.method === 'GET' && (req.url === '/' || req.url === '/index.html')) {
|
|
534
533
|
const requestIceServers = buildRuntimeIceServers();
|
|
535
534
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
536
|
-
res.end(
|
|
535
|
+
res.end(
|
|
536
|
+
buildBrowserHtml(inputPort, minBitrateKbpsSafe, maxBitrateKbpsSafe, requestIceServers),
|
|
537
|
+
);
|
|
537
538
|
} else if (req.method === 'GET' && req.url === '/ice-config') {
|
|
538
539
|
const requestIceServers = buildRuntimeIceServers();
|
|
539
540
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
package/src/main.ts
CHANGED
|
@@ -27,11 +27,12 @@ const player = new C64Player({
|
|
|
27
27
|
gameUrl,
|
|
28
28
|
gameType,
|
|
29
29
|
renderer,
|
|
30
|
+
audio: { assetBaseUrl: base },
|
|
30
31
|
onProgress: (pct, label) => renderer.setProgress(pct, label),
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
// Initialise UI with reference to the player (for audio controls)
|
|
34
|
-
new UIController().init(player);
|
|
35
|
+
new UIController({ assetBaseUrl: base }).init(player);
|
|
35
36
|
|
|
36
37
|
player
|
|
37
38
|
.start()
|
|
@@ -99,7 +100,7 @@ window.addEventListener('c64-controller-disconnected', (e: Event) => {
|
|
|
99
100
|
const detail = (e as CustomEvent).detail;
|
|
100
101
|
status.textContent = `Controller Disconnected : ${detail.index} - ${detail.name}`;
|
|
101
102
|
status.style.color = '#9ecbff';
|
|
102
|
-
})
|
|
103
|
+
});
|
|
103
104
|
|
|
104
105
|
window.addEventListener('c64-load-tool', async (e: Event) => {
|
|
105
106
|
const detail = (e as CustomEvent).detail as
|
|
@@ -101,6 +101,7 @@ export class AudioEngine {
|
|
|
101
101
|
this._suspended = this.ctx?.state === 'suspended';
|
|
102
102
|
if (wasSuspended !== this._suspended) {
|
|
103
103
|
this.fireStateChange();
|
|
104
|
+
this.feedWorklet();
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
107
|
|
|
@@ -140,6 +141,7 @@ export class AudioEngine {
|
|
|
140
141
|
};
|
|
141
142
|
|
|
142
143
|
this._ready = true;
|
|
144
|
+
this.feedWorklet();
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
// ── SID buffer reader ─────────────────────────────────────────────────────
|
|
@@ -150,6 +152,7 @@ export class AudioEngine {
|
|
|
150
152
|
*/
|
|
151
153
|
setSidBufferReader(reader: SidBufferReader): void {
|
|
152
154
|
this._readSidBuffer = reader;
|
|
155
|
+
this.feedWorklet();
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
// ── Sample feeding ────────────────────────────────────────────────────────
|
|
@@ -171,6 +174,7 @@ export class AudioEngine {
|
|
|
171
174
|
await this.ctx.resume();
|
|
172
175
|
this._suspended = this.ctx.state === 'suspended';
|
|
173
176
|
this.fireStateChange();
|
|
177
|
+
this.feedWorklet();
|
|
174
178
|
} catch (err) {
|
|
175
179
|
console.error('AudioEngine: resume failed', err);
|
|
176
180
|
}
|
package/src/player/c64-player.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { C64Emulator } from '../emulator/c64-emulator';
|
|
|
2
2
|
import { getUnsupportedCrtReason, parseCrtInfo } from '../emulator/crt-info';
|
|
3
3
|
import type { GameLoadOptions } from '../types';
|
|
4
4
|
import type { JoystickPort } from '../emulator/constants';
|
|
5
|
-
import type { InputMode } from '../emulator/input';
|
|
5
|
+
import type { InputMode, KeyboardJoystickMap } from '../emulator/input';
|
|
6
6
|
import type CanvasRenderer from './canvas-renderer';
|
|
7
7
|
import { AudioEngine, type AudioEngineOptions } from './audio-engine';
|
|
8
8
|
import InputHandler from './input-handler';
|
|
@@ -14,6 +14,8 @@ const C64_KEYBOARD_BUFFER_LENGTH_ADDR = 0x00c6;
|
|
|
14
14
|
const C64_KEYBOARD_BUFFER_ADDR = 0x0277;
|
|
15
15
|
const C64_KEYBOARD_BUFFER_MAX_LENGTH = 8;
|
|
16
16
|
const PRG_AUTORUN_DELAY_MS = 650;
|
|
17
|
+
const DISK_AUTOLOAD_DELAY_MS = 1500;
|
|
18
|
+
const DISK_AUTOLOAD_RETURN_DELAY_MS = 250;
|
|
17
19
|
const PRG_AUTORUN_BUFFER_TIMEOUT_MS = 2000;
|
|
18
20
|
|
|
19
21
|
export interface C64PlayerOptions {
|
|
@@ -32,6 +34,9 @@ export class C64Player {
|
|
|
32
34
|
private inputHandler: InputHandler | null = null;
|
|
33
35
|
private disableCrtPreloadChecks: boolean = false;
|
|
34
36
|
private destroyed: boolean = false;
|
|
37
|
+
private diskSessionActive: boolean = false;
|
|
38
|
+
private startupLoadInProgress: boolean = false;
|
|
39
|
+
private startupDiskAutoloadPending: boolean = false;
|
|
35
40
|
readonly audio: AudioEngine;
|
|
36
41
|
private readonly options: Required<Pick<C64PlayerOptions, 'wasmUrl' | 'gameUrl' | 'gameType'>> &
|
|
37
42
|
C64PlayerOptions;
|
|
@@ -52,10 +57,20 @@ export class C64Player {
|
|
|
52
57
|
let shouldAutoRunPrgAfterStart = false;
|
|
53
58
|
|
|
54
59
|
if (gameData !== undefined && gameData !== null) {
|
|
55
|
-
|
|
60
|
+
this.startupLoadInProgress = true;
|
|
61
|
+
try {
|
|
62
|
+
await this.loadGameData(gameData, gameType, gameSource ?? 'inline game data', onProgress);
|
|
63
|
+
} finally {
|
|
64
|
+
this.startupLoadInProgress = false;
|
|
65
|
+
}
|
|
56
66
|
shouldAutoRunPrgAfterStart = gameType === 'prg';
|
|
57
67
|
} else if (gameUrl && gameUrl !== 'null') {
|
|
58
|
-
|
|
68
|
+
this.startupLoadInProgress = true;
|
|
69
|
+
try {
|
|
70
|
+
await this.loadGame(gameUrl, gameType, onProgress);
|
|
71
|
+
} finally {
|
|
72
|
+
this.startupLoadInProgress = false;
|
|
73
|
+
}
|
|
59
74
|
shouldAutoRunPrgAfterStart = gameType === 'prg';
|
|
60
75
|
}
|
|
61
76
|
|
|
@@ -63,6 +78,10 @@ export class C64Player {
|
|
|
63
78
|
if (shouldAutoRunPrgAfterStart) {
|
|
64
79
|
await this.autoRunPrgIfRunning();
|
|
65
80
|
}
|
|
81
|
+
if (this.startupDiskAutoloadPending) {
|
|
82
|
+
this.startupDiskAutoloadPending = false;
|
|
83
|
+
await this.autoLoadDiskIfRunning();
|
|
84
|
+
}
|
|
66
85
|
|
|
67
86
|
// Initialise audio in the background — never blocks game startup
|
|
68
87
|
this.initAudio();
|
|
@@ -84,15 +103,14 @@ export class C64Player {
|
|
|
84
103
|
window.dispatchEvent(new CustomEvent('c64-audio-state', { detail: state }));
|
|
85
104
|
};
|
|
86
105
|
|
|
106
|
+
this.audio.setSidBufferReader(() => this.emulator?.getSidBuffer() ?? null);
|
|
107
|
+
|
|
87
108
|
// Fire-and-forget init
|
|
88
109
|
this.audio.init().then((autoplayOk) => {
|
|
89
110
|
if (!this.emulator) return;
|
|
90
111
|
// Tell the SID what sample rate we're using (matches AudioContext)
|
|
91
112
|
this.emulator.setSampleRate(this.audio.sampleRate);
|
|
92
113
|
|
|
93
|
-
// Give the engine a reader that snapshots the SID circular buffer
|
|
94
|
-
this.audio.setSidBufferReader(() => this.emulator?.getSidBuffer() ?? null);
|
|
95
|
-
|
|
96
114
|
if (!autoplayOk) {
|
|
97
115
|
window.dispatchEvent(new CustomEvent('c64-audio-suspended'));
|
|
98
116
|
}
|
|
@@ -201,6 +219,8 @@ export class C64Player {
|
|
|
201
219
|
if (!this.emulator) return;
|
|
202
220
|
try {
|
|
203
221
|
this.emulator.removeCartridge();
|
|
222
|
+
this.diskSessionActive = false;
|
|
223
|
+
this.startupDiskAutoloadPending = false;
|
|
204
224
|
window.dispatchEvent(new CustomEvent('c64-detach', { detail: {} }));
|
|
205
225
|
window.dispatchEvent(new CustomEvent('c64-close-menu'));
|
|
206
226
|
} catch (e) {
|
|
@@ -227,6 +247,8 @@ export class C64Player {
|
|
|
227
247
|
await this.emulator.reboot();
|
|
228
248
|
this.attachInputAndRenderer(this.emulator, this.options.renderer);
|
|
229
249
|
this.emulator.start();
|
|
250
|
+
this.diskSessionActive = false;
|
|
251
|
+
this.startupDiskAutoloadPending = false;
|
|
230
252
|
this.emulator.setSampleRate(this.audio.sampleRate);
|
|
231
253
|
this.audio.setSidBufferReader(() => this.emulator?.getSidBuffer() ?? null);
|
|
232
254
|
window.dispatchEvent(new CustomEvent('c64-reboot', { detail: {} }));
|
|
@@ -262,6 +284,11 @@ export class C64Player {
|
|
|
262
284
|
this.inputHandler?.setKeyboardJoystickPort(port);
|
|
263
285
|
}
|
|
264
286
|
|
|
287
|
+
/** Change which keyboard codes map to joystick controls. */
|
|
288
|
+
setKeyboardJoystickMap(map: KeyboardJoystickMap): void {
|
|
289
|
+
this.inputHandler?.setKeyboardJoystickMap(map);
|
|
290
|
+
}
|
|
291
|
+
|
|
265
292
|
/**
|
|
266
293
|
* Change the input mode ('joystick' | 'keyboard' | 'mixed').
|
|
267
294
|
* - 'joystick' — arrows + ControlLeft control the joystick only (default)
|
|
@@ -315,6 +342,27 @@ export class C64Player {
|
|
|
315
342
|
await this.insertTextIntoKeyboardBuffer('run\n');
|
|
316
343
|
}
|
|
317
344
|
|
|
345
|
+
private async autoLoadDiskIfRunning(): Promise<void> {
|
|
346
|
+
if (!this.emulator || !this.emulator.isRunning()) return;
|
|
347
|
+
await waitMs(DISK_AUTOLOAD_DELAY_MS);
|
|
348
|
+
await this.insertTextIntoKeyboardBuffer('LOAD"*",8,1');
|
|
349
|
+
await waitMs(DISK_AUTOLOAD_RETURN_DELAY_MS);
|
|
350
|
+
await this.insertTextIntoKeyboardBuffer('\n');
|
|
351
|
+
await this.waitForKeyboardBufferEmpty();
|
|
352
|
+
await this.insertTextIntoKeyboardBuffer('run\n');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private async prepareFirstDiskLoad(): Promise<void> {
|
|
356
|
+
if (!this.emulator || this.startupLoadInProgress) return;
|
|
357
|
+
try {
|
|
358
|
+
this.emulator.removeCartridge();
|
|
359
|
+
} catch {
|
|
360
|
+
this.emulator.reset();
|
|
361
|
+
}
|
|
362
|
+
this.emulator.start();
|
|
363
|
+
await waitMs(120);
|
|
364
|
+
}
|
|
365
|
+
|
|
318
366
|
private async insertTextIntoKeyboardBuffer(text: string): Promise<void> {
|
|
319
367
|
if (!this.emulator) return;
|
|
320
368
|
|
|
@@ -355,12 +403,27 @@ export class C64Player {
|
|
|
355
403
|
if (type === 'crt') {
|
|
356
404
|
this.handleCrtPreloadChecks(data, source, onProgress);
|
|
357
405
|
}
|
|
406
|
+
const shouldAutoLoadDisk = type === 'd64' && !this.diskSessionActive;
|
|
407
|
+
if (shouldAutoLoadDisk) {
|
|
408
|
+
await this.prepareFirstDiskLoad();
|
|
409
|
+
}
|
|
358
410
|
this.emulator.loadGame({ type, data });
|
|
359
411
|
if (type === 'prg') {
|
|
412
|
+
this.diskSessionActive = false;
|
|
360
413
|
await this.autoRunPrgIfRunning();
|
|
414
|
+
} else if (type === 'd64') {
|
|
415
|
+
this.diskSessionActive = true;
|
|
416
|
+
if (shouldAutoLoadDisk) {
|
|
417
|
+
if (this.startupLoadInProgress) this.startupDiskAutoloadPending = true;
|
|
418
|
+
else await this.autoLoadDiskIfRunning();
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
this.diskSessionActive = false;
|
|
361
422
|
}
|
|
362
423
|
onProgress?.(100, 'READY!');
|
|
363
|
-
window.dispatchEvent(
|
|
424
|
+
window.dispatchEvent(
|
|
425
|
+
new CustomEvent('c64-load-success', { detail: { ...eventDetail, type } }),
|
|
426
|
+
);
|
|
364
427
|
} catch (err) {
|
|
365
428
|
onProgress?.(0, 'FAILED');
|
|
366
429
|
console.error('Failed to insert cartridge or load game:', err);
|
package/src/player/index.ts
CHANGED
|
@@ -4,4 +4,11 @@ export type { C64PlayerOptions, ProgressCallback } from './c64-player';
|
|
|
4
4
|
export { AudioEngine } from './audio-engine';
|
|
5
5
|
export type { AudioEngineOptions, AudioStateChangeCallback, SidBufferReader } from './audio-engine';
|
|
6
6
|
export { default as InputHandler } from './input-handler';
|
|
7
|
-
export type {
|
|
7
|
+
export type {
|
|
8
|
+
C64Config,
|
|
9
|
+
C64State,
|
|
10
|
+
FrameBuffer,
|
|
11
|
+
AudioBuffer,
|
|
12
|
+
InputEvent,
|
|
13
|
+
GameLoadOptions,
|
|
14
|
+
} from '../types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EmulatorInput
|
|
2
|
-
import type { InputMode } from '../emulator/input';
|
|
1
|
+
import { EmulatorInput } from '../emulator/input';
|
|
2
|
+
import type { InputMode, KeyboardJoystickMap } from '../emulator/input';
|
|
3
3
|
import type { JoystickPort } from '../emulator/constants';
|
|
4
4
|
import type { C64Emulator } from '../emulator/c64-emulator';
|
|
5
5
|
|
|
@@ -31,6 +31,11 @@ export default class InputHandler {
|
|
|
31
31
|
this.emulatorInput.setKeyboardPort(port);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Change which keyboard codes map to joystick controls. */
|
|
35
|
+
setKeyboardJoystickMap(map: KeyboardJoystickMap): void {
|
|
36
|
+
this.emulatorInput.setKeyboardJoystickMap(map);
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
/** Change the input mode ('joystick' | 'keyboard' | 'mixed') */
|
|
35
40
|
setInputMode(mode: InputMode): void {
|
|
36
41
|
this.emulatorInput.setInputMode(mode);
|
|
@@ -51,11 +56,7 @@ export default class InputHandler {
|
|
|
51
56
|
private onCaptureKeyDown(e: KeyboardEvent): void {
|
|
52
57
|
// Block joystick-mapped keys (standard + mixed mode) when overlays are
|
|
53
58
|
// visible or the document is unfocused. Use the union of both key sets.
|
|
54
|
-
|
|
55
|
-
...(JOYSTICK_KEY_CODES as string[]),
|
|
56
|
-
...Object.keys(MIXED_JOYSTICK_KEYS),
|
|
57
|
-
]);
|
|
58
|
-
if (!JOY_KEYS.has(e.code)) return;
|
|
59
|
+
if (!this.isJoystickKey(e)) return;
|
|
59
60
|
|
|
60
61
|
// Block if document is unfocused. Prefer the Visibility API (document.hidden)
|
|
61
62
|
// which is stable under JSDOM; fall back to hasFocus() only if hidden is unavailable.
|
|
@@ -102,11 +103,7 @@ export default class InputHandler {
|
|
|
102
103
|
|
|
103
104
|
private onCaptureKeyUp(e: KeyboardEvent): void {
|
|
104
105
|
// Only block joystick-mapped keys (standard + mixed mode)
|
|
105
|
-
|
|
106
|
-
...(JOYSTICK_KEY_CODES as string[]),
|
|
107
|
-
...Object.keys(MIXED_JOYSTICK_KEYS),
|
|
108
|
-
]);
|
|
109
|
-
if (!JOY_KEYS.has(e.code)) return;
|
|
106
|
+
if (!this.isJoystickKey(e)) return;
|
|
110
107
|
|
|
111
108
|
// Mirror the same blocking logic for keyup events
|
|
112
109
|
try {
|
|
@@ -137,4 +134,8 @@ export default class InputHandler {
|
|
|
137
134
|
// ignore DOM errors
|
|
138
135
|
}
|
|
139
136
|
}
|
|
137
|
+
|
|
138
|
+
private isJoystickKey(e: KeyboardEvent): boolean {
|
|
139
|
+
return this.emulatorInput.isJoystickKeyCode(e.code);
|
|
140
|
+
}
|
|
140
141
|
}
|
|
@@ -49,7 +49,7 @@ export function getAcceptForLoadTypeSelection(selection: LoadTypeSelection): str
|
|
|
49
49
|
const exts =
|
|
50
50
|
selection === 'auto'
|
|
51
51
|
? LOAD_FORMAT_OPTIONS.flatMap((f) => f.extensions)
|
|
52
|
-
: LOAD_FORMAT_OPTIONS.find((f) => f.type === selection)?.extensions ?? [];
|
|
52
|
+
: (LOAD_FORMAT_OPTIONS.find((f) => f.type === selection)?.extensions ?? []);
|
|
53
53
|
return exts.join(',');
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
position: relative;
|
|
4
4
|
width: 768px;
|
|
5
5
|
margin-top: 12px;
|
|
6
|
-
transition:
|
|
6
|
+
transition:
|
|
7
|
+
opacity 0.6s ease,
|
|
8
|
+
transform 0.6s ease;
|
|
7
9
|
}
|
|
8
10
|
.c64-loader.hidden {
|
|
9
11
|
opacity: 0;
|
|
@@ -31,11 +33,14 @@
|
|
|
31
33
|
background: linear-gradient(90deg, #6c6cff 0%, #a8a8ff 50%, #6c6cff 100%);
|
|
32
34
|
background-size: 200% 100%;
|
|
33
35
|
border-radius: 2px;
|
|
34
|
-
transition: width 0.5s cubic-bezier(.22
|
|
36
|
+
transition: width 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
|
|
35
37
|
animation: c64-shimmer 1.5s linear infinite;
|
|
36
38
|
}
|
|
37
39
|
@keyframes c64-shimmer {
|
|
38
|
-
0%
|
|
39
|
-
|
|
40
|
+
0% {
|
|
41
|
+
background-position: 200% 0;
|
|
42
|
+
}
|
|
43
|
+
100% {
|
|
44
|
+
background-position: -200% 0;
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
|
-
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
const css = `
|
|
2
|
-
.c64-help-btn,.c64-hamburger,.c64-unmute-btn{position:fixed;top:12px;width:36px;height:36px;border-radius:6px;border:2px solid #444;background:#111;color:#ddd;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:1000}.c64-help-btn{right:12px;border-radius:50%;color:#7b71d5;font-family:monospace;font-size:18px;font-weight:bold}.c64-hamburger{left:12px;font-family:monospace}.c64-unmute-btn{left:56px;color:#f44;z-index:1010}.c64-unmute-btn.hidden{opacity:0;pointer-events:none}.c64-help-overlay,.c64-menu-overlay{position:fixed;inset:0;background:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:1001;opacity:0;transition:opacity .25s ease;pointer-events:none}.c64-help-overlay.visible,.c64-menu-overlay.visible{opacity:1;pointer-events:auto}.c64-help-dialog,.c64-menu-panel{background:#1a1a2e;border:2px solid #555;border-radius:6px;padding:24px 32px;max-width:760px;width:90%;font-family:monospace;color:#ccc;position:relative}.c64-changelog-dialog{max-height:70vh;overflow:auto}.c64-help-dialog h2{margin:0 0 8px;font-size:16px;color:#7b71d5;letter-spacing:1px}.c64-help-dialog p{margin:0 0 16px;font-size:13px;line-height:1.5;color:#aaa}.c64-help-dialog a{color:#a8a8ff;text-decoration:none}.c64-help-controls,.c64-help-special{margin:0 0 12px;padding:0;list-style:none;font-size:13px}.c64-help-controls li,.c64-help-special li{display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid #2a2a3e}.c64-help-key{background:#2a2a3e;border:1px solid #444;border-radius:3px;padding:1px 8px;font-size:12px;color:#ddd}.c64-help-close{position:absolute;top:10px;right:14px;background:none;border:none;color:#888;font-size:20px;cursor:pointer}.c64-version{display:flex;justify-content:end;font-size:12px;color:#999;margin-top:36px}.c64-menu-overlay{align-items:flex-start;justify-content:flex-start;padding:48px 24px;background:rgba(0,0,0,.5);z-index:1002}.c64-menu-panel{min-width:320px;max-width:520px;padding:16px;background:#0f0f1a;border-color:#333}.c64-menu-header{display:flex;align-items:center;justify-content:space-between}.c64-settings-tabs,.c64-menu-actions,.c64-system-actions,.c64-radio-row,.c64-gamepad-list{display:flex;gap:8px;flex-wrap:wrap}.c64-settings-tab,.c64-btn,.c64-mute-btn{background:#222;border:1px solid #444;color:#ddd;padding:6px 10px;border-radius:4px;cursor:pointer}.c64-settings-tab.active,.c64-gamepad-btn.active{border-color:#7b71d5;color:#fff;background:#25253d}.c64-select{background:#171729;color:#ddd;border:1px solid #444;border-radius:4px;padding:4px 8px;font-family:monospace}.c64-form-row,.c64-audio-row,.c64-cart-preview{display:flex;align-items:center;gap:10px;margin-bottom:10px}.c64-section-label,.c64-audio-section label{display:block;margin:0 0 8px;font-size:13px;color:#aaa}.c64-section-hint,.c64-volume-label,.c64-cart-type{font-size:11px;color:#888}.c64-dragarea{border:2px dashed #2a2a3e;border-radius:6px;padding:12px;margin-top:12px;text-align:center;color:#aaa}.c64-dragarea.dragover{border-color:#7b71d5;color:#fff}.c64-file-input{display:none}.c64-volume-slider{flex:1}.c64-cart-filename{font-size:13px;color:#ccc;word-break:break-all}.c64-checkbox-row{display:inline-flex;gap:8px;align-items:center;color:#ccc;font-size:13px}
|
|
2
|
+
.c64-help-btn,.c64-hamburger,.c64-unmute-btn{position:fixed;top:12px;width:36px;height:36px;border-radius:6px;border:2px solid #444;background:#111;color:#ddd;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:1000}.c64-help-btn{right:12px;border-radius:50%;color:#7b71d5;font-family:monospace;font-size:18px;font-weight:bold}.c64-hamburger{left:12px;font-family:monospace}.c64-unmute-btn{left:56px;color:#f44;z-index:1010}.c64-unmute-btn.hidden{opacity:0;pointer-events:none}.c64-help-overlay,.c64-menu-overlay{position:fixed;inset:0;background:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:1001;opacity:0;transition:opacity .25s ease;pointer-events:none}.c64-help-overlay.visible,.c64-menu-overlay.visible{opacity:1;pointer-events:auto}.c64-help-dialog,.c64-menu-panel{background:#1a1a2e;border:2px solid #555;border-radius:6px;padding:24px 32px;max-width:760px;width:90%;font-family:monospace;color:#ccc;position:relative}.c64-changelog-dialog{max-height:70vh;overflow:auto}.c64-help-dialog h2{margin:0 0 8px;font-size:16px;color:#7b71d5;letter-spacing:1px}.c64-help-dialog p{margin:0 0 16px;font-size:13px;line-height:1.5;color:#aaa}.c64-help-dialog a{color:#a8a8ff;text-decoration:none}.c64-help-controls,.c64-help-special{margin:0 0 12px;padding:0;list-style:none;font-size:13px}.c64-help-controls li,.c64-help-special li{display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid #2a2a3e}.c64-help-key{background:#2a2a3e;border:1px solid #444;border-radius:3px;padding:1px 8px;font-size:12px;color:#ddd}.c64-help-close{position:absolute;top:10px;right:14px;background:none;border:none;color:#888;font-size:20px;cursor:pointer}.c64-version{display:flex;justify-content:end;font-size:12px;color:#999;margin-top:36px}.c64-menu-overlay{align-items:flex-start;justify-content:flex-start;padding:48px 24px;background:rgba(0,0,0,.5);z-index:1002}.c64-menu-panel{min-width:320px;max-width:520px;padding:16px;background:#0f0f1a;border-color:#333}.c64-menu-header{display:flex;align-items:center;justify-content:space-between}.c64-settings-tabs,.c64-menu-actions,.c64-system-actions,.c64-radio-row,.c64-gamepad-list{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.c64-settings-tab,.c64-btn,.c64-mute-btn{background:#222;border:1px solid #444;color:#ddd;padding:6px 10px;border-radius:4px;cursor:pointer}.c64-settings-tab.active,.c64-gamepad-btn.active{border-color:#7b71d5;color:#fff;background:#25253d}.c64-select{background:#171729;color:#ddd;border:1px solid #444;border-radius:4px;padding:4px 8px;font-family:monospace}.c64-form-row,.c64-audio-row,.c64-cart-preview{display:flex;align-items:center;gap:10px;margin-bottom:10px}.c64-section-label,.c64-audio-section label{display:block;margin:0 0 8px;font-size:13px;color:#aaa}.c64-section-hint,.c64-volume-label,.c64-cart-type{font-size:11px;color:#888}.c64-dragarea{border:2px dashed #2a2a3e;border-radius:6px;padding:12px;margin-top:12px;text-align:center;color:#aaa}.c64-dragarea.dragover{border-color:#7b71d5;color:#fff}.c64-file-input{display:none}.c64-volume-slider{flex:1}.c64-cart-filename{font-size:13px;color:#ccc;word-break:break-all}.c64-checkbox-row{display:inline-flex;gap:8px;align-items:center;color:#ccc;font-size:13px}
|
|
3
|
+
.c64-menu-overlay{align-items:center;justify-content:center;padding:0;background:rgba(0,0,0,.7)}
|
|
4
|
+
.c64-menu-panel{max-width:760px;width:90%;min-width:0;max-height:82vh;overflow:auto;padding:24px 32px;background:#1a1a2e;border:2px solid #555;border-radius:6px;color:#ccc;font-family:monospace;box-shadow:none}
|
|
5
|
+
.c64-menu-header{display:block;margin:0 0 16px;padding:0;border:0}.c64-menu-header h2{margin:0;font-size:16px;color:#7b71d5;letter-spacing:1px;text-transform:none}.c64-menu-close{position:absolute;top:10px;right:14px;background:none;border:none;color:#888;font-size:20px;cursor:pointer}
|
|
6
|
+
.c64-settings-tabs{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 18px;padding:0;border:0;background:transparent}.c64-settings-tab{background:#2a2a3e;border:1px solid #444;border-radius:3px;color:#ddd;font:inherit;font-size:12px;padding:4px 10px;cursor:pointer}.c64-settings-tab.active{background:#3a335f;border-color:#7b71d5;color:#fff}
|
|
7
|
+
.c64-section-label{display:block;margin:0 0 8px;color:#7b71d5;font-size:13px;letter-spacing:1px;text-transform:uppercase}.c64-form-row,.c64-radio-row,.c64-system-actions,.c64-menu-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:0 0 12px}.c64-form-row label{color:#aaa;font-size:13px}
|
|
8
|
+
.c64-select,.c64-file-input{background:#111827;border:1px solid #444;border-radius:3px;color:#ddd;font:inherit;font-size:13px;padding:5px 8px}.c64-btn{background:#2a2a3e;border:1px solid #444;border-radius:3px;color:#ddd;font:inherit;font-size:12px;padding:5px 10px;cursor:pointer}.c64-btn:hover:not(:disabled){border-color:#7b71d5;color:#fff}.c64-btn:disabled,.c64-select:disabled{opacity:.55;cursor:not-allowed}
|
|
9
|
+
.c64-dragarea{border:1px dashed #555;border-radius:6px;background:#111827;color:#aaa;padding:18px;margin:0 0 12px;text-align:center}.c64-dragarea.dragover{border-color:#7b71d5;background:#1f1b38;color:#fff}.c64-cart-preview,.c64-tools-section{background:#151527;border:1px solid #2a2a3e;border-radius:6px;padding:12px;margin:12px 0}.c64-section-hint{color:#888;font-size:12px;line-height:1.4;margin:4px 0 12px}.c64-checkbox-row{display:flex;align-items:center;gap:8px;color:#ccc;font-size:13px;margin:14px 0 4px}
|
|
3
10
|
`;
|
|
4
11
|
|
|
5
12
|
export interface UIControllerOptions {
|
|
@@ -155,7 +162,7 @@ export default class UIController {
|
|
|
155
162
|
emptyState.hidden = gamepads.length > 0;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
private downloadSnapshot(snapshot: Uint8Array): void {
|
|
165
|
+
private downloadSnapshot(snapshot: Uint8Array<ArrayBufferLike>): void {
|
|
159
166
|
const snapshotCopy = new Uint8Array(snapshot.byteLength);
|
|
160
167
|
snapshotCopy.set(snapshot);
|
|
161
168
|
const blob = new Blob([snapshotCopy], { type: 'application/bin' });
|
|
@@ -254,9 +261,12 @@ export default class UIController {
|
|
|
254
261
|
private async loadAndShowChangelog(container: HTMLElement) {
|
|
255
262
|
container.classList.add('visible');
|
|
256
263
|
try {
|
|
257
|
-
const res = await fetch(
|
|
258
|
-
|
|
259
|
-
|
|
264
|
+
const res = await fetch(
|
|
265
|
+
this.options.changelogUrl ?? resolveAssetUrl(this.options.assetBaseUrl, 'CHANGELOG.md'),
|
|
266
|
+
{
|
|
267
|
+
cache: 'no-store',
|
|
268
|
+
},
|
|
269
|
+
);
|
|
260
270
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
261
271
|
const raw = await res.text();
|
|
262
272
|
|
|
@@ -320,13 +330,13 @@ export default class UIController {
|
|
|
320
330
|
<div class="c64-menu-body">
|
|
321
331
|
<div class="c64-settings-tabs" role="tablist" aria-label="Settings sections">
|
|
322
332
|
${sections
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
.map(
|
|
334
|
+
(section, i) =>
|
|
335
|
+
`<button class="c64-settings-tab${i === 0 ? ' active' : ''}" data-settings-tab="${section.id}" role="tab" aria-selected="${
|
|
336
|
+
i === 0 ? 'true' : 'false'
|
|
337
|
+
}">${section.label}</button>`,
|
|
338
|
+
)
|
|
339
|
+
.join('')}
|
|
330
340
|
</div>
|
|
331
341
|
|
|
332
342
|
<div class="c64-settings-sections">
|
|
@@ -597,14 +607,15 @@ export default class UIController {
|
|
|
597
607
|
|
|
598
608
|
const section = panel.querySelector('[data-settings-section="system"]');
|
|
599
609
|
// Detach cartridge / hard reset controls
|
|
600
|
-
const saveSnapshotBtn = section?.querySelector(
|
|
610
|
+
const saveSnapshotBtn = section?.querySelector(
|
|
611
|
+
'#c64-save-snapshot-btn',
|
|
612
|
+
) as HTMLButtonElement | null;
|
|
601
613
|
const detachBtn = section?.querySelector('#c64-detach-btn') as HTMLButtonElement | null;
|
|
602
614
|
const resetBtn = section?.querySelector('#c64-reset-btn') as HTMLButtonElement | null;
|
|
603
615
|
const rebootBtn = section?.querySelector('#c64-reboot-btn') as HTMLButtonElement | null;
|
|
604
616
|
const disableChecksToggle = section?.querySelector(
|
|
605
617
|
'#c64-disable-crt-preload-checks',
|
|
606
618
|
) as HTMLInputElement | null;
|
|
607
|
-
|
|
608
619
|
const disableCrtPreloadChecks =
|
|
609
620
|
window.localStorage.getItem(CRT_PRELOAD_CHECKS_STORAGE_KEY) === '1';
|
|
610
621
|
this.player?.setCrtPreloadChecksDisabled(disableCrtPreloadChecks);
|