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
@@ -11,6 +11,13 @@ const CONTROLS = [
11
11
 
12
12
  import type { C64Player } from './c64-player';
13
13
  import type { JoystickPort } from '../emulator/constants';
14
+ import {
15
+ LOAD_FORMAT_OPTIONS,
16
+ getAcceptForLoadTypeSelection,
17
+ getLoadTypeLabel,
18
+ resolveLoadTypeSelection,
19
+ type LoadTypeSelection,
20
+ } from './load-formats';
14
21
 
15
22
  export default class UIController {
16
23
  private helpOverlay: HTMLElement | null = null;
@@ -149,6 +156,18 @@ export default class UIController {
149
156
  if (e.target === overlay) this.closeMenu();
150
157
  });
151
158
 
159
+ const sections = [
160
+ { id: 'load', label: 'Load' },
161
+ { id: 'input', label: 'Input' },
162
+ { id: 'display', label: 'Display' },
163
+ { id: 'audio', label: 'Audio' },
164
+ { id: 'system', label: 'System' },
165
+ ] as const;
166
+
167
+ const loadTypeOptions = LOAD_FORMAT_OPTIONS.map(
168
+ (format) => `<option value="${format.type}">${format.label}</option>`,
169
+ ).join('');
170
+
152
171
  const panel = document.createElement('div');
153
172
  panel.className = 'c64-menu-panel';
154
173
  panel.innerHTML = `
@@ -157,40 +176,83 @@ export default class UIController {
157
176
  <button class="c64-menu-close">&times;</button>
158
177
  </div>
159
178
  <div class="c64-menu-body">
160
- <label style="font-size:13px;color:#aaa">Input</label>
161
- <div style="margin-top:8px; display:flex; gap:12px; align-items:center;">
162
- <label><input type="radio" name="c64-joy-port" value="1" /> Port 1</label>
163
- <label><input type="radio" name="c64-joy-port" value="2" checked /> Port 2</label>
164
- </div>
165
- <div style="height:8px"></div>
166
- <label style="font-size:13px;color:#aaa">Display</label>
167
- <div style="margin-top:8px; display:flex; gap:12px; align-items:center;">
168
- <label><input type="radio" name="c64-display-mode" value="standard" checked /> Standard</label>
169
- <label><input type="radio" name="c64-display-mode" value="full" /> Full</label>
170
- <label><input type="radio" name="c64-display-mode" value="stretch" /> Stretch</label>
171
- </div>
172
- <div style="height:8px"></div>
173
- <label style="font-size:13px;color:#aaa">Load cartridge (.crt)</label>
174
- <div class="c64-dragarea" id="c64-dragarea">Drop a .crt file here or <button class="c64-btn" id="c64-browse">Browse</button></div>
175
- <input class="c64-file-input" id="c64-file-input" type="file" accept=".crt" />
176
- <div class="c64-cart-preview" id="c64-cart-preview" style="display:none">
177
- <div class="c64-cart-icon" id="c64-cart-icon" aria-hidden="true">
178
- <!-- simple C64 cart SVG -->
179
- <svg width="48" height="32" viewBox="0 0 48 32" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="4" width="44" height="24" rx="3" fill="#222" stroke="#555"/><rect x="6" y="8" width="36" height="12" fill="#2b2b3d"/></svg>
180
- </div>
181
- <div class="c64-cart-filename" id="c64-cart-filename"></div>
182
- </div>
183
- <div class="c64-menu-actions">
184
- <div>
185
- <button class="c64-btn" id="c64-load-btn">Load</button>
186
- <button class="c64-btn" id="c64-close-menu">Close</button>
187
- </div>
188
- <div style="margin-top:12px; display:flex; gap:8px;">
189
- <button class="c64-btn" id="c64-detach-btn">Detach Cartridge</button>
190
- <button class="c64-btn" id="c64-reset-btn">Hard Reset</button>
191
- </div>
179
+ <div class="c64-settings-tabs" role="tablist" aria-label="Settings sections">
180
+ ${sections
181
+ .map(
182
+ (section, i) =>
183
+ `<button class="c64-settings-tab${i === 0 ? ' active' : ''}" data-settings-tab="${section.id}" role="tab" aria-selected="${
184
+ i === 0 ? 'true' : 'false'
185
+ }">${section.label}</button>`,
186
+ )
187
+ .join('')}
192
188
  </div>
