What the WebAssembly bundle exports to this site: the play runtime behind the play page, the standalone minigames page, the viewer pages and the ROM patcher. Nothing is uploaded - the disc image a visitor supplies is read in their browser.
legaia-web-play (the play runtime, over legaia-web-minigames, the minigames runtime) and legaia-web-patcher (the ROM patcher) under legaia-web-viewer (the inspectors and the tool bundle’s cdylib); legaia-web-play-bundle is the play bundle’s, which the play, minigames and modes pages load: two wasm bundleslegaia_engine_session::BootSession over the page’s audio output - the type the native window runstick_frame() calls the session’s tick in the native frame order and returns the scene a door just walked intoweb-play holds the play runtime, web-minigames the minigames runtime, web-patcher the ROM patcher, and web-viewer the inspectors; web-viewer depends on web-play and web-patcher, and web-play on web-minigames, never the reverse. wasm-bindgen collects the exports of every crate the bundle links, so which crate an export lives in is invisible to the site’s JavaScript.runtime is the simulation: load a disc, enter a field scene, set the pad word, set the camera azimuth so the D-pad remaps camera-relative, tick a frame, read state. It runs the ported field VM, free movement against the walkability grid, the NPC motion VMs and the dialogue runner.play is what the page draws: the assembled map, the lead’s mesh posed from the world’s live pose frame, and the scene’s placed NPCs at their live positions.The page hands each animation frame’s sim ticks to play_frame_ticks (runtime/frame_ticks.rs), which gives each tick to the owner BootSession::claim_tick names - the field, the pause menu, a shop or name entry - in the order the native window’s sim_tick uses. Menus, shops and name entry therefore step on the sim tick, not the display frame, and the whole frame body is compared state by state against the native window in engine-shell/tests/host_frame_parity.rs.
Much of a frame’s work has an answer nothing reads, since at a town’s camera most bodies are off screen. Outside PSX mode the page leaves out a draw wholly past the side of the clip volume, keeping the others in their order, and holds a posed actor or a morph’s mesh build until the camera or a light can reach it. The overlay canvas and the HUD’s text repaint only when what they show has changed. The picture stays the one the unconditional work gives, which the frame-hash oracle pins.
The map and NPC layers make the native window’s exact resolver calls. NPC clip playback runs in simulation-tick time - one clip player per placed slot, advanced once per tick - so cadence does not depend on the display’s refresh rate and scripted actors perform their cued beats.
| Module | Covers |
|---|---|
play_dialog | the retail dialog reading box |
play_cutscene / play_fmv | the opening prologue chain and the movie beats |
play_camera | the follow camera and the debug orbit |
play_menu | the retail pause menu |
play_battle, play_battle_render, play_battle_fx | live battles: rules tick, the 3D scene, effects |
play_shop | field merchants, the inn prompt, banners |
play_sfx / play_bgm / play_xa | sound effects, scene music, voice clips |
play_minigames, play_fishing | the in-world minigames reached through the scene’s own door warps |
boot_title, play_name_entry | the boot title screen and name entry |
session_save, cards | session saves and the two memory-card ports |
play_dev_menu | the retail developer menu, behind a session-only checkbox that is never persisted |
play_hotkeys | the native window’s option / cheat / camera keys, through the shared engine-session::hotkeys table |
No code on the page looks at the device, so on a GPU short of the defaults the page steps its own picture down. The decision is site/js/play-quality-ladder.js, with no GL, DOM or engine in it.
MSAA is not a rung: it is fixed when a context is created, and it is the smallest of the measured costs, so the context keeps it. ?autoquality=0 leaves the ladder unarmed. The native window has no ladder.
A capped page does not stall on a slow GPU the way an uncapped bench run does: the browser holds back requestAnimationFrame while frames are pending, so cost spreads evenly and the main thread stays free for the audio pump. Below 15 fps the world itself runs slow, since a display frame runs at most four ticks and drops the rest.
The play page and the native window are two framebuffers over one engine, and the failure that costs most is quiet: a screen is wired natively and the web host drifts behind with nothing in any diff to say so.
Every screen’s geometry is a draw-list builder in engine-ui, and a host has that screen exactly when it calls the builder. So the feature surface can be derived from source, and a gate fails when a builder reaches the native window but not this crate. One-host cases live in a waiver file, each with a reason, validated in both directions so it cannot decay into a stale list.
A screen can be fully wired and connected to nothing. The gate answers “does this host call the builder”; it cannot answer “does this host feed it the same model”. The options screen was drawn on both hosts with the gate green while one of them rebuilt its session from defaults on every open and dropped the result on close.
| Area | State against the native window |
|---|---|
| Seru-trade shop screens | closed: one shared composition |
| Options screen | closed: edits persist across reloads in localStorage, the browser twin of the native window’s legaia-options.toml |
| Inn prompt | closed |
| Load / Save rows | closed: both hosts browse two memory-card ports, each a mounted card image, through one card kernel and one slot summary |
| In-world minigames | closed: both hosts enter them from the scene’s door warps |
| Field music, effects, voice | closed |
| Memory-card containers | closed: the page imports every container the window mounts, RetroArch’s .srm included |
| Fullscreen keys | closed: F11 puts the picture full screen, as in the window |
| Bloom in the minigame venues | closed: the page tied bloom to the ground fog’s field-and-battle rule; the window blooms every scene |
| A pass the driver cannot build | closed: ambient occlusion, bloom or fog that cannot start on a browser says so, where it used to turn off silently |
| Movie sound before the engine’s output is up | closed in part: follows the volume slider and the sound switch, not yet the mono and mute options |
| Pixel-exact presentation | closed for PSX rasterisation: the page draws the 320x240 picture at the largest whole multiple of device pixels its layout offers, letterboxed, as the window does; the clean mode still stretches |
The play page reads a disc in three stages (js/play-disc.js), so a visitor is not waiting on movies they may never play and the wasm memory, which never shrinks, does not hold a whole image.
PROT.DAT in its root (a bare PROT.DAT, say) is read whole and goes to load_disc_image, as is a source with no Blob behind it.A consumer that polls every frame asks span(lba, sectors), which answers from what is resident or null, and prefetch on null; it installs on the first frame after the read lands. A window asked through prefetch is held until its consumer calls release, so eviction cannot take it between the read and the install. read is the form for a consumer that uses the bytes once and right away (the voice banks): it answers with the bytes themselves and keeps nothing.
span answers only from one block that covers the whole window. Neighbours are not stitched: a window across two blocks is read again, and the wider block replaces any it covers. What is left once released stays under RESIDENT_CAP, oldest use out first. The cap (32 MiB) holds the largest XA file beside the largest set of clips one scene reads ahead. A read landing with nobody waiting is dropped.
Movies. The window is read when the beat asks and dropped at the install, which copies it and demuxes once. The engine holds the world until then, bounded by INSTALL_TIMEOUT_FRAMES (600 ticks, wall time unless the page runs below about 15 fps), which is about 3 MB/s for MV1.STR. A read past it finishes the beat unplayed and the hand-off runs, as a page with no disc does.
Voice clips. A scene’s and a round’s likely lines are on play_xa_stage_requests_json before they are raised (prestage_xa_clip), so _serveXaStage reads every listed file ahead, widest span per file, and installs one row per frame, oldest first. A line whose row was served plays on the call that raises it. A line nothing listed is deferred: it plays when its row is served, a read and at least a frame after the request. Neither path reaches the simulation, which never reads the XA lane back. The listed lines are a scene’s op-0x36 clips and its minigame door’s announcer lines at scene load, a round’s at battle entry, and the scripted-scene voice line at its program’s seek-ahead, the vsyncs before that program starts it.
Failures. A read that fails is tried three times, a quarter of a second and half a second apart. Then the window is reported failed until its release: the movie finishes unplayed, the clip’s row is installed empty and dropped. The next ask reads again. Since the bytes are not in memory, a file moved or changed on disk during a session costs every movie and clip not yet read.
A trapped engine is rebuilt by reading the head again (recoverRuntime), which goes to the Blob and not through the cap, and the voice banks are read again the same way.
While a movie is up its overlay covers the GL view, and the frame skips its GL draws: the world is held, and every pass that reads the frame (bloom, fog, ambient occlusion, the transition capture) reads one drawn earlier in the same frame. The sync with the engine still runs each frame, and the 2D overlay is still drawn.
The frame where the transition hands over to a fight reads a lot off the disc, and all of it is known when the transition starts: the party, its equipment and the fight’s stage. So while the encounter sits in its transition, the page runs one step per frame of the scene host’s prewarm: the entries the edge reads, each member’s battle form, the stage’s resources.
The steps fill two memos and the disc index’s cache and write nothing else, so no frame or tick can see whether they ran. A key the edge then reads differently is a miss, and builds as it would have. Both hosts and the headless drivers go through the memos; only this page prewarms.
The touch pad (touch-pad.js) is an on-screen PSX pad over the picture: a D-pad, the four face buttons, the shoulders and Select / Start. On a phone held upright and out of fullscreen it sits in a band under the picture instead, where it covers neither the party’s HP readout nor the scene. It does not keep an input path of its own. Each pressed button is held through a virtual source in pad-bindings.js that joins the controller poll, so every reader of a controller press - the field tick, the menus, the title card - takes a touch press with no call site and no binding table of its own. The D-pad is one surface read by angle from its centre, with a dead zone in the middle and about a 45-degree wedge per diagonal, so a thumb rolls between directions without lifting. It shows by default where the only pointer is coarse (a phone or tablet), the Touch pad button toggles it on any device and remembers the choice, and hiding it releases whatever it held.
Checked headless. The controls step of scripts/ci/check-pages.mjs drives what only a browser has, on the built bundle: a file that is not the game is refused in words and the picker still takes the next one; on a touch-only device the pad is up, its D-pad walks the lead and lets go, START opens the pause menu and the first touch has brought sound up; a controller on the standard mapping walks by D-pad and by stick and opens and closes the menu on Start; Fullscreen presents the 4:3 picture at the screen’s height with the keyboard still on the canvas.
Copy report beside the disc picker puts on the clipboard what a bug report needs: the bundle’s version, the browser and GL renderer, the window, the input devices (pointer kind, touch points, whether the touch pad shows, each connected controller and its mapping), the disc file’s name and size, the engine’s state, the stored options and the page’s last warnings and errors. It holds no disc bytes.
The minigames page holds the play hosts’ AudioDirector over one WebAudioOut, opened inside a user gesture. A tab change is that game’s mode entry: the old game’s voices and armed cues go, and the new game’s banks stage as its door warp stages them. Every cue keys a live SPU voice, so its envelope, volume, pan, reverb send and closed-slot silence are the play hosts’; a disc test renders each cue against the director and requires the same samples, and a host-drift tier rejects a cue played as a decoded buffer. Only the BGM is a buffer, an offline render at the same unity gain.
.glb of a scene in the browser.Every module family with its exports, the parity tests, the texture-replacement registry and the long tail of helper modules are in docs/subsystems/browser-host.md.