# play-pce
The PC Engine family in the browser, for : HuCards (PC
Engine and TurboGrafx-16), SuperGrafx cards, and CD-ROM², Super CD-ROM² and Arcade
Card discs, in one page. Nothing is included: the visitor chooses a game of their own
(a `.pce`, or a `.zip` or `.7z` holding one; or a disc's `.cue` with its `.bin` files)
and it is read on their device and never uploaded. HuCards, backup RAM, save states,
per-game settings and the System Card are kept in the browser (IndexedDB); discs are
read where they are and never kept.
The machines are three Rust boards, unchanged, behind one thin wasm-bindgen surface
(`src/lib.rs`): [pcengine-rust](../pcengine-rust) (the base board),
[supergrafx-rust](../supergrafx-rust) (two VDCs and the VPC) and
[pcenginecd-rust](../pcenginecd-rust) (the System Card's RAM, the CD unit, ADPCM, the
Arcade Card). Each is held bus cycle for bus cycle, picture for picture and sample for
sample to its Python reference board. All three give a `pcengine_rust::system::System`,
so one `Console` wraps them all. The page is [play-nes](../play-nes)'s (itself
play-2600's and play-md's): the same bar, chooser, round 8-way touch pad, phone
landscape with the controls over the picture, fullscreen, add to home screen, audio
worklet, run-ahead and rewind.
## What it runs
| What | How it is chosen | Machine |
| --- | --- | --- |
| HuCard | a `.pce` (or `.sgx`), or the one card in a `.zip` or `.7z` | TurboGrafx-16 if the name says "(USA)" (the card reads the region bit), else PC Engine; Settings overrides per game |
| SuperGrafx card | the same | the board's `is_supergrafx_card`: the five cards sold for it (by SHA-1) or a `.sgx` name; Settings can run any card "as SuperGrafx" (other dumps, the two Darius cards) and has the back-panel switch (PC Engine position), which moves while the game runs |
| CD-ROM², Super CD-ROM², Arcade CD-ROM² | the `.cue` and every file it names, chosen together: several files selected at once, a folder (Choose a CD's folder, or dropped), one `.bin` or one a track; `.wav` tracks are read too | a PC Engine with the visitor's System Card (256 KiB is a Super System Card); a TurboGrafx-16 with a US card if Settings says so |
| Arcade Card | Settings, per disc: when the disc needs it / fitted / not fitted | "needs it" is a dozen title words in `src/lib.rs` (the discs sold as Arcade CD-ROM²: Ryuuko no Ken, Mad Stalker, Sapphire, ...), matched against the cue's name; nothing else is known about any title |
| Tennokoe Bank | a card whose name (or its archive's) says "Tennokoe Bank" | its 8 KiB of backup RAM is kept per card. There is no dump of it here: the card type and its RAM were exercised with another card under that name |
**The System Card is bring-your-own.** A disc chosen before there is one makes the
page ask; the card is kept on the device (IndexedDB), the disc starts by itself once
it is chosen, and Settings replaces it. Super System Card 3.0 runs everything.
**CHD is not read.** pcenginecd-rust reads bin/cue only. A dropped `.chd` gets the
conversion line: `chdman extractcd -i game.chd -o game.cue -ob game.bin`. A reader could
be added: the [`chd`](https://crates.io/crates/chd) crate (0.4.0, BSD-3-Clause, pure
Rust, CD codecs) reads hunks from anything `Read + Seek`, which the disc reader below
could be made to be; it was not added here because its dependency tree has not been
audited and a CHD's hunks are compressed, so every seek would unpack inside a frame.
No title database is built in (none with a clear permissive licence was needed): file
names and settings decide, as above. A wrong dump or a renamed file is set right in
Settings.
## Discs: the console runs in a Web Worker
A disc is 200 to 800 MiB and pcenginecd-rust reads sectors **synchronously**
(`SectorSource::read_sector`, from inside a CPU instruction). The disc is never copied
into memory, wasm's or the page's. The design:
- **The console lives in a Web Worker** (`web/worker.js`), for every game, not only
discs: one path, not two. A worker is the one place a browser lets code wait for a
file: `FileReaderSync.readAsArrayBuffer(file.slice(offset, offset + 65536))`. The
page hands the worker the `File` objects the visitor chose (handles, not bytes);
wasm gets one JavaScript function, `(file, offset, length) -> Uint8Array`, and
`src/lib.rs` wraps it as the CD crate's `ImageReader` behind a small cache: the last
24 blocks of 64 KiB (1.5 MiB).
- **The drive is read ahead of, between frames.** A read inside a frame costs that
frame the file's latency. So after each frame the worker calls `Console::read_ahead`,
which fetches (a) the sector a READ command has named while the drive is still
seeking to it (the board's seek model takes many frames), (b) the sector CD audio is
about to start from, and (c) the block after the one the drive is in. On the test
discs every read then falls between frames (see the numbers), on a pool of spinning
disks where one read takes up to 27 ms.
- **The sound goes from the worker straight to the AudioWorklet** over a
`MessagePort` the page hands over once, so it never waits for the page's thread.
The picture goes back to the page as a transferred buffer (and the buffer of the
picture before it is handed back for reuse), drawn when it arrives, which is before
the next display refresh, as when the console ran on the page's thread.
- The page keeps time as play-nes does (frames owed by the clock, at most four at
once), asks for frames one request at a time at the display's tick, and asks again at
once when a reply comes back after a tick has passed, so a slow frame costs one tick.
Why not the other design the brief names (the console on the page's thread, with a
cache the page fills ahead of the drive): a page cannot wait for a file, so the first
read after a seek to somewhere not predicted has no answer when the board asks; the
frame would have to be thrown away and run again from a snapshot once the bytes
arrived, and the sound would break there. A worker needs none of that, uses only what
Firefox and Safari (iOS included) also have (module workers, `FileReaderSync` on a
`File` slice, a `MessagePort` into a worklet; no `SharedArrayBuffer`, so no
cross-origin isolation headers; only Chromium has been run, see "Not here"), and
keeps a board that takes 5 to 9 ms a frame off the page's thread. What it costs: the
pads and the picture cross a `postMessage` each way (well under a millisecond).
The sound sink (`web/audio-worklet.js`) is play-nes's with two changes this board
needed. Its queue starts 80 ms deep and deepens by half each time the sound runs dry
(to 200 ms at most), so a device that stalls now and then gets one click, not one each
stall; and it is held at its depth by playing a block half a percent fast or slow when
it is well off (straight lines between samples), not by dropping sound, because the
page's clock and the sound card's are two clocks and a CD's music shows a dropped
150 ms. At its depth the samples go out exactly as they came. The context runs at the
board's 44.1 kHz where the browser allows it (all current ones do); otherwise the
console resamples by straight lines.
A disc is known between visits by its files' sizes and three samples of the first
file (`discId` in `web/app.js`), so its settings and save states are found again
without reading it through. The games list shows it marked CD; choosing it asks for
its files again.
## Picture, sound, input
- **Picture.** The board gives 242 rows of 9-bit colours, each row the whole 1365
clocks of its line at the dot clock that line had (341, 455 or 682 dots). The page
shows 1152 clocks from clock 32: 288, 384 or 576 dots, each row scaled to the frame's
finest dot clock, at 4:3. A 256-dot picture sits at dots 16-271 of 288 and its 239
lines at rows 3-241 (measured on ten cards, and again on thirteen cards after the boards'
clean rewrite of 2026-11-19, which starts the picture 8 dots earlier in the row: dot 24
of the row at the 5 MHz clock, not 32; the view moved from clock 64 to clock 32 with it,
so HuCard and CD pictures sit where they did. A 7 MHz picture such as Daimakaimura's
moved about 3 dots right of where it was and still fits whole). Settings: hide the overscan (the middle
224 lines and 8/9 of the width), smooth scaling, scanlines. Colours are the board's
own linear 3-bit table (there is no standard conversion).
- **Sound.** `take_audio()` (PSG, CD audio and ADPCM already mixed, 44.1 kHz stereo)
once a frame; the page paces by the length each frame really had (262 or 263 lines,
as the game sets the VCE), not by a nominal rate.
- **Input.** Keyboard: arrows, Z and X (or J, K) for II and I, Right Shift (or Tab)
Select, Enter Run, Q and W turbo II and I, C A S D for III-VI. Controllers by the
standard mapping's positions: bottom II, right I, Select and Start; with the 2-button
pad the left and top buttons are the turbo switches, with the 6-button pad they are
III and IV and the shoulders V and VI; an unmapped pad's hat-switch d-pad (Firefox on
Windows) is read as play-nes reads it; the right stick pressed (R3) pauses. Page keys:
F5/F7 save/load, F8 next slot, F9 sound on and off, P or Pause pause, R or Backspace
held rewind (a controller's left trigger, or the bar's rewind button held, too; see
"Rewind"). Touch: a round
8-way d-pad, II, I, Select, Run, and III-VI when the 6-button pad is chosen; Settings can
buzz on each touch press (Android; off at first). The controls are the family's
(emulator-lineage `docs/proposals/2026-11-play-controls.md`): `web/controls.js` is a copy
of play-nes's, its second line naming the play-nes commit, checked by play-nes's
`scripts/controls-drift.sh`. Settings per game: 2 or 6 buttons, and the
multitap (controllers 2 to 5 are players 2 to 5). Turbo presses on two frames of four,
by the console's own frame counter. The machine has no reset button; the bar has
power off-and-on.
- **Run-ahead** (Settings: Off, 1 or 2 frames, off by default; 3 was dropped, as on the
other sites, and a stored 3 reads as 2): the snapshot pair, as play-nes's
`run-ahead` branch. If the console cannot keep time with it (an Arcade Card disc's
snapshot is 2 MiB a frame), the page gives a frame of it up until the game restarts,
and says so.
## Rewind
Hold R or Backspace, a controller's left trigger, or the bar's rewind button (a finger or
the mouse): each frame held is a step back of four frames, so the game goes back at four
times its speed, with no sound; let go and it plays on from there. The window is about a
minute (900 steps) unless it reaches 48 MiB first. It is play-nes's rewind (the same
`controls.js` sources, the same interval, count and budget, the same silence), with two
differences, both *provisional*:
- **The snapshots are the board's own** `state::save_snapshot`/`load_snapshot` (bincode of
the save state's body: no header, no check, no compression; what run-ahead uses),
exported by `src/lib.rs` as `save_snapshot`/`load_snapshot` beside the ring
(`rewind_step`, `rewind_seconds`, `rewind_memory`, `rewind_count`, `set_rewind`). The
boards are unchanged. A snapshot is the whole machine, the CD unit's included: the SCSI
bus and the drive's head and seek, the CD audio player, the ADPCM unit and its RAM, the
fader, the System Card's RAM, the Arcade Card's 2 MiB, backup RAM. Left out are only the
wiring (the disc itself, switches) and callback queues that are empty between frames.
So rewinding also rewinds backup RAM, as loading a save state does, and the page then
keeps the machine's backup RAM as it is after the rewind. **For players: rewinding past
a game's own save undoes that save** (on a CD, in the backup RAM every game shares).
- **The window is kept as reverse deltas**, not as whole snapshots deflated (play-nes's
way): the newest snapshot as it is, and each older one as the deflated XOR with the one
after it, block by block (4 KiB), each block lined up with the newer snapshot from its
start or from its end, whichever matches better, because the board's sound buffers change
a snapshot's length by a few bytes and move what follows. Deflated whole, a CD game's
snapshot was about 230 KiB (48 MiB held 14 s) and an Arcade Card game's in play about
1.6 MiB (2 s); as deltas they are a few KiB to a few tens of KiB (`Rewind` in
`src/lib.rs`; `scripts/test-native.sh` runs its three tests).
`scripts/check-rewind.mjs` (Node) times the snapshot pair, times a frame with run-ahead 2
with rewind's snapshots kept and without (two consoles in lockstep, taking turns to go
first), measures the window, and checks that a rewind is exact: a console run to frame N
and stepped back S times is in the plain run's state at frame N - 4(S - 1), and from there
runs on as the plain run did (the sound of every frame, the save state 220 to 356 frames
on). On a disc it chooses its rewinds to cross the first READ, CD audio seek, CD audio and
ADPCM playback of the plain run, and says which each crossed.
Numbers (2026-11-23, this machine while other sessions kept it busy, load average 15 to 20;
the fast board 14251c2; 1,800 frames for the cards, 3,600 for the discs; every rewind exact):
| | Snapshot | save / load_snapshot | Window: per step, full | A frame at run-ahead 2, rewind off / on (the frames that keep one) | A step back |
| --- | --- | --- | --- | --- | --- |
| Blazing Lazers | 241 KiB | 0.19 / 0.22 ms | 15 KiB; 60 s in 14 MiB | 3.20 / 3.36 ms (3.82) | 0.7 ms |
| Daimakaimura (SuperGrafx) | 384 KiB | 0.30 / 0.35 ms | 17 KiB; 60 s in 15 MiB | 6.15 / 6.37 ms (6.95) | 1.1 ms |
| Gate of Thunder (Super CD) | 569 KiB | 0.57 / 0.68 ms | 33 KiB; 60 s in 29 MiB | 12.41 / 12.76 ms (14.07) | 1.3-1.5 ms |
| Ryuuko no Ken (Arcade Card) | 2,617 KiB | 4.4 / 4.7 ms | 89 KiB; 36 s in 48 MiB | 20.69 / 22.97 ms (29.87) | 9-20 ms |
(The window's figure per step counts the newest snapshot, kept whole, spread over the
steps.) Rewind costs a frame 0.2 to 0.35 ms on average on the cards and Gate of Thunder,
well inside the frame with run-ahead 2. The Arcade Card is the exception: its snapshot alone
takes the board 4.4 ms each way, so rewind adds about 2.3 ms a frame on average and 9 ms on
the frames that keep one, and a step back costs up to a frame. Run-ahead 2 does not fit on
that disc with or without rewind (the page already gives frames of it up there), and
rewinding there may go back at less than four times speed. Run again on the committed code
(003d7bf, load average about 10), under the check's rule (rewind must not be what breaks a
frame that fitted, and must cost under a quarter of a frame on average), it passed: 1.79 ms
a frame on average, a step back 6-9 ms, every rewind exact. So the Arcade Card keeps the
one rule, a snapshot every 4 frames; an 8-frame interval for it alone was not needed.
`check-browser.mjs` checks the page's side: R held for 1.5 s steps back about 90 times, the
window shrinks, the bar's button lights, no sound is sent while held and none runs dry
after (the worklet's queue is emptied when rewinding starts, as on pause, so the silence is
not counted as the sound running dry); Backspace, the bar's button under the mouse, a
controller's left trigger and a finger on the bar's button each rewind too. In the page, with
run-ahead 2 on Gate of Thunder, the build before rewind and the build with it, run in turn
twice under the same load (load average about 20): both held 59.6 to 60.0 frames a second
over 20 s with no underrun (two and one underruns while settling, before and with rewind);
the worker's frames took 14 to 15 ms.
## What is kept (IndexedDB, database `play-pce`)
| Key | What |
| --- | --- |
| `syscard` | the System Card image and its file name |
| `bram:cd` | the CD unit's 2 KiB of backup RAM: **one store for every game**, as on the machine. Sent to the page about a second after a game writes it; Settings exports it (`play-pce-backup-ram.brm`, the raw 2,048 bytes) and imports one (into the running machine too) |
| `backup:` | a Tennokoe Bank card's 8 KiB |
| `state::` | save states, four slots a game (F5 saves, F7 loads, F8 or the bar's slot button changes slot), each with when, on what machine and with which disc |
| `rom:`, `recent` | the last twelve games; a HuCard's bytes are kept, a disc is listed but not kept |
A save state is the board's own. Since the boards' clean rewrite (2026-11-19) its format
is version 3, and states of versions 1 and 2 (any kept by an earlier build of this page)
are refused by the board with the machine untouched; the page then empties that slot and
says so, rather than offering it again. Rewind's window lives in the worker's memory only
and is not kept (see "Rewind"). A save state holds the machine, not the media: a CD state names
its disc (by its table of contents) and loads only with the same disc chosen again and
the machine set up the same way (the Arcade Card, the pad); the page says which when
the board refuses one. Per-game settings are in `localStorage`. "Forget everything"
clears it all.
HuCard games that save need backup RAM on the expansion port. Settings has "Backup RAM
unit" per card: the CD unit with no disc on the port (`PcEngineCd::make_unit`), sharing
`bram:cd`. Cards boot the same with it (checked); no game's own save has been driven
through it yet.
## The pins (2026-11-20): by git revision
The boards of the clean rewrite of 2026-11-19 come by git revision from GitHub (by path
from sibling clones until Aubrey pushed them on 2026-11-20):
| Crate | Revision | Brings |
| --- | --- | --- |
| pcengine-rust | 8f672f0 (37f17ba's code, plus its git pin of the core) | the board the add-ons name; replaced by the fork in the build |
| huc6280-rust | e1d24a3 (by pcengine-rust's pin) | pcengine-rust's core; not linked in the fast build |
| supergrafx-rust | 01bf58e (40950c1's code, pinned by git) | the SuperGrafx (window origin {4:24, 3:38, 2:24}) |
| pcenginecd-rust | 9a2f106 (3d75dd7's code, pinned by git) | the CD unit (the clean SCSI) |
| pcengine-rust-fast | a checkout (BOARD, default `../pcengine-rust-fast`; 0ac2d97 for the build of 2026-11-20) | the base board the site links (below) |
| huc6280-rust-fast | 73f0829 (by pcengine-rust-fast's pin) | the clean CPU core, under the fast board |
To build against local checkouts of the add-ons or the base board instead, without editing
`Cargo.toml`, pass cargo a patch, e.g.
`--config 'patch."https://github.com/alewman/supergrafx-rust".supergrafx-rust.path="../supergrafx-rust"'`.
`dist/version.json` names the base board's checkout and commit and the add-ons' pinned revisions.
pcenginecd-rust 3d75dd7 keeps the READ's counters private (its new `scsi.rs`), so the read
ahead of a seeking drive (`read_pending` in `src/lib.rs`) is worked out from the bus's
public command block, phase and head. On Gate of Thunder it still leaves no read inside a
frame (65 between frames over 30 s).
## Switching the base board
`Cargo.toml` names the three boards by git revision. The base board is meant to be swapped for its speed fork (`../pcengine-rust-fast`: the same
library name and API) for this crate and both add-ons at once:
```text
BOARD=../pcengine-rust-fast scripts/build-dist.sh
```
One path. Under it is `scripts/stage-board.sh`, a detour that should go: cargo
replaces a package (`[patch]`, or a `paths` override) only by one with the **same
package name**. The add-ons ask
for the package `pcengine-rust`; the fork's package is `pcengine-rust-fast`. So the
script copies the fork's manifest to `target/board` with that one name changed and its
sources beside it, and the build passes `--config 'paths=["target/board"]'`. If the
fork's `[package] name` becomes `pcengine-rust` (its directory and repository can keep
their names), the switch is `paths = ["../pcengine-rust-fast"]` in `.cargo/config.toml`
and nothing else (or a `[patch."https://github.com/alewman/pcengine-rust"]` entry, now that
the boards are pinned by git revision). `dist/version.json` says which checkout and
revisions a build came from.
Since the clean rewrite the fork's core is huc6280-rust-fast where pcengine-rust's is
huc6280-rust, so cargo warns (hidden by the build's `-q`) that the `paths` override "has
altered the original list of dependencies" and that this will one day be an error. It
builds and links only the fast core today (checked in the build's dependency files:
`../huc6280-rust-fast/src`, and no huc6280-rust in `cargo tree`). Whether the `[patch]`
entry above avoids the warning has not been tried.
Built against the fork as it stood on 2026-11-12 (6d90c0e with work in progress), the
same Node bench gives 16.9 times real time on a HuCard and 10.7 on a SuperGrafx card
where the reference boards give 4.1 and 2.7; a disc stays at 3.5 (the CD unit's
`catch_up` every CPU cycle).
## Build, check, deploy
```text
scripts/build-dist.sh # wasm (toolchain 1.93.1, wasm-bindgen 0.2.128, wasm-opt) -> dist/
CARD=game.7z SGX=card.7z CUE=disc.cue SYSCARD=syscard3.pce node scripts/bench-node.mjs
CARD=game.7z SGX=card.7z CUE=disc.cue SYSCARD=syscard3.pce node scripts/check-browser.mjs
CARD=game.7z node scripts/check-run-ahead.mjs # or CUE=... SYSCARD=...
CARD=game.7z node scripts/check-rewind.mjs # or CUE=... SYSCARD=... [ARCADE=on]
scripts/test-native.sh # the crate's Rust tests (the rewind window), natively
scripts/deploy.sh # dist/ -> /docker/appdata/play-pce, nginx behind Traefik
```
`scripts/build-dist.sh` also writes `web/notices.html` (`scripts/notices.py`, after the
wasm, from the tree build-wasm.sh resolved): every component the wasm is built from, its
licence, and its LICENSE and NOTICE files and the licence notices kept in its sources,
verbatim (the cores' MAME BSD-3 notices among them; ares, ISC, is cited in them for facts
only, no code, so it owes no notice), linked from the
start panel and Settings, About. The staged board's files are read from the checkout it was
staged from (`target/board.path`). It stops the build when a family crate has no LICENSE file.
The site includes no games; `notices/games.json` says so, and the build stops if a game is
added to `web/games/` without an entry there.
Each script takes what it is given and skips the rest. `check-browser.mjs` drives the
page in headless Chromium over the DevTools protocol: it feeds the files to the file
inputs (the disc first without a System Card, to see the page ask), lets the game
settle, measures for a while with RUN and I pressed now and then, and checks the frame
rate held, the worklet's underruns and overruns, the picture, the disc's reads, a save
state saved and loaded (the machine's state compared), backup RAM kept across a
reload, the same state loaded after the reload with the disc chosen again; then the
games list, a `.chd`, Settings, the phone layouts, the d-pad's eight slices and two
buttons under two fingers. It first prints how much the machine it runs on stalls a
small paced job, because that decides how its sound numbers read.
The wasm is 759,831 bytes after `wasm-opt -O3` (908,685 before; 2026-11-23, with rewind:
10.6 KB more); `dist/` is twelve files.
### Numbers (2026-11-19, the fast board on the clean rewrite, this machine)
`check-browser.mjs` (headless Chromium 141, `dist/` as built from the pins above; cards
measured for 12 s, the disc for 30 s; every check passed, including the new one: a state
of format version 2 put in slot 2 is refused, the slot emptied, the game runs on):
| | Frames a second held | A frame in the worker, mean (worst) | Underruns, overruns | Disc reads inside / between frames | Save state back |
| --- | --- | --- | --- | --- | --- |
| Blazing Lazers | 59.81 | 1.38 ms (2.6) | 0, 0 | | identical |
| Daimakaimura (SuperGrafx) | 59.79 | 2.60 ms (4.3) | 0, 0 | | identical |
| Gate of Thunder (Super CD) | 59.85 | 3.73 ms (36.3) | 0, 0 | 0 / 65; 4.1 of 508 MiB | identical, and after a reload |
| Blazing Lazers, run-ahead 1 | 59.81 | 2.26 ms (4.3) | 0, 0 | | identical |
| Daimakaimura, run-ahead 1 | 59.82 | 3.62 ms (7.2) | 0, 0 | | identical |
`check-run-ahead.mjs` (Node): sound, end state and picture as the plain run's at every
depth tried; a frame at 0/1/2/3 ahead takes 0.98/2.20/2.95/3.93 ms on Blazing Lazers,
1.55/3.58/5.11/6.50 ms on Daimakaimura, and 4.50/10.14/15.21 ms (0/1/2) on Gate of Thunder.
### Numbers (2026-11-12, the reference boards, this machine)
`bench-node.mjs`, 3,600 frames from power-on with RUN and I pressed now and then
(one core; real time is 59.83 frames a second):
| | Frames a second | Times real time | Disc read |
| --- | --- | --- | --- |
| HuCard: Blazing Lazers (USA), TurboGrafx-16 | 243.0 | 4.06 | |
| SuperGrafx: Daimakaimura | 155.7 | 2.60 | |
| Disc: Ryuuko no Ken, Arcade Card, 464 MiB | 191.1 | 3.19 | 9.3 MiB in 149 reads |
| Disc: Mad Stalker, Arcade Card, 586 MiB | 188.7 | 3.17 | 5.6 MiB in 90 reads |
| Disc: Gate of Thunder (USA), Super CD, 508 MiB | 169.5 | 2.83 | 9.1 MiB in 145 reads |
`check-browser.mjs` (headless Chromium 141, the page from `dist/`; cards measured for
20 s and discs for 60 s after 6 s of settling; every check passed in every run):
| | Frames a second held (the machine's: 59.83) | A frame in the worker, mean (worst) | Sound: underruns, overruns | Disc reads inside a frame / between frames | Save state back | Backup RAM after a reload |
| --- | --- | --- | --- | --- | --- | --- |
| Blazing Lazers | 59.85 | 3.82 ms (7.6) | 0, 0 in 20.0 s | | identical | |
| Daimakaimura (SuperGrafx) | 59.88 | 6.62 ms (15.8) | 0, 0 in 20.0 s | | identical | |
| Ryuuko no Ken (Arcade Card) | 59.75 | 6.17 ms (77.4) | 0, 0 in 60.0 s | 1 (0.7 ms) / 143 (worst 23.0 ms); 9.0 of 464 MiB | identical, 1.6 MiB | the same bytes |
| Mad Stalker (Arcade Card) | 59.80 | 5.24 ms (37.4) | 0, 0 in 60.0 s | 0 / 71 (worst 17.7 ms); 4.4 of 586 MiB | identical | the same bytes |
| Gate of Thunder (Super CD) | 59.83 | 5.80 ms (37.7) | 0, 0 in 60.0 s | 0 / 134 (worst 28.2 ms); 8.4 of 508 MiB | identical | the same bytes |
| Blazing Lazers, run-ahead 1 | 59.63 | 7.64 ms (86.1) | 0, 0 in 20.0 s | | identical | |
The page's heap stays at 10 MiB with a disc in. A disc cut into one file a track (32
files, chosen together) gives byte-identical save states to the one-file disc after
2,400 frames, and passes the same browser check. The picture is 288 dots wide on the
HuCard, 384 on Daimakaimura and on Ryuuko no Ken's title, by the games' dot clocks.
**About the worst frames.** This machine (a 13900K under other load, `powersave`
governor) stalls a paced job by itself: the check's own probe, 3 ms of arithmetic
every 16.7 ms with no browser, took up to 31.6 and 41.6 ms in two of these runs, about
every two seconds, and the same frames run flat out under Node never pass 13 ms. The
worst frames above are those stalls, and the files are on spinning disks (reads of up
to 28 ms). That is what the 80 ms queue and the reads between frames are for; with the
play-nes sink as it was (50 ms, no read-ahead) the same runs gave one to three
underruns each.
`check-run-ahead.mjs` (Node; 600 frames for the cards, 900 for the discs; in every
row the sound of every frame and the end state are identical to the plain run's, and
the picture is the plain run's so many frames later wherever the buttons held):
| | Plain | 1 ahead | 2 ahead | 3 ahead |
| --- | --- | --- | --- | --- |
| Blazing Lazers | 4.06 ms | 8.01 ms (48% of a frame) | 13.39 (80%) | 17.39 (104%) |
| Daimakaimura | 5.95 ms | 13.16 (79%) | 18.96 (113%) | 24.13 (144%) |
| Gate of Thunder | 7.42 ms | 12.60 (75%) | 19.85 (119%) | |
| Ryuuko no Ken (Arcade Card) | 5.18 ms | 20.14 (121%) | 31.87 (191%) | |
Run-ahead is correct everywhere and affordable at one frame on this desktop except
with the Arcade Card, whose snapshot (2 MiB of card RAM through `bincode`, saved and
loaded every frame) costs about 10 ms by itself.
## Dependencies and their licences
No GPL or LGPL code, in the page or under it. The page's JavaScript, CSS, HTML and
icon are this repository's (the page from play-nes, MIT, ours). The Rust crates the
wasm is built from (`cargo tree --target wasm32-unknown-unknown`):
| Crate | Licence | For |
| --- | --- | --- |
| pcengine-rust, supergrafx-rust, pcenginecd-rust, huc6280-rust, sixfiveohtwo (6502-rust) | MIT (ours) | the boards and the CPU |
| wasm-bindgen 0.2.128 (with -macro, -macro-support, -shared), js-sys | MIT OR Apache-2.0 | the JavaScript boundary; the disc reader function |
| zip 2.6 | MIT | cards in a `.zip` |
| sevenz-rust2 0.24.0, lzma-rust2 | Apache-2.0 | cards in a `.7z` |
| flate2, miniz_oxide, adler2, crc32fast, simd-adler32, zopfli | MIT OR Apache-2.0 (miniz_oxide also Zlib, adler2 also 0BSD, simd-adler32 MIT, zopfli Apache-2.0) | deflate: zip, and the boards' save states |
| serde, serde_core, serde_derive, serde_json, bincode, itoa, zmij, memchr | MIT OR Apache-2.0 (bincode and zmij MIT, memchr Unlicense OR MIT) | the boards' save states |
| sha1, digest, block-buffer, crypto-common, generic-array, typenum, cfg-if | MIT OR Apache-2.0 (generic-array MIT) | card and disc identity |
| indexmap, hashbrown, equivalent, log, once_cell, bumpalo, slab, pin-project-lite, futures-core, futures-task, futures-util | MIT OR Apache-2.0 (slab MIT) | carried by zip, sevenz-rust2 and wasm-bindgen |
| proc-macro2, quote, syn, unicode-ident, rustversion, version_check | MIT OR Apache-2.0 (unicode-ident also Unicode-3.0) | build time only |
Tools, not shipped: Rust 1.93.1, wasm-bindgen-cli 0.2.128 (MIT OR Apache-2.0),
Binaryen's `wasm-opt` (Apache-2.0); for the checks Node and Playwright's headless
Chromium.
## Not here
- CHD (above). `.iso` data tracks (the CD crate takes `MODE1/2352` and `AUDIO`), `PREGAP`
lines, compressed audio tracks.
- Discs are not remembered: a File System Access handle kept in IndexedDB would let
Chrome reopen one with a click; iOS has no such thing.
- A reset button (the machine has none), palettes other than the linear one, the
Populous card's RAM between visits (it is not battery RAM), the SuperGrafx with a CD
unit, more than one System Card kept.
- Any browser but headless Chromium 141, and any real phone: the layouts and the touch
pad are checked under Chromium's phone emulation only.
- Speed on a phone: the reference boards run about 3 to 4 times real time under Node
on a desktop core. That is the speed fork's job (one path, above).
## Licence
MIT (see `LICENSE`). No cards, System Card, discs, artwork or NEC or Hudson marks are
included.