agentleFS
Gzyms69Gzyms69/agent-setup-bundle/skills/skill-emulator-wasm/SKILL.md

skill-emulator-wasm

Skill0 starsChanged 3 months agoMITView on GitHub

WebAssembly emulation engineering, Emscripten runtime bridging, retro hardware simulation (CPU/RSP/RDP/APU), ROM header parsing, save state serialization, WebGL rendering, and Web Audio synchronization. Use when developing, analyzing, or debugging WebAssembly emulators, ROM managers, and retro gaming web platforms.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    HTML5 Gamepad API: Must be polled inside requestAnimationFrame using navigator.getGamepads().

    line 70
  2. Distinctive:

    Touch Controls: Use multi-touch virtual joysticks (e.g.

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

WebAssembly & Retro Emulation Engineering Skill

This skill provides architectural patterns, performance optimization, and operational guidelines for browser-based emulation, WebAssembly bridging, and ROM manipulation.


1. Emulator Architecture & Emscripten Bridge

Browser-based emulators (like N64Wasm, RetroArch WASM cores, Mupen64Plus-WASM) bridge compiled C/C++ core engines with browser subsystem APIs:

[ JavaScript / Web Frontend ]
   ├── Input Controller (Gamepad API, Keyboard, Touch/NippleJS)
   ├── Display Manager (WebGL / Canvas context binding)
   ├── Audio Subsystem (Web Audio API / ScriptProcessor / AudioWorklet)
   └── Persistence Layer (IndexedDB / LocalStorage / Cloud Saves)
             │
      Emscripten C-Bridge (`ccall`, `cwrap`, `Module._*`, `FS`)
             │
[ WebAssembly Core Engine (Compiled C/C++) ]
   ├── CPU Interpreter / Dynarec Recompiler
   ├── Reality Co-Processor (RSP / RDP Graphics Engine)
   ├── Memory-Mapped I/O & Memory Controller
   └── Save System (SRAM / FlashRAM / EEPROM 4k/16k / Save States)

2. ROM Header Parsing & Identification (Nintendo 64 Standard)

The first 64 bytes (0x00 - 0x3F) of any N64 ROM contain critical metadata:

Byte OffsetSize (Bytes)Field NameDescription
0x004Magic Number0x80371240 (Big Endian .z64), 0x37804012 (Byte Swapped .v64), 0x40123780 (Little Endian .n64)
0x044Clock RateClock rate seed
0x084Program CounterBoot entry address (default 0x80000400)
0x0C4Release AddressLibrary version
0x104CRC1Checksum 1 (boot verification)
0x144CRC2Checksum 2 (boot verification)
0x188ReservedUnused
0x2020Internal NameASCII title padded with spaces
0x344ReservedUnused
0x384Media FormatCartridge format code
0x3C2Cartridge IDGame ID (e.g. SM for Super Mario, ZL for Zelda)
0x3E1Country CodeE (USA), P (Europe), J (Japan), U (Australia), D (Germany), F (France)
0x3F1VersionROM revision version

3. Audio Synchronization & Rate Matching

Emulated retro consoles produce audio at non-standard sample rates (e.g., 32000Hz, 44100Hz, 48000Hz) tied to CPU cycles. Browser AudioContext typically operates at the hardware host rate (usually 44100Hz or 48000Hz).

  • Buffer Starvation / Underrun: Causes audio clicks, pops, and stutter.
  • Buffer Overflow / High Latency: Causes sound delay and video desync.
  • Dynamic Resampling: Monitor the audio ring buffer fill level. If the buffer is depleting, slightly slow down playback or duplicate samples; if overflowing, skip or interpolate samples to keep latency < 50ms.
  • Audio-to-Video Timing: Emulation frame loops (requestAnimationFrame) should be throttled by the audio buffer consumption to prevent video tearing or erratic speedups.

4. Input Polling & Virtual Controller

  1. HTML5 Gamepad API: Must be polled inside requestAnimationFrame using navigator.getGamepads(). Do not rely on event listeners for stick axes.
  2. Deadzone Filtering: Apply radial or axial deadzones (typically 0.15 - 0.20) to analog sticks to prevent stick drift.
  3. Touch Controls: Use multi-touch virtual joysticks (e.g. NippleJS) with decoupled canvas rendering to prevent blocking touch event processing.

5. Save Data Management & Integrity

  • EEPROM (512B or 2KB): 4Kbit or 16Kbit serial EEPROM used for lightweight saves.
  • SRAM (32KB): Battery-backed Static RAM (.sra).
  • FlashRAM (128KB): High-capacity flash memory (.fla).
  • Save States (.state): Full serialized snapshot of CPU registers, RDRAM, RSP/RDP status, and timer interrupts.
  • IndexedDB over LocalStorage: For ROM caching and save states (>5MB), always prefer IndexedDB over localStorage due to synchronous 5MB quota limitations.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.