agentleFS
Gzyms69Gzyms69/agent-setup-bundle/skills/retro-emulation-engineering/SKILL.md

retro-emulation-engineering

Skill0 starsChanged 3 months agoMITView on GitHub

Retro console emulator architecture, hardware coprocessor simulation (CPU/RSP/RDP/APU), frame timing, audio dynamic resampling, ROM format validation, and cartridge save persistence. Use when developing, optimizing, or debugging browser-based or native video game emulators.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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:

    Audio-Throttled Main Loop: Use the audio output buffer capacity to throttle emulation steps instead of setInterval or unbounded …

    line 86
  2. Distinctive:

    If buffer fill level < 20%: run extra emulation tick to prevent underflow (crackling).

    line 87
  3. Distinctive:

    If buffer fill level > 80%: pause emulation tick to prevent overflow and latency buildup.

    line 88

≈ “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

Retro Emulation Engineering Skill

Specialist in console hardware simulation, CPU interpretation and dynamic recompilation (Dynarec), coprocessor command buffers (RSP/RDP), audio ring buffer synchronization, and ROM format manipulation.


1. Emulation Core Subsystems Topology

An emulator simulates hardware components communicating over virtual buses:

[ MIPS R4300i CPU ] <─── System Bus ───> [ RDRAM (4MB / 8MB Expansion) ]
       │                                            │
       ▼                                            ▼
[ Reality Co-Processor (RCP) ]              [ Serial Interface (SI) ]
   ├── RSP (Vector DSP / Geometry)             └── Controllers & Memory Paks
   ├── RDP (Rasterizer & Blending)          [ Audio Interface (AI) ]
   ├── Video Interface (VI / WebGL)            └── PCM Audio Buffer / DMA
   └── Audio Interface (AI / Web Audio)     [ Peripheral Interface (PI) ]
                                               └── Cartridge ROM & Save Media

2. ROM Header Validation & Auto-Detection Table

Nintendo 64 ROMs exist in three physical endian formats. The first 4 bytes indicate format:

FormatMagic Bytes (Hex)DescriptionNormalization Action
.z6480 37 12 40Big-Endian (Native N64 bus order)Native format; no swap needed.
.v6437 80 40 12Byte-Swapped (Doctor V64 copier)Swap every 2 adjacent bytes (swap16).
.n6440 12 37 80Little-Endian (Z64 copier / PC)Swap every 4 bytes (swap32).

In-Place ROM Normalizer (JavaScript / TypeScript)

export function normalizeN64Rom(data: Uint8Array): Uint8Array {
    if (data.length < 4) return data;
    const b0 = data[0], b1 = data[1], b2 = data[2], b3 = data[3];

    // Already Big-Endian .z64
    if (b0 === 0x80 && b1 === 0x37 && b2 === 0x12 && b3 === 0x40) {
        return data;
    }
    // Byte-swapped .v64 -> swap 16-bit words
    if (b0 === 0x37 && b1 === 0x80 && b2 === 0x40 && b3 === 0x12) {
        const len = data.length - (data.length % 2);
        for (let i = 0; i < len; i += 2) {
            const tmp = data[i];
            data[i] = data[i + 1];
            data[i + 1] = tmp;
        }
        return data;
    }
    // Little-endian .n64 -> swap 32-bit dwords
    if (b0 === 0x40 && b1 === 0x12 && b2 === 0x37 && b3 === 0x80) {
        const len = data.length - (data.length % 4);
        for (let i = 0; i < len; i += 4) {
            const t0 = data[i], t1 = data[i + 1], t2 = data[i + 2], t3 = data[i + 3];
            data[i] = t3;
            data[i + 1] = t2;
            data[i + 2] = t1;
            data[i + 3] = t0;
        }
        return data;
    }
    return data;
}

3. Audio Rate Matching & Frame Pacing

  • Sample Pacing Problem: Emulators generate audio at non-integer rates relative to the 60Hz display refresh cycle.
  • Audio-Throttled Main Loop: Use the audio output buffer capacity to throttle emulation steps instead of setInterval or unbounded requestAnimationFrame:
    • If buffer fill level < 20%: run extra emulation tick to prevent underflow (crackling).
    • If buffer fill level > 80%: pause emulation tick to prevent overflow and latency buildup.

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.