c64-ready 0.10.0 → 1.0.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-Ckbi7gQo.js"></script>
33
33
  </head>
34
34
  <body>
35
35
  <canvas id="c64-screen" width="384" height="272"></canvas>
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+ {
2
+ "tools": [
3
+ "Keyboard-Test.prg",
4
+ "anykey-c64.prg"
5
+ ]
6
+ }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "retro"
11
11
  ],
12
12
  "license": "MIT",
13
- "version": "0.10.0",
13
+ "version": "1.0.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
  // ---------------------------------------------------------------------------
@@ -21,7 +21,7 @@ export const JOYSTICK_KEY_CODES: Array<keyof typeof KEY_TO_JOYSTICK> = Object.ke
21
21
 
22
22
  /**
23
23
  * Input modes:
24
- * - 'joystick' — arrow keys + ControlLeft map to joystick only (default)
24
+ * - 'joystick' — arrow keys + ControlLeft map to joystick only
25
25
  * - 'keyboard' — all keys route to the C64 keyboard matrix; no joystick
26
26
  * - 'mixed' — arrow keys + Z + ControlLeft drive the joystick AND all
27
27
  * other keys route to the C64 keyboard matrix
@@ -414,6 +414,9 @@ export function domKeyToC64Actions(
414
414
  case 'home':
415
415
  main(C64_KEY.CLEAR_HOME);
416
416
  break;
417
+ case 'pageup':
418
+ main(C64_KEY.RESTORE);
419
+ break;
417
420
 
418
421
  // ── Function keys ────────────────────────────────────────────────────────
419
422
  case 'f1':
@@ -482,7 +485,7 @@ export class EmulatorInput {
482
485
  private readonly target: EventTarget;
483
486
  // Which joystick port keyboard events map to (1 or 2). Default is port 2.
484
487
  private keyboardJoystickPort: JoystickPort;
485
- private inputMode: InputMode = 'joystick';
488
+ private inputMode: InputMode = 'mixed';
486
489
  private readonly pressedControls = new Set<MappedControl>();
487
490
  private readonly keyDownHandler = (event: KeyboardEvent): void => {
488
491
  this.handleKeyDown(event);
@@ -212,6 +212,7 @@ export function domKeyToC64Actions(domKey, shiftKey, eventType) {
212
212
  case 'control': main(C64_KEY.COMMODORE); break; // Ctrl → CBM key
213
213
  case 'capslock': main(C64_KEY.COMMODORE); break; // CapsLock → CBM key
214
214
  case 'home': main(C64_KEY.CLEAR_HOME); break;
215
+ case 'pageup': main(C64_KEY.RESTORE); break;
215
216
 
216
217
  // ── Function keys ────────────────────────────────────────────────────────
217
218
  case 'f1': main(C64_KEY.F1); break;
@@ -251,4 +252,3 @@ export function domKeyToC64Actions(domKey, shiftKey, eventType) {
251
252
 
252
253
  return actions;
253
254
  }
254
-
@@ -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,37 @@ 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_setDriveEnabled(1);
589
+ exports.c64_insertDisk(ptr, byteLen);
590
+ } else if (loadType === 'snapshot') {
591
+ exports.c64_loadSnapshot(ptr, byteLen);
592
+ } else {
593
+ throw new Error(`Unsupported load-file type: ${loadType}`);
594
+ }
595
+ } finally {
596
+ c64wasm.free(ptr);
597
+ }
539
598
  const gapMs = Date.now() - gapStart;
540
599
  //
541
600
  // ── Audio RTP re-sync after blocking gap ─────────────────────
@@ -556,8 +615,8 @@ export async function runHeadless(options = {}) {
556
615
  if (verbose) console.error(`[headless] pushed ${gapMs}ms silence to re-align audio RTP after cart load`);
557
616
  }
558
617
  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`);
618
+ if (verbose) console.error(`[headless] file loaded: ${filename} (${loadType}, ${byteLen} bytes, gap=${gapMs}ms)`);
619
+ else if (logEvents) console.error(`[event] cart-loaded filename=${filename} type=${loadType} bytes=${byteLen} gap=${gapMs}ms`);
561
620
  resolve();
562
621
  } catch (err) {
563
622
  if (verbose) console.error('[headless] cart load (deferred) error:', err);
@@ -580,14 +639,9 @@ export async function runHeadless(options = {}) {
580
639
  if (verbose) console.error('[headless] cart detached');
581
640
  else if (logEvents) console.error(`[event] cart-detached gap=${gapMs}ms`);
582
641
  } 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.
642
+ // Instant hard reset: reset machine state but keep current media
643
+ // attached (cartridge/disk), matching offline player behavior.
589
644
  const gapStart = Date.now();
590
- exports.c64_removeCartridge();
591
645
  exports.c64_reset();
592
646
  const gapMs = Date.now() - gapStart;
593
647
  resetSidRing();
@@ -752,7 +806,9 @@ export async function runHeadless(options = {}) {
752
806
  const EVENT_LOOP_LOG_MS = 5000;
753
807
  eventLoopLogTimer = setInterval(() => {
754
808
  const lag = eventLoopMonitor ? eventLoopMonitor.min / 1e6 : 0; // ms
755
- if (lag > 5 && (logEvents || verbose)) { // only log if >5ms lag
809
+ // Keep event-loop lag diagnostics behind --verbose only. These can be
810
+ // noisy in steady-state and are intended for performance debugging.
811
+ if (lag > 5 && verbose) { // only log if >5ms lag
756
812
  console.error(`[event] event-loop-lag min=${lag.toFixed(2)}ms`);
757
813
  }
758
814
  if (eventLoopMonitor) eventLoopMonitor.reset();
@@ -1074,7 +1130,8 @@ export async function runHeadless(options = {}) {
1074
1130
  if (driftPct > 10) {
1075
1131
  console.error(`[event] drift fps-actual=${actualFps.toFixed(1)} fps-target=${targetFps} drift=${drift > 0 ? '+' : ''}${drift.toFixed(1)} (${driftPct.toFixed(0)}%)`);
1076
1132
  }
1077
- if (videoFramesDroppedLateWindow > 0 || videoFramesDroppedCapWindow > 0) {
1133
+ // Keep per-window drop telemetry behind --verbose only.
1134
+ if (verbose && (videoFramesDroppedLateWindow > 0 || videoFramesDroppedCapWindow > 0)) {
1078
1135
  console.error(`[event] webrtc-video-drop sent=${videoFramesSent} late=${videoFramesDroppedLateWindow} cap=${videoFramesDroppedCapWindow} totalLate=${videoFramesDroppedLate} totalCap=${videoFramesDroppedCap} fpsCap=${webrtcSendFps}`);
1079
1136
  }
1080
1137
  }