@gameslate/sdk 0.3.11 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ description: Build a GameSlate plugin for a game, from choosing how to read its
7
7
 
8
8
  A plugin teaches GameSlate one or more games. It runs in GameSlate's sandbox (QuickJS: no files, no
9
9
  network, no Node APIs) and gets only what the core hands it: a game's memory (`GameMemory`) for live
10
- state, and the player's own files (`InputFile`s) for assets. Work through the steps in order. Don't
10
+ state (plus `memory.log?.(...)` for session-deduplicated diagnostic lines), and the player's own files (`InputFile`s) for assets. Work through the steps in order. Don't
11
11
  skip verification: a wrong address that looks plausible is worse than no address.
12
12
 
13
13
  ## 1. Pick the state source
@@ -32,11 +32,17 @@ Then `yarn install && yarn check`. `check` runs the typecheck, the tests, the bu
32
32
 
33
33
  - `plugin/manifest.json`: the plugin's id, name, version, `sdkApi`, and `games[]`;
34
34
  - `plugin/live.ts`: the plugin module, with its packs and memory sources. Put the decoder in
35
- `plugin/decode.ts` and the offsets in `plugin/offsets.ts`, both imported by `live.ts`. The
35
+ `plugin/decode.ts` and the offsets in `plugin/offsets.ts`, both imported by `live.ts`. When a
36
+ plugin supports multiple games (like `gameslate-n64`), give each game its own folder
37
+ `plugin/<game-id>/` (`source.ts`, `pack.ts`, `addresses.ts`, `map.ts`, `assets.ts`, etc.) and
38
+ keep only `manifest.json`, `live.ts`, `assets.ts` and shared helpers at `plugin/` root. The
36
39
  bundler follows the imports.
37
40
  - optionally `plugin/assets.ts`: asset extractors (add `assets` to the manifest);
38
- - `test/live.test.ts`: builds the plugin, loads it in the core's own sandbox, reads a fake
41
+ - `plugin/live.test.ts`: builds the plugin, loads it in the core's own sandbox, reads a fake
39
42
  memory, and runs the pack contract check (`checkCatalogue`). Keep it.
43
+ - Tests sit beside the code they test (`plugin/<game-id>/source.ts` → `source.test.ts`), never in
44
+ a separate `test/` folder. The bundle takes only what `live.ts` and `assets.ts` import, so tests
45
+ and test helpers in `plugin/` never ship.
40
46
  - CI, and `.claude/skills/`: this skill and `verify-gameslate-plugin`.
41
47
 
42
48
  Each manifest game has:
@@ -68,6 +74,9 @@ evaluator in the SDK decides "done", "collected" and "available". Rules:
68
74
  counter out of `counters` rather than reporting 0.
69
75
  - Give counters a `role` (`health`, `magic`, `armor`, `keys`) so shared UI finds them.
70
76
  - Use `format: 'percent'` with a `max` for meters.
77
+ - Use `format: 'duration'` for times kept in milliseconds (shown as 1'23"456), give an item
78
+ `count` (a counter id) when the player holds several, and set `hideMissing` on a `counters`
79
+ layout whose counters exist only in some modes (Dr. Mario's other bottles). Needs sdk 0.3.13.
71
80
 
72
81
  **What to put in a pack** (Mario Kart 64 and Star Fox 64 in gameslate-n64 are worked examples):
73
82
 
@@ -98,7 +107,9 @@ An unknown build means refuse to attach, never "try the nearest offsets".
98
107
  **Open-source ports.** Compile a probe against the game's headers: print `sizeof` of a big struct
99
108
  (it must equal what the shipped build uses) and the `offsetof` of each field. Put each value in
100
109
  `offsets.ts`, with a comment naming the struct field and where the number came from. Header
101
- comments like `/* 0x0E9C */` are not a source.
110
+ comments like `/* 0x0E9C */` are not a source, and never carry N64 decomp offsets onto a 64-bit PC
111
+ port (pointer widening shifts every downstream member: Perfect Dark's `chrdata` grows `0x354 → 0x3d0`
112
+ and `floorroom` moves `0x2b2 → 0x2fe`).
102
113
 
103
114
  **Console decompilations:**
104
115
 
@@ -137,7 +148,13 @@ fails to compile). Constants come back signed.
137
148
  comments or a symbol's `size:` over its count: the run fails if the probe disagrees. And compile
138
149
  the probe in the C standard the game was built with (`-std=gnu89` for IDO and KMC GCC games):
139
150
  Dr. Mario 64's `bool` is a 4-byte enum under C89 but clang's 1-byte `_Bool` under C17, which put
140
- every field after it 6 bytes early while looking perfectly plausible.
151
+ every field after it 6 bytes early while looking perfectly plausible. Check
152
+ the SDK you run has it (0.3.9 or later): 0.3.8 accepts the key and ignores it, which hid a wrong
153
+ size in GoldenEye's spec. IDO accepts members that clang drops without a word:
154
+ `struct coord16;` inside a struct (GoldenEye's `inherits` macro) is an anonymous member to IDO
155
+ and an empty forward declaration to clang, so `sizeof(StandTilePoint)` probed 2, not 8.
156
+ `-fms-extensions` fixes that one and breaks other headers; probe the file-format twin
157
+ (`StandFilePoint`) or take the stride from the compiled code.
141
158
 
142
159
  For another revision add `"subtract": "0xA190"` (and check the delta against verified leads
143
160
  first). Commit the spec and the generated table; the decomp and ROM stay local.
@@ -166,13 +183,17 @@ first). Commit the spec and the generated table; the decomp and ROM stay local.
166
183
  7. **Sizes and signs come from declarations and probes, never from guesses:** a 14-byte struct
167
184
  isn't 16 (`CourseVtx` has 2-byte alignment); a `u8` read as `getInt8` turns 0xFD into -3.
168
185
  8. **Check each offset in the compiled code as well.** A matching decomp's objects are the
169
- truth the probe models: `mips-linux-gnu-objdump -dr build/<region>/src/<file>.o` on a
170
- one-line accessor gives the offset and the array stride (GoldenEye's
186
+ truth the probe models: `mips-linux-gnu-objdump -dr build/<region>/src/<file>.o` (or
187
+ `llvm-objdump -dr`) on an accessor gives the offset, width and array stride (GoldenEye's
171
188
  `getCurrentPlayerWeaponId` is a shift-add chain making ×0x3A8, then `lw v0,2160(t8)`:
172
- `struct hand` is 0x3A8 bytes and `weaponnum` sits at 0x870). Every GoldenEye read was checked
173
- this way; it costs minutes and catches a probe compiled with the wrong defines.
189
+ `struct hand` is 0x3A8 bytes and `weaponnum` sits at 0x870; `DestroyObjectRecord.ObjRefID` sits
190
+ in a pointer union so `lhu 0x4` reads the upper zero halfword on big-endian MIPS whereas
191
+ `objective_status.o` executes `lw $4, 0x4($18)` + mask). Likewise, check helper macros before
192
+ reading binary asset streams: GoldenEye's `ntohs`/`ntohl` (`CharArrayTo16`/`CharArrayTo32`) read
193
+ unaligned big-endian bytes even though generated `.c` assets write reversed hex literals via
194
+ `CharArrayFrom*Rev`.
174
195
 
175
- **Leads, from LiveSplit or RetroAchievements:**
196
+ **Leads, from LiveSplit, RetroAchievements or GameShark lists:**
176
197
 
177
198
  - A lead is not a source. Verify every value live, across levels, menus and loads.
178
199
  - Record where it came from, and **never copy their code**: addresses are facts, scripts aren't.
@@ -180,9 +201,56 @@ first). Commit the spec and the generated table; the decomp and ROM stay local.
180
201
  console's big-endian address: byte = address ^ 3, 16-bit = address ^ 2, 32-bit as is.
