@gameslate/sdk 0.3.21 → 0.3.23
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.
- package/README.md +7 -0
- package/build/build-plugin.d.mts +4 -0
- package/build/build-plugin.mjs +46 -0
- package/lib/assets.d.ts +3 -0
- package/lib/host/asset-sandbox.d.ts +11 -0
- package/lib/host/asset-sandbox.js +42 -5
- package/lib/host/index.d.ts +1 -0
- package/lib/host/index.js +1 -0
- package/lib/host/inspect.d.ts +4 -1
- package/lib/host/inspect.js +53 -13
- package/lib/host/live-sandbox.d.ts +5 -0
- package/lib/host/live-sandbox.js +10 -0
- package/lib/host/quickjs-guest.d.ts +5 -0
- package/lib/host/quickjs-guest.js +53 -2
- package/lib/host/verify.d.ts +14 -14
- package/lib/host/wasm-host.d.ts +51 -0
- package/lib/host/wasm-host.js +270 -0
- package/lib/plugin/index.d.ts +1 -0
- package/lib/plugin/index.js +3 -2
- package/lib/plugin/sandbox-guest.js +21 -5
- package/lib/plugin/wasm.d.ts +17 -0
- package/lib/plugin/wasm.js +17 -0
- package/lib/plugin-manifest.d.ts +50 -0
- package/lib/plugin-manifest.js +19 -0
- package/lib/sandbox-protocol.d.ts +12 -0
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +113 -2
- package/template/github/workflows/ci.yml +2 -2
- package/template/github/workflows/release.yml +2 -2
|
@@ -118,6 +118,14 @@ every player confirm the update. The core (and `validate`) refuses live code tha
|
|
|
118
118
|
the manifest doesn't list. A manifest without `builds` still loads, with a permission naming only
|
|
119
119
|
the game; declare them anyway, since that leniency is for releases built before 0.3.21.
|
|
120
120
|
|
|
121
|
+
Read each name from the build itself, never from memory. An N64 ROM's name is its header's own
|
|
122
|
+
title (bytes `0x20`-`0x33`, trimmed), which often differs from the box: `STARFOX64`,
|
|
123
|
+
`CASTLEVANIA2`, `Silicon Valley`. For a revision you have no ROM of (one the decomp builds but
|
|
124
|
+
nobody has dumped here), use the decomp's own name for that ROM and say so in the commit. And
|
|
125
|
+
`validate` checks only one way (every build the code matches is listed): add a test that the
|
|
126
|
+
manifest lists no build that no source matches, since a stray build still asks every player
|
|
127
|
+
(gameslate-n64's `plugin/manifest.test.ts`).
|
|
128
|
+
|
|
121
129
|
**Memory is read only from games launched through GameSlate.** The core reads a process only
|
|
122
130
|
when it descends from a `gameslate run --` launch wrapper that is connected to the daemon
|
|
123
131
|
(Steam launch options `~/.local/bin/gameslate run -- %command%`, or `n64-gameslate` for
|
|
@@ -347,6 +355,50 @@ Every image of a game uses one format. In the sandbox:
|
|
|
347
355
|
- **Data licensing:** ship the extractor, never its output. Textures, models and renders are
|
|
348
356
|
built on the player's machine and never committed.
|
|
349
357
|
|
|
358
|
+
### WebAssembly for hot loops (sdk 0.3.22)
|
|
359
|
+
|
|
360
|
+
QuickJS interprets: a tight pixel or decompression loop runs 20–150× slower than in V8 (the
|
|
361
|
+
core's palette-to-RGBA demonstration: 1330 ms against 10 ms for 16 M pixels). When a build is
|
|
362
|
+
slow, move the loop into a WebAssembly module the plugin bundles:
|
|
363
|
+
|
|
364
|
+
- **Build it in the plugin repo, with a toolchain the repo owns,** into `plugin/wasm/<name>.wasm`
|
|
365
|
+
(a `yarn build:wasm` script, run before `yarn build`). Commit the source; git-ignore
|
|
366
|
+
`plugin/wasm/` and have CI and the release build it, so the shipped binary is the one the
|
|
367
|
+
source makes. The folder holds built modules only: anything else fails the build. `gameslate-plugin build` copies every `wasm/*.wasm`
|
|
368
|
+
beside `live.js`, refuses one that isn't valid WebAssembly, and lists each in the manifest's
|
|
369
|
+
`wasm` with its sha256. Up to 4 modules, 8 MB each.
|
|
370
|
+
- **Imports: `env.memory` and the sandbox's capabilities only.** The core refuses a module that
|
|
371
|
+
imports anything else (WASI, `env.abort`, a global or a table) or defines its own memory. Link
|
|
372
|
+
so the memory is imported:
|
|
373
|
+
- Rust: `--target wasm32-unknown-unknown`, `-C link-arg=--import-memory`, no `std` I/O; import
|
|
374
|
+
capabilities in an `extern "C"` block under `#[link(wasm_import_module = "gameslate")]`
|
|
375
|
+
(`fn input_read(handle: i32, offset: i64, length: i32, ptr: i32);`).
|
|
376
|
+
- C (clang): `--target=wasm32 -nostdlib -Wl,--no-entry -Wl,--export-dynamic
|
|
377
|
+
-Wl,--import-memory`; declare `__attribute__((import_module("gameslate"),
|
|
378
|
+
import_name("input_read")))`.
|
|
379
|
+
- AssemblyScript: `--importMemory --runtime stub --use abort=` (its default `env.abort` import
|
|
380
|
+
is refused); `@external("gameslate", "input_read") declare function input_read(...)`.
|
|
381
|
+
- **Capabilities:** asset code's modules may import `gameslate.input_read(handle: i32, offset:
|
|
382
|
+
i64, length: i32, ptr: i32)`, which reads an input range (64 MB at most) straight into the
|
|
383
|
+
module's memory; the handle is `InputFile.handle`. Live code's modules import nothing.
|
|
384
|
+
- **Memory:** the core creates it with a maximum of 1 GB (asset code) or 16 MB (live code), or
|
|
385
|
+
the module's own smaller maximum. `memory.grow` past it returns -1. Declare a starting size
|
|
386
|
+
(`--initial-memory`) big enough for your buffers, or grow it yourself.
|
|
387
|
+
- **Calling it:** `wasmModule('<name>.wasm')` from `@gameslate/sdk/plugin` gives `call(fn,
|
|
388
|
+
...numbers)`, `write(ptr, bytes)`, `read(ptr, length)` (at most 64 MB, 16 MB in live code) and
|
|
389
|
+
`memoryBytes()`. Only numbers cross
|
|
390
|
+
(i32/f32/f64 arguments; an i64 result comes back as a number). Each call costs about 0.5 ms (a
|
|
391
|
+
watchdog guards it), so call once per buffer or per asset, never per pixel. Big inputs: let
|
|
392
|
+
the module read them with `input_read` instead of `write`-ing them through the interpreter.
|
|
393
|
+
- **Budget:** a call shares the guest call's time budget; a module still running at the deadline
|
|
394
|
+
is stopped mid-loop and the sandbox switches off (the asset fails, the next gets a fresh one).
|
|
395
|
+
- **Licence:** the module's source is code like any other: port only MIT/BSD/CC0 code into it
|
|
396
|
+
(see "Read the decomp's licence" under Pitfalls). Compilers drop the `/*! Derived from … */`
|
|
397
|
+
header, so the notice that ships is the repo's `THIRD_PARTY_NOTICES.md` (copied into every
|
|
398
|
+
build): list the ported source and every crate or C library linked into the module there
|
|
399
|
+
(`cargo about` can generate it). A game's own native library (a proprietary
|
|
400
|
+
decompressor DLL) can't be loaded this way.
|
|
401
|
+
|
|
350
402
|
### Registry data: what the plugin commits
|
|
351
403
|
|
|
352
404
|
A plugin carries its games' committed map data in `plugin/registry/games/<gameId>/` (sdk 0.3.17):
|
|
@@ -649,6 +701,47 @@ the plugin repos) in the same change as the fix. The next game should not have t
|
|
|
649
701
|
- **Take level and map ids from the decomp's enums, not the ROM's tables.** Diddy Kong Racing's
|
|
650
702
|
`include/asset_enums.h` names all 65 level headers (`ASSET_LEVEL_*`), and `addresses` copies
|
|
651
703
|
them as constants: the place table is then source code, with nothing game-derived committed.
|
|
704
|
+
- **Find a ROM's script table by the command that loads it.** Super Mario 64's level-script
|
|
705
|
+
segment isn't named in any header: scan the ROM on 4-byte steps for the load command's bytes
|
|
706
|
+
and require every hit to agree, so another ROM fails loud instead of reading hand-copied
|
|
707
|
+
linker numbers. Read a variable-length stream (SM64 collision, whose special-object records
|
|
708
|
+
vary by a table in the game's code) only as far as you need, and record what that leaves out
|
|
709
|
+
as a gap (its water boxes). When one place spans several levels (the Bowser arenas share
|
|
710
|
+
their course), fold the level into `roomId` (level × 8 + area) and test that each level's
|
|
711
|
+
rooms appear on its own place only. A level script's start position is a free projection
|
|
712
|
+
check: a live read at the level start must equal it (SM64, 2026-12-05).
|
|
713
|
+
- **A table no symbol names: find it by its shape, strictly.** Diddy Kong Racing's asset lookup
|
|
714
|
+
table is found by its layout; require exactly one match and that its sections end past the
|
|
715
|
+
table, or a count word followed by zeros passes as a table of empty sections. Follow the
|
|
716
|
+
decomp's spawn call to the object map it really spawns (`track_spawn_objects(…, 0)` reads
|
|
717
|
+
`unkBA`, not `collectables`), and check the header width (`sizeof(uintptr_t)` words put
|
|
718
|
+
entries at byte 16). Water batches are often flagged no-collision: keep them by the water
|
|
719
|
+
render flag or surface type, or the lakes vanish. Before trusting a decomp function's flag
|
|
720
|
+
test, count each category (surface type × flags) over the ROM: that census showed DKR's lakes
|
|
721
|
+
are water-render batches flagged no-collision, and its `UNK_F` "water" a hidden height cap,
|
|
722
|
+
which a fix drawn from the functions alone would have got wrong. Every start the ROM gives makes a
|
|
723
|
+
projection check for every track: measure the height gap first (DKR's is 0–50, Smokey starts
|
|
724
|
+
in the air) (DKR, 2026-12-05).
|
|
725
|
+
- **Detect a ROM's byte order from its first word, never its extension.** A `.v64` file can hold
|
|
726
|
+
z64 bytes (BK, 2026-12-05).
|
|
727
|
+
- **Rare's indicator-byte streams** (`file_isNextByteExpected`): copy the held-back byte
|
|
728
|
+
exactly; a list's indicator may be missing when its count is 0; a count can be narrower than
|
|
729
|
+
its byte (6 bits in BK's setup files), so refuse larger values. offsetof can't pin a
|
|
730
|
+
bitfield: confirm it by disassembling the accessor (`llvm-objdump -d`) and place it relative
|
|
731
|
+
to a pinned neighbouring field (BK, 2026-12-05).
|
|
732
|
+
- **Exit pins: read the spawn function first.** Some exits never place the player (BK's 0x65),
|
|
733
|
+
some use hard-coded positions (0x80 and up): neither gets a pin. Keep duplicate exit nodes
|
|
734
|
+
with unique ids (a `Map` keeps the last, not the one the game uses). Many exits drop the
|
|
735
|
+
player in from above: check every exit lands over a drawn floor in plan, and most on the
|
|
736
|
+
ground, not ±N units for all. The player's wall and ceiling queries pass through water, so
|
|
737
|
+
draw only water faces that point up (BK, 2026-12-05).
|
|
738
|
+
- **Mirror modes: draw the course as built.** `roomId` means a room to shared code (layer
|
|
739
|
+
choice, actor filters, AI prompts: "I'm in Room 1"), so never use it for a mode. Where the
|
|
740
|
+
game mirrors its world (Mario Kart 64's Extra cups), the reader negates x and the heading
|
|
741
|
+
back; where it mirrors only the screen (DKR), positions already fit the map as built. Showing
|
|
742
|
+
a mirrored map would need a contract field, not a second layer per race (DKR review,
|
|
743
|
+
2026-12-05). A new `map_2d` goes in the source's capabilities, `registry-specs.ts` and the
|
|
744
|
+
manifest together, or the support step refuses `map.status: partial`.
|
|
652
745
|
- **Dump the real "empty" record before you write the empty check.** A review asked for Wave Race
|
|
653
746
|
64's "no ground" to be "all eight header words zero"; Port Blue's header has zero extents but
|
|
654
747
|
still names an 8 x 6 grid, so that check would have thrown on a real course. Match the empty
|
|
@@ -994,8 +1087,11 @@ the plugin repos) in the same change as the fix. The next game should not have t
|
|
|
994
1087
|
drums" in "four rooms", where the game has five cabinets you open and burn with timed mines,
|
|
995
1088
|
and a dish "console" where you stick a mine on the dish. Write each fact from a walkthrough
|
|
996
1089
|
(a GameFAQs FAQ, often mirrored as PDFs on video-games-museum.com; the Wayback Machine serves
|
|
997
|
-
pages that refuse fetches; StrategyWiki answers 403
|
|
998
|
-
|
|
1090
|
+
pages that refuse fetches; StrategyWiki answers 403; zeldadungeon.net blocks automated fetches
|
|
1091
|
+
behind a bot challenge, but Zelda Wiki serves wikitext at
|
|
1092
|
+
`https://zeldawiki.wiki/wiki/<Page>?action=raw`, following a `#REDIRECT` stub to its target),
|
|
1093
|
+
in your own words, and name it in the commit. Add a test, gated on the local labels file, that
|
|
1094
|
+
fails when a hint holds a label whole,
|
|
999
1095
|
a quoted multi-word piece of one, or a five-word run of one; pin its matcher on made-up labels
|
|
1000
1096
|
so it runs everywhere (TS2, 2026-12-05).
|
|
1001
1097
|
- **Fact-check every level's hints, not only the one caught.** The other nine TS2 levels were
|
|
@@ -1016,6 +1112,21 @@ the plugin repos) in the same change as the fix. The next game should not have t
|
|
|
1016
1112
|
"exit" may be the player's start position, so check it. A pin whose object appears only on
|
|
1017
1113
|
some difficulties gets `hiddenWhen`, built from the setup entry's per-difficulty flags
|
|
1018
1114
|
(TS2, 2026-12-05).
|
|
1115
|
+
- **Name an actor from its code, and check its params first.** Six of Ship of Harkinian's chest
|
|
1116
|
+
labels named the wrong item, and a dozen actor labels named the wrong character (an OoT
|
|
1117
|
+
"Grog", a "Gerudo Fighter" that the code calls a thief). Take a chest's item from the decomp's
|
|
1118
|
+
get-item enum, and an actor's name from its overlay Description or, without one, its Navi
|
|
1119
|
+
enemy id (`NAVI_ENEMY_*`) and the type enum in its header; the `case`s in Init show where an
|
|
1120
|
+
NPC stands. One actor id can be several characters (a father and his five sons, Goron types)
|
|
1121
|
+
and its params can pick the variant (Keese types 0–1 are on fire): read the enum before
|
|
1122
|
+
writing a params-based label, and pin each id to its enum name in a test (SoH, 2026-12-05).
|
|
1123
|
+
- **Give a pin status from an item only when owning it proves the pin.** An item that's sold,
|
|
1124
|
+
consumed, burnt or traded on (a Deku Shield, Magic Beans, Bombchus, the Odd Mushroom) doesn't
|
|
1125
|
+
show which chest it came from: use the chest's own flag, or leave the pin untracked. Check
|
|
1126
|
+
how the game hands the item over before writing a "Chest" rule (OoT's Fire Arrows lie free at
|
|
1127
|
+
Lake Hylia, Zelda gives the Light Arrows, MM's Link starts with his sword), and test that
|
|
1128
|
+
every rule's label is one the pin-label table can produce: a rule no pin matches does
|
|
1129
|
+
nothing and nothing reports it (SoH, 2026-12-05).
|
|
1019
1130
|
- **Invented hints name the wrong tool, place and method.** Perfect Dark's hints were wrong on
|
|
1020
1131
|
almost every mission: a Data Uplink on cleaning robots (two consoles start them), Mining
|
|
1021
1132
|
Explosives on a hangar door (a technician's key card), a security "booth" with biometrics, a
|