c64-ready 1.0.1 → 1.1.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/README.md +70 -62
- package/bin/headless.mjs +1 -1
- package/dist/assets/CHANGELOG-0a7A8Ekq.js +391 -0
- package/dist/assets/index-BESofQoh.js +627 -0
- package/dist/games/cartridges/goat-beat.crt +0 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/public/games/cartridges/goat-beat.crt +0 -0
- package/src/emulator/c64-emulator.ts +3 -5
- package/src/emulator/input.ts +239 -19
- package/src/headless/headless-cli.mjs +73 -37
- package/src/headless/input-server.mjs +276 -102
- package/src/headless/webrtc-server.mjs +51 -5
- package/src/main.ts +12 -0
- package/src/player/c64-player.ts +21 -6
- package/src/player/input-handler.ts +8 -0
- package/src/player/styles/ui-controller.css +13 -0
- package/src/player/ui-controller.ts +128 -12
- package/src/types/emulator.ts +1 -1
- package/dist/assets/CHANGELOG-B12WeYEc.js +0 -116
- package/dist/assets/index-fUdEY2R7.js +0 -610
|
@@ -358,6 +358,7 @@
|
|
|
358
358
|
}
|
|
359
359
|
.c64-radio-row {
|
|
360
360
|
margin-top: 8px;
|
|
361
|
+
margin-bottom: 16px;
|
|
361
362
|
display: flex;
|
|
362
363
|
gap: 12px;
|
|
363
364
|
align-items: center;
|
|
@@ -371,6 +372,18 @@
|
|
|
371
372
|
color: #888;
|
|
372
373
|
line-height: 1.4;
|
|
373
374
|
}
|
|
375
|
+
.c64-gamepad-list {
|
|
376
|
+
margin-top: 8px;
|
|
377
|
+
margin-bottom: 8px;
|
|
378
|
+
display: flex;
|
|
379
|
+
flex-wrap: wrap;
|
|
380
|
+
gap: 8px;
|
|
381
|
+
}
|
|
382
|
+
.c64-gamepad-btn.active {
|
|
383
|
+
background: #7b71d5;
|
|
384
|
+
border-color: #948bff;
|
|
385
|
+
color: #fff;
|
|
386
|
+
}
|
|
374
387
|
.c64-dragarea {
|
|
375
388
|
border: 2px dashed #2a2a3e;
|
|
376
389
|
border-radius: 6px;
|
|
@@ -39,6 +39,16 @@ import {
|
|
|
39
39
|
|
|
40
40
|
const CRT_PRELOAD_CHECKS_STORAGE_KEY = 'c64-disable-crt-preload-checks';
|
|
41
41
|
|
|
42
|
+
type ConnectedGamepad = {
|
|
43
|
+
index: number;
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function formatSnapshotFilename(now: Date = new Date()): string {
|
|
48
|
+
const pad = (value: number): string => String(value).padStart(2, '0');
|
|
49
|
+
return `snapshot-${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}.c64`;
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
export default class UIController {
|
|
43
53
|
private helpOverlay: HTMLElement | null = null;
|
|
44
54
|
private settingsOverlay: HTMLElement | null = null;
|
|
@@ -47,15 +57,98 @@ export default class UIController {
|
|
|
47
57
|
// Save previous overflow styles so we can restore them when exiting full/stretch
|
|
48
58
|
private savedHtmlOverflow: string | null = null;
|
|
49
59
|
private savedBodyOverflow: string | null = null;
|
|
60
|
+
private connectedGamepads = new Map<number, ConnectedGamepad>();
|
|
61
|
+
private readonly handleControllerConnected = (event: Event): void => {
|
|
62
|
+
const detail = (event as CustomEvent<{ name?: string; index?: number }>).detail;
|
|
63
|
+
if (typeof detail?.index !== 'number') return;
|
|
64
|
+
this.connectedGamepads.set(detail.index, {
|
|
65
|
+
index: detail.index,
|
|
66
|
+
name: detail.name ?? `Gamepad ${detail.index}`,
|
|
67
|
+
});
|
|
68
|
+
this.renderGamepadButtons();
|
|
69
|
+
};
|
|
70
|
+
private readonly handleControllerDisconnected = (event: Event): void => {
|
|
71
|
+
const detail = (event as CustomEvent<{ index?: number }>).detail;
|
|
72
|
+
if (typeof detail?.index !== 'number') return;
|
|
73
|
+
this.connectedGamepads.delete(detail.index);
|
|
74
|
+
this.renderGamepadButtons();
|
|
75
|
+
};
|
|
50
76
|
|
|
51
77
|
init(player?: C64Player): void {
|
|
52
78
|
this.player = player ?? null;
|
|
79
|
+
this.syncConnectedGamepads();
|
|
53
80
|
this.injectCSS();
|
|
54
81
|
this.createButton();
|
|
55
82
|
this.createDialog();
|
|
56
83
|
this.createHamburger();
|
|
57
84
|
this.createMenu();
|
|
58
85
|
this.createUnmuteButton();
|
|
86
|
+
window.addEventListener('c64-controller-connected', this.handleControllerConnected);
|
|
87
|
+
window.addEventListener('c64-controller-disconnected', this.handleControllerDisconnected);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private syncConnectedGamepads(): void {
|
|
91
|
+
this.connectedGamepads.clear();
|
|
92
|
+
const gamepads = navigator.getGamepads?.() ?? [];
|
|
93
|
+
for (const gamepad of gamepads) {
|
|
94
|
+
if (!gamepad) continue;
|
|
95
|
+
this.connectedGamepads.set(gamepad.index, {
|
|
96
|
+
index: gamepad.index,
|
|
97
|
+
name: gamepad.id,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private getConnectedGamepads(): ConnectedGamepad[] {
|
|
103
|
+
return Array.from(this.connectedGamepads.values()).sort((a, b) => a.index - b.index);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private getGamepadLabel(gamepad: ConnectedGamepad): string {
|
|
107
|
+
const shortenedName = gamepad.name.replace(/\s*\([^)]*\)\s*$/u, '').trim();
|
|
108
|
+
const name = shortenedName || gamepad.name.trim() || `Gamepad ${gamepad.index}`;
|
|
109
|
+
return `${gamepad.index}: ${name}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private renderGamepadButtons(): void {
|
|
113
|
+
const container = document.getElementById('c64-gamepad-list');
|
|
114
|
+
const emptyState = document.getElementById('c64-gamepad-empty');
|
|
115
|
+
if (!container || !emptyState) return;
|
|
116
|
+
|
|
117
|
+
const gamepads = this.getConnectedGamepads();
|
|
118
|
+
const activeIndex = this.player?.getActiveGamepadIndex() ?? -1;
|
|
119
|
+
|
|
120
|
+
container.replaceChildren(
|
|
121
|
+
...gamepads.map((gamepad) => {
|
|
122
|
+
const button = document.createElement('button');
|
|
123
|
+
const active = gamepad.index === activeIndex;
|
|
124
|
+
button.type = 'button';
|
|
125
|
+
button.className = `c64-btn c64-gamepad-btn${active ? ' active' : ''}`;
|
|
126
|
+
button.textContent = this.getGamepadLabel(gamepad);
|
|
127
|
+
button.setAttribute('aria-pressed', active ? 'true' : 'false');
|
|
128
|
+
button.addEventListener('click', () => {
|
|
129
|
+
if (!this.player) return;
|
|
130
|
+
this.player.setActiveGamepadIndex(gamepad.index);
|
|
131
|
+
this.renderGamepadButtons();
|
|
132
|
+
});
|
|
133
|
+
return button;
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
emptyState.hidden = gamepads.length > 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private downloadSnapshot(snapshot: Uint8Array): void {
|
|
141
|
+
const snapshotCopy = new Uint8Array(snapshot.byteLength);
|
|
142
|
+
snapshotCopy.set(snapshot);
|
|
143
|
+
const blob = new Blob([snapshotCopy], { type: 'application/bin' });
|
|
144
|
+
const url = URL.createObjectURL(blob);
|
|
145
|
+
const link = document.createElement('a');
|
|
146
|
+
link.href = url;
|
|
147
|
+
link.download = formatSnapshotFilename();
|
|
148
|
+
document.body.appendChild(link);
|
|
149
|
+
link.click();
|
|
150
|
+
link.remove();
|
|
151
|
+
URL.revokeObjectURL(url);
|
|
59
152
|
}
|
|
60
153
|
|
|
61
154
|
private injectCSS(): void {
|
|
@@ -204,13 +297,13 @@ export default class UIController {
|
|
|
204
297
|
<div class="c64-menu-body">
|
|
205
298
|
<div class="c64-settings-tabs" role="tablist" aria-label="Settings sections">
|
|
206
299
|
${sections
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
300
|
+
.map(
|
|
301
|
+
(section, i) =>
|
|
302
|
+
`<button class="c64-settings-tab${i === 0 ? ' active' : ''}" data-settings-tab="${section.id}" role="tab" aria-selected="${
|
|
303
|
+
i === 0 ? 'true' : 'false'
|
|
304
|
+
}">${section.label}</button>`,
|
|
305
|
+
)
|
|
306
|
+
.join('')}
|
|
214
307
|
</div>
|
|
215
308
|
|
|
216
309
|
<div class="c64-settings-sections">
|
|
@@ -266,6 +359,9 @@ export default class UIController {
|
|
|
266
359
|
<label><input type="radio" name="c64-input-mode" value="mixed" checked /> Mixed</label>
|
|
267
360
|
</div>
|
|
268
361
|
<div id="c64-input-mode-hint" class="c64-section-hint">Arrows + Z + Ctrl = joystick & all other keys → C64 keyboard</div>
|
|
362
|
+
<label class="c64-section-label">Gamepads</label>
|
|
363
|
+
<div id="c64-gamepad-list" class="c64-gamepad-list"></div>
|
|
364
|
+
<div id="c64-gamepad-empty" class="c64-section-hint">To use a gamepad, connect it to your computer and press any button.</div>
|
|
269
365
|
</section>
|
|
270
366
|
|
|
271
367
|
<section class="c64-settings-section" data-settings-section="display" hidden>
|
|
@@ -284,6 +380,7 @@ export default class UIController {
|
|
|
284
380
|
<section class="c64-settings-section" data-settings-section="system" hidden>
|
|
285
381
|
<label class="c64-section-label">System Actions</label>
|
|
286
382
|
<div class="c64-system-actions">
|
|
383
|
+
<button class="c64-btn" id="c64-save-snapshot-btn">Save Snapshot</button>
|
|
287
384
|
<button class="c64-btn" id="c64-detach-btn">Detach Cartridge</button>
|
|
288
385
|
<button class="c64-btn" id="c64-reset-btn">Hard Reset</button>
|
|
289
386
|
<button class="c64-btn" id="c64-reboot-btn">Reboot Emulator</button>
|
|
@@ -313,18 +410,18 @@ export default class UIController {
|
|
|
313
410
|
|
|
314
411
|
const activateSection = (sectionId: string) => {
|
|
315
412
|
tabButtons.forEach((tab) => {
|
|
316
|
-
const active = tab.
|
|
413
|
+
const active = tab.getAttribute('data-settings-tab') === sectionId;
|
|
317
414
|
tab.classList.toggle('active', active);
|
|
318
415
|
tab.setAttribute('aria-selected', active ? 'true' : 'false');
|
|
319
416
|
});
|
|
320
417
|
sectionEls.forEach((section) => {
|
|
321
|
-
section.hidden = section.
|
|
418
|
+
section.hidden = section.getAttribute('data-settings-section') !== sectionId;
|
|
322
419
|
});
|
|
323
420
|
};
|
|
324
421
|
|
|
325
422
|
tabButtons.forEach((tab) => {
|
|
326
423
|
tab.addEventListener('click', () => {
|
|
327
|
-
const sectionId = tab.
|
|
424
|
+
const sectionId = tab.getAttribute('data-settings-tab');
|
|
328
425
|
if (sectionId) activateSection(sectionId);
|
|
329
426
|
});
|
|
330
427
|
});
|
|
@@ -424,7 +521,7 @@ export default class UIController {
|
|
|
424
521
|
: [];
|
|
425
522
|
|
|
426
523
|
return entries
|
|
427
|
-
.map((entry) => {
|
|
524
|
+
.map((entry: unknown) => {
|
|
428
525
|
const path =
|
|
429
526
|
typeof entry === 'string'
|
|
430
527
|
? entry
|
|
@@ -446,7 +543,7 @@ export default class UIController {
|
|
|
446
543
|
);
|
|
447
544
|
return { name: filename, url, type } satisfies ToolItem;
|
|
448
545
|
})
|
|
449
|
-
.filter((v): v is ToolItem => !!v);
|
|
546
|
+
.filter((v: ToolItem | null): v is ToolItem => !!v);
|
|
450
547
|
};
|
|
451
548
|
|
|
452
549
|
const loadToolsManifest = async () => {
|
|
@@ -480,6 +577,7 @@ export default class UIController {
|
|
|
480
577
|
|
|
481
578
|
const section = panel.querySelector('[data-settings-section="system"]');
|
|
482
579
|
// Detach cartridge / hard reset controls
|
|
580
|
+
const saveSnapshotBtn = section?.querySelector('#c64-save-snapshot-btn') as HTMLButtonElement | null;
|
|
483
581
|
const detachBtn = section?.querySelector('#c64-detach-btn') as HTMLButtonElement | null;
|
|
484
582
|
const resetBtn = section?.querySelector('#c64-reset-btn') as HTMLButtonElement | null;
|
|
485
583
|
const rebootBtn = section?.querySelector('#c64-reboot-btn') as HTMLButtonElement | null;
|
|
@@ -498,6 +596,22 @@ export default class UIController {
|
|
|
498
596
|
this.player?.setCrtPreloadChecksDisabled(disabled);
|
|
499
597
|
});
|
|
500
598
|
}
|
|
599
|
+
if (saveSnapshotBtn) {
|
|
600
|
+
saveSnapshotBtn.addEventListener('click', () => {
|
|
601
|
+
if (!this.player || typeof this.player.getSnapshot !== 'function') return;
|
|
602
|
+
const statusEl = document.getElementById('status');
|
|
603
|
+
try {
|
|
604
|
+
this.downloadSnapshot(this.player.getSnapshot());
|
|
605
|
+
if (statusEl) {
|
|
606
|
+
statusEl.textContent = 'Snapshot saved';
|
|
607
|
+
}
|
|
608
|
+
} catch (err) {
|
|
609
|
+
if (statusEl) {
|
|
610
|
+
statusEl.textContent = `Snapshot save failed: ${String((err as Error)?.message ?? err)}`;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
501
615
|
if (detachBtn) {
|
|
502
616
|
detachBtn.addEventListener('click', () => {
|
|
503
617
|
if (!this.player) return;
|
|
@@ -595,6 +709,7 @@ export default class UIController {
|
|
|
595
709
|
if (r.checked) applyInputMode(r.value);
|
|
596
710
|
});
|
|
597
711
|
});
|
|
712
|
+
this.renderGamepadButtons();
|
|
598
713
|
|
|
599
714
|
// ── Display section wiring ─────────────────────────────────────────────
|
|
600
715
|
const displayRadios = panel.querySelectorAll(
|
|
@@ -668,6 +783,7 @@ export default class UIController {
|
|
|
668
783
|
window.addEventListener('c64-close-dialog', () => {
|
|
669
784
|
this.closeMenu();
|
|
670
785
|
});
|
|
786
|
+
|
|
671
787
|
// Close settings when a load completes or errors so the user sees the result
|
|
672
788
|
// window.addEventListener('c64-load-success', () => {
|
|
673
789
|
// this.settingsOverlay?.classList.remove('visible');
|
package/src/types/emulator.ts
CHANGED
|
@@ -1,116 +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
|
-
- Merge pull request #76 from hayesmaker/fix/emulator-reboot-recovery (4b18cef)
|
|
8
|
-
- fix(emulator): add full reboot recovery across browser and headless (c755986)
|
|
9
|
-
- Merge pull request #73 from hayesmaker/chore/v1.0.0-publish (e67cca2)
|
|
10
|
-
|
|
11
|
-
## v1.0.0 - 2026-04-16T23:12:30+01:00
|
|
12
|
-
|
|
13
|
-
Initial C64-Live release!
|
|
14
|
-
|
|
15
|
-
## 0.11.0 - 2026-04-11T10:50:57+01:00
|
|
16
|
-
|
|
17
|
-
## What's Changed\r
|
|
18
|
-
* Chore/deploy and release by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/36\r
|
|
19
|
-
* Feature/add prg support by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/37\r
|
|
20
|
-
* Feature/live settings parity backend by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/38\r
|
|
21
|
-
* fix(d64): reset state before headless disk insert by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/39\r
|
|
22
|
-
* Chore/prepare deployment 0.11.0 by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/40\r
|
|
23
|
-
\r
|
|
24
|
-
\r
|
|
25
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.10.0...0.11.0
|
|
26
|
-
|
|
27
|
-
## v0.10.0 - 2026-04-09T09:24:54+01:00
|
|
28
|
-
|
|
29
|
-
## What's Changed\r
|
|
30
|
-
* Fix/input flood instrumentation by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/34\r
|
|
31
|
-
* feat(headless): improve WebRTC stability, telemetry, and admin controls by @hayesmaker in https://github.com/hayesmaker/c64-ready/pull/35\r
|
|
32
|
-
\r
|
|
33
|
-
\r
|
|
34
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.8.0...v0.10.0
|
|
35
|
-
|
|
36
|
-
## v0.8.0 - 2026-04-05T08:53:20+01:00
|
|
37
|
-
|
|
38
|
-
Headless multiplayer tested and working on C64cade. See CHANGELOG.md for specific details.
|
|
39
|
-
|
|
40
|
-
## v0.6.2 - 2026-03-27T20:43:20Z
|
|
41
|
-
|
|
42
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.6.1...v0.6.2
|
|
43
|
-
|
|
44
|
-
## v0.6.1 - 2026-03-27T20:36:27Z
|
|
45
|
-
|
|
46
|
-
- chore(release): 0.6.1 (27df16c)
|
|
47
|
-
- fix: serve path corrected for running emulator via npm (56b9f1a)
|
|
48
|
-
- chore: updated changelogs (e9c6320)
|
|
49
|
-
|
|
50
|
-
## v0.6.0 - 2026-03-27T20:21:42Z
|
|
51
|
-
|
|
52
|
-
- chore(release): 0.6.0 (fce6cf9)
|
|
53
|
-
- chore(release): 0.5.2 (cbf9175)
|
|
54
|
-
- feat: added input handling api to the headless runner (73eebfb)
|
|
55
|
-
- fix(headless): use correct output path relative to project (299607e)
|
|
56
|
-
- chore: add cartridges to headless npm (f8d72c9)
|
|
57
|
-
- Merge pull request #20 from hayesmaker/feature/headless-audio (ba60d4b)
|
|
58
|
-
- feat: headless player with audio working good (4203361)
|
|
59
|
-
- fix: docker env file reading (3761a76)
|
|
60
|
-
- Merge pull request #19 from hayesmaker/chore/docker-headless (da1d530)
|
|
61
|
-
- chore: Docker docs (054323d)
|
|
62
|
-
- chore: changelogs (auto) (2a3dab0)
|
|
63
|
-
- chore: dockerized headless c64 player (7bc7770)
|
|
64
|
-
- chore: cleanup source files (27925b4)
|
|
65
|
-
|
|
66
|
-
## v0.5.1 - 2026-03-23T10:09:37Z
|
|
67
|
-
|
|
68
|
-
## What's Changed\r
|
|
69
|
-
* fix(browser): joystick keys detached when opening ui panels\r
|
|
70
|
-
\r
|
|
71
|
-
\r
|
|
72
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.5.0...v0.5.1
|
|
73
|
-
|
|
74
|
-
## v0.5.0 - 2026-03-23T08:56:08Z
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- chore: fix typings and UI controller behavior for joystick/display settings (e843785)
|
|
78
|
-
- Merge remote-tracking branch 'origin/master' (2f5150f)
|
|
79
|
-
- chore(release): 0.5.0 (1c67934)
|
|
80
|
-
- chore: update changelog (auto) [skip ci] (07c46ba)
|
|
81
|
-
- Merge pull request #18 from hayesmaker/feature/more-ui-controller-settings (7557af9)
|
|
82
|
-
- chore: fix lints (45d0b3d)
|
|
83
|
-
- feat: simple input and display settings (c5e60b1)
|
|
84
|
-
- chore(styles): extract inline CSS to module styles/ and import as raw (74f1d41)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
## v0.4.0 - 2026-03-22T23:27:35Z
|
|
89
|
-
|
|
90
|
-
## What's Changed\r
|
|
91
|
-
* chore: release script enhancements \r
|
|
92
|
-
* chore(release): generate changelog inside release commit\r
|
|
93
|
-
* feature/headless cli runner \r
|
|
94
|
-
\r
|
|
95
|
-
\r
|
|
96
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.3.0...v0.4.0
|
|
97
|
-
|
|
98
|
-
## v0.3.0 - 2026-03-21T15:16:11Z
|
|
99
|
-
|
|
100
|
-
Added Audio support - Now load Robocop3.crt and enjoy!\r
|
|
101
|
-
\r
|
|
102
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.2.0...v0.3.0
|
|
103
|
-
|
|
104
|
-
## v0.2.0 - 2026-03-21T13:25:25Z
|
|
105
|
-
|
|
106
|
-
**Full Changelog**: https://github.com/hayesmaker/c64-ready/compare/v0.1.0...v0.2.0
|
|
107
|
-
|
|
108
|
-
## v0.1.0 - 2026-03-20T23:42:38Z
|
|
109
|
-
|
|
110
|
-
First release of C64-ready. \r
|
|
111
|
-
\r
|
|
112
|
-
Emulator working, and loading Legend of Wilf, with default keyboard controls.\r
|
|
113
|
-
No Audio support.\r
|
|
114
|
-
Github pages deployments.
|
|
115
|
-
|
|
116
|
-
`;export{e as default};
|