181
202
  - RA notes are per game, not per revision. Struct offsets carry across revisions; absolute
182
203
  addresses don't.
204
+ - **N64 GameShark / Action Replay codes** (`80AAAAAA 00VV`, `81AAAAAA VVVV`) are big-endian guest
205
+ addresses as written. `gameslate drive codes <snapshot dir> <cheats.txt>` reads every value a
206
+ list names across a TAS series. Lists are per revision, and a code writes the smallest width
207
+ that works (Banjo-Kazooie's health code is the low byte of an s32): find the field's start.
208
+ Project64's `Config/Cheats/*.cht` files are per revision; `drive codes` reads them with
209
+ `--rom <rom>` and refuses a list whose header CRC isn't that ROM's.
183
210
  - A byte-pattern lead stays a pattern: read it with `memory.scan({ pattern, kind, offset })`, so it
184
211
  survives patches. It must match exactly once.
185
212
 
213
+ **Finding an address the decomp doesn't name:** replay a TAS to snapshots (`drive tas
214
+ --emulator bizhawk --watch …`), then `gameslate drive find <snapshot dir> --at <frames>
215
+ --values 10,19,30 --decomp <decomp>` ranks the aligned 1/2/4-byte values holding exactly what the
216
+ screen showed (or `--changes changed,same`: moved, then held) and lists the functions that load
217
+ or store each (docs/emulator-driving.md, "Finding an address from snapshots"). Three distinct
218
+ values pin a count; a 0/1 flag needs the whole series. A hit is a lead: read those functions and
219
+ confirm the width and sign there, as with any lead.
220
+
221
+ **No movie, but a table the boot loads (save records, defaults):** copy any N64 `.bk2` made on the
222
+ same BizHawk, set `GameName` and `SHA1` in its `Header.txt` to your ROM's, and replace its `Input
223
+ Log.txt` with the `LogKey` lines, N neutral frames and `[/Input]`. `drive tas` boots it on an
224
+ empty save, and the snapshots show the table holding its init values at every entry (F-Zero X's
225
+ 24 course records all read `MAX_TIMER` from frame 60, 2026-12-04). That pins the address and the
226
+ stride, not a set value: say so, and leave the set case to synthetic memory and a live check.
227
+
228
+ **A game with no decomp (Castlevania: Legacy of Darkness is the worked example):** the leads and
229
+ the screen are all the evidence there is, so `addresses.ts` is hand-written with each address's
230
+ frames and what the screen showed.
231
+ - **Name stage ids from their title cards.** `--watch` on the map id snapshots the dark
232
+ transition. Replay again to 240 frames after each change, where the stage's name card shows,
233
+ and tile the screenshots (`ffmpeg -i %03d.png -vf tile=4x4`) to read them at once.
234
+ - **Name only the ids the run visited.** Leave the rest as `area-0x..`, not the list's guess.
235
+ - **A value seen in one stretch is not a phase flag.** A byte constant on the title and in play
236
+ can be a counter: LoD's 0x801CAA87 read 0 on the title and 6 in all 90 play snapshots, but a
237
+ `--watch` on it showed 0, 2, 6 in the first 2400 frames. Watch a candidate through its change
238
+ before using it, and leave the phase undetected (a Known Gap) when no candidate holds.
239
+ - **`screen.png` can be blank** when the screen isn't drawn from RDRAM. Judge by BizHawk's own
240
+ `bizhawk.png` and say so in the README.
241
+ - `--watch` also snapshots the movie's end, so a watched run plays the whole movie. Snapshot
242
+ folders are zero-padded (`024000/`).
243
+
244
+ **Naming a struct the decomp leaves `unkNN`:** when the address is known but the fields aren't
245
+ (Mario Party 3's `GwStory`), print the struct's bytes at every snapshot of a TAS that plays that
246
+ mode through, and keep only the frames where they change. A counter climbs once per stage, an
247
+ array fills slot by slot, and the final screen fixes what the values mean (seven 4s and six 3s
248
+ against seven S and six A). Name only the values a screen showed; count the rest together
249
+ ("below A") until a run shows them. Then:
250
+ - **Count only the slots the progress index has reached.** The struct keeps the last game's bytes
251
+ until a new one overwrites them.
252
+ - **Gate on the mode bit the game uses.** For example, `playMode & 4` for Story play.
253
+
186
254
  **Reading:** read whole blocks (the save struct in one read) where the values sit together.
187
255
  Sample with `seqlockSample(readFrameCounter, readPayload)` (from `@gameslate/sdk/plugin`) so a
188
256
  frame isn't half old and half new: it rereads until the game's frame counter is the same before
@@ -192,6 +260,10 @@ per poll. Numbers are explicit about width, sign and byte order (`readUInt16BE`
192
260
 
193
261
  ## 5. Assets (optional): maps, icons, meshes from the player's files
194
262
 
263
+ **No space to map?** A single-screen puzzle (Dr. Mario's bottle, Puzzle League's stack) gets no
264
+ map: set `panels: { map: false }` on the pack (sdk 0.3.12) and the app leaves the map panel out.
265
+ Anything with a place to move through, a track or a board still gets one.
266
+
195
267
  `assets.ts` exports an extractor per game:
196
268
 
197
269
  - `listAssets(inputs, pick)` must be cheap: name what can be built.
@@ -243,6 +315,70 @@ Every image of a game uses one format. In the sandbox:
243
315
  the gameslate repo's `yarn vite-node tools/registry-add-game.ts <spec.json>`, which writes the
244
316
  manifest, keeps any hints, sets the index entry and rehashes channels with the registry
245
317
  builders' own writers (gameslate-n64's `tools/registry-specs.ts` writes its specs).
318
+ 8. **No mesh traced? Map what the game itself navigates by.** Wave Race 64's course meshes sit in
319
+ unsplit MIO0 blobs, but its buoy and AI node lists are plain 8-byte records (x, z, type,
320
+ angle) in a raw course file, one list per difficulty: they give the course's shape, the start
321
+ line and every buoy. Port the game's own classification of each record (jump tables, the
322
+ flags its draw loop tests) rather than guessing from what the dots look like, and when the
323
+ layout changes with a setting (difficulty), pin per setting with `hiddenWhen`. Lines from
324
+ waypoint to waypoint can cut across land: draw the dense lane nodes, not the sparse "next
325
+ buoy" chain.
326
+ 9. **Tables in a code segment's `.data`** are read from the ROM at `vram − segment vram + segment
327
+ ROM start`. Those two are linker-script symbols the `.map` reader skips: take them from the
328
+ map's `.<segment> 0x<vram> … load address 0x<rom>` line, say so in the source, and check a
329
+ value you know (a pointer the code loads) so a wrong mapping fails loud.
330
+ 10. **Positions an unnamed decomp hides:** look for code comparing a struct's floats with world
331
+ things (a water or floor height lookup taking `(unk44, unk4C)`, a look-ahead adding `512 ×
332
+ unk6C`): that names position and facing. Confirm the struct's stride in the compiled code.
333
+ 11. **Spline courses (F-Zero X):** when a course is control points joined by a curve, port the
334
+ curve exactly (F-Zero X's per-point tension from `func_8009DB28`, the cardinal weights of
335
+ `Course_SplineGetPosition`) and draw the ribbon from it: centre ± the basis' side vector
336
+ (up × forward, the up vector banked about the tangent as `Matrix_SetAxisRotation` does) times
337
+ each side's radius, interpolated by length along the segment. Then **follow the course from
338
+ ROM to race**, not just the load: F-Zero X recentres the points on their x/z extent
339
+ (`func_80074634`) and restarts the loop after the start line piece (`Course_SegmentsInit`), so
340
+ the ROM's coordinates sat 300-450 units off every machine. Check against the game's own spline
341
+ point for a machine (`segmentPositionInfo.segmentPos`) read live, not just its position: that
342
+ tells "my curve is wrong" from "my track is in the wrong place". Sample all racers, not only
343
+ player 1: 30 machines across the grid catch a sideways offset one machine can hide.
344
+ 12. **Object-placement maps (Star Fox 64):** when a level is a list of placed objects, not a mesh,
345
+ draw the list where the game's *loader* puts each one, per loader: SF64's on-rails
346
+ `Object_Load` sets z = −zPos1 − 3000 + zPos2, while its all-range loaders use +zPos1
347
+ (Fortuna, Corneria) or −zPos1 (Bolse, Sector Z, Venom). Pick the player coordinate in the
348
+ same frame: on rails SF64's `pos.z` runs along the path and `trueZpos` is the Arwing's place
349
+ among the objects (collisions compare them directly). A decomp built for another revision can
350
+ still give asset offsets: parse every list at them in the player's ROM and refuse one that
351
+ isn't a sorted, terminated list. Levels that switch modes (on rails → all-range boss, warp
352
+ zones) get one layer per mode, chosen by a `roomId` the reader sets from the mode variable;
353
+ size an arena to include how far past its edge the player can fly before turning back.
354
+ **Every `roomId` the reader can emit needs a layer; test it.** List each mode the game can
355
+ put each level in (grep every write to the mode variable in the decomp, not only the obvious
356
+ one: SF64's Andross goes all-range in two places), drive the reader through them all and
357
+ assert each `roomId` is in some layer's `rooms`. A missing layer fails silently: the SDK falls
358
+ back to another layer and the arrow lands in the wrong place. Check each loader for extra
359
+ terms too (Andross's alone adds zPos2).
360
+ **Sides from the game's own checks:** allies and enemies can share an object id and AI type
361
+ (Katina's Cornerian fighters differ from its enemies only by `animFrame`). Find the field the
362
+ game's ally logic reads, and scope it to the levels where that logic runs.
363
+ 13. **Stale pointers at a level change:** a player pointer and mode variables can still hold the
364
+ last level's values for a few frames. Gate position on the game's own "level running" state
365
+ (SF64's `gPlayState == PLAY_UPDATE`), not on plausible-looking values, and drop cutscene states
366
+ that fly the player off the map (level complete, warp entry). TAS snapshots taken at stage
367
+ starts show exactly these frames; ask `drive tas` for mid-level frames too.
368
+ 14. **Walkable-floor data makes the map, and its rooms pick the floor (GoldenEye).** When a game
369
+ keeps a "where can I stand" list (GoldenEye's stan tiles: polygons, each filed under a room),
370
+ draw that, not the render geometry, and let the room choose the layer: read the room of the
371
+ tile under the player (`prop->stan->room`) and under each guard, put every room on exactly one
372
+ floor (rooms that lie over each other more than a storey apart go on different floors; test
373
+ that no room is on two), and list them in `rooms`. Heights then never have to separate floors.
374
+ Divide by the game's own unit scale (`levelscale`) where it does. Shade height by rank, not by
375
+ range: one far-off drop (Dam's foot of the wall, 270 m down) flattens a linear scale.
376
+ 15. **Compressed files need the game's decompressor in the sandbox.** There is no zlib there:
377
+ GoldenEye's files are 0x1172 + raw DEFLATE, so `plugin/inflate.ts` is a small DEFLATE port
378
+ tested against node's zlib (stored, fixed, dynamic). The tables naming the files can sit in a
379
+ compressed data segment too (GoldenEye's `.cdata`): unpack it once per run and read the
380
+ tables at `vaddr − segment vaddr`, checking what you read (the empty first entry, each
381
+ entry's index) so a wrong mapping fails loud. A run over all 20 stages took 5 s in the sandbox.
246
382
 
247
383
  ## 6. Tests
248
384
 
@@ -265,12 +401,35 @@ Every image of a game uses one format. In the sandbox:
265
401
  `review-correctness` lens, or a fresh agent given the code and the decomp's paths, not your
266
402
  conclusions). On Mario Kart 64 it found three real bugs the renders didn't show.
267
403
 
268
- ## 7. Verify live
404
+ ## 7. Verify live and document support
269
405
 
270
406
  Use the `verify-gameslate-plugin` skill. It drives the game to a known moment, reads what your
271
407
  plugin reports, screenshots the game and GameSlate, and checks them against `verify.json`. Until a build
272
408
  passes, say so in the README ("unverified: offsets from leads") and keep it out of a release.
273
409
 
410
+ Every game ships a `<game>/README.md` (`plugin/<game-id>/README.md` in a multi-game plugin, or
411
+ `src/README.md` / `plugin/README.md` in a single-game plugin) whose YAML frontmatter conforms to
412
+ `@gameslate/sdk`'s `GameSupportSchema` (pinned `builds` + verification tier; `map` status,
413
+ `assetSource`, `geometry`, `layers`, `controls`, live `player`/`actors`, `pins`; and `panels` for
414
+ vitals, inventory, missions, reference, timelines, and AI) followed by the five required headings
415
+ in order:
416
+
417
+ 1. `## Builds & Asset Extraction`
418
+ 2. `## Map`
419
+ 3. `## Vitals, Inventory, Missions & Reference`
420
+ 4. `## Known Gaps`
421
+ 5. `## Verification`
422
+
423
+ Keep `<!-- gameslate:support-table:start -->` … `<!-- gameslate:support-table:end -->` in the
424
+ repo's top-level `README.md` and run:
425
+
426
+ ```sh
427
+ gameslate-plugin support plugin --built dist/<id> --write
428
+ ```
429
+
430
+ It cross-checks every per-game `README.md` against the built `GamePack`, `supportedBuildIds`,
431
+ `capabilities`, and `assets.ts` extractors, and splices the updated summary table into `README.md`.
432
+
274
433
  ## 8. Release
275
434
 
276
435
  ```sh
@@ -287,6 +446,109 @@ plugin exactly as the core will before running it. Then bump `version`, tag `vX.
287
446
  game could repeat, add it here (in `@gameslate/sdk`'s `template/claude/skills`, then copy it into
288
447
  the plugin repos) in the same change as the fix. The next game should not have to find it again.
289
448
 
449
+ - **Run the support check in `check` once the repo has a support table.** Add `"support":
450
+ "gameslate-plugin support plugin --built dist/<id>"` and `&& yarn support` to `check`. Without
451
+ it, gameslate-n64's README frontmatter said Harvest Moon 64 had no missions for a release after
452
+ it gained 16, and three hand-edited table rows drifted from what the generator writes (2026-12-04).
453
+ Change a pack's missions, items or map, then rerun it with `--write`.
454
+ - **A save table copied at boot can be read half-copied.** The daemon reads memory between the
455
+ game's own steps, so a poll can land in the middle of a loop like F-Zero X's `Save_Load`. If
456
+ the copy runs in order, read "copied, then not yet" as still loading. Throw only on a shape no
457
+ copy leaves, such as a loaded entry after an unloaded one (2026-12-04 review).
458
+ - **Read a round's fields only once the round is up.** Mario Golf's course select runs
459
+ `holeIndex--` and wraps the hole only at the end of the function, so a poll in the menus can see
460
+ hole -1. Its first cut range-checked the hole on every poll, so it could throw in a menu that
461
+ never shows one. Read the scene first, and read and check the round's fields only in a round
462
+ scene (2026-12-04 review).
463
+ - **Follow the game's own lookup, not the field's name.** Mario Golf's Ring Shot reuses
464
+ `GameState.holeIndex` as a stage number. The game maps the stage through `f_RingShotHoles` in
465
+ `GetHoleRecordIndex`, and the driving range always uses hole 0. Before indexing a table by a
466
+ field, grep for the functions that read that field, and mirror their branches. Read the game's
467
+ tables from RAM rather than copying them. A file-static goes under the spec's `statics`; when
468
+ the decomp also builds with GCC, `nm` on its ELF confirms the offset.
469
+ - **Write a different value at each address in a poll test.** Bomberman Hero's poll test wrote 3
470
+ to both bombs and fire, so a swap of the two in `readRaw` still passed. Take a snapshot where
471
+ the fields differ (frame 15000 had bombs 4 and fire 3 on the HUD).
472
+ - **Bound what makes cleared memory impossible.** With no title byte found, Bomberman Hero's
473
+ all-zero RAM read as play with health 0 of 0, and the "one hit left" chip fired. The bar starts
474
+ at 4 segments and only grows, so a bar under 4 now throws; and a chip for "one left" says
475
+ `gte: 1, lte: 1`, since 0 is not one left.
476
+ - **Check each RE address note against a snapshot before using it.** DOOM64-RE's notes were right
477
+ for `gamemap` and `players[]`, but its `totalkills`/`totalitems`/`totalsecret` addresses read 0
478
+ all through MAP01, a level full of monsters. One note being right says nothing about the next.
479
+ - **Don't take a threshold from a game message without reading its condition.** Doom 64's
480
+ "medikit that you REALLY need" tests health after the medikit is added, so it never shows; a
481
+ chip citing it as "the game's own 25" cited a bug. A health chip also wants `gte: 1`: a dead
482
+ player still lies in the level.
483
+ - **Declare `'map_2d'` on `source.capabilities`, not only in the registry manifest.** Five N64
484
+ games shipped map extractors and `map_2d` in `gameslate-registry` while omitting `'map_2d'` from
485
+ `source.capabilities` in `source.ts`. `gameslate-plugin support` cross-checks `map.status`
486
+ against `source.capabilities` so the two cannot drift.
487
+ - **An unnamed id in a header can still be written: find every writer before you throw on it.**
488
+ Harvest Moon 64's rucksack loops run 9 times over 8-byte arrays, so its ninth slot is
489
+ `heldItem`, whatever Pete holds: a tavern beer (122, set in `shop.c`), a fox facing east (an id
490
+ inside an 8-wide block `items.h` names only by its first). Reading it as a rucksack slot and
491
+ throwing on unnamed ids would have dropped the whole state the moment he picked one up. Grep the
492
+ assignments (`= ` on the field, `SET_` in cutscene bytecode) and the flag table that limits what
493
+ a slot may hold (`itemFlags`' `ITEM_RUCKSACK_STORABLE`) before calling an id impossible.
494
+ - **A bit that marks a mission done must never be cleared.** Check `clear…Bit` calls in C *and*
495
+ the cutscene bytecode's `CLEAR_SPECIAL_BIT n, array[w]` (numeric, so grep the word and bit, not
496
+ the name). HM64's `HAVE_GREENHOUSE` is cleared by a typhoon and `WON_VEGETABLE_FESTIVAL` after
497
+ Basil's visit, so neither can be a mission. Read where a bit is set, too: `HAVE_STABLE` reads like
498
+ a house extension but is a Horse Race medal prize.
499
+ - **Use the item-name table the menu itself reads.** Quest 64's decomp leaves item ids unnamed;
500
+ disassembling the inventory menu's draw (`names[gInventory[i]]`, a pointer table in a
501
+ decompressed data blob) gave the id → name map and the empty value from the init loop. Pin the
502
+ names with a ROM-gated test that decodes the table, so a wrong index fails.
503
+ - **A table the decomp hasn't split is still in the ROM.** Quest 64's `gBossData` (8 bosses,
504
+ 0x18 bytes each) lives in an unsplit data blob. Scanning the ROM for the struct's shape found
505
+ it at 0xD873A0: plausible map ids, zero padding, RAM pointers, and a `bossNumber` that is a
506
+ permutation of 0..7. Pin what you take from it with a ROM-gated test (`Q64_ROM`), so the table
507
+ is checked against the player's dump, not committed as an unchecked copy.
508
+ - **Map from the collision data, not the display meshes.** Wave Race 64's land sat in compressed
509
+ display lists with untraced matrices, but its collision walls and ground triangles were already
510
+ uncompressed, in world units, inside the course file the buoys came from. Find the function that
511
+ answers "what floor is under this point" or "push this point out of a wall", and read what it
512
+ reads. Rebuild a triangle stored as planes (normal, edge planes, distance) by meeting the planes,
513
+ and check each one against the game's own inside test.
514
+ - **No symbol file? Build the decomp for its linker map, without root.** Super Mario 64's decomp
515
+ ships no symbol list, and this machine had no MIPS binutils, no docker and no sudo.
516
+ `apt-get download binutils-mips-linux-gnu` then `dpkg -x <deb> <dir>` unpacks a working
517
+ `mips-linux-gnu-*` into your home (run it with `LD_LIBRARY_PATH=<dir>/usr/lib/x86_64-linux-gnu`
518
+ and the `bin` dir on `PATH`); `make VERSION=us COMPARE=1` then built the matching ROM and
519
+ `build/us/sm64.us.map`, which `addresses` reads as an ld map (statics such as `sCurrPlayMode`
520
+ included). A decomp that refuses non-IDO compilers (`#error Matching build is only possible on
521
+ IDO`) needs the probe's clang args to define what the guard asks for (`NON_MATCHING`,
522
+ `AVOID_UB`): check the guarded headers change only macros, and let `expectSizes` and the
523
+ decomp's own `/*0xA8*/` offset comments confirm the layout.
524
+ Some decomps also need a MIPS gcc (Diddy Kong Racing's `make setup` builds binutils from source
525
+ unless both `<prefix>-ld` and `<prefix>-gcc` exist): unpack `gcc-13-mips-linux-gnu`,
526
+ `cpp-13-mips-linux-gnu` and `gcc-13-mips-linux-gnu-base` the same way and link
527
+ `mips-linux-gnu-gcc` to `-gcc-13`. A tool that wants a missing `-dev` header (`pcre2.h`) takes
528
+ the unpacked dev package through `CPATH` and `LIBRARY_PATH`.
529
+ - **IDO statics and structs declared in `.c` files.** IDO keeps `static` variables out of the ld
530
+ map and the object's symbol table, and clang can't `offsetof` a struct the headers don't
531
+ declare. Both come from the build's objects: `objdump -dr` on the accessor shows the static as
532
+ `.bss` + offset (Banjo-Kazooie's `playerPosition_get`: `lui/addiu a1, .bss+0`), which goes in
533
+ the address spec's `statics` with that accessor as its `evidence`; and a field's offset and
534
+ width are the load the accessor does (`getGameMode`: `lw v0, 4(sGameState)`). Cite each in the
535
+ source.
536
+ - **Take level and map ids from the decomp's enums, not the ROM's tables.** Diddy Kong Racing's
537
+ `include/asset_enums.h` names all 65 level headers (`ASSET_LEVEL_*`), and `addresses` copies
538
+ them as constants: the place table is then source code, with nothing game-derived committed.
539
+ - **Dump the real "empty" record before you write the empty check.** A review asked for Wave Race
540
+ 64's "no ground" to be "all eight header words zero"; Port Blue's header has zero extents but
541
+ still names an 8 x 6 grid, so that check would have thrown on a real course. Match the empty
542
+ case to what the game's own empty data holds, and test it on the ROM.
543
+ - **Two cheat lists that disagree are not evidence.** Quest 64's element bytes are Fire, Earth,
544
+ Water, Wind in one Action Replay list, and Fire, Water, Wind, Earth in another site's table.
545
+ Leave the values unnamed and say what run would settle it. Count claims from the log, too:
546
+ a README said a TAS "saw all seven" Kirby bases, but its watch log held six.
547
+ - **A second build with the same fields at a fixed shift gets its own source.** The sandbox picks
548
+ the source whose `supportedBuildIds` has the build, so make the source a function of the
549
+ delta (Star Fox 64: US 1.1 = US 1.0 + 0xA190), and add a test pinning each lead plus the delta
550
+ to the decomp's own symbol. Give the extractor each build's ROM table offset, not one
551
+ hard-coded.
290
552
  - **"Racing" is more than one state.** Wave Race 64 runs the race in its race state, then in five
291
553
  more after the finish line, a retire or a quit, until the results (0x29-0x2D): reading only the
292
554
  named race state dropped the final place as it was decided. Find the function that dispatches
@@ -318,6 +580,26 @@ the plugin repos) in the same change as the fix. The next game should not have t
318
580
  emulator's command line, and the game must have booted. CIC-6103 and 6106 games (Paper Mario,
