c64-ready 3.1.0 → 3.3.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 +44 -2
- package/bin/agent.mjs +18 -0
- package/bin/serve.mjs +41 -133
- package/dist/assets/ActionBiker-CWiKt9dn.js +1 -0
- package/dist/assets/Panther-D558qV3B.js +1 -0
- package/dist/assets/RainbowIslands-CgoxK_qP.js +1 -0
- package/dist/assets/RoadRunner-DR_cGZ-h.js +1 -0
- package/dist/assets/RocnRope-DrUGJ0pW.js +1 -0
- package/dist/assets/Thrust-rDKv3Thu.js +1 -0
- package/dist/assets/index-C84W-vN0.js +318 -0
- package/dist/assets/src-CNh6UV6R.js +2 -0
- package/dist/index.html +19 -4
- package/dist-ts/player/c64-player.d.ts +8 -0
- package/dist-ts/player/c64-player.d.ts.map +1 -1
- package/dist-ts/player/c64-player.js +14 -1
- package/dist-ts/player/c64-player.js.map +1 -1
- package/dist-ts/player/canvas-renderer.js +1 -1
- package/dist-ts/player/display-layout.d.ts +40 -0
- package/dist-ts/player/display-layout.d.ts.map +1 -0
- package/dist-ts/player/display-layout.js +76 -0
- package/dist-ts/player/display-layout.js.map +1 -0
- package/dist-ts/player/ui-controller.d.ts +15 -2
- package/dist-ts/player/ui-controller.d.ts.map +1 -1
- package/dist-ts/player/ui-controller.js +209 -93
- package/dist-ts/player/ui-controller.js.map +1 -1
- package/dist-ts/player/ultimate-bridge.d.ts +41 -0
- package/dist-ts/player/ultimate-bridge.d.ts.map +1 -0
- package/dist-ts/player/ultimate-bridge.js +117 -0
- package/dist-ts/player/ultimate-bridge.js.map +1 -0
- package/dist-ts/player/ultimate-panel.d.ts +32 -0
- package/dist-ts/player/ultimate-panel.d.ts.map +1 -0
- package/dist-ts/player/ultimate-panel.js +258 -0
- package/dist-ts/player/ultimate-panel.js.map +1 -0
- package/package.json +10 -4
- package/src/headless/agent-cli.mjs +825 -0
- package/src/headless/player-server.mjs +197 -0
- package/src/headless/png.mjs +72 -0
- package/src/headless/webrtc-server.mjs +115 -13
- package/src/main.ts +25 -1
- package/src/player/c64-player.ts +22 -1
- package/src/player/canvas-renderer.ts +1 -1
- package/src/player/display-layout.ts +109 -0
- package/src/player/ui-controller.ts +237 -93
- package/src/player/ultimate-bridge.ts +161 -0
- package/src/player/ultimate-panel.ts +315 -0
- package/dist/assets/RainbowIslands-BjfmJB8z.js +0 -1
- package/dist/assets/index-B8DSjPqI.js +0 -243
- package/dist/assets/src-_trgwTvp.js +0 -2
- /package/dist/assets/{BeachHead-CuSwFD4k.js → BeachHead-BLcSLEEh.js} +0 -0
- /package/dist/assets/{ChuckieEgg-CPqBnAOF.js → ChuckieEgg-Bv2nxhYv.js} +0 -0
- /package/dist/assets/{ForbiddenForest-DsQ9jsc8.js → ForbiddenForest-CWEFgjVq.js} +0 -0
- /package/dist/assets/{Galaga-Cutc3p9s.js → Galaga-DknmKlo5.js} +0 -0
- /package/dist/assets/{Gribbly-DdZ_hHFt.js → Gribbly-nFVwULpF.js} +0 -0
- /package/dist/assets/{Hercules-vZYKm7GG.js → Hercules-Dbx_KaEi.js} +0 -0
- /package/dist/assets/{LegendOfWilf-CxSMOjsj.js → LegendOfWilf-BBW1Y7LQ.js} +0 -0
- /package/dist/assets/{MariosCementFactory-z0IZ0q30.js → MariosCementFactory-DtpgUfFO.js} +0 -0
- /package/dist/assets/{MoleAttack-buC6ChYy.js → MoleAttack-D_2aAX2V.js} +0 -0
- /package/dist/assets/{MunchyWorm-D2Zv7i0Q.js → MunchyWorm-BqWD5x4j.js} +0 -0
- /package/dist/assets/{ParkPatrol-CVj7hyoB.js → ParkPatrol-9pwc_jcb.js} +0 -0
- /package/dist/assets/{PottyPigeon-0SYpIUBa.js → PottyPigeon-CZnjIrGr.js} +0 -0
- /package/dist/assets/{Stix-BU-qUCeC.js → Stix-o2hS_Ekr.js} +0 -0
- /package/dist/assets/{Tilt-C5KtKisF.js → Tilt-BKb_k_R2.js} +0 -0
- /package/dist/assets/{UpNDown-CATRO7Mz.js → UpNDown-BQXEmKfk.js} +0 -0
- /package/dist/assets/{Uridium-DanS2KoH.js → Uridium-9u86vh1V.js} +0 -0
- /package/dist/assets/{VegetablesDeluxe-C41ViimS.js → VegetablesDeluxe-DbmngV50.js} +0 -0
- /package/dist/assets/{marked.esm-fTuuvbcB.js → marked.esm-DhpYx7TE.js} +0 -0
- /package/dist/assets/{purify.es-CRM-GE0Y.js → purify.es-CWuqV7zK.js} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive display layout for the browser player.
|
|
3
|
+
*
|
|
4
|
+
* The user-facing display *mode* (Settings → Display) is combined with the
|
|
5
|
+
* device context (fullscreen, touch device, orientation) to produce a concrete
|
|
6
|
+
* *layout*, which is written to `<html data-c64-layout="…">`. All sizing is
|
|
7
|
+
* done by the CSS below so the canvas follows viewport / rotation changes
|
|
8
|
+
* without any JS resize handling.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type DisplayMode = 'standard' | 'full' | 'stretch';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* - `standard` — desktop default: up to 2x (768×544) with a border, scaled down to fit.
|
|
15
|
+
* - `fill-width` — touch portrait default: the full width of the screen.
|
|
16
|
+
* - `contain` — largest size that fits the viewport, aspect ratio kept
|
|
17
|
+
* (fills the height on landscape phones / tablets).
|
|
18
|
+
* - `stretch` — fill the whole viewport, aspect ratio ignored.
|
|
19
|
+
*/
|
|
20
|
+
export type DisplayLayout = 'standard' | 'fill-width' | 'contain' | 'stretch';
|
|
21
|
+
|
|
22
|
+
export interface DisplayContext {
|
|
23
|
+
fullscreen: boolean;
|
|
24
|
+
touch: boolean;
|
|
25
|
+
portrait: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const DISPLAY_MODES: readonly DisplayMode[] = ['standard', 'full', 'stretch'];
|
|
29
|
+
export const DISPLAY_MODE_STORAGE_KEY = 'c64-display-mode';
|
|
30
|
+
|
|
31
|
+
/** Media query identifying phones / tablets (no hover, coarse pointer). */
|
|
32
|
+
export const TOUCH_DEVICE_QUERY = '(hover: none) and (pointer: coarse)';
|
|
33
|
+
export const PORTRAIT_QUERY = '(orientation: portrait)';
|
|
34
|
+
|
|
35
|
+
export function isDisplayMode(value: unknown): value is DisplayMode {
|
|
36
|
+
return typeof value === 'string' && (DISPLAY_MODES as readonly string[]).includes(value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveDisplayLayout(mode: DisplayMode, ctx: DisplayContext): DisplayLayout {
|
|
40
|
+
if (mode === 'stretch') return 'stretch';
|
|
41
|
+
if (mode === 'full') return 'contain';
|
|
42
|
+
if (ctx.fullscreen) return 'contain';
|
|
43
|
+
if (ctx.touch) return ctx.portrait ? 'fill-width' : 'contain';
|
|
44
|
+
return 'standard';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Layouts that take over the whole viewport (no page scrolling, overlays dimmed). */
|
|
48
|
+
export function isFillLayout(layout: DisplayLayout): boolean {
|
|
49
|
+
return layout === 'contain' || layout === 'stretch';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Every dvh rule is preceded by a vh fallback for older browsers.
|
|
53
|
+
export const displayLayoutCss = `
|
|
54
|
+
html[data-c64-layout=fill-width] #c64-screen{border:none;width:100vw;height:auto}
|
|
55
|
+
html[data-c64-layout=contain] #c64-screen{border:none;height:auto;width:min(100vw,calc(100vh * 384 / 272));width:min(100vw,calc(100dvh * 384 / 272))}
|
|
56
|
+
html[data-c64-layout=stretch] #c64-screen{border:none;aspect-ratio:auto;object-fit:fill;width:100vw;height:100vh;height:100dvh}
|
|
57
|
+
html[data-c64-fill],html[data-c64-fill] body{overflow:hidden;overscroll-behavior:none}
|
|
58
|
+
html[data-c64-fill] body{height:100vh;height:100dvh;min-height:0}
|
|
59
|
+
html[data-c64-fill] .c64-help-btn,html[data-c64-fill] .c64-hamburger,html[data-c64-fill] .c64-fullscreen-btn,html[data-c64-fill] .c64-unmute-btn:not(.hidden){opacity:.4;transition:opacity .2s ease}
|
|
60
|
+
html[data-c64-fill] .c64-help-btn:hover,html[data-c64-fill] .c64-hamburger:hover,html[data-c64-fill] .c64-fullscreen-btn:hover,html[data-c64-fill] .c64-unmute-btn:not(.hidden):hover,html[data-c64-fill] .c64-help-btn:focus-visible,html[data-c64-fill] .c64-hamburger:focus-visible,html[data-c64-fill] .c64-fullscreen-btn:focus-visible{opacity:1}
|
|
61
|
+
html[data-c64-fill] .c64-loader{position:fixed;left:50%;bottom:16px;margin:0;translate:-50% 0;z-index:950}
|
|
62
|
+
.c64-fullscreen-btn{position:fixed;top:12px;right:56px;width:36px;height:36px;padding:0;border-radius:6px;border:2px solid #444;background:#111;color:#ddd;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:1000}
|
|
63
|
+
.c64-fullscreen-btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
export const FULLSCREEN_ENTER_ICON =
|
|
67
|
+
'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>';
|
|
68
|
+
export const FULLSCREEN_EXIT_ICON =
|
|
69
|
+
'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';
|
|
70
|
+
|
|
71
|
+
type FullscreenDocument = Document & {
|
|
72
|
+
webkitFullscreenElement?: Element | null;
|
|
73
|
+
webkitFullscreenEnabled?: boolean;
|
|
74
|
+
webkitExitFullscreen?: () => Promise<void> | void;
|
|
75
|
+
};
|
|
76
|
+
type FullscreenElement = HTMLElement & {
|
|
77
|
+
webkitRequestFullscreen?: () => Promise<void> | void;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** iPhone Safari has no element fullscreen API — the button is hidden there. */
|
|
81
|
+
export function isFullscreenSupported(doc: Document = document): boolean {
|
|
82
|
+
const d = doc as FullscreenDocument;
|
|
83
|
+
const el = d.documentElement as FullscreenElement;
|
|
84
|
+
const canRequest =
|
|
85
|
+
typeof el.requestFullscreen === 'function' || typeof el.webkitRequestFullscreen === 'function';
|
|
86
|
+
const enabled = d.fullscreenEnabled ?? d.webkitFullscreenEnabled ?? canRequest;
|
|
87
|
+
return canRequest && enabled !== false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function isFullscreenActive(doc: Document = document): boolean {
|
|
91
|
+
const d = doc as FullscreenDocument;
|
|
92
|
+
return !!(d.fullscreenElement ?? d.webkitFullscreenElement);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export async function toggleFullscreen(doc: Document = document): Promise<void> {
|
|
96
|
+
const d = doc as FullscreenDocument;
|
|
97
|
+
if (isFullscreenActive(d)) {
|
|
98
|
+
await (d.exitFullscreen ? d.exitFullscreen() : d.webkitExitFullscreen?.());
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Fullscreen the whole page (not just the canvas) so the menu, help and
|
|
102
|
+
// unmute overlays keep working while in fullscreen.
|
|
103
|
+
const el = d.documentElement as FullscreenElement;
|
|
104
|
+
if (el.requestFullscreen) {
|
|
105
|
+
await el.requestFullscreen({ navigationUI: 'hide' });
|
|
106
|
+
} else {
|
|
107
|
+
await el.webkitRequestFullscreen?.();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -10,6 +10,10 @@ const css = `
|
|
|
10
10
|
.c64-dragarea{border:1px dashed #555;border-radius:6px;background:#111827;color:#aaa;padding:18px;margin:0 0 12px;text-align:center}.c64-dragarea.dragover{border-color:#7b71d5;background:#1f1b38;color:#fff}.c64-cart-preview,.c64-tools-section{background:#151527;border:1px solid #2a2a3e;border-radius:6px;padding:12px;margin:12px 0}.c64-section-hint{color:#888;font-size:12px;line-height:1.4;margin:4px 0 12px}.c64-checkbox-row{display:flex;align-items:center;gap:8px;color:#ccc;font-size:13px;margin:14px 0 4px}
|
|
11
11
|
.c64-text-input,.c64-textarea{background:#111827;border:1px solid #444;border-radius:3px;color:#ddd;font:inherit;font-size:13px;padding:5px 8px}.c64-text-input{min-width:180px}.c64-textarea{box-sizing:border-box;width:100%;min-height:120px;resize:vertical}.c64-cheevos-json-file{display:none}.c64-inline-status{color:#888;font-size:12px}
|
|
12
12
|
.c64-cheat-list{display:grid;gap:12px;margin:0 0 12px}.c64-cheat-card{background:#151527;border:1px solid #2a2a3e;border-radius:6px;padding:12px}.c64-cheat-card-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 10px;color:#ddd;font-size:13px}.c64-cheat-remove{background:none;border:0;color:#ff9a9a;cursor:pointer;font:inherit;font-size:12px}.c64-cheat-grid{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 10px;align-items:center}.c64-cheat-input{background:#111827;border:1px solid #444;border-radius:3px;color:#ddd;font:inherit;font-size:13px;min-width:0;padding:5px 8px}.c64-cheat-error{color:#ff9a9a;font-size:12px;margin:8px 0 0}.c64-cheat-status{color:#aaa;font-size:12px;line-height:1.4;margin:8px 0 0}.c64-cheat-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}@media (max-width:600px){.c64-cheat-grid{grid-template-columns:1fr}.c64-cheat-grid label{margin-top:4px}}
|
|
13
|
+
.c64-help-dialog,.c64-menu-panel{box-sizing:border-box;max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.c64-menu-panel{max-height:min(82vh,calc(100dvh - 32px))}.c64-changelog-dialog{max-height:min(70vh,calc(100dvh - 32px))}
|
|
14
|
+
.c64-help-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:24px;margin:0 0 8px}.c64-help-controls li{align-items:center;gap:8px;padding:3px 0}.c64-help-keys{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:4px}.c64-help-key{font-family:inherit;white-space:nowrap}.c64-help-dialog p.c64-help-note{margin:4px 0 0;font-size:12px;color:#888}.c64-help-dialog .c64-version{margin-top:16px}.c64-help-dialog h3{margin:16px 0 6px;font-size:13px;color:#a8a8ff;letter-spacing:1px;text-transform:uppercase}.c64-help-key-note{font-size:12px;color:#888;font-style:italic}.c64-keymap-dialog .c64-help-close{position:sticky;top:0;float:right;margin:-12px -18px 0 0}
|
|
15
|
+
@media (max-width:560px){.c64-help-controls{grid-template-columns:1fr}.c64-help-dialog,.c64-menu-panel{padding:20px 16px;width:calc(100% - 24px)}}
|
|
16
|
+
.c64-cheat-status[data-mode=ok]{color:#8fd694}.c64-cheat-status[data-mode=error]{color:#f77}#c64-ultimate-device[data-connected]{color:#8fd694}.c64-settings-section .c64-section-hint a{color:#a8a8ff;text-decoration:none}
|
|
13
17
|
`;
|
|
14
18
|
|
|
15
19
|
export interface UIControllerOptions {
|
|
@@ -24,35 +28,91 @@ function resolveAssetUrl(baseUrl: string | undefined, path: string): string {
|
|
|
24
28
|
return `${base.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
['
|
|
30
|
-
['
|
|
31
|
-
['
|
|
32
|
-
['
|
|
31
|
+
/** Help dialog controls guide: [label, keys]. Rendered as a compact two-column grid. */
|
|
32
|
+
const CONTROLS: ReadonlyArray<readonly [string, readonly string[]]> = [
|
|
33
|
+
['Joystick', ['↑', '↓', '←', '→']],
|
|
34
|
+
['Fire', ['Z', 'Left Ctrl']],
|
|
35
|
+
['Fast-forward', ['Alt +', 'Alt −']],
|
|
36
|
+
['Normal speed', ['Alt ⌫']],
|
|
37
|
+
['Run/Stop', ['Esc']],
|
|
38
|
+
['Inst/Del', ['⌫', 'Del']],
|
|
39
|
+
['Clr/Home', ['Home']],
|
|
40
|
+
['Commodore', ['Ctrl', 'Caps Lock']],
|
|
41
|
+
['Control', ['Tab']],
|
|
42
|
+
['£', ['\\']],
|
|
43
|
+
['← / ↑ glyphs', ['`', '^']],
|
|
44
|
+
['F1–F8', ['F1–F8']],
|
|
33
45
|
];
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
[
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
type KeymapEntry = readonly [label: string, keys: readonly string[], note?: string];
|
|
48
|
+
|
|
49
|
+
/** Full keyboard map, linked from the help dialog: [section title, entries]. */
|
|
50
|
+
const FULL_KEYMAP: ReadonlyArray<readonly [string, readonly KeymapEntry[]]> = [
|
|
51
|
+
[
|
|
52
|
+
'Joystick',
|
|
53
|
+
[
|
|
54
|
+
['Up / Down', ['↑', '↓']],
|
|
55
|
+
['Left / Right', ['←', '→']],
|
|
56
|
+
['Fire', ['Z', 'Left Ctrl']],
|
|
57
|
+
],
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
'Emulator',
|
|
61
|
+
[
|
|
62
|
+
['Faster', ['Alt +']],
|
|
63
|
+
['Slower', ['Alt −']],
|
|
64
|
+
['Normal speed', ['Alt ⌫']],
|
|
65
|
+
],
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
'C64 keyboard',
|
|
69
|
+
[
|
|
70
|
+
['Run/Stop', ['Esc']],
|
|
71
|
+
['Restore', [], 'not supported yet'],
|
|
72
|
+
['Return', ['Enter']],
|
|
73
|
+
['Shift', ['Shift']],
|
|
74
|
+
['Inst/Del', ['⌫', 'Del']],
|
|
75
|
+
['Clr/Home', ['Home']],
|
|
76
|
+
['Commodore', ['Ctrl', 'Caps Lock']],
|
|
77
|
+
['Control', ['Tab']],
|
|
78
|
+
['F1–F8', ['F1–F8']],
|
|
79
|
+
['← (arrow left)', ['`']],
|
|
80
|
+
['↑ (arrow up)', ['^', '~']],
|
|
81
|
+
['£ (pound)', ['\\']],
|
|
82
|
+
['Colon / Semicolon', [':', ';', '[', ']']],
|
|
83
|
+
['Slash', ['/', '?']],
|
|
84
|
+
['Comma / Period', [',', '.', '<', '>']],
|
|
85
|
+
['Letters, numbers, + − * = @', [], 'as typed'],
|
|
86
|
+
],
|
|
87
|
+
],
|
|
50
88
|
];
|
|
51
89
|
|
|
90
|
+
function renderKeymapItem([label, keys, note]: KeymapEntry): string {
|
|
91
|
+
const chips = keys.map((key) => `<kbd class="c64-help-key">${key}</kbd>`).join('');
|
|
92
|
+
const extra = note ? `<span class="c64-help-key-note">${note}</span>` : '';
|
|
93
|
+
return `<li><span>${label}</span><span class="c64-help-keys">${chips}${extra}</span></li>`;
|
|
94
|
+
}
|
|
95
|
+
|
|
52
96
|
import type { C64Player } from './c64-player';
|
|
53
97
|
import type { JoystickPort } from '../emulator/constants';
|
|
54
98
|
import { chooseAndStoreCheevosRom, storeCheevosRomFile } from './local-rom-store';
|
|
55
99
|
import { toViteFsUrl } from './startup-params';
|
|
100
|
+
import UltimatePanel from './ultimate-panel';
|
|
101
|
+
import {
|
|
102
|
+
DISPLAY_MODE_STORAGE_KEY,
|
|
103
|
+
FULLSCREEN_ENTER_ICON,
|
|
104
|
+
FULLSCREEN_EXIT_ICON,
|
|
105
|
+
PORTRAIT_QUERY,
|
|
106
|
+
TOUCH_DEVICE_QUERY,
|
|
107
|
+
displayLayoutCss,
|
|
108
|
+
isDisplayMode,
|
|
109
|
+
isFillLayout,
|
|
110
|
+
isFullscreenActive,
|
|
111
|
+
isFullscreenSupported,
|
|
112
|
+
resolveDisplayLayout,
|
|
113
|
+
toggleFullscreen,
|
|
114
|
+
} from './display-layout';
|
|
115
|
+
import type { DisplayMode } from './display-layout';
|
|
56
116
|
import {
|
|
57
117
|
LOAD_FORMAT_OPTIONS,
|
|
58
118
|
getAcceptForLoadTypeSelection,
|
|
@@ -236,8 +296,11 @@ export default class UIController {
|
|
|
236
296
|
this.applyCheatAction(cheat);
|
|
237
297
|
};
|
|
238
298
|
// Save previous overflow styles so we can restore them when exiting full/stretch
|
|
239
|
-
private
|
|
240
|
-
private
|
|
299
|
+
private displayMode: DisplayMode = 'standard';
|
|
300
|
+
private fullscreenBtn: HTMLButtonElement | null = null;
|
|
301
|
+
private keymapOverlay: HTMLElement | null = null;
|
|
302
|
+
private touchQuery: MediaQueryList | null = null;
|
|
303
|
+
private portraitQuery: MediaQueryList | null = null;
|
|
241
304
|
private connectedGamepads = new Map<number, ConnectedGamepad>();
|
|
242
305
|
private readonly handleControllerConnected = (event: Event): void => {
|
|
243
306
|
const detail = (event as CustomEvent<{ name?: string; index?: number }>).detail;
|
|
@@ -269,6 +332,8 @@ export default class UIController {
|
|
|
269
332
|
this.createHamburger();
|
|
270
333
|
this.createMenu();
|
|
271
334
|
this.createUnmuteButton();
|
|
335
|
+
this.createFullscreenButton();
|
|
336
|
+
this.initDisplayLayout();
|
|
272
337
|
window.addEventListener('keydown', this.handleCheatKeyDown, true);
|
|
273
338
|
window.addEventListener('c64-controller-connected', this.handleControllerConnected);
|
|
274
339
|
window.addEventListener('c64-controller-disconnected', this.handleControllerDisconnected);
|
|
@@ -699,7 +764,7 @@ export default class UIController {
|
|
|
699
764
|
if (document.querySelector('style[data-c64-help]')) return;
|
|
700
765
|
const style = document.createElement('style');
|
|
701
766
|
style.setAttribute('data-c64-help', '');
|
|
702
|
-
style.textContent = css;
|
|
767
|
+
style.textContent = css + displayLayoutCss;
|
|
703
768
|
document.head.appendChild(style);
|
|
704
769
|
}
|
|
705
770
|
|
|
@@ -725,13 +790,9 @@ export default class UIController {
|
|
|
725
790
|
if (e.target === overlay) this.close();
|
|
726
791
|
});
|
|
727
792
|
|
|
728
|
-
const controlItems = CONTROLS.map(
|
|
729
|
-
|
|
730
|
-
)
|
|
731
|
-
|
|
732
|
-
const specialItems = SPECIAL_KEYS.map(
|
|
733
|
-
([action, key]) => `<li><span>${action}</span><span class="c64-help-key">${key}</span></li>`,
|
|
734
|
-
).join('');
|
|
793
|
+
const controlItems = CONTROLS.map(([action, keys]) => renderKeymapItem([action, keys])).join(
|
|
794
|
+
'',
|
|
795
|
+
);
|
|
735
796
|
|
|
736
797
|
overlay.innerHTML = `
|
|
737
798
|
<div class="c64-help-dialog">
|
|
@@ -741,8 +802,7 @@ export default class UIController {
|
|
|
741
802
|
<p><a href="https://github.com/hayesmaker/c64-ready" target="_blank" rel="noopener">Source code on GitHub</a> · <a href="#" id="c64-view-changelog">View changelog</a></p>
|
|
742
803
|
<h2>CONTROLS</h2>
|
|
743
804
|
<ul class="c64-help-controls">${controlItems}</ul>
|
|
744
|
-
<
|
|
745
|
-
<ul class="c64-help-special">${specialItems}</ul>
|
|
805
|
+
<p class="c64-help-note">Other keys type as on your keyboard. <a href="#" id="c64-view-keymap">Full keyboard map →</a></p>
|
|
746
806
|
<div class="c64-version">${this.getVersionLabel()}</div>
|
|
747
807
|
</div>
|
|
748
808
|
`;
|
|
@@ -775,6 +835,36 @@ export default class UIController {
|
|
|
775
835
|
this.loadAndShowChangelog(changelogOverlay);
|
|
776
836
|
});
|
|
777
837
|
}
|
|
838
|
+
|
|
839
|
+
// Full keyboard map modal (hidden by default)
|
|
840
|
+
const keymapSections = FULL_KEYMAP.map(
|
|
841
|
+
([title, entries]) =>
|
|
842
|
+
`<h3>${title}</h3><ul class="c64-help-controls">${entries.map(renderKeymapItem).join('')}</ul>`,
|
|
843
|
+
).join('');
|
|
844
|
+
const keymapOverlay = document.createElement('div');
|
|
845
|
+
keymapOverlay.className = 'c64-help-overlay c64-keymap-overlay';
|
|
846
|
+
keymapOverlay.style.zIndex = '1003';
|
|
847
|
+
keymapOverlay.innerHTML = `
|
|
848
|
+
<div class="c64-help-dialog c64-keymap-dialog">
|
|
849
|
+
<button class="c64-help-close" aria-label="Close">×</button>
|
|
850
|
+
<h2>KEYBOARD MAP</h2>
|
|
851
|
+
<p class="c64-help-note">Mixed input mode (the default): arrows and Z / Left Ctrl drive the joystick, every other key goes to the C64 keyboard. Change it under Settings → Input.</p>
|
|
852
|
+
${keymapSections}
|
|
853
|
+
</div>
|
|
854
|
+
`;
|
|
855
|
+
const closeKeymap = () => keymapOverlay.classList.remove('visible');
|
|
856
|
+
keymapOverlay.addEventListener('click', (e) => {
|
|
857
|
+
if (e.target === keymapOverlay) closeKeymap();
|
|
858
|
+
});
|
|
859
|
+
keymapOverlay.querySelector('.c64-help-close')!.addEventListener('click', closeKeymap);
|
|
860
|
+
document.body.appendChild(keymapOverlay);
|
|
861
|
+
this.keymapOverlay = keymapOverlay;
|
|
862
|
+
overlay.querySelector('#c64-view-keymap')!.addEventListener('click', (ev) => {
|
|
863
|
+
ev.preventDefault();
|
|
864
|
+
const dialog = keymapOverlay.querySelector('.c64-help-dialog');
|
|
865
|
+
if (dialog) dialog.scrollTop = 0;
|
|
866
|
+
keymapOverlay.classList.add('visible');
|
|
867
|
+
});
|
|
778
868
|
}
|
|
779
869
|
|
|
780
870
|
private async loadAndShowChangelog(container: HTMLElement) {
|
|
@@ -811,6 +901,96 @@ export default class UIController {
|
|
|
811
901
|
}
|
|
812
902
|
}
|
|
813
903
|
|
|
904
|
+
// ── Display layout & fullscreen ─────────────────────────────────────────
|
|
905
|
+
|
|
906
|
+
private initDisplayLayout(): void {
|
|
907
|
+
let stored: string | null = null;
|
|
908
|
+
try {
|
|
909
|
+
stored = window.localStorage.getItem(DISPLAY_MODE_STORAGE_KEY);
|
|
910
|
+
} catch {
|
|
911
|
+
// storage unavailable (private mode / blocked) — use the default
|
|
912
|
+
}
|
|
913
|
+
this.displayMode = isDisplayMode(stored) ? stored : 'standard';
|
|
914
|
+
|
|
915
|
+
if (typeof window.matchMedia === 'function') {
|
|
916
|
+
this.touchQuery = window.matchMedia(TOUCH_DEVICE_QUERY);
|
|
917
|
+
this.portraitQuery = window.matchMedia(PORTRAIT_QUERY);
|
|
918
|
+
this.touchQuery.addEventListener?.('change', this.applyDisplayLayout);
|
|
919
|
+
this.portraitQuery.addEventListener?.('change', this.applyDisplayLayout);
|
|
920
|
+
}
|
|
921
|
+
document.addEventListener('fullscreenchange', this.applyDisplayLayout);
|
|
922
|
+
document.addEventListener('webkitfullscreenchange', this.applyDisplayLayout);
|
|
923
|
+
|
|
924
|
+
this.setDisplayMode(this.displayMode, { persist: false });
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/** Change the user-selected display mode (Settings → Display). */
|
|
928
|
+
setDisplayMode(mode: DisplayMode, { persist = true }: { persist?: boolean } = {}): void {
|
|
929
|
+
this.displayMode = mode;
|
|
930
|
+
if (persist) {
|
|
931
|
+
try {
|
|
932
|
+
window.localStorage.setItem(DISPLAY_MODE_STORAGE_KEY, mode);
|
|
933
|
+
} catch {
|
|
934
|
+
// ignore — preference just won't survive a reload
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
const radio = document.querySelector<HTMLInputElement>(
|
|
938
|
+
`input[name="c64-display-mode"][value="${mode}"]`,
|
|
939
|
+
);
|
|
940
|
+
if (radio) radio.checked = true;
|
|
941
|
+
|
|
942
|
+
const canvas = document.getElementById('c64-screen');
|
|
943
|
+
canvas?.setAttribute('data-display-mode', mode);
|
|
944
|
+
this.applyDisplayLayout();
|
|
945
|
+
window.dispatchEvent(new CustomEvent('c64-display-mode-changed', { detail: { mode } }));
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
getDisplayMode(): DisplayMode {
|
|
949
|
+
return this.displayMode;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
private readonly applyDisplayLayout = (): void => {
|
|
953
|
+
const fullscreen = isFullscreenActive();
|
|
954
|
+
const layout = resolveDisplayLayout(this.displayMode, {
|
|
955
|
+
fullscreen,
|
|
956
|
+
touch: this.touchQuery?.matches ?? false,
|
|
957
|
+
portrait: this.portraitQuery?.matches ?? false,
|
|
958
|
+
});
|
|
959
|
+
const root = document.documentElement;
|
|
960
|
+
root.setAttribute('data-c64-layout', layout);
|
|
961
|
+
root.toggleAttribute('data-c64-fill', isFillLayout(layout));
|
|
962
|
+
root.toggleAttribute('data-c64-fullscreen', fullscreen);
|
|
963
|
+
if (this.fullscreenBtn) {
|
|
964
|
+
this.fullscreenBtn.innerHTML = fullscreen ? FULLSCREEN_EXIT_ICON : FULLSCREEN_ENTER_ICON;
|
|
965
|
+
this.fullscreenBtn.title = fullscreen ? 'Exit fullscreen' : 'Fullscreen';
|
|
966
|
+
this.fullscreenBtn.setAttribute('aria-label', this.fullscreenBtn.title);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
async toggleFullscreen(): Promise<void> {
|
|
971
|
+
try {
|
|
972
|
+
await toggleFullscreen();
|
|
973
|
+
} catch (error) {
|
|
974
|
+
console.warn('[c64-ready] fullscreen request failed:', error);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
private createFullscreenButton(): void {
|
|
979
|
+
if (!isFullscreenSupported()) return;
|
|
980
|
+
const btn = document.createElement('button');
|
|
981
|
+
btn.className = 'c64-fullscreen-btn';
|
|
982
|
+
btn.type = 'button';
|
|
983
|
+
btn.innerHTML = FULLSCREEN_ENTER_ICON;
|
|
984
|
+
btn.title = 'Fullscreen';
|
|
985
|
+
btn.setAttribute('aria-label', 'Fullscreen');
|
|
986
|
+
btn.addEventListener('click', () => {
|
|
987
|
+
btn.blur(); // keep keyboard focus off the button so Space etc. reach the C64
|
|
988
|
+
void this.toggleFullscreen();
|
|
989
|
+
});
|
|
990
|
+
document.body.appendChild(btn);
|
|
991
|
+
this.fullscreenBtn = btn;
|
|
992
|
+
}
|
|
993
|
+
|
|
814
994
|
private createHamburger(): void {
|
|
815
995
|
const btn = document.createElement('button');
|
|
816
996
|
btn.className = 'c64-hamburger';
|
|
@@ -834,6 +1014,7 @@ export default class UIController {
|
|
|
834
1014
|
{ id: 'audio', label: 'Audio' },
|
|
835
1015
|
{ id: 'cheevos', label: 'Cheevos' },
|
|
836
1016
|
{ id: 'cheats', label: 'Cheats' },
|
|
1017
|
+
{ id: 'ultimate', label: 'Ultimate' },
|
|
837
1018
|
{ id: 'system', label: 'System' },
|
|
838
1019
|
] as const;
|
|
839
1020
|
|
|
@@ -925,6 +1106,10 @@ export default class UIController {
|
|
|
925
1106
|
<label><input type="radio" name="c64-display-mode" value="full" /> Full</label>
|
|
926
1107
|
<label><input type="radio" name="c64-display-mode" value="stretch" /> Stretch</label>
|
|
927
1108
|
</div>
|
|
1109
|
+
<div class="c64-section-hint">Standard: 2x size on desktop; fills the screen width on phones in portrait and the screen height in landscape. Full: as large as the window allows. Stretch: fills the window, ignoring the aspect ratio.</div>
|
|
1110
|
+
<div class="c64-menu-actions">
|
|
1111
|
+
<button class="c64-btn" id="c64-fullscreen-toggle" type="button">Toggle Fullscreen</button>
|
|
1112
|
+
</div>
|
|
928
1113
|
</section>
|
|
929
1114
|
|
|
930
1115
|
<section class="c64-settings-section" data-settings-section="audio" hidden>
|
|
@@ -977,6 +1162,10 @@ export default class UIController {
|
|
|
977
1162
|
</div>
|
|
978
1163
|
</section>
|
|
979
1164
|
|
|
1165
|
+
<section class="c64-settings-section" data-settings-section="ultimate" hidden>
|
|
1166
|
+
<div id="c64-ultimate-section-anchor"></div>
|
|
1167
|
+
</section>
|
|
1168
|
+
|
|
980
1169
|
<section class="c64-settings-section" data-settings-section="system" hidden>
|
|
981
1170
|
<label class="c64-section-label">System Actions</label>
|
|
982
1171
|
<div class="c64-system-actions">
|
|
@@ -1433,6 +1622,10 @@ export default class UIController {
|
|
|
1433
1622
|
const audioContainer = panel.querySelector('#c64-audio-section-anchor') as HTMLElement;
|
|
1434
1623
|
this.createAudioSection(audioContainer);
|
|
1435
1624
|
|
|
1625
|
+
// ── Ultimate section ──────────────────────────────────────────────────
|
|
1626
|
+
const ultimateContainer = panel.querySelector('#c64-ultimate-section-anchor') as HTMLElement;
|
|
1627
|
+
new UltimatePanel(ultimateContainer, () => this.player).init();
|
|
1628
|
+
|
|
1436
1629
|
// ── Input section wiring ───────────────────────────────────────────────
|
|
1437
1630
|
const joyRadios = panel.querySelectorAll(
|
|
1438
1631
|
'input[name="c64-joy-port"]',
|
|
@@ -1487,70 +1680,20 @@ export default class UIController {
|
|
|
1487
1680
|
const displayRadios = panel.querySelectorAll(
|
|
1488
1681
|
'input[name="c64-display-mode"]',
|
|
1489
1682
|
) as NodeListOf<HTMLInputElement>;
|
|
1490
|
-
const canvas = document.getElementById('c64-screen') as HTMLCanvasElement | null;
|
|
1491
|
-
const applyDisplayMode = (mode: string) => {
|
|
1492
|
-
if (!canvas) return;
|
|
1493
|
-
// Reset to defaults first
|
|
1494
|
-
canvas.style.width = '';
|
|
1495
|
-
canvas.style.height = '';
|
|
1496
|
-
canvas.style.objectFit = '';
|
|
1497
|
-
canvas.removeAttribute('data-display-mode');
|
|
1498
|
-
|
|
1499
|
-
if (mode === 'standard') {
|
|
1500
|
-
// Use the default CSS size (no change)
|
|
1501
|
-
canvas.style.width = '';
|
|
1502
|
-
canvas.style.height = '';
|
|
1503
|
-
// Restore the default border from CSS
|
|
1504
|
-
canvas.style.border = '';
|
|
1505
|
-
// Restore any previously-saved page overflow styles so scrollbars reappear
|
|
1506
|
-
if (this.savedHtmlOverflow !== null) {
|
|
1507
|
-
document.documentElement.style.overflow = this.savedHtmlOverflow;
|
|
1508
|
-
this.savedHtmlOverflow = null;
|
|
1509
|
-
} else {
|
|
1510
|
-
document.documentElement.style.overflow = '';
|
|
1511
|
-
}
|
|
1512
|
-
if (this.savedBodyOverflow !== null) {
|
|
1513
|
-
document.body.style.overflow = this.savedBodyOverflow;
|
|
1514
|
-
this.savedBodyOverflow = null;
|
|
1515
|
-
} else {
|
|
1516
|
-
document.body.style.overflow = '';
|
|
1517
|
-
}
|
|
1518
|
-
} else if (mode === 'full') {
|
|
1519
|
-
// Maintain aspect ratio, make canvas fill the full height of the browser
|
|
1520
|
-
canvas.style.height = '100vh';
|
|
1521
|
-
canvas.style.width = 'auto';
|
|
1522
|
-
canvas.style.objectFit = 'contain';
|
|
1523
|
-
// Remove canvas border in full-screen-like modes
|
|
1524
|
-
canvas.style.border = 'none';
|
|
1525
|
-
// Hide page scrollbars (prevent overflow when canvas touches edges)
|
|
1526
|
-
if (this.savedHtmlOverflow === null)
|
|
1527
|
-
this.savedHtmlOverflow = document.documentElement.style.overflow;
|
|
1528
|
-
if (this.savedBodyOverflow === null) this.savedBodyOverflow = document.body.style.overflow;
|
|
1529
|
-
document.documentElement.style.overflow = 'hidden';
|
|
1530
|
-
document.body.style.overflow = 'hidden';
|
|
1531
|
-
} else if (mode === 'stretch') {
|
|
1532
|
-
// Stretch to full width and height (may alter aspect ratio)
|
|
1533
|
-
canvas.style.width = '100vw';
|
|
1534
|
-
canvas.style.height = '100vh';
|
|
1535
|
-
canvas.style.objectFit = 'fill';
|
|
1536
|
-
// Remove canvas border in full-screen-like modes
|
|
1537
|
-
canvas.style.border = 'none';
|
|
1538
|
-
// Hide page scrollbars (prevent overflow when canvas touches edges)
|
|
1539
|
-
if (this.savedHtmlOverflow === null)
|
|
1540
|
-
this.savedHtmlOverflow = document.documentElement.style.overflow;
|
|
1541
|
-
if (this.savedBodyOverflow === null) this.savedBodyOverflow = document.body.style.overflow;
|
|
1542
|
-
document.documentElement.style.overflow = 'hidden';
|
|
1543
|
-
document.body.style.overflow = 'hidden';
|
|
1544
|
-
}
|
|
1545
|
-
canvas.setAttribute('data-display-mode', mode);
|
|
1546
|
-
window.dispatchEvent(new CustomEvent('c64-display-mode-changed', { detail: { mode } }));
|
|
1547
|
-
};
|
|
1548
|
-
|
|
1549
1683
|
displayRadios.forEach((r) => {
|
|
1550
1684
|
r.addEventListener('change', () => {
|
|
1551
|
-
if (r.checked)
|
|
1685
|
+
if (r.checked && isDisplayMode(r.value)) this.setDisplayMode(r.value);
|
|
1552
1686
|
});
|
|
1553
1687
|
});
|
|
1688
|
+
const fullscreenToggle = panel.querySelector('#c64-fullscreen-toggle') as HTMLButtonElement;
|
|
1689
|
+
if (isFullscreenSupported()) {
|
|
1690
|
+
fullscreenToggle.addEventListener('click', () => {
|
|
1691
|
+
this.closeMenu();
|
|
1692
|
+
void this.toggleFullscreen();
|
|
1693
|
+
});
|
|
1694
|
+
} else {
|
|
1695
|
+
fullscreenToggle.hidden = true;
|
|
1696
|
+
}
|
|
1554
1697
|
|
|
1555
1698
|
window.addEventListener('c64-close-dialog', () => {
|
|
1556
1699
|
this.closeMenu();
|
|
@@ -1668,5 +1811,6 @@ export default class UIController {
|
|
|
1668
1811
|
|
|
1669
1812
|
close(): void {
|
|
1670
1813
|
this.helpOverlay?.classList.remove('visible');
|
|
1814
|
+
this.keymapOverlay?.classList.remove('visible');
|
|
1671
1815
|
}
|
|
1672
1816
|
}
|