c64-ready 0.10.0 → 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.
@@ -0,0 +1,127 @@
1
+ Thank you for downloading the Commodore 64 Font!
2
+
3
+ The first computer I ever owned was a great little 8-bit wonder called the
4
+ Commodore 64. Due to the hours upon hours I spent both playing games and
5
+ learning to program (at age 12 in 1986) I gained a love for computers.
6
+
7
+ Needless to say, I created a true type font that mimics the machine's
8
+ character set. Each symbol that was present on the original Commodore 64
9
+ computer is available in the font.
10
+
11
+ I added a number of dingbats when possible. The "3D" pictures of the
12
+ Commodore 64 and 1541 Disk Drive were created from photos of my system.
13
+ A number of the dingbats are based on other dingbats available on the
14
+ Internet.
15
+
16
+
17
+ Anyway, please enjoy.
18
+
19
+ Devin D. Cook
20
+ www.DevinCook.com
21
+
22
+
23
+ Revision History
24
+ ================
25
+
26
+ =============
27
+ Version 6.3
28
+ =============
29
+
30
+ * Updated embedding flags
31
+
32
+ =============
33
+ Version 6.22
34
+ =============
35
+
36
+ * I made a few very minor changes to a couple of characters
37
+
38
+ * The postscript names were fixed - I didn't have all the characters
39
+ named properly.
40
+
41
+
42
+ =============
43
+ Version 6.21
44
+ =============
45
+
46
+ * The metrics for the font were perfected.
47
+
48
+ * The settings for the underline and strikethru effects (added by
49
+ Windows) were set correctly.
50
+
51
+ * The characters for the curly brackets were modified
52
+
53
+ * The font is now properly mapped to the Windows Symbol platform
54
+ and the Macintosh Latin platforms.
55
+
56
+ * Each character is now properly aligned and characters fit snugly
57
+ togather on different lines. This allows you to create Commodore
58
+ PET-ASCII art!
59
+
60
+ * I updated the Commodore Logo - which was slightly incorrect in the last
61
+ version.
62
+
63
+ * I rearranged all the dingbats
64
+
65
+ * The Windows Logo was replaced with the Commodore logo on all the dingbats.
66
+ The font still has all the stand-alone dingbats from version 5.2
67
+
68
+ * The simple dingbats for the C64 and 1541 Disk Drive were fixed.
69
+
70
+ * The Pac-Man dingbats were fixed
71
+
72
+ * Atari logo was fixed
73
+
74
+ * The Amiga symbol was added.
75
+
76
+ * The mouse graphic was made "white" and the Commodore logo was added
77
+
78
+ * A number of new dingbats were added. Some of the company names were
79
+ removed to make room. The new characters are as follows: "White" Commodore
80
+ logo, Computer Key, Seal, Mousepad, Sign, Gift, Muscle, Framed Logo, Note,
81
+ Award, Logo in a Circle, and a computer monitor.
82
+
83
+
84
+ =============
85
+ Version 5.2
86
+ =============
87
+
88
+ * I fixed an error in the uppercase "M" and all characters were aligned.
89
+
90
+
91
+ =============
92
+ Version 5.0 - The Following was added
93
+ =============
94
+
95
+ * Commodore & Amiga logos
96
+
97
+ * Simple Commodore 64 & 1541 Disk Drive
98
+
99
+ * Commodore 64 and 1541 Disk Drive simple icons
100
+
101
+ * Commodore 64 and 1541 Disk Drive (created from ACTUAL photos of my system)
102
+
103
+ * 5.25" disk in Commodore sleeve and 5.25" without
104
+
105
+ * "READY." prompt
106
+
107
+ * Commodore 64 logo
108
+
109
+ * Mouse
110
+
111
+ * Pac-Man (facing 4 directions), ghosts (Inky, Blinky, Pinky & Clyde),
112
+ pellets, Pac-Man logo
113
+
114
+ * Logos for Intel Inside, Microsoft, Windows, Internet Explorer
115
+
116
+ * Common windows (one with a Windows logo), folders, documents, disks ...
117
+
118
+ * Minimize, Maximize, Normalize, Close icons
119
+
120
+ * Apple logo, Macintosh logo, Mac-OS, Macintosh boot, Apple disk, Quicktime
121
+
122
+ * Logos for other companies:
123
+ Microtek, AST, Atari, Sun, Franklin, iomega, Xerox, HP, IBM, Fugitsu,
124
+ Epson, Acer, Compaq, Intel, 3 Com, NEC, Digital, Seagate, Novell,
125
+ Canon, NeXt
126
+
127
+
package/dist/index.html CHANGED
@@ -29,7 +29,7 @@
29
29
  font-size: 13px;