319
581
  Banjo-Kazooie) load below their header's entry point; the core works that out from the boot
320
582
  code's CRC.
583
+ RetroArch's `SCREENSHOT` under WSLg can save a black frame while the game runs (Donkey Kong 64,
584
+ even with the pause menu up): judge the screen by RAM (the frame counter, the map, the
585
+ actor), not by the capture. To see the screen, use the software renderer and draw the
586
+ framebuffer from a save state (Pokémon Puzzle League, 2026-12-03). In the `--appendconfig`
587
+ file:
588
+ - `core_options_path` names a file with `mupen64plus-rdp-plugin = "angrylion"`.
589
+ - `global_core_options = "true"` and `game_specific_options = "false"` are set. Without them,
590
+ the per-core `Mupen64Plus-Next.opt` wins and the option is ignored.
591
+ - `savestate_file_compression = "false"` is set.
592
+
593
+ Then send `SAVE_STATE` over the network port. The state lands in a `Mupen64Plus-Next/` folder
594
+ under `savestate_directory`. Draw it with `rdramFromState` (`packages/daemon/src/drive/retroarch-state.ts`)
595
+ and `readScreen`. GLideN64 doesn't write the framebuffer to RDRAM, so this needs angrylion.
596
+ Kill RetroArch by pid: `pkill -f <rom>` also matches the shell running it.
597
+ - **A HUD slot can change meaning.** Before calling a read wrong because the HUD disagrees, read
598
+ the draw code. Puzzle League draws the stop timer where the speed level goes while "STOP"
599
+ shows (`text.c`), so a HUD "01" against a `currLevel` of 2 was right.
600
+ - **A menu's type can name the mode through play.** Puzzle League's `geTypeMenu` keeps the
601
+ mode's own range of `enum_TypeMenu` while the round runs. Map ranges, not single values, and
602
+ play each mode you can to confirm it.
321
603
  - **A symbol may be a pointer, not the struct.** The gap to the next symbol in the map is its
