@gameslate/sdk 0.3.23 → 0.3.24
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 +10 -6
- package/bin/gameslate-plugin.mjs +25 -19
- package/lib/host/addresses.d.ts +29 -1
- package/lib/host/addresses.js +117 -4
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +79 -0
package/README.md
CHANGED
|
@@ -75,23 +75,27 @@ the input `downloads/<id>`; the player sees it among the plugin's permissions.
|
|
|
75
75
|
|
|
76
76
|
`0.3.x` speaks plugin contract (`sdkApi`) 3: new 0.3 versions add tools, never change the contract. The core refuses a plugin built for another contract.
|
|
77
77
|
|
|
78
|
-
- **0.3.
|
|
78
|
+
- **0.3.24**: `gameslate-plugin addresses` takes `sourceTypes` (`[{ file, types }]`): types a
|
|
79
|
+
decomp declares only in a `.c` file, lifted into the probe at probe time so their `offsetof`
|
|
80
|
+
and `sizeof` can be checked. A declaration inside an `#if` region, or holding a preprocessor
|
|
81
|
+
line, is refused.
|
|
82
|
+
- **0.3.22**: plugins may bundle WebAssembly. `gameslate-plugin build`
|
|
79
83
|
copies `wasm/*.wasm` into the build and pins each in the manifest's `wasm`; code calls them with
|
|
80
84
|
`wasmModule('<file>.wasm')` (`call`, `read`, `write`, `memoryBytes`). A module may import only
|
|
81
85
|
`env.memory` and, in asset code, `gameslate.input_read`; the core caps its memory and stops a
|
|
82
86
|
call at the time budget. `InputFile.handle` names an input to `input_read`. The build skill's
|
|
83
87
|
"WebAssembly for hot loops" has the toolchain flags.
|
|
84
|
-
- **0.3.19
|
|
88
|
+
- **0.3.19**: no plugin code runs outside the sandbox.
|
|
85
89
|
- `extract` (`afterAssets`, `pythonExtract`) is gone from the contract: the manifest schema is
|
|
86
90
|
strict and refuses it, and `gameslate-plugin build` refuses an `extract.ts`;
|
|
87
91
|
- games declare `downloads: [{ id, url, sha256 }]`, fetched by the core and read as the input
|
|
88
92
|
`downloads/<id>`;
|
|
89
93
|
- a `notes` asset output (`{ kind: 'notes', id, json }`, the text of one JSON object), written as
|
|
90
94
|
`notes/<id>.json` for a pack's `localSource`.
|
|
91
|
-
- **
|
|
92
|
-
variables placed at their object's section base in the ld map plus the offset
|
|
93
|
-
shows (IDO keeps statics out of the map), each with its `evidence`.
|
|
94
|
-
- **0.3.9
|
|
95
|
+
- **Earlier 0.3** (version not recorded): `gameslate-plugin addresses` takes `statics`,
|
|
96
|
+
file-static variables placed at their object's section base in the ld map plus the offset
|
|
97
|
+
their accessor shows (IDO keeps statics out of the map), each with its `evidence`.
|
|
98
|
+
- **0.3.9**: `gameslate-plugin addresses` takes `expectSizes` and fails
|
|
95
99
|
when the probe disagrees with a size the decomp states. `verify.json`'s `expect` also checks the inventory (`has`,
|
|
96
100
|
`lacks`, `exactly`), the equipped item (`null` for nothing) and flags; a flag the state doesn't
|
|
97
101
|
report is a mismatch, not false.
|
package/bin/gameslate-plugin.mjs
CHANGED
|
@@ -121,27 +121,32 @@ if (command === 'build' && dir && values.out) {
|
|
|
121
121
|
const table = buildAddressTable(spec, {
|
|
122
122
|
read: file => fs.readFileSync(path.join(decomp, file), 'utf8'),
|
|
123
123
|
compile: source => {
|
|
124
|
+
/* the probe holds decomp text (sourceTypes): it never outlives the compile */
|
|
124
125
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gs-probe-'));
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
try {
|
|
127
|
+
const probe = path.join(dir, 'probe.c');
|
|
128
|
+
fs.writeFileSync(probe, source);
|
|
129
|
+
const stubs = path.join(dir, 'stubs');
|
|
130
|
+
for (const h of spec.stubHeaders) {
|
|
131
|
+
fs.mkdirSync(path.dirname(path.join(stubs, h)), { recursive: true });
|
|
132
|
+
fs.writeFileSync(
|
|
133
|
+
path.join(stubs, h),
|
|
134
|
+
'/* stub: generated by the decomp build */\n',
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
/* after the decomp's own include paths: a real header wins over a stub */
|
|
138
|
+
const args = [
|
|
139
|
+
...spec.clang.args,
|
|
140
|
+
...(spec.stubHeaders.length ? ['-idirafter', stubs] : []),
|
|
141
|
+
];
|
|
142
|
+
return execFileSync(spec.clang.binary, [...args, '-S', '-o', '-', probe], {
|
|
143
|
+
cwd: decomp,
|
|
144
|
+
encoding: 'utf8',
|
|
145
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
146
|
+
});
|
|
147
|
+
} finally {
|
|
148
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
134
149
|
}
|
|
135
|
-
/* after the decomp's own include paths: a real header wins over a stub */
|
|
136
|
-
const args = [
|
|
137
|
-
...spec.clang.args,
|
|
138
|
-
...(spec.stubHeaders.length ? ['-idirafter', stubs] : []),
|
|
139
|
-
];
|
|
140
|
-
return execFileSync(spec.clang.binary, [...args, '-S', '-o', '-', probe], {
|
|
141
|
-
cwd: decomp,
|
|
142
|
-
encoding: 'utf8',
|
|
143
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
144
|
-
});
|
|
145
150
|
},
|
|
146
151
|
});
|
|
147
152
|
const commit = (() => {
|
|
@@ -158,6 +163,7 @@ if (command === 'build' && dir && values.out) {
|
|
|
158
163
|
`gameslate-plugin addresses ${path.basename(specFile)}:`,
|
|
159
164
|
`- symbols from ${spec.symbolFiles.join(', ')}${spec.subtract ? `, less 0x${spec.subtract.toString(16)} (another revision)` : ''};`,
|
|
160
165
|
`- offsets, sizes and constants from a probe of ${spec.includes.join(', ') || 'no headers'},`,
|
|
166
|
+
...spec.sourceTypes.map(s => ` with ${s.types.join(', ')} lifted from ${s.file},`),
|
|
161
167
|
` compiled by ${spec.clang.binary} ${spec.clang.args.filter(a => !a.startsWith('-I')).join(' ')}.`,
|
|
162
168
|
].join('\n');
|
|
163
169
|
const text = addressModule(table, provenance);
|
package/lib/host/addresses.d.ts
CHANGED
|
@@ -9,6 +9,20 @@ export declare const AddressSpecSchema: z.ZodObject<{
|
|
|
9
9
|
subtract: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodString, number, string>]>>;
|
|
10
10
|
/** headers the probe includes, in order */
|
|
11
11
|
includes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
12
|
+
/** types a `.c` file declares for itself, lifted into the probe after the includes (in
|
|
13
|
+
* order) at probe time: the decomp's text never enters the spec or the repo */
|
|
14
|
+
sourceTypes: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
15
|
+
/** relative to the decomp */
|
|
16
|
+
file: z.ZodEffects<z.ZodString, string, string>;
|
|
17
|
+
/** a typedef's `Name`, or `struct|union|enum Tag` */
|
|
18
|
+
types: z.ZodArray<z.ZodString, "many">;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
file: string;
|
|
21
|
+
types: string[];
|
|
22
|
+
}, {
|
|
23
|
+
file: string;
|
|
24
|
+
types: string[];
|
|
25
|
+
}>, "many">>;
|
|
12
26
|
/** headers the decomp generates at build time, given as empty files so an unbuilt checkout
|
|
13
27
|
* compiles; a layout that really needs one still fails to compile, loudly */
|
|
14
28
|
stubHeaders: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -60,6 +74,10 @@ export declare const AddressSpecSchema: z.ZodObject<{
|
|
|
60
74
|
decomp: string;
|
|
61
75
|
symbolFiles: string[];
|
|
62
76
|
subtract: number;
|
|
77
|
+
sourceTypes: {
|
|
78
|
+
file: string;
|
|
79
|
+
types: string[];
|
|
80
|
+
}[];
|
|
63
81
|
stubHeaders: string[];
|
|
64
82
|
clang: {
|
|
65
83
|
binary: string;
|
|
@@ -85,6 +103,10 @@ export declare const AddressSpecSchema: z.ZodObject<{
|
|
|
85
103
|
};
|
|
86
104
|
includes?: string[] | undefined;
|
|
87
105
|
subtract?: string | number | undefined;
|
|
106
|
+
sourceTypes?: {
|
|
107
|
+
file: string;
|
|
108
|
+
types: string[];
|
|
109
|
+
}[] | undefined;
|
|
88
110
|
stubHeaders?: string[] | undefined;
|
|
89
111
|
symbols?: string[] | undefined;
|
|
90
112
|
statics?: Record<string, {
|
|
@@ -136,9 +158,15 @@ export declare function probeEntries(spec: Pick<AddressSpec, 'offsets' | 'sizes'
|
|
|
136
158
|
})[];
|
|
137
159
|
export declare function probeSource(includes: readonly string[], entries: ReadonlyArray<{
|
|
138
160
|
expr: string;
|
|
139
|
-
}
|
|
161
|
+
}>, declarations?: readonly string[]): string;
|
|
140
162
|
/** probe_N's value from clang's assembly (`probe_3:` then `.4byte 612` or `.word 612`). */
|
|
141
163
|
export declare function parseProbeAssembly(asm: string, count: number): number[];
|
|
164
|
+
/** A type's declaration as `file` writes it: `typedef struct|union|enum [Tag] { … } Name;` for
|
|
165
|
+
* `Name`, or `struct|union|enum Tag { … };` (or a typedef with that tag) for `struct Tag`, at
|
|
166
|
+
* file scope. Throws naming the file and the type unless the file declares it exactly once, or
|
|
167
|
+
* when its text depends on the preprocessor (it sits in an `#if` region, or holds a directive):
|
|
168
|
+
* the probe's macros aren't the file's, so the lifted layout could silently differ. */
|
|
169
|
+
export declare function liftType(text: string, file: string, type: string): string;
|
|
142
170
|
export interface AddressTable {
|
|
143
171
|
symbols: Record<string, number>;
|
|
144
172
|
offsets: Record<string, number>;
|
package/lib/host/addresses.js
CHANGED
|
@@ -4,8 +4,9 @@ import { z } from 'zod';
|
|
|
4
4
|
* plugin's addresses have a source instead of being typed in. Globals come from the build's
|
|
5
5
|
* symbol map (a GNU ld map, or splat's `symbol_addrs` files), less a constant when the decomp
|
|
6
6
|
* builds another revision than the player's ROM. Struct offsets, sizes and constants come from a
|
|
7
|
-
* probe compiled with clang against the decomp's own headers
|
|
8
|
-
* the compiler folds each value into the assembly.
|
|
7
|
+
* probe compiled with clang against the decomp's own headers (and typedefs lifted from its `.c`
|
|
8
|
+
* files) for the console's ABI: no code runs, the compiler folds each value into the assembly.
|
|
9
|
+
* The effects (files, clang) are parameters.
|
|
9
10
|
*/
|
|
10
11
|
const Hex = z.union([
|
|
11
12
|
z.number().int(),
|
|
@@ -24,6 +25,23 @@ export const AddressSpecSchema = z.object({
|
|
|
24
25
|
subtract: Hex.default(0),
|
|
25
26
|
/** headers the probe includes, in order */
|
|
26
27
|
includes: z.array(z.string()).default([]),
|
|
28
|
+
/** types a `.c` file declares for itself, lifted into the probe after the includes (in
|
|
29
|
+
* order) at probe time: the decomp's text never enters the spec or the repo */
|
|
30
|
+
sourceTypes: z
|
|
31
|
+
.array(z.object({
|
|
32
|
+
/** relative to the decomp */
|
|
33
|
+
file: z
|
|
34
|
+
.string()
|
|
35
|
+
.regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*\.c$/, 'a .c file relative to the decomp')
|
|
36
|
+
.refine(f => !f.split('/').includes('..'), 'a path inside the decomp'),
|
|
37
|
+
/** a typedef's `Name`, or `struct|union|enum Tag` */
|
|
38
|
+
types: z
|
|
39
|
+
.array(z
|
|
40
|
+
.string()
|
|
41
|
+
.regex(/^(?:(?:struct|union|enum) )?[A-Za-z_][A-Za-z0-9_]*$/, 'a typedef name or struct|union|enum Tag'))
|
|
42
|
+
.min(1),
|
|
43
|
+
}))
|
|
44
|
+
.default([]),
|
|
27
45
|
/** headers the decomp generates at build time, given as empty files so an unbuilt checkout
|
|
28
46
|
* compiles; a layout that really needs one still fails to compile, loudly */
|
|
29
47
|
stubHeaders: z.array(z.string().regex(/^[A-Za-z0-9_./-]+\.h$/)).default([]),
|
|
@@ -142,10 +160,11 @@ export function probeEntries(spec) {
|
|
|
142
160
|
})),
|
|
143
161
|
];
|
|
144
162
|
}
|
|
145
|
-
export function probeSource(includes, entries) {
|
|
163
|
+
export function probeSource(includes, entries, declarations = []) {
|
|
146
164
|
return [
|
|
147
165
|
'/* generated by gameslate-plugin addresses: each value folds into the assembly */',
|
|
148
166
|
...includes.map(h => `#include ${h.startsWith('<') ? h : `"${h}"`}`),
|
|
167
|
+
...declarations,
|
|
149
168
|
...entries.map((e, i) => `const long probe_${i} = (long)(${e.expr});`),
|
|
150
169
|
'',
|
|
151
170
|
].join('\n');
|
|
@@ -168,6 +187,93 @@ export function parseProbeAssembly(asm, count) {
|
|
|
168
187
|
return v;
|
|
169
188
|
});
|
|
170
189
|
}
|
|
190
|
+
/** C source with its comments and string and character literals blanked to spaces (newlines
|
|
191
|
+
* kept), so a brace inside one doesn't count and every position still matches the original. */
|
|
192
|
+
function blankCommentsAndLiterals(text) {
|
|
193
|
+
const blank = (s) => s.replace(/[^\n]/g, ' ');
|
|
194
|
+
return text.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"(?:\\[\s\S]|[^"\\\n])*"|'(?:\\[\s\S]|[^'\\\n])*'/g, blank);
|
|
195
|
+
}
|
|
196
|
+
/* `[typedef] struct|union|enum [Tag] {`; a function or an initialiser matches too, but never
|
|
197
|
+
* ends in a declarator its type's name can equal */
|
|
198
|
+
const TYPE_OPEN = /\b(typedef\s+)?(struct|union|enum)\b([^;{}]*)\{/g;
|
|
199
|
+
const DECLARATOR_END = /^\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/;
|
|
200
|
+
const CONDITIONAL = /^[ \t]*#[ \t]*(if|ifdef|ifndef|endif)\b/gm;
|
|
201
|
+
const DIRECTIVE_LINE = /^[ \t]*#/m;
|
|
202
|
+
/** Where the brace at `open` closes in `code`, if it does. */
|
|
203
|
+
function closingBrace(code, open) {
|
|
204
|
+
let depth = 0;
|
|
205
|
+
for (let at = open; at < code.length; at++) {
|
|
206
|
+
if (code[at] === '{')
|
|
207
|
+
depth++;
|
|
208
|
+
else if (code[at] === '}' && --depth === 0)
|
|
209
|
+
return at;
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
/** Each `TYPE_OPEN` at file scope (outside every brace), with how many `#if` regions it is in. */
|
|
214
|
+
function fileScopeOpens(code) {
|
|
215
|
+
const directives = [...code.matchAll(CONDITIONAL)].map(d => ({
|
|
216
|
+
at: d.index,
|
|
217
|
+
step: d[1] === 'endif' ? -1 : 1,
|
|
218
|
+
}));
|
|
219
|
+
const out = [];
|
|
220
|
+
let depth = 0;
|
|
221
|
+
let at = 0;
|
|
222
|
+
for (const open of code.matchAll(TYPE_OPEN)) {
|
|
223
|
+
for (; at < open.index; at++) {
|
|
224
|
+
if (code[at] === '{')
|
|
225
|
+
depth++;
|
|
226
|
+
else if (code[at] === '}')
|
|
227
|
+
depth--;
|
|
228
|
+
}
|
|
229
|
+
if (depth !== 0)
|
|
230
|
+
continue;
|
|
231
|
+
const conditionals = directives
|
|
232
|
+
.filter(d => d.at < open.index)
|
|
233
|
+
.reduce((n, d) => n + d.step, 0);
|
|
234
|
+
out.push({ open, conditionals });
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
/** A type's declaration as `file` writes it: `typedef struct|union|enum [Tag] { … } Name;` for
|
|
239
|
+
* `Name`, or `struct|union|enum Tag { … };` (or a typedef with that tag) for `struct Tag`, at
|
|
240
|
+
* file scope. Throws naming the file and the type unless the file declares it exactly once, or
|
|
241
|
+
* when its text depends on the preprocessor (it sits in an `#if` region, or holds a directive):
|
|
242
|
+
* the probe's macros aren't the file's, so the lifted layout could silently differ. */
|
|
243
|
+
export function liftType(text, file, type) {
|
|
244
|
+
const code = blankCommentsAndLiterals(text);
|
|
245
|
+
const found = [];
|
|
246
|
+
for (const { open, conditionals } of fileScopeOpens(code)) {
|
|
247
|
+
const tag = open[3]?.trim();
|
|
248
|
+
const tagName = tag ? `${open[2]} ${tag}` : undefined;
|
|
249
|
+
const close = closingBrace(code, open.index + open[0].length - 1);
|
|
250
|
+
/* an open that never closes and isn't this type's (two `#ifdef` function headers sharing
|
|
251
|
+
* one body) is skipped */
|
|
252
|
+
if (close === undefined) {
|
|
253
|
+
if (tagName === type)
|
|
254
|
+
throw new Error(`${file}: ${type}'s braces never close`);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const end = DECLARATOR_END.exec(code.slice(close + 1));
|
|
258
|
+
/* a plain declaration must end at its brace: `struct S { … } var;` defines a variable */
|
|
259
|
+
if (!end || (!open[1] && end[1]))
|
|
260
|
+
continue;
|
|
261
|
+
if (end[1] !== type && tagName !== type)
|
|
262
|
+
continue;
|
|
263
|
+
if (conditionals > 0)
|
|
264
|
+
throw new Error(`${file}: ${type} is declared inside an #if region: not lifted`);
|
|
265
|
+
const declaration = text.slice(open.index, close + 1 + end[0].length);
|
|
266
|
+
if (DIRECTIVE_LINE.test(declaration))
|
|
267
|
+
throw new Error(`${file}: ${type}'s declaration holds a preprocessor line: not lifted`);
|
|
268
|
+
found.push(declaration);
|
|
269
|
+
}
|
|
270
|
+
const [declaration] = found;
|
|
271
|
+
if (!declaration)
|
|
272
|
+
throw new Error(`${file} declares no ${type} to lift ("typedef struct|union|enum { … } Name;" or "struct|union|enum Tag { … };" at file scope)`);
|
|
273
|
+
if (found.length > 1)
|
|
274
|
+
throw new Error(`${file} declares ${type} ${found.length} times`);
|
|
275
|
+
return declaration;
|
|
276
|
+
}
|
|
171
277
|
/** Each file-static at its object's section base plus the accessor's offset, into `known`. */
|
|
172
278
|
function placeStatics(spec, sections, known) {
|
|
173
279
|
for (const [name, st] of Object.entries(spec.statics)) {
|
|
@@ -202,9 +308,16 @@ export function buildAddressTable(spec, effects) {
|
|
|
202
308
|
const table = { symbols: {}, offsets: {}, sizes: {}, constants: {} };
|
|
203
309
|
for (const s of [...spec.symbols, ...Object.keys(spec.statics)])
|
|
204
310
|
table.symbols[s] = ((known.get(s) ?? 0) - spec.subtract) >>> 0;
|
|
311
|
+
/* `Tri` and `struct Tri` lift the same text: declare it once */
|
|
312
|
+
const declarations = [
|
|
313
|
+
...new Set(spec.sourceTypes.flatMap(({ file, types }) => {
|
|
314
|
+
const text = effects.read(file);
|
|
315
|
+
return types.map(t => liftType(text, file, t));
|
|
316
|
+
})),
|
|
317
|
+
];
|
|
205
318
|
const entries = probeEntries(spec);
|
|
206
319
|
if (entries.length) {
|
|
207
|
-
const values = parseProbeAssembly(effects.compile(probeSource(spec.includes, entries)), entries.length);
|
|
320
|
+
const values = parseProbeAssembly(effects.compile(probeSource(spec.includes, entries, declarations)), entries.length);
|
|
208
321
|
entries.forEach((e, i) => {
|
|
209
322
|
table[e.kind][e.name] = values[i] ?? 0;
|
|
210
323
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gameslate/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.24",
|
|
4
4
|
"description": "Build plugins for GameSlate, the second-screen companion for PC games: the plugin contract, game-state and catalogue schemas, and the plugin builder.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -173,6 +173,25 @@ A decomp that generates headers at build time (Paper Mario's `item_enum.h`) need
|
|
|
173
173
|
list them in `"stubHeaders"` and the probe gets empty ones (a layout that really needs one still
|
|
174
174
|
fails to compile). Constants come back signed.
|
|
175
175
|
|
|
176
|
+
A struct the decomp declares only inside a `.c` file (Donkey Kong 64's `CollisionStaticTri` in
|
|
177
|
+
`src/global/6AD90_collision.c`) can't be included, and its layout must still come from `offsetof`,
|
|
178
|
+
not from typing it in. Name the file and the types instead:
|
|
179
|
+
`"sourceTypes": [{ "file": "src/global/6AD90_collision.c", "types": ["CollisionStaticTri"] }]`.
|
|
180
|
+
A type is a typedef's `Name` (`typedef struct|union|enum [Tag] { … } Name;`) or a tagged
|
|
181
|
+
`struct|union|enum Tag` (`enum SurfaceKind { … };`, whose values `constants` can then name). At
|
|
182
|
+
probe time the run lifts each declaration out of the file into the probe, after the `includes`
|
|
183
|
+
(which must declare what it uses, such as `s16`), in the order listed. The spec holds only names,
|
|
184
|
+
so no decomp code reaches the repo, whatever its licence. It fails naming the file and the type
|
|
185
|
+
when the file doesn't declare it exactly once at file scope, and when the preprocessor shapes it
|
|
186
|
+
(it sits in an `#if` region, or holds a directive): the probe's macros aren't the file's, so the
|
|
187
|
+
layout could change without a word. A macro the `.c` defines for itself (an array length) fails
|
|
188
|
+
the compile. Not lifted: several declarators or a pointer one (`} A, *APtr;`), an attribute after
|
|
189
|
+
the brace (a packed struct must never lose it), `typedef const struct`. A forward
|
|
190
|
+
`typedef struct Tag Name;` with a separate `struct Tag { … };` is lifted as `struct Tag`, and
|
|
191
|
+
`offsets` and `sizes` name it that way too (`struct Tag.field`). The probe's temp file holds the
|
|
192
|
+
lifted text and is removed after the compile; clang's errors echo it too, so don't quote them in
|
|
193
|
+
commits or issues.
|
|
194
|
+
|
|
176
195
|
**Always list `"expectSizes"`** for the structs you read, from the decomp's `// size = 0x…`
|
|
177
196
|
comments or a symbol's `size:` over its count: the run fails if the probe disagrees. And compile
|
|
178
197
|
the probe in the C standard the game was built with (`-std=gnu89` for IDO and KMC GCC games):
|
|
@@ -735,6 +754,66 @@ the plugin repos) in the same change as the fix. The next game should not have t
|
|
|
735
754
|
player in from above: check every exit lands over a drawn floor in plan, and most on the
|
|
736
755
|
ground, not ±N units for all. The player's wall and ceiling queries pass through water, so
|
|
737
756
|
draw only water faces that point up (BK, 2026-12-05).
|
|
757
|
+
- **Draw links the game makes, never links you guess.** Mario Party's first map joined board
|
|
758
|
+
chains to the nearest space within 500 units and drew the joins as paths; a fork could show a
|
|
759
|
+
road the board doesn't have, and a link it didn't find looked like a dead end. Read the joins
|
|
760
|
+
from the board code; where you can't, mark the loose end "not read" rather than drawing or
|
|
761
|
+
hiding it (fail-loud, MP1 review, 2026-12-05).
|
|
762
|
+
- **Reusing a sibling game's decoder: compare the routines instruction by instruction.** Walk
|
|
763
|
+
both ROMs' functions to `jr ra`; if only `lui`/`addiu` address halves and `jal` targets differ,
|
|
764
|
+
it's the same algorithm (decoding thousands of files only shows it doesn't crash). Move the
|
|
765
|
+
shared decoder out of the first game's folder so no pack imports another. A table only asm
|
|
766
|
+
names can be pinned by scanning the ROM for `jal <fn>` and the `addiu a1,zero,imm` beside it
|
|
767
|
+
(MP1, 2026-12-05).
|
|
768
|
+
- **Bound a map by every place the game can put a player**, not just what's drawn: invisible
|
|
769
|
+
event spots and the standoff of a waiting player (MP1's ±60, from a table in `.data`).
|
|
770
|
+
- **An asset-table entry of size 0 means "missing".** Its offset points at the next entry's
|
|
771
|
+
data, so following it reads another level (two of Conker's levels showed the same spawns).
|
|
772
|
+
Return null, with a regression test whose size-0 entry points at real data (Conker,
|
|
773
|
+
2026-12-05).
|
|
774
|
+
- **Collision from display lists: port the game's walker exactly**, quirks included: Conker's
|
|
775
|
+
G_VTX fills slots from `first` up to `count`, not `first + count`; G_TRI1 slots are 7 bits,
|
|
776
|
+
G_TRI2/TRI4 5 bits. Prove each with a golden only the right width passes, and set the bits a
|
|
777
|
+
neighbouring field's wrong mask would pick up, or mask mutations survive. Check the game's
|
|
778
|
+
array sizes against the data (`verts[31]` against 32-vertex loads) and say which reading
|
|
779
|
+
you take.
|
|
780
|
+
- **Band a painter's-order drawing by height, not by colour runs.** A layer per run of one
|
|
781
|
+
colour made 324 layers on one Conker level and passed the 99-layer cap on DK64's Jungle
|
|
782
|
+
Japes; a fixed number of height bands, each drawn water, then ground, then hazard, don't
|
|
783
|
+
blow up.
|
|
784
|
+
- **A game's "no data" fallback is rarely a fact about the level.** Conker's spawn fallback
|
|
785
|
+
reads the first record of a block every level shares: refuse the level instead, and show by
|
|
786
|
+
census that no supported level hits it. Likewise check where water lives (props and zones,
|
|
787
|
+
not the mesh's materials) before claiming it's drawn, and when walls are resolved in
|
|
788
|
+
hand-written asm, say the wall threshold is a drawing choice.
|
|
789
|
+
- **Code that follows a decomp's routines step by step is derived from it**, even with no lines
|
|
790
|
+
copied: give each such file the `/*! Derived from … */` header so the notice ships in the
|
|
791
|
+
bundle. A notices test that checks wording must slice out that decomp's own section, or
|
|
792
|
+
another section's "Derived from it:" hides the mutation (Conker review, 2026-12-05).
|
|
793
|
+
- **`listAssets` stays cheap** by reading only the asset table, through word-aligned windows
|
|
794
|
+
converted per window to big-endian (z64/v64/n64), never the whole ROM.
|
|
795
|
+
- **A decomp's copy of a standard library is not the decomp's to license.** DK64's decomp
|
|
796
|
+
(CC0) reconstructs gzip 1.2.4 (GPL) for its boot loader; a header reader written from it
|
|
797
|
+
carried gzip's flag names and step order into MIT code. Read standard formats from their
|
|
798
|
+
RFC, reuse the repo's licensed inflater, and when an agent has already read the GPL copy, have
|
|
799
|
+
a fresh agent rewrite it from a prose spec. A census of the ROM keeps that spec small: every
|
|
800
|
+
DK64 stream has FLG 0 or FNAME, so accept those and throw on the rest (DK64 review,
|
|
801
|
+
2026-12-05).
|
|
802
|
+
- **Classify triangles on the stored integers, before scaling.** Dividing first turns an exact
|
|
803
|
+
zero cross product into rounding noise, so edge-on faces slip into the floors (DK64).
|
|
804
|
+
- **Check a known-wet map before trusting the floors for water.** DK64 keeps water as rectangles
|
|
805
|
+
in the map file, apart from the collision mesh. Asset tables can redirect one entry to
|
|
806
|
+
another's data (bit 31 in DK64): follow redirects with a hop limit, and test a loop.
|
|
807
|
+
- **Confirm a sine table's period from the disassembly** (4096 steps in DK64) before setting a
|
|
808
|
+
heading offset and sign, and test the arrow against the direction of movement.
|
|
809
|
+
- **ROM-gated tests assert structure, not ROM counts or ids.** "Which spawns have no floor" or
|
|
810
|
+
"216 maps have files" read from the ROM are derived data; instead assert bounds and shapes,
|
|
811
|
+
such as the unreadable map ids forming one run at the end (DK64 review).
|
|
812
|
+
- **A place that covers several maps can't get a drawing.** DK64's live reader groups 95
|
|
813
|
+
unnamed maps as a world's "elsewhere"; plan for one place per map when a game has unnamed
|
|
814
|
+
maps.
|
|
815
|
+
- **Keep exploration tests out of a shared tree.** A `*.scratch.test.ts` broke another agent's
|
|
816
|
+
check: explore from the scratchpad.
|
|
738
817
|
- **Mirror modes: draw the course as built.** `roomId` means a room to shared code (layer
|
|
739
818
|
choice, actor filters, AI prompts: "I'm in Room 1"), so never use it for a mode. Where the
|
|
740
819
|
game mirrors its world (Mario Kart 64's Extra cups), the reader negates x and the heading
|