30
30
  }
31
31
  </style>
32
- <script type="module" crossorigin src="/c64-ready/assets/index-Cioamf6E.js"></script>
32
+ <script type="module" crossorigin src="/c64-ready/assets/index-CeQto0sd.js"></script>
33
33
  </head>
34
34
  <body>
35
35
  <canvas id="c64-screen" width="384" height="272"></canvas>
Binary file
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "retro"
11
11
  ],
12
12
  "license": "MIT",
13
- "version": "0.10.0",
13
+ "version": "0.11.0",
14
14
  "type": "module",
15
15
  "engines": {
16
16
  "node": ">=24.14"
@@ -143,16 +143,17 @@ export class C64Emulator {
143
143
  try {
144
144
  switch (options.type) {
145
145
  case 'prg':
146
- x.c64_loadPRG(ptr, options.data.length);
146
+ x.c64_loadPRG(ptr, options.data.length, 1);
147
147
  break;
148
148
  case 'd64':
149
+ x.c64_setDriveEnabled(1);
149
150
  x.c64_insertDisk(ptr, options.data.length);
150
151
  break;
151
152
  case 'crt':
152
153
  x.c64_loadCartridge(ptr, options.data.length);
153
154
  break;
154
155
  case 'snapshot':
155
- x.c64_loadSnapshot(ptr, options.data.length);
156
+ this.loadSnapshotData(ptr, options.data.length);
156
157
  break;
157
158
  }
158
159
  } finally {
@@ -293,6 +294,13 @@ export class C64Emulator {
293
294
  return snap;
294
295
  }
295
296
 
297
+ private loadSnapshotData(ptr: number, len: number): void {
298
+ const x = this.wasm.exports;
299
+ if (!x) throw new Error('WASM not ready');
300
+ x.c64_loadSnapshot(ptr, len);
301
+ this.frameCount = 0;
302
+ }
303
+
296
304
  // ---------------------------------------------------------------------------
297
305
  // Debugger
298
306
  // ---------------------------------------------------------------------------
@@ -96,6 +96,46 @@ function parseCrtInfo(data, filename) {
96
96
  return { line, hwType, hwName, exrom, game, bankConfig, cartName, chipCount, totalRomBytes };
97
97
  }
98
98
 
99
+ function inferLoadType(filename = '') {
100
+ const lower = String(filename).toLowerCase();
101
+ if (lower.endsWith('.crt')) return 'crt';
102
+ if (lower.endsWith('.prg')) return 'prg';
103
+ if (lower.endsWith('.d64')) return 'd64';
104
+ if (lower.endsWith('.snapshot') || lower.endsWith('.c64') || lower.endsWith('.s64')) return 'snapshot';
105
+ return 'crt';
106
+ }
107
+
108
+ function sleepMs(ms) {
109
+ return new Promise((resolve) => setTimeout(resolve, ms));
110
+ }
111
+
112
+ async function typeCommandText(exports, text, opts = {}) {
113
+ if (!exports) return;
114
+ const settleMs = Number.isFinite(opts.settleMs) ? opts.settleMs : 120;
115
+ const keyDelayMs = Number.isFinite(opts.keyDelayMs) ? opts.keyDelayMs : 22;
116
+
117
+ if (settleMs > 0) await sleepMs(settleMs);
118
+
119
+ for (const ch of text) {
120
+ const key = ch === '\n' ? 'Enter' : ch;
121
+ const down = domKeyToC64Actions(key, false, 'keydown');
122
+ for (const act of down) {
123
+ if (act.action === 'press') exports.keyboard_keyPressed(act.key);
124
+ else exports.keyboard_keyReleased(act.key);
125
+ }
126
+ if (typeof exports.debugger_update === 'function') exports.debugger_update(12);
127
+ if (keyDelayMs > 0) await sleepMs(keyDelayMs);
128
+
129
+ const up = domKeyToC64Actions(key, false, 'keyup');
130
+ for (const act of up) {
131
+ if (act.action === 'press') exports.keyboard_keyPressed(act.key);
132
+ else exports.keyboard_keyReleased(act.key);
133
+ }
134
+ if (typeof exports.debugger_update === 'function') exports.debugger_update(12);
135
+ if (keyDelayMs > 0) await sleepMs(keyDelayMs);
136
+ }
137
+ }
138
+
99
139
  // ── Build info ────────────────────────────────────────────────────────────────
100
140
  // Read once at module load so every createInputServer call gets the same values.
101
141
  const _repoRootForBuildInfo = path.resolve(new URL('../../', import.meta.url).pathname);
@@ -505,7 +545,8 @@ export async function runHeadless(options = {}) {
505
545
  disconnectAllWebrtcPeers: (reason) => disconnectAllWebrtcPeers(reason),
506
546
  onCommand: (cmd) => {
507
547
  if (!exports) return;
508
- if (cmd.type === 'load-crt') {
548
+ if (cmd.type === 'load-file' || cmd.type === 'load-crt') {
549
+ const requestedType = cmd.type === 'load-crt' ? 'crt' : (cmd.fileType ?? inferLoadType(cmd.filename));
509
550
  // Decode base64 → Uint8Array immediately and release the large
510
551
  // base64 string from the cmd object as soon as possible so GC
511
552
  // can reclaim it during the subsequent async gap.
@@ -523,19 +564,39 @@ export async function runHeadless(options = {}) {
523
564
  // Return a Promise so input-server waits before broadcasting
524
565
  // cart-loaded — ensuring clients are told only after load succeeds.
525
566
  return new Promise((resolve, reject) => {
526
- setImmediate(() => {
567
+ setImmediate(async () => {
527
568
  try {
528
569
  const gapStart = Date.now();
529
- exports.c64_removeCartridge();
530
- exports.c64_reset(); // clean slate before loading new cart
531
- const cartInfo = parseCrtInfo(arr, filename);
532
- if (cartInfo) console.error(cartInfo.line);
570
+ const loadType = requestedType;
571
+ // For cartridge loads, reset first so bank state does not leak.
572
+ if (loadType === 'crt') {
573
+ exports.c64_removeCartridge();
574
+ exports.c64_reset();
575
+ }
533
576
  const ptr = c64wasm.allocAndWrite(arr);
534
577
  c64wasm.updateHeapViews();
535
578
  heap = c64wasm.heap;
536
- exports.c64_loadCartridge(ptr, byteLen);
537
- // free(ptr), debugger_set_speed and debugger_play intentionally
538
- // omitted: c64_loadCartridge internally resets and resumes.
579
+ try {
580
+ if (loadType === 'crt') {
581
+ const cartInfo = parseCrtInfo(arr, filename);
582
+ if (cartInfo) console.error(cartInfo.line);
583
+ exports.c64_loadCartridge(ptr, byteLen);
584
+ } else if (loadType === 'prg') {
585
+ exports.c64_loadPRG(ptr, byteLen, 1);
586
+ await typeCommandText(exports, 'run\n');
587
+ } else if (loadType === 'd64') {
588
+ exports.c64_removeCartridge();
589
+ exports.c64_reset();
590
+ exports.c64_setDriveEnabled(1);
591
+ exports.c64_insertDisk(ptr, byteLen);
592
+ } else if (loadType === 'snapshot') {
593
+ exports.c64_loadSnapshot(ptr, byteLen);
594
+ } else {
595
+ throw new Error(`Unsupported load-file type: ${loadType}`);
596
+ }
597
+ } finally {
598
+ c64wasm.free(ptr);
599
+ }
539
600
  const gapMs = Date.now() - gapStart;
540
601
  //
541
602
  // ── Audio RTP re-sync after blocking gap ─────────────────────
@@ -556,8 +617,8 @@ export async function runHeadless(options = {}) {
556
617
  if (verbose) console.error(`[headless] pushed ${gapMs}ms silence to re-align audio RTP after cart load`);
557
618
  }
558
619
  if (webrtcServer) webrtcServer.forceKeyframe(webrtcEncoder?.videoTrack);
559
- if (verbose) console.error(`[headless] cart loaded: ${filename} (${byteLen} bytes, gap=${gapMs}ms)`);
560
- else if (logEvents) console.error(`[event] cart-loaded filename=${filename} bytes=${byteLen} gap=${gapMs}ms`);
620
+ if (verbose) console.error(`[headless] file loaded: ${filename} (${loadType}, ${byteLen} bytes, gap=${gapMs}ms)`);
621
+ else if (logEvents) console.error(`[event] cart-loaded filename=${filename} type=${loadType} bytes=${byteLen} gap=${gapMs}ms`);
561
622
  resolve();
562
623
  } catch (err) {
563
624
  if (verbose) console.error('[headless] cart load (deferred) error:', err);
@@ -580,14 +641,9 @@ export async function runHeadless(options = {}) {
580
641
  if (verbose) console.error('[headless] cart detached');
581
642
  else if (logEvents) console.error(`[event] cart-detached gap=${gapMs}ms`);
582
643
  } else if (cmd.type === 'hard-reset') {
583
- // Instant hard reset: detach cart and soft-reset the machine.
584
- // c64_removeCartridge() is ~0ms; c64_reset() with no cart is ~110ms
585
- // and runs synchronously inline — no setImmediate deferral needed
586
- // since there is no loadCartridge call to block the event loop.
587
- // The game is intentionally NOT reloaded: hard reset returns to
588
- // the BASIC prompt / blank screen, matching real C64 behaviour.
644
+ // Instant hard reset: reset machine state but keep current media
645
+ // attached (cartridge/disk), matching offline player behavior.
589
646
  const gapStart = Date.now();
590
- exports.c64_removeCartridge();
591
647
  exports.c64_reset();
592
648
  const gapMs = Date.now() - gapStart;
593
649
  resetSidRing();
@@ -130,6 +130,10 @@ export function createInputServer(opts = {}) {
130
130
 
131
131
  // Joystick port swap — when true, host uses port 1, P2 uses port 2
132
132
  let portsSwapped = false;
133
+ // Optional host-defined override for independent per-role joystick ports.
134
+ let portOverrideEnabled = false;
135
+ let overrideHostPort = 2;
136
+ let overrideP2Port = 1;
133
137
 
134
138
  // ── Host reconnect grace period ───────────────────────────────────────────
135
139
  // When the host disconnects we hold off on promoting P2 for up to
@@ -140,8 +144,12 @@ export function createInputServer(opts = {}) {
140
144
  // Seeded from opts.initialCartFilename when a default game is pre-loaded.
141
145
  let currentCartFilename = opts.initialCartFilename ?? null;
142
146
 
143
- function hostPort() { return portsSwapped ? 1 : 2; }
144
- function p2Port() { return portsSwapped ? 2 : 1; }
147
+ function hostPort() {
148
+ return portOverrideEnabled ? overrideHostPort : (portsSwapped ? 1 : 2);
149
+ }
150
+ function p2Port() {
151
+ return portOverrideEnabled ? overrideP2Port : (portsSwapped ? 2 : 1);
152
+ }
145
153
 
146
154
  // ── Host inactivity timeout ───────────────────────────────────────────────
147
155
  let hostTimeoutTimer = null;
@@ -226,6 +234,9 @@ export function createInputServer(opts = {}) {
226
234
  hostClient = null;
227
235
  hostUsername = null;
228
236
  inviteToken = null;
237
+ portOverrideEnabled = false;
238
+ overrideHostPort = 2;
239
+ overrideP2Port = 1;
229
240
  clearHostTimeout();
230
241
  clearGrace();
231
242
  // Broadcast host-left with reason so clients can show a contextual notice
@@ -248,6 +259,9 @@ export function createInputServer(opts = {}) {
248
259
  hostUsername = null;
249
260
  inviteToken = null;
250
261
  portsSwapped = false;
262
+ portOverrideEnabled = false;
263
+ overrideHostPort = 2;
264
+ overrideP2Port = 1;
251
265
  setWsIdentity(targetWs, 'spectator', null);
252
266
  broadcastAll({ type: 'host-left', username: leaving, reason });
253
267
  broadcastAll({ type: 'p2-slot-status', open: false });
@@ -470,6 +484,38 @@ export function createInputServer(opts = {}) {
470
484
  });
471
485
  return;
472
486
  }
487
+
488
+ // ── Host-defined independent joystick port override ───────────────────
489
+ if (msg.type === 'set-port-override') {
490
+ if (ws !== hostClient) return;
491
+ const enabled = !!msg.enabled;
492
+ const hp = Number(msg.hostPort);
493
+ const pp = Number(msg.p2Port);
494
+ if (!Number.isFinite(hp) || !Number.isFinite(pp) || (hp !== 1 && hp !== 2) || (pp !== 1 && pp !== 2)) {
495
+ if (verbose) console.error('[input-server] invalid set-port-override payload');
496
+ logEv('error', { kind: 'set-port-override-invalid', hostPort: msg.hostPort, p2Port: msg.p2Port });
497
+ return;
498
+ }
499
+ portOverrideEnabled = enabled;
500
+ overrideHostPort = hp;
501
+ overrideP2Port = pp;
502
+ logEv('port-override-updated', {
503
+ enabled: portOverrideEnabled,
504
+ hostPort: overrideHostPort,
505
+ p2Port: overrideP2Port,
506
+ effectiveHostPort: hostPort(),
507
+ effectiveP2Port: p2Port(),
508
+ });
509
+ broadcastAll({
510
+ type: 'port-override-updated',
511
+ enabled: portOverrideEnabled,
512
+ hostPort: overrideHostPort,
513
+ p2Port: overrideP2Port,
514
+ effectiveHostPort: hostPort(),
515
+ effectiveP2Port: p2Port(),
516
+ });
517
+ return;
518
+ }
473
519
  // ── Voluntary player 2 leave ──────────────────────────────────────────
474
520
  if (msg.type === 'p2-leave') {
475
521
  if (ws === p2Client) {
@@ -497,6 +543,9 @@ export function createInputServer(opts = {}) {
497
543
  hostUsername = null;
498
544
  inviteToken = null;
499
545
  portsSwapped = false;
546
+ portOverrideEnabled = false;
547
+ overrideHostPort = 2;
548
+ overrideP2Port = 1;
500
549
  setWsIdentity(ws, 'spectator', null);
501
550
  if (verbose) console.error(`[input-server] host ${leaving} voluntarily left`);
502
551
  logEv('host-left', { username: leaving, reason: 'voluntary' });
@@ -706,6 +755,36 @@ export function createInputServer(opts = {}) {
706
755
  }
707
756
 
708
757
  // ── Emulator commands (host only) ─────────────────────────────────────
758
+ if (msg.type === 'load-file') {
759
+ if (ws !== hostClient) return;
760
+ const loadFilename = msg.filename ?? '';
761
+ const fileType = msg.fileType ?? 'crt';
762
+ if (verbose) console.error(`[input-server] load-file: ${loadFilename || '?'} (${fileType})`);
763
+ logEv('cmd-load-file', {
764
+ filename: loadFilename || '?',
765
+ fileType,
766
+ dataLen: (msg.data ?? '').length,
767
+ });
768
+ broadcastAll({ type: 'cart-loading', filename: loadFilename });
769
+ Promise.resolve()
770
+ .then(() => onCommand({ type: 'load-file', filename: loadFilename, fileType, data: msg.data ?? '' }))
771
+ .then(() => {
772
+ currentCartFilename = loadFilename || null;
773
+ broadcastAll({ type: 'cart-loaded', filename: loadFilename });
774
+ })
775
+ .catch((e) => {
776
+ broadcastAll({ type: 'cart-load-error', reason: String(e?.message ?? e) });
777
+ if (verbose) console.error('[input-server] load-file error:', e);
778
+ logEv('error', {
779
+ kind: 'load-file-failed',
780
+ filename: loadFilename,
781
+ fileType,
782
+ err: String(e?.message ?? e),
783
+ });
784
+ });
785
+ return;
786
+ }
787
+
709
788
  if (msg.type === 'load-crt') {
710
789
  if (ws !== hostClient) return;
711
790
  if (verbose) console.error(`[input-server] load-crt: ${msg.filename ?? '?'}`);
@@ -713,7 +792,7 @@ export function createInputServer(opts = {}) {
713
792
  const loadFilename = msg.filename ?? '';
714
793
  broadcastAll({ type: 'cart-loading', filename: loadFilename });
715
794
  Promise.resolve()
716
- .then(() => onCommand({ type: 'load-crt', filename: loadFilename, data: msg.data ?? '' }))
795
+ .then(() => onCommand({ type: 'load-file', filename: loadFilename, fileType: 'crt', data: msg.data ?? '' }))
717
796
  .then(() => {
718
797
  currentCartFilename = loadFilename || null;
719
798
  broadcastAll({ type: 'cart-loaded', filename: loadFilename });
@@ -819,6 +898,9 @@ export function createInputServer(opts = {}) {
819
898
  // Tag with role so onInput can include it in logEvents output
820
899
  // without input-server needing to know about logEvents details.
821
900
  msg._role = role;
901
+ if (msg.type === 'joystick') {
902
+ msg.joystickPort = role === 'host' ? hostPort() : p2Port();
903
+ }
822
904
  if (onInput) onInput(msg);
823
905
  if (Number.isFinite(msg.inputId) && ws.readyState === ws.OPEN) {
824
906
  try {
@@ -855,6 +937,9 @@ export function createInputServer(opts = {}) {
855
937
  hostUsername = null;
856
938
  inviteToken = null;
857
939
  portsSwapped = false;
940
+ portOverrideEnabled = false;
941
+ overrideHostPort = 2;
942
+ overrideP2Port = 1;
858
943
  onHostDisconnect(leaving);
859
944
  }
860
945
 
@@ -891,6 +976,13 @@ export function createInputServer(opts = {}) {
891
976
  host: hostActive ? { username: hostUsername, joystickPort: hostPort() } : null,
892
977
  player2: p2Username ? { username: p2Username, joystickPort: p2Port() } : null,
893
978
  p2SlotOpen: isP2SlotOpen(),
979
+ portOverride: {
980
+ enabled: portOverrideEnabled,
981
+ hostPort: overrideHostPort,
982
+ p2Port: overrideP2Port,
983
+ effectiveHostPort: hostPort(),
984
+ effectiveP2Port: p2Port(),
985
+ },
894
986
  ...(currentCartFilename ? { cartFilename: currentCartFilename } : {}),
895
987
  joystickBitmask: { up: 0x1, down: 0x2, left: 0x4, right: 0x8, fire: 0x10 },
896
988
  ...(serverVersion ? { serverVersion } : {}),
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: `${base}games/cartridges/legend-of-wilf.crt`,
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) => {
@@ -54,10 +74,12 @@ updateFavicon();
54
74
  window.addEventListener('c64-load-file', async (e: Event) => {
55
75
  const detail = (e as CustomEvent).detail;
56
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
81
  renderer.showLoader();
60
- await player.loadFile(file);
82
+ await player.loadFile(file, isSupportedLoadType(loadType) ? loadType : undefined);
61
83
  renderer.hideLoader();
62
84
  } catch (err) {
63
85
  console.error(err);
@@ -78,3 +100,13 @@ window.addEventListener('c64-load-error', (e: Event) => {
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
+ });