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 CHANGED
@@ -21,6 +21,7 @@ Build a clean, testable C64 emulator for the web, with a focus on:
21
21
  https://hayesmaker.github.io/c64-ready/
22
22
 
23
23
  ## Install and run locally
24
+
24
25
  - Prerequisites: Node.js 18+ and npm (see https://nodejs.org/)
25
26
 
26
27
  Install dependencies:
@@ -69,9 +70,10 @@ joystick input channel. No separate media server is required.
69
70
 
70
71
  #### With NPM
71
72
 
72
- ```bash
73
+ ````bash
73
74
  npx c64-ready```
74
- ```
75
+ ````
76
+
75
77
  This starts a static server that serves the browser player on `http://localhost:5173/c64-ready/` by default.
76
78
 
77
79
  #### With Docker
@@ -120,25 +122,25 @@ Note: VICE `.vsf` snapshots are currently disabled in the browser runtime.
120
122
  All options live in `docker/.env` (copy from `docker/.env.example`). See that file for
121
123
  the full annotated list.
122
124
 
123
- | Variable | Default | Description |
124
- |----------|---------|-------------|
125
- | `WASM_PATH` | `/app/public/c64.wasm` | Path to the WASM binary inside the container |
126
- | `GAME_PATH` | *(empty)* | Cartridge to load on startup — leave blank to boot to BASIC |
127
- | `FPS` | `50` | Target frame rate (`50` = PAL, `60` = NTSC) |
128
- | `AUDIO` | `1` | Set to `1` to include SID audio in the WebRTC stream |
129
- | `DURATION` | *(empty = forever)* | Stop after this many seconds |
130
- | `VERBOSE` | *(empty)* | Set to `1` for per-frame diagnostics in container logs |
131
- | `LOG_EVENTS` | `1` | Log player joins/leaves, cart loads, input events |
132
- | `WEBRTC_ENABLED` | `1` | Must be `1` — WebRTC is the only supported streaming mode |
133
- | `WEBRTC_PORT` | `9002` | Port inside the container for the WebRTC server |
134
- | `WEBRTC_HOST_PORT` | `9002` | Host-side port mapping for the WebRTC server |
135
- | `MAX_SPECTATORS` | `3` | Max concurrent spectator connections (players are separate, see below) |
136
- | `WEBRTC_MIN_BITRATE_KBPS` | `200` | VP8 SDP `x-google-min-bitrate` hint in kbps |
137
- | `WEBRTC_MAX_BITRATE_KBPS` | `600` | VP8 SDP `x-google-max-bitrate` hint in kbps |
138
- | `WEBRTC_OUTPUT_FPS` | `40` | Cap outgoing WebRTC video FPS (`0` disables cap) |
139
- | `C64_ADMIN_TOKEN` | *(empty)* | Shared token required by `c64-admin` (`status`, `kick`) |
140
- | `WS_PORT` | `9001` | WebSocket input server port inside the container |
141
- | `WS_HOST_PORT` | `9001` | Host-side port mapping for the input WebSocket |
125
+ | Variable | Default | Description |
126
+ | ------------------------- | ---------------------- | ---------------------------------------------------------------------- |
127
+ | `WASM_PATH` | `/app/public/c64.wasm` | Path to the WASM binary inside the container |
128
+ | `GAME_PATH` | _(empty)_ | Cartridge to load on startup — leave blank to boot to BASIC |
129
+ | `FPS` | `50` | Target frame rate (`50` = PAL, `60` = NTSC) |
130
+ | `AUDIO` | `1` | Set to `1` to include SID audio in the WebRTC stream |
131
+ | `DURATION` | _(empty = forever)_ | Stop after this many seconds |
132
+ | `VERBOSE` | _(empty)_ | Set to `1` for per-frame diagnostics in container logs |
133
+ | `LOG_EVENTS` | `1` | Log player joins/leaves, cart loads, input events |
134
+ | `WEBRTC_ENABLED` | `1` | Must be `1` — WebRTC is the only supported streaming mode |
135
+ | `WEBRTC_PORT` | `9002` | Port inside the container for the WebRTC server |
136
+ | `WEBRTC_HOST_PORT` | `9002` | Host-side port mapping for the WebRTC server |
137
+ | `MAX_SPECTATORS` | `10` | Max concurrent spectator connections (players are separate, see below) |
138
+ | `WEBRTC_MIN_BITRATE_KBPS` | `200` | VP8 SDP `x-google-min-bitrate` hint in kbps |
139
+ | `WEBRTC_MAX_BITRATE_KBPS` | `600` | VP8 SDP `x-google-max-bitrate` hint in kbps |
140
+ | `WEBRTC_OUTPUT_FPS` | `40` | Cap outgoing WebRTC video FPS (`0` disables cap) |
141
+ | `C64_ADMIN_TOKEN` | _(empty)_ | Shared token required by `c64-admin` (`status`, `kick`) |
142
+ | `WS_PORT` | `9001` | WebSocket input server port inside the container |
143
+ | `WS_HOST_PORT` | `9001` | Host-side port mapping for the input WebSocket |
142
144
 
143
145
  ### Admin CLI
144
146
 
@@ -244,12 +246,16 @@ let ready = false;
244
246
 
245
247
  function joystickPush(port, direction, fire) {
246
248
  if (!ready) return;
247
- ws.send(JSON.stringify({ type: 'joystick', action: 'push', joystickPort: port, direction, fire }));
249
+ ws.send(
250
+ JSON.stringify({ type: 'joystick', action: 'push', joystickPort: port, direction, fire }),
251
+ );
248
252
  }
249
253
 
250
254
  function joystickRelease(port, direction, fire) {
251
255
  if (!ready) return;
252
- ws.send(JSON.stringify({ type: 'joystick', action: 'release', joystickPort: port, direction, fire }));
256
+ ws.send(
257
+ JSON.stringify({ type: 'joystick', action: 'release', joystickPort: port, direction, fire }),
258
+ );
253
259
  }
254
260
 
255
261
  // --- lifecycle -------------------------------------------------------
@@ -278,9 +284,9 @@ import readline from 'readline';
278
284
  const rl = readline.createInterface({ input: process.stdin });
279
285
  rl.on('line', (line) => {
280
286
  const [action, direction] = line.trim().split(' ');
281
- if (action === 'push') joystickPush(2, direction);
287
+ if (action === 'push') joystickPush(2, direction);
282
288
  if (action === 'release') joystickRelease(2, direction);
283
- if (action === 'quit') ws.close();
289
+ if (action === 'quit') ws.close();
284
290
  });
285
291
  ```
286
292
 
@@ -316,20 +322,20 @@ document.addEventListener('keyup', (evt) => {
316
322
  import { InputBridge } from 'c64-ready/src/headless/input-bridge';
317
323
 
318
324
  // Encode a joystick push and release
319
- const push = InputBridge.encodeJoystick(2, 'push', 'right');
325
+ const push = InputBridge.encodeJoystick(2, 'push', 'right');
320
326
  const release = InputBridge.encodeJoystick(2, 'release', 'right');
321
327
 
322
328
  // Encode fire button
323
- const firePush = InputBridge.encodeJoystick(2, 'push', undefined, true);
329
+ const firePush = InputBridge.encodeJoystick(2, 'push', undefined, true);
324
330
  const fireRelease = InputBridge.encodeJoystick(2, 'release', undefined, true);
325
331
 
326
332
  // Encode a keypress
327
333
  const keyDown = InputBridge.encodeKeypress(65, 'down'); // 'A'
328
- const keyUp = InputBridge.encodeKeypress(65, 'up');
334
+ const keyUp = InputBridge.encodeKeypress(65, 'up');
329
335
 
330
336
  // Send push on button-down, release on button-up — never infer release from a timer
331
- gamepad.on('buttondown', (btn) => ws.send(InputBridge.encodeJoystick(2, 'push', btn.direction)));
332
- gamepad.on('buttonup', (btn) => ws.send(InputBridge.encodeJoystick(2, 'release', btn.direction)));
337
+ gamepad.on('buttondown', (btn) => ws.send(InputBridge.encodeJoystick(2, 'push', btn.direction)));
338
+ gamepad.on('buttonup', (btn) => ws.send(InputBridge.encodeJoystick(2, 'release', btn.direction)));
333
339
  ```
334
340
 
335
341
  ### Docker — enabling input
@@ -346,11 +352,11 @@ Then connect your client to `ws://localhost:9001`.
346
352
 
347
353
  `c64-ready` can be installed as a dependency and used in three ways:
348
354
 
349
- | Use-case | How |
350
- |---|---|
351
- | Run the browser player locally | `npx c64-ready` (zero config) |
352
- | TypeScript / Node API | `import` from sub-path exports |
353
- | Vite browser app | Copy or re-use `src/player/*` with your own Vite project |
355
+ | Use-case | How |
356
+ | ------------------------------ | -------------------------------------------------------- |
357
+ | Run the browser player locally | `npx c64-ready` (zero config) |
358
+ | TypeScript / Node API | `import` from sub-path exports |
359
+ | Vite browser app | Copy or re-use `src/player/*` with your own Vite project |
354
360
 
355
361
  ### Prerequisites
356
362
 
@@ -382,11 +388,11 @@ Open the URL printed to the terminal in any modern browser:
382
388
 
383
389
  **Options:**
384
390
 
385
- | Flag | Default | Description |
386
- |------|---------|-------------|
387
- | `--port <n>` | `5173` | HTTP port to listen on |
388
- | `--host` | localhost | Bind to `0.0.0.0` so the player is reachable on the local network |
389
- | `--help` | | Print usage |
391
+ | Flag | Default | Description |
392
+ | ------------ | --------- | ----------------------------------------------------------------- |
393
+ | `--port <n>` | `5173` | HTTP port to listen on |
394
+ | `--host` | localhost | Bind to `0.0.0.0` so the player is reachable on the local network |
395
+ | `--help` | | Print usage |
390
396
 
391
397
  ```zsh
392
398
  # Different port, accessible on the LAN
@@ -429,7 +435,7 @@ emulator.onFrame = (frame) => {
429
435
  };
430
436
 
431
437
  // Load a cartridge (.crt file bytes)
432
- const crtBytes = new Uint8Array(await fetch('/games/mygame.crt').then(r => r.arrayBuffer()));
438
+ const crtBytes = new Uint8Array(await fetch('/games/mygame.crt').then((r) => r.arrayBuffer()));
433
439
  emulator.loadGame({ type: 'crt', data: crtBytes });
434
440
 
435
441
  // Start the emulation loop
@@ -459,7 +465,7 @@ if (frame) {
459
465
 
460
466
  // Forward remote input from an external source (e.g. WebSocket message)
461
467
  headless.inputBridge.receiveRemoteInput(
462
- JSON.stringify({ type: 'joystick', action: 'push', joystickPort: 2, direction: 'up' })
468
+ JSON.stringify({ type: 'joystick', action: 'push', joystickPort: 2, direction: 'up' }),
463
469
  );
464
470
  ```
465
471
 
@@ -471,17 +477,17 @@ headless.inputBridge.receiveRemoteInput(
471
477
  import { InputBridge } from 'c64-ready/input-bridge';
472
478
 
473
479
  // Joystick
474
- const push = InputBridge.encodeJoystick(2, 'push', 'right');
480
+ const push = InputBridge.encodeJoystick(2, 'push', 'right');
475
481
  const release = InputBridge.encodeJoystick(2, 'release', 'right');
476
- const fire = InputBridge.encodeJoystick(2, 'push', undefined, true);
482
+ const fire = InputBridge.encodeJoystick(2, 'push', undefined, true);
477
483
 
478
484
  // Keyboard (C64 key code)
479
485
  const keyDown = InputBridge.encodeKeypress(65, 'down'); // key code 65 = 'A'
480
- const keyUp = InputBridge.encodeKeypress(65, 'up');
486
+ const keyUp = InputBridge.encodeKeypress(65, 'up');
481
487
 
482
488
  // Send via WebSocket — push on button-down, release on button-up
483
- gamepad.on('buttondown', (btn) => ws.send(InputBridge.encodeJoystick(2, 'push', btn.direction)));
484
- gamepad.on('buttonup', (btn) => ws.send(InputBridge.encodeJoystick(2, 'release', btn.direction)));
489
+ gamepad.on('buttondown', (btn) => ws.send(InputBridge.encodeJoystick(2, 'push', btn.direction)));
490
+ gamepad.on('buttonup', (btn) => ws.send(InputBridge.encodeJoystick(2, 'release', btn.direction)));
485
491
  ```
486
492
 
487
493
  ### Using the player in your own Vite app
@@ -492,14 +498,14 @@ Copy the files you need into your own Vite project and import them directly:
492
498
 
493
499
  ```ts
494
500
  // In your Vite project (TypeScript + Vite)
495
- import { C64Player } from './vendor/c64-ready/src/player/c64-player';
496
- import CanvasRenderer from './vendor/c64-ready/src/player/canvas-renderer';
497
- import { AudioEngine } from './vendor/c64-ready/src/player/audio-engine';
501
+ import { C64Player } from './vendor/c64-ready/src/player/c64-player';
502
+ import CanvasRenderer from './vendor/c64-ready/src/player/canvas-renderer';
503
+ import { AudioEngine } from './vendor/c64-ready/src/player/audio-engine';
498
504
 
499
505
  const renderer = new CanvasRenderer('c64-canvas');
500
- const player = new C64Player({
501
- wasmUrl: '/c64.wasm',
502
- gameUrl: '/games/mygame.crt',
506
+ const player = new C64Player({
507
+ wasmUrl: '/c64.wasm',
508
+ gameUrl: '/games/mygame.crt',
503
509
  renderer,
504
510
  });
505
511
 
@@ -519,6 +525,7 @@ npm run package:build
519
525
  ```
520
526
 
521
527
  This produces:
528
+
522
529
  - `dist/` — Vite browser bundle (served by `c64-ready` CLI)
523
530
  - `dist-ts/` — compiled JS + `.d.ts` declarations (imported by API consumers)
524
531
 
@@ -527,12 +534,13 @@ This produces:
527
534
  The project deploys to GitHub Pages automatically via GitHub Actions.
528
535
 
529
536
  On every push to `master`:
537
+
530
538
  1. Tests run (`npm test`)
531
539
  2. If tests pass, a production build is created (`npm run build`)
532
540
  3. The `dist/` output is deployed to GitHub Pages
533
541
 
534
-
535
542
  ## Work in Progress:
543
+
536
544
  - Proof of Concept Implementation:
537
545
  - [x] WASM module loading and initialization
538
546
  - [x] Emulator control and state management
@@ -568,14 +576,14 @@ git push origin master && git push --tags
568
576
 
569
577
  Extended documentation lives in the [`docs/`](docs/) folder:
570
578
 
571
- | File | Description |
572
- |------|-------------|
573
- | [`AUDIO_ENGINE.md`](docs/AUDIO_ENGINE.md) | SID audio pipeline, worklet pull-model, timing rules |
574
- | [`HEADLESS_INPUT.md`](docs/HEADLESS_INPUT.md) | Headless WebSocket input API reference |
575
- | [`HEADLESS_RUNNING.md`](docs/HEADLESS_RUNNING.md) | Headless CLI usage, frame/timing rules, ffmpeg integration |
576
- | [`PROJECT_OVERVIEW.md`](docs/PROJECT_OVERVIEW.md) | High-level architecture and design decisions |
577
- | [`CHANGELOG_RELEASES.md`](docs/CHANGELOG_RELEASES.md) | Release workflow, `tools/release.sh`, changelog generator |
578
- | [`WIKI_PUBLISHING.md`](docs/WIKI_PUBLISHING.md) | How to sync `docs/` to the GitHub wiki via `tools/publish_wiki.sh` |
579
+ | File | Description |
580
+ | ----------------------------------------------------- | ------------------------------------------------------------------ |
581
+ | [`AUDIO_ENGINE.md`](docs/AUDIO_ENGINE.md) | SID audio pipeline, worklet pull-model, timing rules |
582
+ | [`HEADLESS_INPUT.md`](docs/HEADLESS_INPUT.md) | Headless WebSocket input API reference |
583
+ | [`HEADLESS_RUNNING.md`](docs/HEADLESS_RUNNING.md) | Headless CLI usage, frame/timing rules, ffmpeg integration |
584
+ | [`PROJECT_OVERVIEW.md`](docs/PROJECT_OVERVIEW.md) | High-level architecture and design decisions |
585
+ | [`CHANGELOG_RELEASES.md`](docs/CHANGELOG_RELEASES.md) | Release workflow, `tools/release.sh`, changelog generator |
586
+ | [`WIKI_PUBLISHING.md`](docs/WIKI_PUBLISHING.md) | How to sync `docs/` to the GitHub wiki via `tools/publish_wiki.sh` |
579
587
 
580
588
  The wiki is kept in sync automatically by the `.github/workflows/publish_wiki.yml` CI workflow
581
589
  on every push to `master`. To publish manually:
package/bin/headless.mjs CHANGED
@@ -56,7 +56,7 @@ Options:
56
56
  --fps <n> Target frame rate (default: 50 for PAL)
57
57
  --webrtc Start a WebRTC streaming server (low-latency; replaces RTMP+flv.js)
58
58
  --webrtc-port <n> WebRTC signalling + player HTTP port (default: 9002)
59
- --max-spectators <n> Max concurrent spectator WebRTC connections (default: 3)
59
+ --max-spectators <n> Max concurrent spectator WebRTC connections (default: 10)
60
60
  Players count separately (up to 2), so total WebRTC peers = n+2.
61
61
  New connections beyond this limit receive { type: 'capacity-full' }.
62
62
  --webrtc-min-bitrate-kbps <n> VP8 SDP x-google-min-bitrate hint (default: 200)