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.
Files changed (41) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +94 -22
  3. package/bin/admin.mjs +196 -0
  4. package/bin/headless.mjs +26 -3
  5. package/bin/serve.mjs +3 -0
  6. package/dist/assets/CHANGELOG-CPMeNyjb.js +261 -0
  7. package/dist/assets/index-CeQto0sd.js +499 -0
  8. package/dist/c64-ready/c64-ready.gif +0 -0
  9. package/dist/fonts/Commodore Angled v1.2.ttf +0 -0
  10. package/dist/fonts/Commodore Rounded v1.2.ttf +0 -0
  11. package/dist/fonts/Commodore-64-v6.3.TTF +0 -0
  12. package/dist/fonts/READ ME!.txt +127 -0
  13. package/dist/fonts/button-commodore-64-font.gif +0 -0
  14. package/dist/games/cartridges/bubble-bobble.crt +0 -0
  15. package/dist/games/cartridges/ghosts-n-goblins.crt +0 -0
  16. package/dist/games/snapshots/LVLLVL%BAAL.c64 +0 -0
  17. package/dist/games/snapshots/VICE2-4%APOLLO18.vsf +0 -0
  18. package/dist/games/snapshots/VICE3.10%ELEVATOR.vsf +0 -0
  19. package/dist/index.html +1 -1
  20. package/dist/tools/Keyboard-Test.prg +0 -0
  21. package/package.json +6 -2
  22. package/public/games/cartridges/bubble-bobble.crt +0 -0
  23. package/public/games/cartridges/ghosts-n-goblins.crt +0 -0
  24. package/src/emulator/c64-emulator.ts +10 -2
  25. package/src/emulator/crt-info.ts +210 -0
  26. package/src/emulator/input.ts +542 -7
  27. package/src/headless/c64-key-map.mjs +254 -0
  28. package/src/headless/c64-wasm.mjs +4 -1
  29. package/src/headless/headless-cli.mjs +832 -123
  30. package/src/headless/input-server.mjs +947 -14
  31. package/src/headless/webrtc-encoder.mjs +251 -0
  32. package/src/headless/webrtc-server.mjs +1327 -0
  33. package/src/main.ts +39 -7
  34. package/src/player/c64-player.ts +131 -14
  35. package/src/player/input-handler.ts +22 -6
  36. package/src/player/load-formats.ts +58 -0
  37. package/src/player/styles/ui-controller.css +69 -2
  38. package/src/player/ui-controller.ts +167 -36
  39. package/src/types/emulator.ts +2 -1
  40. package/dist/assets/CHANGELOG-C1nvP1iO.js +0 -96
  41. package/dist/assets/index-Cioamf6E.js +0 -394
@@ -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.6.2",
13
+ "version": "0.11.0",
14
14
  "type": "module",
15
15
  "engines": {
16
16
  "node": ">=24.14"
@@ -32,7 +32,8 @@
32
32
  },
33
33
  "bin": {
34
34
  "c64-ready": "bin/serve.mjs",
35
- "c64-headless": "bin/headless.mjs"
35
+ "c64-headless": "bin/headless.mjs",
36
+ "c64-admin": "bin/admin.mjs"
36
37
  },