193
189
 
190
+ <div class="c64-settings-sections">
191
+ <section class="c64-settings-section" data-settings-section="load">
192
+ <label class="c64-section-label">Load Game</label>
193
+ <div class="c64-form-row">
194
+ <label for="c64-load-format">Format</label>
195
+ <select id="c64-load-format" class="c64-select">
196
+ <option value="auto">Auto detect (recommended)</option>
197
+ ${loadTypeOptions}
198
+ </select>
199
+ </div>
200
+ <div class="c64-dragarea" id="c64-dragarea">
201
+ <span id="c64-dragarea-copy">Drop a game file here or</span>
202
+ <button class="c64-btn" id="c64-browse">Browse</button>
203
+ </div>
204
+ <input class="c64-file-input" id="c64-file-input" type="file" />
205
+ <div class="c64-cart-preview" id="c64-cart-preview" hidden>
206
+ <div class="c64-cart-icon" id="c64-cart-icon" aria-hidden="true">
207
+ <svg width="48" height="32" viewBox="0 0 48 32" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="4" width="44" height="24" rx="3" fill="#222" stroke="#555"/><rect x="6" y="8" width="36" height="12" fill="#2b2b3d"/></svg>
208
+ </div>
209
+ <div>
210
+ <div class="c64-cart-filename" id="c64-cart-filename"></div>
211
+ <div class="c64-cart-type" id="c64-cart-type"></div>
212
+ </div>
213
+ </div>
214
+ <div class="c64-menu-actions">
215
+ <button class="c64-btn" id="c64-load-btn">Load</button>
216
+ <button class="c64-btn" id="c64-close-menu">Close</button>
217
+ </div>
218
+ </section>
219
+
220
+ <section class="c64-settings-section" data-settings-section="input" hidden>
221
+ <label class="c64-section-label">Input Port</label>
222
+ <div class="c64-radio-row">
223
+ <label><input type="radio" name="c64-joy-port" value="1" /> Port 1</label>
224
+ <label><input type="radio" name="c64-joy-port" value="2" checked /> Port 2</label>
225
+ </div>
226
+ <label class="c64-section-label">Input Mode</label>
227
+ <div class="c64-radio-row c64-radio-row-wrap">
228
+ <label><input type="radio" name="c64-input-mode" value="joystick" checked /> Joystick</label>
229
+ <label><input type="radio" name="c64-input-mode" value="keyboard" /> Keyboard</label>
230
+ <label><input type="radio" name="c64-input-mode" value="mixed" /> Mixed</label>
231
+ </div>
232
+ <div id="c64-input-mode-hint" class="c64-section-hint">Arrows + Ctrl = joystick</div>
233
+ </section>
234
+
235
+ <section class="c64-settings-section" data-settings-section="display" hidden>
236
+ <label class="c64-section-label">Display Mode</label>
237
+ <div class="c64-radio-row">
238
+ <label><input type="radio" name="c64-display-mode" value="standard" checked /> Standard</label>
239
+ <label><input type="radio" name="c64-display-mode" value="full" /> Full</label>
240
+ <label><input type="radio" name="c64-display-mode" value="stretch" /> Stretch</label>
241
+ </div>
242
+ </section>
243
+
244
+ <section class="c64-settings-section" data-settings-section="audio" hidden>
245
+ <div id="c64-audio-section-anchor"></div>
246
+ </section>
247
+
248
+ <section class="c64-settings-section" data-settings-section="system" hidden>
249
+ <label class="c64-section-label">System Actions</label>
250
+ <div class="c64-system-actions">
251
+ <button class="c64-btn" id="c64-detach-btn">Detach Cartridge</button>
252
+ <button class="c64-btn" id="c64-reset-btn">Hard Reset</button>
253
+ </div>
254
+ </section>
255
+ </div>
194
256
  </div>