322
604
  size: Super Smash Bros.' `gSCManagerBattleState` is 4 bytes, a pointer that the opening movies
323
605
  aim at their own staged fights. Read through it, and check the pointer lands in RAM.
@@ -327,7 +609,65 @@ the plugin repos) in the same change as the fix. The next game should not have t
327
609
  pointer aims at) when one variable isn't enough.
328
610
  - **Attract demos** run the real game loop with the demo's own data (Paper Mario's demo story,
329
611
  Dr. Mario's demo bottles, Smash's auto-demo and openings): find the flag or scene that marks
330
- them before trusting any value, and make them read as the title.
612
+ them before trusting any value, and make them read as the title. Credits that fly through real
613
+ levels are the same trap (Super Mario 64: `gCurrDemoInput` marks the demos, which play real
614
+ courses on file 1; `gCurrCreditsEntry` marks the credits flythrough). Grep the decomp for the
615
+ checks the game itself makes before it saves or counts (`save_file.c` skips both).
616
+ Donkey Kong 64's demo runs under `GAME_MODE_PLAY` on real maps with a real kong actor; only
617
+ `gMenuCurrentMode == MENU_MODE_DEMO` marks it, and the live run caught it reading `in_stage`.
618
+ When the enum lives in a `.c` file the header probe can't reach, name the value in the source
619
+ with that citation.
620
+ - **A map loads over several frames: find the game's "hold the screen" test.** Donkey Kong 64 sets
621
+ the new map, then spends 30 or more frames loading behind a black screen with the player at a
622
+ placeholder (700, 0, 70) and the game mode already back to play. Only the main loop's own test,
623
+ `gScreenRenderFlags & 1` with `gScreenFadeProgress == 31.0f`, marks them. A TAS replay caught
624
+ it: snapshots a few frames after each map change read `in_stage` over a black screen. Read the
625
+ main loop for the condition under which it skips drawing, and send those frames to `loading`.
626
+ - **Read the game's own lookup tables live, don't copy them.** A per-map table in `.data` (Donkey
627
+ Kong 64's map → world `gMapHubWorldIndex`, 221 bytes) is in RAM from boot: read the one byte
628
+ for the current map each poll instead of committing a copy (it is game data, and a copy can
629
+ drift). Bound the index first, and refuse a value past the table's range.
630
+ - **"No player" is not always "a menu".** Super Mario 64's cake ending spawns no Mario, so a
631
+ phase that tested "Mario exists" first sent the ending to the title screen; the unit test fed
632
+ the ending with Mario present, a state the game never makes. Read the level script of every
633
+ screen you name, and test each row with the values the game really holds there.
634
+ - **A mode without a file can still fill the save.** Diddy Kong Racing's Tracks mode merges every
635
+ save into the settings the adventure reads (`menu.c`), so tracks unlocked anywhere looked like
636
+ this file's progress. Find each mode that plays without a file and leave the save out there.
637
+ - **Some "menus" are films.** Diddy Kong Racing runs the new adventure's opening and the credits
638
+ as menus (`MENU_NEWGAME_CINEMATIC`, `MENU_CREDITS`) under the same game mode as file select;
639
+ the live run caught the opening reading `menu`. Read the menu id too, and send films to
640
+ `cutscene`.
641
+ - **A zero is a value too: check what BSS reads as before boot sets it.** Diddy Kong Racing's
642
+ `gGameMode` is 0 (`GAMEMODE_INGAME`) and `gMapId` 0 (Central Area) from the settings'
643
+ allocation until `thread3_main` sets the intro, so a "settings allocated" guard alone reported
644
+ the player in the hub during boot. For each mode or map variable, find where it is first set
645
+ and what its zero means. When the variable has no "not yet" value, gate on a neighbour that
646
+ does: Mario Party's current overlay is BSS (0 is Memory Match), but `omovlhisidx` is `.data`
647
+ initialised to -1 until boot's first `omOvlCallEx`, so a negative index is "no state".
648
+ - **Show the number the HUD shows, by its draw call.** A stored count and the HUD's can differ:
649
+ Conker's US HUD draws the lives less the one in use, and draws a cash score of 0x7D00 as
650
+ 1000000 (`hud_drawMain`). Find where the HUD draws each counter and apply the same transform,
651
+ citing it, so the phone agrees with the TV.
652
+ - **Probe with the build's version define.** A decomp that builds several versions from one tree
653
+ changes struct layouts under `#if VERSION` (Conker's US `Actor` gained `ceilingY`: 0x32C, not
654
+ the debug build's 0x328). Pass the Makefile's `-DVERSION=…` to the probe and pin the size in
655
+ `expectSizes` against the header's own comment.
656
+ - **A global the decomp doesn't name: read its setter from the ROM.** When the value you need is
657
+ only stored inside a function still in asm (Mario Party's current overlay, in `omOvlGotoEx`),
658
+ disassemble that function straight from the ROM: its ROM offset is `vram - segment vram +
659
+ segment start` from the splat yaml, and `mips-linux-gnu-objdump -D -b binary -m mips -EB
660
+ --adjust-vma=<vram>` on a `dd` slice shows the `lui/sw` pair. Keep the address as a named
661
+ constant whose comment quotes those instructions, and check every path that changes the value
662
+ (a call, a return, a plain goto) goes through that store.
663
+ - **A count is often set before its list is filled.** Diddy Kong Racing's `spawn_racers` sets
664
+ `gNumRacers` and only then fills `gRacersByPort` (an unzeroed pool), so a poll mid-load sees
665
+ NULL or stale slots. Read such lists only in the state that owns them (a loaded level), treat a
666
+ NULL slot as not ready, and keep throwing on a non-NULL pointer outside RAM.
667
+ - **Before a file is chosen, the save index is stale.** Super Mario 64's `gCurrSaveFileNum` starts
668
+ at 1 and keeps the last file after Save & Quit, so file select showed file 1's stars as fact.
669
+ Leave save-derived flags and counters out until a file is entered (an absent flag reads as
670
+ untracked), and keep them where a file is known (in play, the ending).
331
671
  - **The game mode can be a function pointer:** when the decomp keeps the current mode in a
332
672
  file-static the symbol maps don't list, read the mode table instead (Paper Mario:
333
673
  `gMainGameMode[0].step` equals a `state_step_*` symbol).
@@ -94,11 +94,33 @@ Script the route per game as inputs plus checks, such as "Start until game state
94
94
  Glide64mk2): a movie that sits at frame 0 or crashes may run with `Core` 1 (interpreter) in a
95
95
  copy of its `SyncSettings.json`, but such a copy is a deviation: prove sync (menu picks, counts
96
96
  rising steadily, no lost health, level clears) before trusting any frame of it.
97
+ - **Naming an enum's values from a TAS** (an ability, a character, a fruit): the decomp often
98
+ proves the address and the numbering but not which value is which. Replay with `--watch
99
+ <addr>:<size>` and "-" for frames to log every change, then replay to a few hundred frames
100
+ after each value's first change and read the HUD (the change frame itself often predates the
101
+ HUD update). On 2026-12-03 this settled Kirby 64's base abilities (1 Burning, 2 Stone, 3 Ice …)
102
+ where the first table, written without it, had five of seven wrong. Never name values from
103
+ memory or from a sibling game's order.
97
104
  - **RetroArch** can load a state at start (`-e <slot>`), answers network commands and takes the
