7. @fleetmesh/arcade#
@fleetmesh/arcade implements the browser-side arcade runtime in TypeScript: a Game Boy (DMG-01) emulator, WASM-4 and NIP-5A nsite runtimes, an asset parser for uploaded cartridges and bundles, IndexedDB-backed SRAM persistence, score records, and Textile shard envelopes for ROMs, engines, and scores. Its host-side counterpart is Arcade Host Store (fleetmesh_protocols.arcade).
7.1. Installation#
npm install @fleetmesh/arcade@next
Runtime dependency: @fleetmesh/textile.
7.2. Emulation and Runtimes#
DmgSystem executes Game Boy ROMs across the SM83 CPU (gb/gbCpuSm83), memory management unit and bank controller (gb/gbMmu), and 160×144 scanline PPU (gb/gbPpu). Execution advances frame by frame via stepFrame using a DmgJoypadState input snapshot, and exportSaveState captures full machine state. Wasm4CartridgeRuntime executes WASM-4 cartridges, and buildNsiteSandboxDemoSrcDoc generates the sandboxed iframe srcdoc for NIP-5A nsite applications (with sanitizeBridgeTone bounding audio bridge requests from sandboxed content).
7.3. Cartridges and Assets#
verifyGbCartridgeBao(rom) validates the Game Boy header checksum and computes the ROM’s Bao root. parseUploadedArcadeAsset parses uploaded .gb/.gbc ROMs, WASM cartridges, and nsite bundles. buildValidGbRom generates valid ROM binaries for seeded titles (SEEDED_ARCADE_GAMES), and SEEDED_GRASP_ENGINES enumerates the seeded engines.
7.4. Saves and Scores#
saveArcadeSramToIdb and loadArcadeSramFromIdb persist cartridge SRAM in the browser’s IndexedDB through @fleetmesh/textile (falling back to in-memory storage when IndexedDB is unavailable), ensuring committed saves survive page reloads.
mintDeterministicTasReceipt records a score together with the Bao roots of the ROM and the joypad input log. Score records are currently unverified: deterministic replay verification is not yet implemented, so every record carries engine_profile: 'unverified', does not constitute a Nostr kind 30811 compute receipt, and loadTasReceiptsLeaderboard displays only submitted records without cryptographic proof of execution.
buildArcadeRomShard, buildArcadeEngineShard, and buildArcadeScoreShard package ROMs, engines, and scores into portable Textile shards.
7.5. Host Adapter#
configureArcadeHost registers offline blob storage callbacks (getOfflineBlob, putOfflineBlob, deleteOfflineBlob), offline index tracking, fetchRemoteArcadeBinary (which verifies downloaded host binaries against the expected Bao root and optional SHA-256 digest), host library and engine listings, and gitBaseUrl. When unconfigured, ROMs, engines, and saves persist to IndexedDB, remote binary fetches return empty results, and arcadeRepoUrl resolves only relative to the local host’s /git path.
7.6. Modules#
Module |
Contents |
|---|---|
|
Game Boy (DMG-01) emulator core. |
|
Game and score types, palettes, header validation, |
|
|
|
|
|
SRAM persistence, score records, leaderboard helpers, and the nsite iframe sandbox bridge. |
|
Textile shard builders for ROMs, engines, and scores. |
|
Seeded engines, artwork assets, and binary fibers. |
|
|