c64-ready 0.6.2 → 0.11.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/LICENSE +22 -0
- package/README.md +94 -22
- package/bin/admin.mjs +196 -0
- package/bin/headless.mjs +26 -3
- package/bin/serve.mjs +3 -0
- package/dist/assets/CHANGELOG-CPMeNyjb.js +261 -0
- package/dist/assets/index-CeQto0sd.js +499 -0
- package/dist/c64-ready/c64-ready.gif +0 -0
- package/dist/fonts/Commodore Angled v1.2.ttf +0 -0
- package/dist/fonts/Commodore Rounded v1.2.ttf +0 -0
- package/dist/fonts/Commodore-64-v6.3.TTF +0 -0
- package/dist/fonts/READ ME!.txt +127 -0
- package/dist/fonts/button-commodore-64-font.gif +0 -0
- package/dist/games/cartridges/bubble-bobble.crt +0 -0
- package/dist/games/cartridges/ghosts-n-goblins.crt +0 -0
- package/dist/games/snapshots/LVLLVL%BAAL.c64 +0 -0
- package/dist/games/snapshots/VICE2-4%APOLLO18.vsf +0 -0
- package/dist/games/snapshots/VICE3.10%ELEVATOR.vsf +0 -0
- package/dist/index.html +1 -1
- package/dist/tools/Keyboard-Test.prg +0 -0
- package/package.json +6 -2
- package/public/games/cartridges/bubble-bobble.crt +0 -0
- package/public/games/cartridges/ghosts-n-goblins.crt +0 -0
- package/src/emulator/c64-emulator.ts +10 -2
- package/src/emulator/crt-info.ts +210 -0
- package/src/emulator/input.ts +542 -7
- package/src/headless/c64-key-map.mjs +254 -0
- package/src/headless/c64-wasm.mjs +4 -1
- package/src/headless/headless-cli.mjs +832 -123
- package/src/headless/input-server.mjs +947 -14
- package/src/headless/webrtc-encoder.mjs +251 -0
- package/src/headless/webrtc-server.mjs +1327 -0
- package/src/main.ts +39 -7
- package/src/player/c64-player.ts +131 -14
- package/src/player/input-handler.ts +22 -6
- package/src/player/load-formats.ts +58 -0
- package/src/player/styles/ui-controller.css +69 -2
- package/src/player/ui-controller.ts +167 -36
- package/src/types/emulator.ts +2 -1
- package/dist/assets/CHANGELOG-C1nvP1iO.js +0 -96
- package/dist/assets/index-Cioamf6E.js +0 -394
package/src/main.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { C64Player } from './player/c64-player';
|
|
2
2
|
import CanvasRenderer from './player/canvas-renderer';
|
|
3
3
|
import UIController from './player/ui-controller';
|
|
4
|
+
import { inferLoadTypeFromFilename, isSupportedLoadType } from './player/load-formats';
|
|
4
5
|
|
|
5
6
|
const status = document.getElementById('status')!;
|
|
6
7
|
const renderer = new CanvasRenderer('c64-screen');
|
|
7
8
|
const base = import.meta.env.BASE_URL;
|
|
9
|
+
const params = new URLSearchParams(window.location.search);
|
|
10
|
+
|
|
11
|
+
function resolveGameFromParam(raw: string | null, baseUrl: string): string {
|
|
12
|
+
if (!raw) return `${baseUrl}games/cartridges/legend-of-wilf.crt`;
|
|
13
|
+
const value = raw.trim();
|
|
14
|
+
if (!value) return `${baseUrl}games/cartridges/legend-of-wilf.crt`;
|
|
15
|
+
if (value.toLowerCase() === 'null') return '';
|
|
16
|
+
if (/^https?:\/\//i.test(value)) return value;
|
|
17
|
+
if (value.startsWith('/')) return value;
|
|
18
|
+
return `${baseUrl}${value.replace(/^\/+/, '')}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const gameUrl = resolveGameFromParam(params.get('game'), base);
|
|
22
|
+
const gameType = inferLoadTypeFromFilename(gameUrl || '') ?? 'crt';
|
|
8
23
|
|
|
9
24
|
// Create player and keep in outer scope so UI can trigger file loads
|
|
10
25
|
const player = new C64Player({
|
|
11
26
|
wasmUrl: `${base}c64.wasm`,
|
|
12
|
-
gameUrl
|
|
27
|
+
gameUrl,
|
|
28
|
+
gameType,
|
|
13
29
|
renderer,
|
|
14
30
|
onProgress: (pct, label) => renderer.setProgress(pct, label),
|
|
15
31
|
});
|
|
@@ -20,6 +36,10 @@ new UIController().init(player);
|
|
|
20
36
|
player
|
|
21
37
|
.start()
|
|
22
38
|
.then(() => {
|
|
39
|
+
if (!gameUrl) {
|
|
40
|
+
status.textContent = 'Autoload disabled (?game=null)';
|
|
41
|
+
status.style.color = '#9ecbff';
|
|
42
|
+
}
|
|
23
43
|
renderer.hideLoader();
|
|
24
44
|
})
|
|
25
45
|
.catch((err) => {
|
|
@@ -53,15 +73,17 @@ updateFavicon();
|
|
|
53
73
|
// Listen for files selected via the UI and load into the emulator
|
|
54
74
|
window.addEventListener('c64-load-file', async (e: Event) => {
|
|
55
75
|
const detail = (e as CustomEvent).detail;
|
|
56
|
-
const file: File | undefined = detail
|
|
76
|
+
const file: File | undefined = detail.file;
|
|
77
|
+
const requestedType = detail.type;
|
|
78
|
+
const loadType = requestedType === 'auto' ? undefined : requestedType;
|
|
57
79
|
if (!file) return;
|
|
58
80
|
try {
|
|
59
|
-
renderer.showLoader
|
|
60
|
-
await player.loadFile(file);
|
|
61
|
-
renderer.hideLoader
|
|
81
|
+
renderer.showLoader();
|
|
82
|
+
await player.loadFile(file, isSupportedLoadType(loadType) ? loadType : undefined);
|
|
83
|
+
renderer.hideLoader();
|
|
62
84
|
} catch (err) {
|
|
63
85
|
console.error(err);
|
|
64
|
-
renderer.setError
|
|
86
|
+
renderer.setError('LOAD ERROR');
|
|
65
87
|
status.textContent = `Load error: ${err}`;
|
|
66
88
|
status.style.color = '#f44';
|
|
67
89
|
}
|
|
@@ -74,7 +96,17 @@ window.addEventListener('c64-load-error', (e: Event) => {
|
|
|
74
96
|
| undefined;
|
|
75
97
|
const msg = detail?.error ?? 'Unknown load error';
|
|
76
98
|
console.error('C64 load error event:', detail);
|
|
77
|
-
renderer.setError
|
|
99
|
+
renderer.setError('LOAD ERROR');
|
|
78
100
|
status.textContent = `Load error: ${msg}`;
|
|
79
101
|
status.style.color = '#f44';
|
|
80
102
|
});
|
|
103
|
+
|
|
104
|
+
window.addEventListener('c64-load-info', (e: Event) => {
|
|
105
|
+
const detail = (e as CustomEvent).detail as
|
|
106
|
+
| { mode?: string; source?: string; message?: string }
|
|
107
|
+
| undefined;
|
|
108
|
+
if (!detail?.message) return;
|
|
109
|
+
status.textContent = detail.message;
|
|
110
|
+
status.style.color = detail.mode === 'warning' ? '#f9c74f' : '#9ecbff';
|
|
111
|
+
console.info('C64 load info event:', detail);
|
|
112
|
+
});
|
package/src/player/c64-player.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { C64Emulator } from '../emulator/c64-emulator';
|
|
2
|
+
import { domKeyToC64Actions } from '../emulator/input';
|
|
3
|
+
import { parseCrtInfo } from '../emulator/crt-info';
|
|
2
4
|
import type { GameLoadOptions } from '../types';
|
|
3
5
|
import type { JoystickPort } from '../emulator/constants';
|
|
6
|
+
import type { InputMode } from '../emulator/input';
|
|
4
7
|
import type CanvasRenderer from './canvas-renderer';
|
|
5
8
|
import { AudioEngine } from './audio-engine';
|
|
6
9
|
import InputHandler from './input-handler';
|
|
10
|
+
import { getLoadTypeLabel, inferLoadTypeFromFilename } from './load-formats';
|
|
7
11
|
|
|
8
12
|
export type ProgressCallback = (percent: number, label: string) => void;
|
|
9
13
|
|
|
@@ -36,7 +40,9 @@ export class C64Player {
|
|
|
36
40
|
this.inputHandler.attach();
|
|
37
41
|
renderer.attachTo(this.emulator);
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
if (gameUrl && gameUrl !== 'null') {
|
|
44
|
+
await this.loadGame(gameUrl, gameType, onProgress);
|
|
45
|
+
}
|
|
40
46
|
|
|
41
47
|
this.emulator.start();
|
|
42
48
|
|
|
@@ -116,7 +122,7 @@ export class C64Player {
|
|
|
116
122
|
data = new Uint8Array(await response.arrayBuffer());
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
onProgress?.(90,
|
|
125
|
+
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(type)}...`);
|
|
120
126
|
// Basic validation for cartridge files — some malformed .crt files can
|
|
121
127
|
// silently fail inside the WASM loader; catch common format problems here
|
|
122
128
|
if (type === 'crt' && !isValidCRT(data)) {
|
|
@@ -125,8 +131,18 @@ export class C64Player {
|
|
|
125
131
|
console.error(err);
|
|
126
132
|
throw err;
|
|
127
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
|
+
this.assertSnapshotFormatSupported(data, type, url);
|
|
140
|
+
this.emitSnapshotLoadInfo(type, url);
|
|
128
141
|
try {
|
|
129
142
|
this.emulator.loadGame({ type, data });
|
|
143
|
+
if (type === 'prg') {
|
|
144
|
+
await this.autoRunPrgIfRunning();
|
|
145
|
+
}
|
|
130
146
|
onProgress?.(100, 'READY!');
|
|
131
147
|
// Notify UI that load succeeded
|
|
132
148
|
window.dispatchEvent(new CustomEvent('c64-load-success', { detail: { url, type } }));
|
|
@@ -142,32 +158,42 @@ export class C64Player {
|
|
|
142
158
|
}
|
|
143
159
|
|
|
144
160
|
// Load a game from a File/Blob provided by the user (drag & drop / file input)
|
|
145
|
-
async loadFile(file: File, type
|
|
161
|
+
async loadFile(file: File, type?: GameLoadOptions['type']): Promise<void> {
|
|
146
162
|
if (!this.emulator) throw new Error('Emulator not initialised — call start() first');
|
|
147
163
|
const onProgress = this.options.onProgress;
|
|
164
|
+
const resolvedType = type ?? inferLoadTypeFromFilename(file.name) ?? 'crt';
|
|
148
165
|
try {
|
|
149
166
|
onProgress?.(20, `READING FILE ${file.name}...`);
|
|
150
167
|
const ab = await file.arrayBuffer();
|
|
151
168
|
const data = new Uint8Array(ab);
|
|
152
|
-
onProgress?.(90,
|
|
153
|
-
if (
|
|
169
|
+
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(resolvedType)}...`);
|
|
170
|
+
if (resolvedType === 'crt' && !isValidCRT(data)) {
|
|
154
171
|
onProgress?.(0, 'INVALID CRT');
|
|
155
172
|
const err = new Error('Invalid CRT file format');
|
|
156
173
|
console.error(err);
|
|
157
174
|
throw err;
|
|
158
175
|
}
|
|
176
|
+
if (resolvedType === 'crt') {
|
|
177
|
+
const info = parseCrtInfo(data, file.name);
|
|
178
|
+
if (info) console.log(info.line);
|
|
179
|
+
}
|
|
180
|
+
this.assertSnapshotFormatSupported(data, resolvedType, file.name);
|
|
181
|
+
this.emitSnapshotLoadInfo(resolvedType, file.name);
|
|
159
182
|
try {
|
|
160
|
-
this.emulator.loadGame({ type, data });
|
|
183
|
+
this.emulator.loadGame({ type: resolvedType, data });
|
|
184
|
+
if (resolvedType === 'prg') {
|
|
185
|
+
await this.autoRunPrgIfRunning();
|
|
186
|
+
}
|
|
161
187
|
onProgress?.(100, 'READY!');
|
|
162
188
|
window.dispatchEvent(
|
|
163
|
-
new CustomEvent('c64-close-dialog', { detail: { file: file.name, type } }),
|
|
189
|
+
new CustomEvent('c64-close-dialog', { detail: { file: file.name, type: resolvedType } }),
|
|
164
190
|
);
|
|
165
191
|
} catch (err) {
|
|
166
192
|
onProgress?.(0, 'FAILED');
|
|
167
193
|
console.error('Failed to insert cartridge from file:', err);
|
|
168
194
|
window.dispatchEvent(
|
|
169
195
|
new CustomEvent('c64-load-error', {
|
|
170
|
-
detail: { error: String(err), file: file.name, type },
|
|
196
|
+
detail: { error: String(err), file: file.name, type: resolvedType },
|
|
171
197
|
}),
|
|
172
198
|
);
|
|
173
199
|
throw err;
|
|
@@ -210,13 +236,104 @@ export class C64Player {
|
|
|
210
236
|
setKeyboardJoystickPort(port: JoystickPort): void {
|
|
211
237
|
this.inputHandler?.setKeyboardJoystickPort(port);
|
|
212
238
|
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Change the input mode ('joystick' | 'keyboard' | 'mixed').
|
|
242
|
+
* - 'joystick' — arrows + ControlLeft control the joystick only (default)
|
|
243
|
+
* - 'keyboard' — all keys go to the C64 keyboard matrix
|
|
244
|
+
* - 'mixed' — arrows + Z + ControlLeft drive the joystick; all other
|
|
245
|
+
* keys route to the C64 keyboard matrix simultaneously
|
|
246
|
+
*/
|
|
247
|
+
setInputMode(mode: InputMode): void {
|
|
248
|
+
this.inputHandler?.setInputMode(mode);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private async autoRunPrgIfRunning(): Promise<void> {
|
|
252
|
+
if (!this.emulator || !this.emulator.isRunning()) return;
|
|
253
|
+
await waitMs(120);
|
|
254
|
+
await this.typeCommand('run\n');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private async typeCommand(command: string): Promise<void> {
|
|
258
|
+
if (!this.emulator) return;
|
|
259
|
+
|
|
260
|
+
for (const char of command) {
|
|
261
|
+
const domKey = char === '\n' ? 'enter' : char;
|
|
262
|
+
|
|
263
|
+
const down = domKeyToC64Actions(domKey, false, 'keydown');
|
|
264
|
+
for (const act of down) {
|
|
265
|
+
if (act.action === 'press') this.emulator.keyDown(act.key);
|
|
266
|
+
else this.emulator.keyUp(act.key);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
await waitMs(22);
|
|
270
|
+
|
|
271
|
+
const up = domKeyToC64Actions(domKey, false, 'keyup');
|
|
272
|
+
for (const act of up) {
|
|
273
|
+
if (act.action === 'press') this.emulator.keyDown(act.key);
|
|
274
|
+
else this.emulator.keyUp(act.key);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
await waitMs(22);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private emitSnapshotLoadInfo(type: GameLoadOptions['type'], source: string): void {
|
|
282
|
+
if (type !== 'snapshot') return;
|
|
283
|
+
|
|
284
|
+
const mode = 'native';
|
|
285
|
+
const message = `Loading native LVL snapshot (${source})`;
|
|
286
|
+
|
|
287
|
+
console.info(`[snapshot] mode=${mode} source=${source}`);
|
|
288
|
+
window.dispatchEvent(new CustomEvent('c64-load-info', { detail: { mode, source, message } }));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private assertSnapshotFormatSupported(
|
|
292
|
+
data: Uint8Array,
|
|
293
|
+
type: GameLoadOptions['type'],
|
|
294
|
+
source: string,
|
|
295
|
+
): void {
|
|
296
|
+
if (type !== 'snapshot') return;
|
|
297
|
+
if (!hasViceSnapshotMagic(data)) return;
|
|
298
|
+
|
|
299
|
+
const err = new Error(
|
|
300
|
+
`Unsupported snapshot format for ${source}. VICE .vsf snapshots are disabled for now; use LVLLVL/native snapshots (.c64, .snapshot, .s64).`,
|
|
301
|
+
);
|
|
302
|
+
console.error(err);
|
|
303
|
+
window.dispatchEvent(
|
|
304
|
+
new CustomEvent('c64-load-info', {
|
|
305
|
+
detail: {
|
|
306
|
+
mode: 'warning',
|
|
307
|
+
source,
|
|
308
|
+
message: 'Snapshot must be LVLLVL/native format (.c64, .snapshot, .s64).',
|
|
309
|
+
},
|
|
310
|
+
}),
|
|
311
|
+
);
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
213
314
|
}
|
|
214
315
|
|
|
215
|
-
//
|
|
316
|
+
// CRT format validator — delegates to parseCrtInfo so magic-check logic lives in one place.
|
|
216
317
|
function isValidCRT(data: Uint8Array): boolean {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
318
|
+
return parseCrtInfo(data) !== null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function formatLoadProgressLabel(type: GameLoadOptions['type']): string {
|
|
322
|
+
const label = getLoadTypeLabel(type);
|
|
323
|
+
const suffixStart = label.indexOf(' (');
|
|
324
|
+
const plain = suffixStart > 0 ? label.slice(0, suffixStart) : label;
|
|
325
|
+
return plain.toUpperCase();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function waitMs(ms: number): Promise<void> {
|
|
329
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function hasViceSnapshotMagic(data: Uint8Array): boolean {
|
|
333
|
+
const magic = 'VICE Snapshot File\x1a';
|
|
334
|
+
if (data.length < magic.length) return false;
|
|
335
|
+
for (let i = 0; i < magic.length; i++) {
|
|
336
|
+
if (data[i] !== magic.charCodeAt(i)) return false;
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
222
339
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EmulatorInput, JOYSTICK_KEY_CODES } from '../emulator/input';
|
|
1
|
+
import { EmulatorInput, JOYSTICK_KEY_CODES, MIXED_JOYSTICK_KEYS } from '../emulator/input';
|
|
2
|
+
import type { InputMode } from '../emulator/input';
|
|
2
3
|
import type { JoystickPort } from '../emulator/constants';
|
|
3
4
|
import type { C64Emulator } from '../emulator/c64-emulator';
|
|
4
5
|
|
|
@@ -30,10 +31,22 @@ export default class InputHandler {
|
|
|
30
31
|
this.emulatorInput.setKeyboardPort(port);
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/** Change the input mode ('joystick' | 'keyboard' | 'mixed') */
|
|
35
|
+
setInputMode(mode: InputMode): void {
|
|
36
|
+
this.emulatorInput.setInputMode(mode);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getInputMode(): InputMode {
|
|
40
|
+
return this.emulatorInput.getInputMode();
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
private onCaptureKeyDown(e: KeyboardEvent): void {
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
const JOY_KEYS = new Set(
|
|
44
|
+
// Block joystick-mapped keys (standard + mixed mode) when overlays are
|
|
45
|
+
// visible or the document is unfocused. Use the union of both key sets.
|
|
46
|
+
const JOY_KEYS = new Set([
|
|
47
|
+
...(JOYSTICK_KEY_CODES as string[]),
|
|
48
|
+
...Object.keys(MIXED_JOYSTICK_KEYS),
|
|
49
|
+
]);
|
|
37
50
|
if (!JOY_KEYS.has(e.code)) return;
|
|
38
51
|
|
|
39
52
|
// Block if document is unfocused. Prefer the Visibility API (document.hidden)
|
|
@@ -80,8 +93,11 @@ export default class InputHandler {
|
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
private onCaptureKeyUp(e: KeyboardEvent): void {
|
|
83
|
-
// Only block joystick-mapped keys
|
|
84
|
-
const JOY_KEYS = new Set(
|
|
96
|
+
// Only block joystick-mapped keys (standard + mixed mode)
|
|
97
|
+
const JOY_KEYS = new Set([
|
|
98
|
+
...(JOYSTICK_KEY_CODES as string[]),
|
|
99
|
+
...Object.keys(MIXED_JOYSTICK_KEYS),
|
|
100
|
+
]);
|
|
85
101
|
if (!JOY_KEYS.has(e.code)) return;
|
|
86
102
|
|
|
87
103
|
// Mirror the same blocking logic for keyup events
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { GameLoadOptions } from '../types';
|
|
2
|
+
|
|
3
|
+
export type LoadType = GameLoadOptions['type'];
|
|
4
|
+
export type LoadTypeSelection = LoadType | 'auto';
|
|
5
|
+
|
|
6
|
+
export interface LoadFormatOption {
|
|
7
|
+
type: LoadType;
|
|
8
|
+
label: string;
|
|
9
|
+
extensions: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const LOAD_FORMAT_OPTIONS: LoadFormatOption[] = [
|
|
13
|
+
{ type: 'crt', label: 'Cartridge (.crt)', extensions: ['.crt'] },
|
|
14
|
+
{ type: 'prg', label: 'Program (.prg)', extensions: ['.prg'] },
|
|
15
|
+
{ type: 'd64', label: 'Disk image (.d64)', extensions: ['.d64'] },
|
|
16
|
+
{
|
|
17
|
+
type: 'snapshot',
|
|
18
|
+
label: 'Snapshot (.snapshot, .c64, .s64)',
|
|
19
|
+
extensions: ['.snapshot', '.c64', '.s64'],
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const LOAD_TYPE_SET = new Set<LoadType>(LOAD_FORMAT_OPTIONS.map((f) => f.type));
|
|
24
|
+
|
|
25
|
+
export function isSupportedLoadType(value: unknown): value is LoadType {
|
|
26
|
+
return typeof value === 'string' && LOAD_TYPE_SET.has(value as LoadType);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function inferLoadTypeFromFilename(filename: string): LoadType | null {
|
|
30
|
+
const lower = filename.toLowerCase();
|
|
31
|
+
for (const format of LOAD_FORMAT_OPTIONS) {
|
|
32
|
+
if (format.extensions.some((ext) => lower.endsWith(ext))) {
|
|
33
|
+
return format.type;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveLoadTypeSelection(
|
|
40
|
+
selection: LoadTypeSelection,
|
|
41
|
+
filename: string,
|
|
42
|
+
fallback: LoadType = 'crt',
|
|
43
|
+
): LoadType {
|
|
44
|
+
if (selection !== 'auto') return selection;
|
|
45
|
+
return inferLoadTypeFromFilename(filename) ?? fallback;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getAcceptForLoadTypeSelection(selection: LoadTypeSelection): string {
|
|
49
|
+
const exts =
|
|
50
|
+
selection === 'auto'
|
|
51
|
+
? LOAD_FORMAT_OPTIONS.flatMap((f) => f.extensions)
|
|
52
|
+
: LOAD_FORMAT_OPTIONS.find((f) => f.type === selection)?.extensions ?? [];
|
|
53
|
+
return exts.join(',');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getLoadTypeLabel(type: LoadType): string {
|
|
57
|
+
return LOAD_FORMAT_OPTIONS.find((f) => f.type === type)?.label ?? type.toUpperCase();
|
|
58
|
+
}
|
|
@@ -262,6 +262,64 @@
|
|
|
262
262
|
}
|
|
263
263
|
.c64-menu-header { display:flex; align-items:center; justify-content:space-between; }
|
|
264
264
|
.c64-menu-close { background:none; border:none; color:#888; font-size:20px; cursor:pointer; }
|
|
265
|
+
.c64-settings-tabs {
|
|
266
|
+
display: flex;
|
|
267
|
+
gap: 8px;
|
|
268
|
+
flex-wrap: wrap;
|
|
269
|
+
margin-bottom: 12px;
|
|
270
|
+
}
|
|
271
|
+
.c64-settings-tab {
|
|
272
|
+
background: #171729;
|
|
273
|
+
border: 1px solid #353552;
|
|
274
|
+
color: #c5c5df;
|
|
275
|
+
padding: 6px 10px;
|
|
276
|
+
border-radius: 4px;
|
|
277
|
+
cursor: pointer;
|
|
278
|
+
font-size: 12px;
|
|
279
|
+
}
|
|
280
|
+
.c64-settings-tab.active {
|
|
281
|
+
border-color: #7b71d5;
|
|
282
|
+
color: #fff;
|
|
283
|
+
background: #25253d;
|
|
284
|
+
}
|
|
285
|
+
.c64-settings-section {
|
|
286
|
+
padding-top: 2px;
|
|
287
|
+
}
|
|
288
|
+
.c64-section-label {
|
|
289
|
+
display: block;
|
|
290
|
+
margin: 0 0 8px;
|
|
291
|
+
font-size: 13px;
|
|
292
|
+
color: #aaa;
|
|
293
|
+
}
|
|
294
|
+
.c64-form-row {
|
|
295
|
+
display: flex;
|
|
296
|
+
align-items: center;
|
|
297
|
+
gap: 10px;
|
|
298
|
+
margin-bottom: 10px;
|
|
299
|
+
}
|
|
300
|
+
.c64-select {
|
|
301
|
+
background: #171729;
|
|
302
|
+
color: #ddd;
|
|
303
|
+
border: 1px solid #444;
|
|
304
|
+
border-radius: 4px;
|
|
305
|
+
padding: 4px 8px;
|
|
306
|
+
font-family: monospace;
|
|
307
|
+
}
|
|
308
|
+
.c64-radio-row {
|
|
309
|
+
margin-top: 8px;
|
|
310
|
+
display: flex;
|
|
311
|
+
gap: 12px;
|
|
312
|
+
align-items: center;
|
|
313
|
+
}
|
|
314
|
+
.c64-radio-row-wrap {
|
|
315
|
+
flex-wrap: wrap;
|
|
316
|
+
}
|
|
317
|
+
.c64-section-hint {
|
|
318
|
+
margin-top: 6px;
|
|
319
|
+
font-size: 11px;
|
|
320
|
+
color: #888;
|
|
321
|
+
line-height: 1.4;
|
|
322
|
+
}
|
|
265
323
|
.c64-dragarea {
|
|
266
324
|
border: 2px dashed #2a2a3e;
|
|
267
325
|
border-radius: 6px;
|
|
@@ -271,16 +329,25 @@
|
|
|
271
329
|
color: #aaa;
|
|
272
330
|
background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
|
|
273
331
|
}
|
|
332
|
+
.c64-dragarea button {
|
|
333
|
+
margin-left: 6px;
|
|
334
|
+
}
|
|
274
335
|
.c64-dragarea.dragover { border-color: #7b71d5; color: #fff; }
|
|
275
336
|
.c64-cart-preview { display:flex; gap:12px; align-items:center; margin-top:12px; }
|
|
276
337
|
.c64-cart-icon { width:56px; height:40px; background:#222; border:1px solid #333; display:flex; align-items:center; justify-content:center; border-radius:4px; }
|
|
277
338
|
.c64-cart-filename { font-size:13px; color:#ccc; word-break:break-all; }
|
|
339
|
+
.c64-cart-type { font-size: 11px; color: #888; margin-top: 2px; }
|
|
278
340
|
.c64-file-input { display:none; }
|
|
279
341
|
.c64-menu-actions {
|
|
280
342
|
margin-top:12px;
|
|
281
343
|
display:flex;
|
|
282
|
-
flex-
|
|
344
|
+
flex-wrap: wrap;
|
|
283
345
|
gap:8px;
|
|
284
346
|
}
|
|
347
|
+
.c64-system-actions {
|
|
348
|
+
margin-top: 4px;
|
|
349
|
+
display: flex;
|
|
350
|
+
gap: 8px;
|
|
351
|
+
flex-wrap: wrap;
|
|
352
|
+
}
|
|
285
353
|
.c64-btn { background:#222; border:1px solid #444; color:#ddd; padding:6px 10px; border-radius:4px; cursor:pointer; }
|
|
286
|
-
|