98
105
  network RetroPad. Its mupen64plus-next core crashed on one dev machine with one build and ran
99
106
  for an hour with another (`stable-cores`): check that it boots a game first. Under it,
100
107
  `drive frame` comes back black (the renderer doesn't write the frame to RDRAM) and so do its own
101
108
  screenshots under WSL: take frames from Gopher64, or check values with `peek` instead.
109
+ Navigating blind, poll the game's menu id (`gCurrentMenuId`) after each press so you know
110
+ which screen you're on. Its `RESET` network command did nothing on 1.22.2: to start over, quit
111
+ RetroArch and launch it again.
112
+ - **No TAS for your build? Drive RetroArch and check against the game's own numbers.** Super
113
+ Mario 64 US had no `.bk2` (TASVideos' only one is the Japanese ROM). With the network RetroPad
114
+ and `drive ra READ_CORE_MEMORY` it was checked in minutes: title → file select → in level, the
115
+ spawn against the level script's `MARIO_POS`, Start for pause. For save bits nobody can earn
116
+ by pressing buttons blind, write known bits into the save buffer at file select (after the
117
+ boot load, before the file is entered), enter the file, and compare your count with the one
118
+ the game computes from them (SM64's `numStars`, shown on the HUD). Two traps: mupen64plus-next
119
+ answers `READ_CORE_MEMORY` and takes `WRITE_CORE_MEMORY` in host order (little-endian words),
120
+ so read and write aligned words and swap them (`retroarch-command.ts` does for reads); and in
121
+ JavaScript `0x8033bac6 & ~3` is negative, so align with `(a & ~3) >>> 0`. A second Start on
122
+ SM64's file select already enters file A: check the "in a level" pointer is still null before
123
+ writing.
102
124
  - **PC games:** a save file at that moment, loaded by hand. Then the tool only reads; leave
103
125
  `retroarch` out of the spec.
104
126
 
@@ -240,6 +262,9 @@ the start straight, so holding A long enough fetches an item to check the held-i
240
262
 
241
263
  - **RetroArch doesn't answer** (`didn't answer "READ_CORE_RAM …"`): network commands are off, or
242
264
  the port is taken. Check the appended config.
265
+ - **Stopping an emulator you started:** keep its PID (`… & echo $! > ra.pid`, then `kill $(cat
266
+ ra.pid)`). `pkill -f <pattern>` also matches the shell running that command line, so it kills
267
+ your own command and leaves the emulator running (twice on 2026-12-01).
243
268
  - **No state from the daemon:** is the daemon running with your plugin (its log lists the
244
269
  plugins it loaded), and does `validate` pass? Does the ROM's build id match one in
245
270
  `supportedBuildIds`? The daemon reports an unsupported build to the page.
@@ -11,7 +11,7 @@ import { expect, it } from 'vitest';
11
11
  it('reads health in the sandbox', async () => {
12
12
  const out = fs.mkdtempSync(path.join(os.tmpdir(), '{{id}}-'));
13
13
  await buildPlugin({
14
- srcDir: path.resolve(__dirname, '../plugin'),
14
+ srcDir: path.resolve(__dirname),
15
15
  outDir: out,
16
16
  testedWith: ['test'],
17
17
  });
@@ -10,5 +10,5 @@
10
10
  "types": ["node"],
11
11
  "noEmit": true
12
12
  },
13
- "include": ["plugin/**/*", "test/**/*"]
13
+ "include": ["plugin/**/*"]
14
14
  }