195
257
  `;
196
258
 
@@ -202,18 +264,59 @@ export default class UIController {
202
264
  // The settings overlay is the overlay we just created
203
265
  this.settingsOverlay = overlay;
204
266
 
267
+ const tabButtons = panel.querySelectorAll('[data-settings-tab]') as NodeListOf<HTMLButtonElement>;
268
+ const sectionEls = panel.querySelectorAll(
269
+ '[data-settings-section]'
270
+ ) as NodeListOf<HTMLElement>;
271
+
272
+ const activateSection = (sectionId: string) => {
273
+ tabButtons.forEach((tab) => {
274
+ const active = tab.dataset.settingsTab === sectionId;
275
+ tab.classList.toggle('active', active);
276
+ tab.setAttribute('aria-selected', active ? 'true' : 'false');
277
+ });
278
+ sectionEls.forEach((section) => {
279
+ section.hidden = section.dataset.settingsSection !== sectionId;
280
+ });
281
+ };
282
+
283
+ tabButtons.forEach((tab) => {
284
+ tab.addEventListener('click', () => {
285
+ const sectionId = tab.dataset.settingsTab;
286
+ if (sectionId) activateSection(sectionId);
287
+ });
288
+ });
289
+
205
290
  // wire up file input and drag/drop
206
291
  this.fileInput = panel.querySelector('#c64-file-input') as HTMLInputElement;
207
292
  const dragarea = panel.querySelector('#c64-dragarea') as HTMLElement;
293
+ const dragareaCopy = panel.querySelector('#c64-dragarea-copy') as HTMLElement;
208
294
  const browse = panel.querySelector('#c64-browse') as HTMLButtonElement;
295
+ const loadTypeSelect = panel.querySelector('#c64-load-format') as HTMLSelectElement;
209
296
  const preview = panel.querySelector('#c64-cart-preview') as HTMLElement;
210
297
  const previewName = panel.querySelector('#c64-cart-filename') as HTMLElement;
298
+ const previewType = panel.querySelector('#c64-cart-type') as HTMLElement;
299
+
300
+ const updateLoadChooser = () => {
301
+ const selection = (loadTypeSelect.value as LoadTypeSelection) ?? 'auto';
302
+ this.fileInput!.accept = getAcceptForLoadTypeSelection(selection);
303
+ if (selection === 'auto') {
304
+ dragareaCopy.textContent = 'Drop a game file here or';
305
+ } else {
306
+ dragareaCopy.textContent = `Drop a ${getLoadTypeLabel(selection)} file here or`;
307
+ }
308
+ };
309
+ updateLoadChooser();
310
+ loadTypeSelect.addEventListener('change', updateLoadChooser);
211
311
 
212
312
  const handleFile = (file: File) => {
213
- preview.style.display = 'flex';
313
+ const selection = (loadTypeSelect.value as LoadTypeSelection) ?? 'auto';
314
+ const loadType = resolveLoadTypeSelection(selection, file.name);
315
+ preview.hidden = false;
214
316
  previewName.textContent = file.name;
317
+ previewType.textContent = getLoadTypeLabel(loadType);
215
318
  // dispatch event for main code to pick up
216
- const ev = new CustomEvent('c64-load-file', { detail: { file } });
319
+ const ev = new CustomEvent('c64-load-file', { detail: { file, type: loadType } });
217
320
  window.dispatchEvent(ev);
218
321
  };
219
322
 
@@ -244,7 +347,7 @@ export default class UIController {
244
347
  else this.fileInput?.click();
245
348
  });
246
349
 
247
- const section = document.querySelector('.c64-menu-actions');
350
+ const section = panel.querySelector('[data-settings-section="system"]');
248
351
  // Detach cartridge / hard reset controls
249
352
  const detachBtn = section?.querySelector('#c64-detach-btn') as HTMLButtonElement | null;
250
353
  const resetBtn = section?.querySelector('#c64-reset-btn') as HTMLButtonElement | null;
@@ -273,7 +376,8 @@ export default class UIController {
273
376
  }
274
377
 
275
378
  // ── Audio section ─────────────────────────────────────────────────────
276
- this.createAudioSection(panel.querySelector('.c64-menu-body')!);
379
+ const audioContainer = panel.querySelector('#c64-audio-section-anchor') as HTMLElement;
380
+ this.createAudioSection(audioContainer);
277
381
 
278
382
  // ── Input section wiring ───────────────────────────────────────────────
279
383
  const joyRadios = panel.querySelectorAll(
@@ -297,6 +401,33 @@ export default class UIController {
297
401
  });
298
402
  });
299
403
 
404
+ // ── Input mode wiring ──────────────────────────────────────────────────
405
+ const inputModeHints: Record<string, string> = {
406
+ joystick: 'Arrows + Ctrl = joystick only',
407
+ keyboard: 'All keys &rarr; C64 keyboard matrix',
408
+ mixed: 'Arrows + Z + Ctrl = joystick &amp; all other keys &rarr; C64 keyboard',
409
+ };
410
+ const inputModeRadios = panel.querySelectorAll(
411
+ 'input[name="c64-input-mode"]',
412
+ ) as NodeListOf<HTMLInputElement>;
413
+ const hintEl = panel.querySelector('#c64-input-mode-hint') as HTMLElement | null;
414
+ const applyInputMode = (mode: string) => {
415
+ if (hintEl) hintEl.innerHTML = inputModeHints[mode] ?? '';
416
+ window.dispatchEvent(new CustomEvent('c64-set-input-mode', { detail: { mode } }));
417
+ if (this.player && typeof this.player.setInputMode === 'function') {
418
+ try {
419
+ this.player.setInputMode(mode as import('../emulator/input').InputMode);
420
+ } catch {
421
+ // ignore
422
+ }
423
+ }
424
+ };
425
+ inputModeRadios.forEach((r) => {
426
+ r.addEventListener('change', () => {
427
+ if (r.checked) applyInputMode(r.value);
428
+ });
429
+ });
430
+
300
431
  // ── Display section wiring ─────────────────────────────────────────────
301
432
  const displayRadios = panel.querySelectorAll(
302
433
  'input[name="c64-display-mode"]',
@@ -51,7 +51,7 @@ export interface WASMExports {
51
51
  c64_insertDisk(ptr: number, len: number): void;
52
52
 
53
53
  // Loading
54
- c64_loadPRG(ptr: number, len: number): void;
54
+ c64_loadPRG(ptr: number, len: number, inject?: number): void;
55
55
  c64_loadCartridge(ptr: number, len: number): void;
56
56
  c64_removeCartridge(): void;
57
57
 
@@ -81,6 +81,7 @@ export interface WASMExports {
81
81
  c64_setRegX(v: number): void;
82
82
  c64_setRegY(v: number): void;
83
83
  c64_setRegA(v: number): void;
84
+ c64_setSP?(v: number): void;
84
85
  c64_getCycleCount(): number;
85
86
 
86
87
  // CPU flags
@@ -1,96 +0,0 @@
1
- var e=`# Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- ## Unreleased
6
-
7
- No unreleased changes.
8
-
9
- ## v0.5.0 - 2026-03-23T09:12:04+00:00
10
-
11
- - chore: fix typings and UI controller behavior for joystick/display settings (e843785)
12
- - Merge remote-tracking branch 'origin/master' (2f5150f)
13
- - chore(release): 0.5.0 (1c67934)
14
- - chore: update changelog (auto) [skip ci] (07c46ba)
15
- - Merge pull request #18 from hayesmaker/feature/more-ui-controller-settings (7557af9)
16
- - chore: fix lints (45d0b3d)
17
- - feat: simple input and display settings (c5e60b1)
18
- - chore(styles): extract inline CSS to module styles/ and import as raw (74f1d41)
19
-
20
- ## v0.4.0 - 2026-03-22T23:27:35+00:00
21
-
22
- - chore(release): 0.4.0 (ccff6b7)
23
- - Merge pull request #17 from hayesmaker/feature/headless-cli-runner (7bcd326)
24
- - Merge branch 'master' into feature/headless-cli-runner (561a02b)
25
- - chore: stop auto generated changelogs prs (a9822ca)
26
- - chore: update changelog (auto) [skip ci] (0fefa3d)
27
- - chore: update changelog (auto) [skip ci] (8a8668f)
28
- - chore: update changelog (auto) [skip ci] (75373a5)
29
- - chore: update changelog (auto) [skip ci] (a87a12a)
30
- - Merge pull request #15 from hayesmaker/feature/headless-cli-runner (1b0b510)
31
- - chore(release): generate changelog inside release commit; add --local to generator (d5687a3)
32
- - Merge pull request #13 from hayesmaker/chore/update-changelog-2026-03-22T23-05-37-281Z-a1ccae7 (8f20c94)
33
- - chore: update changelog (auto) [skip ci] (a1ccae7)
34
- - Merge pull request #10 from hayesmaker/chore/update-changelog-2026-03-22T23-04-34-067Z-ae4bc22 (7365710)
35
- - Merge pull request #11 from hayesmaker/feature/headless-cli-runner (78df809)
36
- - chore: update changelog (auto) [skip ci] (ae4bc22)
37
- - Merge pull request #9 from hayesmaker/chore/update-changelog-2026-03-22T18-25-45-840Z-bdf7b14 (e6e66d4)
38
- - chore: release script enhancements (920a654)
39
- - chore: update changelog (auto) [skip ci] (bdf7b14)
40
- - Merge pull request #8 from hayesmaker/feature/headless-cli-runner (02ee198)
41
- - chore: docs re-org (2efa3c0)
42
- - chore(docs): keep CHANGELOG.md at repo root and update publish script (a2e1292)
43
- - chore(docs): remove docs/CHANGELOG.md (keep root CHANGELOG.md) (726a914)
44
- - chore(docs): move CHANGELOG.md back to repo root and restore generator output (27710f0)
45
- - chore(docs): move repo root markdown into docs/ and update imports/generator (a713e07)
46
- - chore(docs): add docs/ copies of repo root markdown and wiki publish helper (4089d45)
47
- - chore(tests): remove tests from src; canonical tests now under test/ (5aef5d6)
48
- - chore: remove duplicate cartridge in games/; use public/games as canonical asset (87bd78d)
49
- - chore(headless): prefer public/games for default cartridge; remove repo-level fallback (10b5c8f)
50
- - Merge pull request #6 from hayesmaker/chore/update-changelog-2026-03-21T15-22-06-743Z-5ae1fea (f887858)
51
- - chore: fix lints (7242ab0)
52
- - feat(headless): adds a headless c64 emulation mode (715f943)
53
- - feat(headless): headless runner first commit (acb9e7f)
54
- - chore: update changelog (auto) [skip ci] (5ae1fea)
55
-
56
- ## v0.3.0 - 2026-03-21T15:16:11+00:00
57
-
58
- - chore(release): 0.3.0 (40d518c)
59
- - feat: audio support (ee0f378)
60
- - chore: filter changelogs from frontend (3192369)
61
- - fix: changelog requests (8be31d6)
62
- - chore: update changelog (auto) [skip ci] (ac19ea9)
63
- - ci: trigger changelog workflow (node24) (0853680)
64
- - ci: use Node 24 in changelog workflow (02065db)
65
- - chore: fix changelog action (5675eda)
66
-
67
- ## v0.2.0 - 2026-03-21T13:25:25+00:00
68
-
69
- - chore(release): 0.2.0 (991d9e7)
70
- - chore: prepare release 0.2.0 (b31be4b)
71
- - feat: adds cart loading support (559d866)
72
- - chore: update changelog (auto) [skip ci] (9b1c57e)
73
- - chore: update changelog (auto) [skip ci] (6c44232)
74
- - chore: fix wiki (a6b1c9d)
75
- - chore: link to overview from home wiki (bd91242)
76
- - chore: attempt to fix wiki publish (30de988)
77
- - chore: push plan to wiki (36e9639)
78
- - chore: added wiki project overview (865c003)
79
- - chore: added prettier linting and cleanup of source (c2e2199)
80
- - chore: page link in banner (6cad53a)
81
- - feat: power led favicon (b8b4825)
82
- - chore: regenerated lockfile (fa871eb)
83
-
84
- ## v0.1.0 - 2026-03-20T23:42:38+00:00
85
-
86
- - build: bump version to 0.1.0 (ef6ee3f)
87
- - chore: ensure minimum node (2977a5e)
88
- - feat: added github pages deployment (c55c362)
89
- - chore: docs (2dff0bb)
90
- - c64 ready (8ff3291)
91
- - feat: c64-ready gif (eecdea5)
92
- - feat: render ticks and readme (696b107)
93
- - feat: larger canvas view (d1d8856)
94
- - feat: working proof of concept initial commit (89e9a6e)
95
-
96
- `;export{e as default};