37
38
  "exports": {
38
39
  ".": {
@@ -54,6 +55,7 @@
54
55
  "./wasm": "./public/c64.wasm"
55
56
  },
56
57
  "files": [
58
+ "LICENSE",
57
59
  "bin/",
58
60
  "src/",
59
61
  "dist/",
@@ -70,6 +72,7 @@
70
72
  "@types/gif.js": "^0.2.5",
71
73
  "@types/marked": "^5.0.2",
72
74
  "@types/node": "^25.5.0",
75
+ "@types/ws": "^8.18.1",
73
76
  "eslint": "^10.1.0",
74
77
  "eslint-config-prettier": "^10.1.8",
75
78
  "eslint-plugin-prettier": "^5.5.5",
@@ -83,6 +86,7 @@
83
86
  "vitest": "^3.2.4"
84
87
  },
85
88
  "dependencies": {
89
+ "@roamhq/wrtc": "^0.10.0",
86
90
  "dompurify": "^3.0.5",
87
91
  "marked": "^5.0.2",
88
92
  "ws": "^8.20.0"
@@ -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
  // ---------------------------------------------------------------------------
@@ -0,0 +1,210 @@
1
+ /**
2
+ * crt-info.ts
3
+ *
4
+ * Lightweight parser for the CRT cartridge file format.
5
+ * Returns a human-readable summary line and structured metadata.
6
+ *
7
+ * Reference: https://vice-emu.sourceforge.io/vice_17.html#SEC380
8
+ *
9
+ * CRT header layout (all multi-byte fields are big-endian):
10
+ * 0x00 16 bytes Signature: "C64 CARTRIDGE "
11
+ * 0x10 4 bytes Header length (usually 0x40)
12
+ * 0x14 2 bytes CRT version
13
+ * 0x16 2 bytes Hardware type (cart type ID)
14
+ * 0x18 1 byte EXROM line status
15
+ * 0x19 1 byte GAME line status
16
+ * 0x1A 6 bytes Reserved
17
+ * 0x20 32 bytes Cart name (null-terminated ASCII)
18
+ * <headerLen>+ CHIP packets
19
+ *
20
+ * CHIP packet layout:
21
+ * 0x00 4 bytes Signature: "CHIP"
22
+ * 0x04 4 bytes Total packet length (including this header)
23
+ * 0x08 2 bytes Chip type (0=ROM, 1=RAM, 2=Flash)
24
+ * 0x0A 2 bytes Bank number
25
+ * 0x0C 2 bytes Load address
26
+ * 0x0E 2 bytes Data size (bytes)
27
+ * 0x10 N bytes Data
28
+ */
29
+
30
+ /** Subset of well-known hardware type names (matches VICE source). */
31
+ export const CRT_HW_TYPES: Record<number, string> = {
32
+ 0: 'Normal cartridge',
33
+ 1: 'Action Replay',
34
+ 2: 'KCS Power Cartridge',
35
+ 3: 'Final Cartridge III',
36
+ 4: 'Simons BASIC',
37
+ 5: 'Ocean type 1',
38
+ 6: 'Expert Cartridge',
39
+ 7: 'Fun Play, Power Play',
40
+ 8: 'Super Games',
41
+ 9: 'Atomic Power',
42
+ 10: 'Epyx Fastload',
43
+ 11: 'Westermann Learning',
44
+ 12: 'Rex Utility',
45
+ 13: 'Final Cartridge I',
46
+ 14: 'Magic Formel',
47
+ 15: 'C64 Game System (SYSTEM 3)',
48
+ 16: 'Warp Speed',
49
+ 17: 'Dinamic',
50
+ 18: 'Zaxxon / Super Zaxxon (SEGA)',
51
+ 19: 'Magic Desk / Domark / HES Australia',
52
+ 20: 'Super Snapshot V5',
53
+ 21: 'Comal-80',
54
+ 22: 'Structured BASIC',
55
+ 23: 'Ross',
56
+ 24: 'Dela EP64',
57
+ 25: 'Dela EP7x8',
58
+ 26: 'Dela EP256',
59
+ 27: 'Rex EP256',
60
+ 28: 'Mikro Assembler',
61
+ 29: 'Final Cartridge Plus',
62
+ 30: 'Action Replay 4',
63
+ 31: 'Stardos',
64
+ 32: 'EasyFlash',
65
+ 33: 'EasyFlash Xbank',
66
+ 34: 'Capture',
67
+ 35: 'Action Replay 3',
68
+ 36: 'Retro Replay',
69
+ 37: 'MMC64',
70
+ 38: 'MMC Replay',
71
+ 39: 'IDE64',
72
+ 40: 'Super Snapshot V4',
73
+ 41: 'IEEE-488',
74
+ 42: 'Game Killer',
75
+ 43: 'Prophet64',
76
+ 44: 'EXOS',
77
+ 45: 'Freeze Frame',
78
+ 46: 'Freeze Machine',
79
+ 47: 'Snapshot64',
80
+ 48: 'Super Explode V5.0',
81
+ 49: 'Magic Voice',
82
+ 50: 'Action Replay 2',
83
+ 51: 'MACH 5',
84
+ 52: 'Diashow-Maker',
85
+ 53: 'Pagefox',
86
+ 54: 'Kingsoft',
87
+ 55: 'Silverrock 128K Longshot',
88
+ 56: 'Formel 64',
89
+ 57: 'RGCD',
90
+ 58: 'RR-Net MK3',
91
+ 59: 'Easy Calc',
92
+ 60: 'GMod2',
93
+ 61: 'MAX Basic',
94
+ 62: 'GMod3',
95
+ 63: 'ZIPP-CODE 48',
96
+ 64: 'Blackbox V8',
97
+ 65: 'Blackbox V3',
98
+ 66: 'Blackbox V4',
99
+ 67: 'REX RAM-Floppy',
100
+ 68: 'BIS-Plus',
101
+ 69: 'SD-BOX',
102
+ 70: 'MultiMAX',
103
+ 71: 'Blackbox V9',
104
+ 72: 'Lt. Kernal Host Adaptor',
105
+ 73: 'RAMLink',
106
+ 74: 'H.E.R.O.',
107
+ 75: 'IEEE Flash! 64',
108
+ 76: 'Turtle Graphics II',
109
+ 77: 'Freeze Frame MK2',
110
+ 78: 'Partner 64',
111
+ };
112
+
113
+ export interface CrtInfo {
114
+ /** Full human-readable log line, ready to pass to console.log/error. */
115
+ line: string;
116
+ /** Numeric hardware type ID from the CRT header. */
117
+ hwType: number;
118
+ /** Human-readable hardware type name. */
119
+ hwName: string;
120
+ /** EXROM line value (0 or 1). */
121
+ exrom: number;
122
+ /** GAME line value (0 or 1). */
123
+ game: number;
124
+ /** Bank configuration derived from EXROM/GAME bits. */
125
+ bankConfig: string;
126
+ /** Cart name string from the header (may be empty). */
127
+ cartName: string;
128
+ /** Number of CHIP packets found. */
129
+ chipCount: number;
130
+ /** Total ROM data bytes across all CHIP packets. */
131
+ totalRomBytes: number;
132
+ }
133
+
134
+ function readU32BE(buf: Uint8Array, offset: number): number {
135
+ return (((buf[offset] << 24) | (buf[offset + 1] << 16) | (buf[offset + 2] << 8) | buf[offset + 3]) >>> 0);
136
+ }
137
+
138
+ function readU16BE(buf: Uint8Array, offset: number): number {
139
+ return (((buf[offset] << 8) | buf[offset + 1]) >>> 0);
140
+ }
141
+
142
+ /**
143
+ * Parse a CRT file and return a human-readable summary plus structured metadata.
144
+ *
145
+ * @param data Raw CRT bytes.
146
+ * @param filename Optional filename shown in the log prefix (e.g. "game.crt").
147
+ * @returns `null` if the data is too short or the magic bytes are absent.
148
+ */
149
+ export function parseCrtInfo(data: Uint8Array, filename?: string): CrtInfo | null {
150
+ // Need at least 0x40 bytes for the full CRT header
151
+ if (!data || data.length < 0x40) return null;
152
+
153
+ // Validate magic "C64 CARTRIDGE"
154
+ const magic = String.fromCharCode(...Array.from(data.slice(0, 16)));
155
+ if (!magic.startsWith('C64 CARTRIDGE')) return null;
156
+
157
+ const headerLen = readU32BE(data, 0x10); // typically 0x40
158
+ const hwType = readU16BE(data, 0x16);
159
+ const exrom = data[0x18];
160
+ const game = data[0x19];
161
+
162
+ // Cart name: null-terminated ASCII at 0x20, up to 32 bytes
163
+ let cartName = '';
164
+ for (let i = 0x20; i < 0x40 && data[i] !== 0; i++) {
165
+ cartName += String.fromCharCode(data[i]);
166
+ }
167
+ cartName = cartName.trim();
168
+
169
+ // Bank config from EXROM/GAME bits (mirrors VICE behaviour)
170
+ // exrom=0 game=0 → 16K (ROML+ROMH)
171
+ // exrom=0 game=1 → 8K (ROML only)
172
+ // exrom=1 game=0 → Ultimax
173
+ // exrom=1 game=1 → inactive (pass-through)
174
+ let bankConfig: string;
175
+ if (exrom === 0 && game === 0) bankConfig = '16K (ROML+ROMH)';
176
+ else if (exrom === 0 && game === 1) bankConfig = '8K (ROML only)';
177
+ else if (exrom === 1 && game === 0) bankConfig = 'Ultimax';
178
+ else bankConfig = 'inactive (pass-through)';
179
+
180
+ // Walk CHIP packets to count them and sum up actual ROM data bytes
181
+ let chipCount = 0;
182
+ let totalRomBytes = 0;
183
+ let offset = Math.max(headerLen, 0x40);
184
+
185
+ while (offset + 16 <= data.length) {
186
+ const chipMagic = String.fromCharCode(...Array.from(data.slice(offset, offset + 4)));
187
+ if (chipMagic !== 'CHIP') break;
188
+
189
+ const packetLen = readU32BE(data, offset + 4);
190
+ if (packetLen < 16) break; // malformed packet
191
+
192
+ const dataSize = readU16BE(data, offset + 0x0E);
193
+ chipCount++;
194
+ totalRomBytes += dataSize;
195
+ offset += packetLen;
196
+ }
197
+
198
+ const hwName = CRT_HW_TYPES[hwType] ?? `Unknown(${hwType})`;
199
+ const fileLabel = filename ? ` "${filename}"` : '';
200
+ const namePart = cartName ? ` name="${cartName}"` : '';
201
+ const kbActual = (totalRomBytes / 1024).toFixed(0);
202
+
203
+ const line =
204
+ `[C64 cart]${fileLabel} loading: hwType=${hwType}(${hwName})` +
205
+ ` | ${bankConfig} flags, ${kbActual}K actual` +
206
+ ` | ${chipCount} CHIP(s) | ${data.length} bytes${namePart}`;
207
+
208
+ return { line, hwType, hwName, exrom, game, bankConfig, cartName, chipCount, totalRomBytes };
209
+ }
210
+