@gameslate/sdk 0.3.8 → 0.3.10

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 CHANGED
@@ -61,6 +61,10 @@ validates it and writes every file.
61
61
 
62
62
  `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.
63
63
 
64
+ - **0.3.9** (not yet published): `gameslate-plugin addresses` takes `expectSizes` and fails
65
+ when the probe disagrees with a size the decomp states. `verify.json`'s `expect` also checks the inventory (`has`,
66
+ `lacks`, `exactly`), the equipped item (`null` for nothing) and flags; a flag the state doesn't
67
+ report is a mismatch, not false.
64
68
  - **0.3.8:** `verify.json` `steps` drive an emulator to its moment through GameSlate's
65
69
  `gameslate drive`, with any `emulator` command:
66
70
  - `press` once, until a check matches, or taking turns between keys;
@@ -29,6 +29,11 @@ export declare const AddressSpecSchema: z.ZodObject<{
29
29
  sizes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
30
30
  /** any integer constant expression: enum values, macros */
31
31
  constants: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
32
+ /** sizes the decomp states (a `// size = 0x3C4` comment, a symbol's `size:` over its count):
33
+ * the probe must agree, or the run fails. A probe compiled in the wrong language standard
34
+ * (C17's 1-byte bool against the game's C89 4-byte enum) shifts every later offset while
35
+ * looking fine; this catches it. */
36
+ expectSizes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodString, number, string>]>>>;
32
37
  }, "strip", z.ZodTypeAny, {
33
38
  includes: string[];
34
39
  decomp: string;
@@ -43,6 +48,7 @@ export declare const AddressSpecSchema: z.ZodObject<{
43
48
  offsets: string[];
44
49
  sizes: string[];
45
50
  constants: Record<string, string>;
51
+ expectSizes: Record<string, number>;
46
52
  }, {
47
53
  decomp: string;
48
54
  symbolFiles: string[];
@@ -57,6 +63,7 @@ export declare const AddressSpecSchema: z.ZodObject<{
57
63
  offsets?: string[] | undefined;
58
64
  sizes?: string[] | undefined;
59
65
  constants?: Record<string, string> | undefined;
66
+ expectSizes?: Record<string, string | number> | undefined;
60
67
  }>;
61
68
  export type AddressSpec = z.infer<typeof AddressSpecSchema>;
62
69
  /** Symbols from an ld map (` 0x800dc50c gGamestate`) or a splat file (`gGameState = 0x80177834;`). */
@@ -67,7 +74,7 @@ export declare function splitMember(spec: string): {
67
74
  member: string;
68
75
  };
69
76
  /** One probe entry per value: `const long probe_N = (expr);`. */
70
- export declare function probeEntries(spec: Pick<AddressSpec, 'offsets' | 'sizes' | 'constants'>): ({
77
+ export declare function probeEntries(spec: Pick<AddressSpec, 'offsets' | 'sizes' | 'constants'> & Partial<Pick<AddressSpec, 'expectSizes'>>): ({
71
78
  kind: "offsets";
72
79
  name: string;
73
80
  expr: string;
@@ -35,6 +35,11 @@ export const AddressSpecSchema = z.object({
35
35
  sizes: z.array(z.string()).default([]),
36
36
  /** any integer constant expression: enum values, macros */
37
37
  constants: z.record(z.string(), z.string()).default({}),
38
+ /** sizes the decomp states (a `// size = 0x3C4` comment, a symbol's `size:` over its count):
39
+ * the probe must agree, or the run fails. A probe compiled in the wrong language standard
40
+ * (C17's 1-byte bool against the game's C89 4-byte enum) shifts every later offset while
41
+ * looking fine; this catches it. */
42
+ expectSizes: z.record(z.string(), Hex).default({}),
38
43
  });
39
44
  const LD_MAP_LINE = /^\s+0x([0-9a-fA-F]{8,16})\s+([A-Za-z_][A-Za-z0-9_]*)\s*$/;
40
45
  const SPLAT_LINE = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*0x([0-9a-fA-F]+)\s*;/;
@@ -71,7 +76,11 @@ export function probeEntries(spec) {
71
76
  expr: `__builtin_offsetof(${type}, ${member})`,
72
77
  };
73
78
  }),
74
- ...spec.sizes.map(t => ({ kind: 'sizes', name: t, expr: `sizeof(${t})` })),
79
+ ...[...new Set([...spec.sizes, ...Object.keys(spec.expectSizes ?? {})])].map(t => ({
80
+ kind: 'sizes',
81
+ name: t,
82
+ expr: `sizeof(${t})`,
83
+ })),
75
84
  ...Object.entries(spec.constants).map(([name, expr]) => ({
76
85
  kind: 'constants',
77
86
  name,
@@ -124,6 +133,11 @@ export function buildAddressTable(spec, effects) {
124
133
  table[e.kind][e.name] = values[i] ?? 0;
125
134
  });
126
135
  }
136
+ const wrong = Object.entries(spec.expectSizes).filter(([t, size]) => table.sizes[t] !== size);
137
+ if (wrong.length)
138
+ throw new Error(`the probe disagrees with the decomp on ${wrong
139
+ .map(([t, size]) => `sizeof(${t}): 0x${(table.sizes[t] ?? 0).toString(16)}, expected 0x${size.toString(16)}`)
140
+ .join('; ')} (check the language standard and defines)`);
127
141
  return table;
128
142
  }
129
143
  const hex = (n) => (n < 0 ? `-0x${(-n).toString(16)}` : `0x${n.toString(16)}`);
@@ -35,17 +35,47 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
35
35
  min: number;
36
36
  max: number;
37
37
  }>]>>>;
38
+ /** what the inventory must hold, must not hold, or must hold exactly (any order) */
39
+ inventory: z.ZodOptional<z.ZodObject<{
40
+ has: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
41
+ lacks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
42
+ exactly: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ has: string[];
45
+ lacks: string[];
46
+ exactly?: string[] | undefined;
47
+ }, {
48
+ has?: string[] | undefined;
49
+ lacks?: string[] | undefined;
50
+ exactly?: string[] | undefined;
51
+ }>>;
52
+ /** the equipped item, or null for nothing */
53
+ equipped: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
+ /** flags that must read true or false (a flag the state doesn't report is a mismatch) */
55
+ flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
38
56
  }, "strip", z.ZodTypeAny, {
39
57
  counters: Record<string, number | {
40
58
  min: number;
41
59
  max: number;
42
60
  }>;
61
+ flags: Record<string, boolean>;
62
+ inventory?: {
63
+ has: string[];
64
+ lacks: string[];
65
+ exactly?: string[] | undefined;
66
+ } | undefined;
43
67
  roomId?: number | undefined;
44
68
  phase?: string | undefined;
45
69
  locationId?: string | undefined;
46
70
  difficulty?: string | undefined;
47
71
  variant?: string | undefined;
72
+ equipped?: string | null | undefined;
48
73
  }, {
74
+ inventory?: {
75
+ has?: string[] | undefined;
76
+ lacks?: string[] | undefined;
77
+ exactly?: string[] | undefined;
78
+ } | undefined;
49
79
  roomId?: number | undefined;
50
80
  phase?: string | undefined;
51
81
  locationId?: string | undefined;
@@ -55,6 +85,8 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
55
85
  min: number;
56
86
  max: number;
57
87
  }> | undefined;
88
+ equipped?: string | null | undefined;
89
+ flags?: Record<string, boolean> | undefined;
58
90
  }>;
59
91
  } & {
60
92
  times: z.ZodDefault<z.ZodNumber>;
@@ -64,15 +96,27 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
64
96
  min: number;
65
97
  max: number;
66
98
  }>;
99
+ flags: Record<string, boolean>;
100
+ inventory?: {
101
+ has: string[];
102
+ lacks: string[];
103
+ exactly?: string[] | undefined;
104
+ } | undefined;
67
105
  roomId?: number | undefined;
68
106
  phase?: string | undefined;
69
107
  locationId?: string | undefined;
70
108
  difficulty?: string | undefined;
71
109
  variant?: string | undefined;
110
+ equipped?: string | null | undefined;
72
111
  };
73
112
  times: number;
74
113
  }, {
75
114
  state: {
115
+ inventory?: {
116
+ has?: string[] | undefined;
117
+ lacks?: string[] | undefined;
118
+ exactly?: string[] | undefined;
119
+ } | undefined;
76
120
  roomId?: number | undefined;
77
121
  phase?: string | undefined;
78
122
  locationId?: string | undefined;
@@ -82,6 +126,8 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
82
126
  min: number;
83
127
  max: number;
84
128
  }> | undefined;
129
+ equipped?: string | null | undefined;
130
+ flags?: Record<string, boolean> | undefined;
85
131
  };
86
132
  times?: number | undefined;
87
133
  }>]>>;
@@ -102,11 +148,18 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
102
148
  min: number;
103
149
  max: number;
104
150
  }>;
151
+ flags: Record<string, boolean>;
152
+ inventory?: {
153
+ has: string[];
154
+ lacks: string[];
155
+ exactly?: string[] | undefined;
156
+ } | undefined;
105
157
  roomId?: number | undefined;
106
158
  phase?: string | undefined;
107
159
  locationId?: string | undefined;
108
160
  difficulty?: string | undefined;
109
161
  variant?: string | undefined;
162
+ equipped?: string | null | undefined;
110
163
  };
111
164
  times: number;
112
165
  } | undefined;
@@ -119,6 +172,11 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
119
172
  times?: number | undefined;
120
173
  } | {
121
174
  state: {
175
+ inventory?: {
176
+ has?: string[] | undefined;
177
+ lacks?: string[] | undefined;
178
+ exactly?: string[] | undefined;
179
+ } | undefined;
122
180
  roomId?: number | undefined;
123
181
  phase?: string | undefined;
124
182
  locationId?: string | undefined;
@@ -128,6 +186,8 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
128
186
  min: number;
129
187
  max: number;
130
188
  }> | undefined;
189
+ equipped?: string | null | undefined;
190
+ flags?: Record<string, boolean> | undefined;
131
191
  };
132
192
  times?: number | undefined;
133
193
  } | undefined;
@@ -164,17 +224,47 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
164
224
  min: number;
165
225
  max: number;
166
226
  }>]>>>;
227
+ /** what the inventory must hold, must not hold, or must hold exactly (any order) */
228
+ inventory: z.ZodOptional<z.ZodObject<{
229
+ has: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
230
+ lacks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
231
+ exactly: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
232
+ }, "strip", z.ZodTypeAny, {
233
+ has: string[];
234
+ lacks: string[];
235
+ exactly?: string[] | undefined;
236
+ }, {
237
+ has?: string[] | undefined;
238
+ lacks?: string[] | undefined;
239
+ exactly?: string[] | undefined;
240
+ }>>;
241
+ /** the equipped item, or null for nothing */
242
+ equipped: z.ZodOptional<z.ZodNullable<z.ZodString>>;
243
+ /** flags that must read true or false (a flag the state doesn't report is a mismatch) */
244
+ flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
167
245
  }, "strip", z.ZodTypeAny, {
168
246
  counters: Record<string, number | {
169
247
  min: number;
170
248
  max: number;
171
249
  }>;
250
+ flags: Record<string, boolean>;
251
+ inventory?: {
252
+ has: string[];
253
+ lacks: string[];
254
+ exactly?: string[] | undefined;
255
+ } | undefined;
172
256
  roomId?: number | undefined;
173
257
  phase?: string | undefined;
174
258
  locationId?: string | undefined;
175
259
  difficulty?: string | undefined;
176
260
  variant?: string | undefined;
261
+ equipped?: string | null | undefined;
177
262
  }, {
263
+ inventory?: {
264
+ has?: string[] | undefined;
265
+ lacks?: string[] | undefined;
266
+ exactly?: string[] | undefined;
267
+ } | undefined;
178
268
  roomId?: number | undefined;
179
269
  phase?: string | undefined;
180
270
  locationId?: string | undefined;
@@ -184,6 +274,8 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
184
274
  min: number;
185
275
  max: number;
186
276
  }> | undefined;
277
+ equipped?: string | null | undefined;
278
+ flags?: Record<string, boolean> | undefined;
187
279
  }>;
188
280
  } & {
189
281
  times: z.ZodDefault<z.ZodNumber>;
@@ -193,15 +285,27 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
193
285
  min: number;
194
286
  max: number;
195
287
  }>;
288
+ flags: Record<string, boolean>;
289
+ inventory?: {
290
+ has: string[];
291
+ lacks: string[];
292
+ exactly?: string[] | undefined;
293
+ } | undefined;
196
294
  roomId?: number | undefined;
197
295
  phase?: string | undefined;
198
296
  locationId?: string | undefined;
199
297
  difficulty?: string | undefined;
200
298
  variant?: string | undefined;
299
+ equipped?: string | null | undefined;
201
300
  };
202
301
  times: number;
203
302
  }, {
204
303
  state: {
304
+ inventory?: {
305
+ has?: string[] | undefined;
306
+ lacks?: string[] | undefined;
307
+ exactly?: string[] | undefined;
308
+ } | undefined;
205
309
  roomId?: number | undefined;
206
310
  phase?: string | undefined;
207
311
  locationId?: string | undefined;
@@ -211,6 +315,8 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
211
315
  min: number;
212
316
  max: number;
213
317
  }> | undefined;
318
+ equipped?: string | null | undefined;
319
+ flags?: Record<string, boolean> | undefined;
214
320
  };
215
321
  times?: number | undefined;
216
322
  }>]>;
@@ -228,11 +334,18 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
228
334
  min: number;
229
335
  max: number;
230
336
  }>;
337
+ flags: Record<string, boolean>;
338
+ inventory?: {
339
+ has: string[];
340
+ lacks: string[];
341
+ exactly?: string[] | undefined;
342
+ } | undefined;
231
343
  roomId?: number | undefined;
232
344
  phase?: string | undefined;
233
345
  locationId?: string | undefined;
234
346
  difficulty?: string | undefined;
235
347
  variant?: string | undefined;
348
+ equipped?: string | null | undefined;
236
349
  };
237
350
  times: number;
238
351
  };
@@ -244,6 +357,11 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
244
357
  times?: number | undefined;
245
358
  } | {
246
359
  state: {
360
+ inventory?: {
361
+ has?: string[] | undefined;
362
+ lacks?: string[] | undefined;
363
+ exactly?: string[] | undefined;
364
+ } | undefined;
247
365
  roomId?: number | undefined;
248
366
  phase?: string | undefined;
249
367
  locationId?: string | undefined;
@@ -253,6 +371,8 @@ declare const StepSchema: z.ZodUnion<[z.ZodObject<{
253
371
  min: number;
254
372
  max: number;
255
373
  }> | undefined;
374
+ equipped?: string | null | undefined;
375
+ flags?: Record<string, boolean> | undefined;
256
376
  };
257
377
  times?: number | undefined;
258
378
  };
@@ -354,17 +474,47 @@ export declare const VerifySpecSchema: z.ZodObject<{
354
474
  min: number;
355
475
  max: number;
356
476
  }>]>>>;
477
+ /** what the inventory must hold, must not hold, or must hold exactly (any order) */
478
+ inventory: z.ZodOptional<z.ZodObject<{
479
+ has: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
480
+ lacks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
481
+ exactly: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
482
+ }, "strip", z.ZodTypeAny, {
483
+ has: string[];
484
+ lacks: string[];
485
+ exactly?: string[] | undefined;
486
+ }, {
487
+ has?: string[] | undefined;
488
+ lacks?: string[] | undefined;
489
+ exactly?: string[] | undefined;
490
+ }>>;
491
+ /** the equipped item, or null for nothing */
492
+ equipped: z.ZodOptional<z.ZodNullable<z.ZodString>>;
493
+ /** flags that must read true or false (a flag the state doesn't report is a mismatch) */
494
+ flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
357
495
  }, "strip", z.ZodTypeAny, {
358
496
  counters: Record<string, number | {
359
497
  min: number;
360
498
  max: number;
361
499
  }>;
500
+ flags: Record<string, boolean>;
501
+ inventory?: {
502
+ has: string[];
503
+ lacks: string[];
504
+ exactly?: string[] | undefined;
505
+ } | undefined;
362
506
  roomId?: number | undefined;
363
507
  phase?: string | undefined;
364
508
  locationId?: string | undefined;
365
509
  difficulty?: string | undefined;
366
510
  variant?: string | undefined;
511
+ equipped?: string | null | undefined;
367
512
  }, {
513
+ inventory?: {
514
+ has?: string[] | undefined;
515
+ lacks?: string[] | undefined;
516
+ exactly?: string[] | undefined;
517
+ } | undefined;
368
518
  roomId?: number | undefined;
369
519
  phase?: string | undefined;
370
520
  locationId?: string | undefined;
@@ -374,6 +524,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
374
524
  min: number;
375
525
  max: number;
376
526
  }> | undefined;
527
+ equipped?: string | null | undefined;
528
+ flags?: Record<string, boolean> | undefined;
377
529
  }>;
378
530
  } & {
379
531
  times: z.ZodDefault<z.ZodNumber>;
@@ -383,15 +535,27 @@ export declare const VerifySpecSchema: z.ZodObject<{
383
535
  min: number;
384
536
  max: number;
385
537
  }>;
538
+ flags: Record<string, boolean>;
539
+ inventory?: {
540
+ has: string[];
541
+ lacks: string[];
542
+ exactly?: string[] | undefined;
543
+ } | undefined;
386
544
  roomId?: number | undefined;
387
545
  phase?: string | undefined;
388
546
  locationId?: string | undefined;
389
547
  difficulty?: string | undefined;
390
548
  variant?: string | undefined;
549
+ equipped?: string | null | undefined;
391
550
  };
392
551
  times: number;
393
552
  }, {
394
553
  state: {
554
+ inventory?: {
555
+ has?: string[] | undefined;
556
+ lacks?: string[] | undefined;
557
+ exactly?: string[] | undefined;
558
+ } | undefined;
395
559
  roomId?: number | undefined;
396
560
  phase?: string | undefined;
397
561
  locationId?: string | undefined;
@@ -401,6 +565,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
401
565
  min: number;
402
566
  max: number;
403
567
  }> | undefined;
568
+ equipped?: string | null | undefined;
569
+ flags?: Record<string, boolean> | undefined;
404
570
  };
405
571
  times?: number | undefined;
406
572
  }>]>>;
@@ -421,11 +587,18 @@ export declare const VerifySpecSchema: z.ZodObject<{
421
587
  min: number;
422
588
  max: number;
423
589
  }>;
590
+ flags: Record<string, boolean>;
591
+ inventory?: {
592
+ has: string[];
593
+ lacks: string[];
594
+ exactly?: string[] | undefined;
595
+ } | undefined;
424
596
  roomId?: number | undefined;
425
597
  phase?: string | undefined;
426
598
  locationId?: string | undefined;
427
599
  difficulty?: string | undefined;
428
600
  variant?: string | undefined;
601
+ equipped?: string | null | undefined;
429
602
  };
430
603
  times: number;
431
604
  } | undefined;
@@ -438,6 +611,11 @@ export declare const VerifySpecSchema: z.ZodObject<{
438
611
  times?: number | undefined;
439
612
  } | {
440
613
  state: {
614
+ inventory?: {
615
+ has?: string[] | undefined;
616
+ lacks?: string[] | undefined;
617
+ exactly?: string[] | undefined;
618
+ } | undefined;
441
619
  roomId?: number | undefined;
442
620
  phase?: string | undefined;
443
621
  locationId?: string | undefined;
@@ -447,6 +625,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
447
625
  min: number;
448
626
  max: number;
449
627
  }> | undefined;
628
+ equipped?: string | null | undefined;
629
+ flags?: Record<string, boolean> | undefined;
450
630
  };
451
631
  times?: number | undefined;
452
632
  } | undefined;
@@ -483,17 +663,47 @@ export declare const VerifySpecSchema: z.ZodObject<{
483
663
  min: number;
484
664
  max: number;
485
665
  }>]>>>;
666
+ /** what the inventory must hold, must not hold, or must hold exactly (any order) */
667
+ inventory: z.ZodOptional<z.ZodObject<{
668
+ has: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
669
+ lacks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
670
+ exactly: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
671
+ }, "strip", z.ZodTypeAny, {
672
+ has: string[];
673
+ lacks: string[];
674
+ exactly?: string[] | undefined;
675
+ }, {
676
+ has?: string[] | undefined;
677
+ lacks?: string[] | undefined;
678
+ exactly?: string[] | undefined;
679
+ }>>;
680
+ /** the equipped item, or null for nothing */
681
+ equipped: z.ZodOptional<z.ZodNullable<z.ZodString>>;
682
+ /** flags that must read true or false (a flag the state doesn't report is a mismatch) */
683
+ flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
486
684
  }, "strip", z.ZodTypeAny, {
487
685
  counters: Record<string, number | {
488
686
  min: number;
489
687
  max: number;
490
688
  }>;
689
+ flags: Record<string, boolean>;
690
+ inventory?: {
691
+ has: string[];
692
+ lacks: string[];
693
+ exactly?: string[] | undefined;
694
+ } | undefined;
491
695
  roomId?: number | undefined;
492
696
  phase?: string | undefined;
493
697
  locationId?: string | undefined;
494
698
  difficulty?: string | undefined;
495
699
  variant?: string | undefined;
700
+ equipped?: string | null | undefined;
496
701
  }, {
702
+ inventory?: {
703
+ has?: string[] | undefined;
704
+ lacks?: string[] | undefined;
705
+ exactly?: string[] | undefined;
706
+ } | undefined;
497
707
  roomId?: number | undefined;
498
708
  phase?: string | undefined;
499
709
  locationId?: string | undefined;
@@ -503,6 +713,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
503
713
  min: number;
504
714
  max: number;
505
715
  }> | undefined;
716
+ equipped?: string | null | undefined;
717
+ flags?: Record<string, boolean> | undefined;
506
718
  }>;
507
719
  } & {
508
720
  times: z.ZodDefault<z.ZodNumber>;
@@ -512,15 +724,27 @@ export declare const VerifySpecSchema: z.ZodObject<{
512
724
  min: number;
513
725
  max: number;
514
726
  }>;
727
+ flags: Record<string, boolean>;
728
+ inventory?: {
729
+ has: string[];
730
+ lacks: string[];
731
+ exactly?: string[] | undefined;
732
+ } | undefined;
515
733
  roomId?: number | undefined;
516
734
  phase?: string | undefined;
517
735
  locationId?: string | undefined;
518
736
  difficulty?: string | undefined;
519
737
  variant?: string | undefined;
738
+ equipped?: string | null | undefined;
520
739
  };
521
740
  times: number;
522
741
  }, {
523
742
  state: {
743
+ inventory?: {
744
+ has?: string[] | undefined;
745
+ lacks?: string[] | undefined;
746
+ exactly?: string[] | undefined;
747
+ } | undefined;
524
748
  roomId?: number | undefined;
525
749
  phase?: string | undefined;
526
750
  locationId?: string | undefined;
@@ -530,6 +754,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
530
754
  min: number;
531
755
  max: number;
532
756
  }> | undefined;
757
+ equipped?: string | null | undefined;
758
+ flags?: Record<string, boolean> | undefined;
533
759
  };
534
760
  times?: number | undefined;
535
761
  }>]>;
@@ -547,11 +773,18 @@ export declare const VerifySpecSchema: z.ZodObject<{
547
773
  min: number;
548
774
  max: number;
549
775
  }>;
776
+ flags: Record<string, boolean>;
777
+ inventory?: {
778
+ has: string[];
779
+ lacks: string[];
780
+ exactly?: string[] | undefined;
781
+ } | undefined;
550
782
  roomId?: number | undefined;
551
783
  phase?: string | undefined;
552
784
  locationId?: string | undefined;
553
785
  difficulty?: string | undefined;
554
786
  variant?: string | undefined;
787
+ equipped?: string | null | undefined;
555
788
  };
556
789
  times: number;
557
790
  };
@@ -563,6 +796,11 @@ export declare const VerifySpecSchema: z.ZodObject<{
563
796
  times?: number | undefined;
564
797
  } | {
565
798
  state: {
799
+ inventory?: {
800
+ has?: string[] | undefined;
801
+ lacks?: string[] | undefined;
802
+ exactly?: string[] | undefined;
803
+ } | undefined;
566
804
  roomId?: number | undefined;
567
805
  phase?: string | undefined;
568
806
  locationId?: string | undefined;
@@ -572,6 +810,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
572
810
  min: number;
573
811
  max: number;
574
812
  }> | undefined;
813
+ equipped?: string | null | undefined;
814
+ flags?: Record<string, boolean> | undefined;
575
815
  };
576
816
  times?: number | undefined;
577
817
  };
@@ -631,17 +871,47 @@ export declare const VerifySpecSchema: z.ZodObject<{
631
871
  min: number;
632
872
  max: number;
633
873
  }>]>>>;
874
+ /** what the inventory must hold, must not hold, or must hold exactly (any order) */
875
+ inventory: z.ZodOptional<z.ZodObject<{
876
+ has: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
877
+ lacks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
878
+ exactly: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
879
+ }, "strip", z.ZodTypeAny, {
880
+ has: string[];
881
+ lacks: string[];
882
+ exactly?: string[] | undefined;
883
+ }, {
884
+ has?: string[] | undefined;
885
+ lacks?: string[] | undefined;
886
+ exactly?: string[] | undefined;
887
+ }>>;
888
+ /** the equipped item, or null for nothing */
889
+ equipped: z.ZodOptional<z.ZodNullable<z.ZodString>>;
890
+ /** flags that must read true or false (a flag the state doesn't report is a mismatch) */
891
+ flags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
634
892
  }, "strip", z.ZodTypeAny, {
635
893
  counters: Record<string, number | {
636
894
  min: number;
637
895
  max: number;
638
896
  }>;
897
+ flags: Record<string, boolean>;
898
+ inventory?: {
899
+ has: string[];
900
+ lacks: string[];
901
+ exactly?: string[] | undefined;
902
+ } | undefined;
639
903
  roomId?: number | undefined;
640
904
  phase?: string | undefined;
641
905
  locationId?: string | undefined;
642
906
  difficulty?: string | undefined;
643
907
  variant?: string | undefined;
908
+ equipped?: string | null | undefined;
644
909
  }, {
910
+ inventory?: {
911
+ has?: string[] | undefined;
912
+ lacks?: string[] | undefined;
913
+ exactly?: string[] | undefined;
914
+ } | undefined;
645
915
  roomId?: number | undefined;
646
916
  phase?: string | undefined;
647
917
  locationId?: string | undefined;
@@ -651,6 +921,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
651
921
  min: number;
652
922
  max: number;
653
923
  }> | undefined;
924
+ equipped?: string | null | undefined;
925
+ flags?: Record<string, boolean> | undefined;
654
926
  }>;
655
927
  /** values to read through the emulator too: each must equal the plugin's counter */
656
928
  memory: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -695,11 +967,18 @@ export declare const VerifySpecSchema: z.ZodObject<{
695
967
  min: number;
696
968
  max: number;
697
969
  }>;
970
+ flags: Record<string, boolean>;
971
+ inventory?: {
972
+ has: string[];
973
+ lacks: string[];
974
+ exactly?: string[] | undefined;
975
+ } | undefined;
698
976
  roomId?: number | undefined;
699
977
  phase?: string | undefined;
700
978
  locationId?: string | undefined;
701
979
  difficulty?: string | undefined;
702
980
  variant?: string | undefined;
981
+ equipped?: string | null | undefined;
703
982
  };
704
983
  times: number;
705
984
  } | undefined;
@@ -715,11 +994,18 @@ export declare const VerifySpecSchema: z.ZodObject<{
715
994
  min: number;
716
995
  max: number;
717
996
  }>;
997
+ flags: Record<string, boolean>;
998
+ inventory?: {
999
+ has: string[];
1000
+ lacks: string[];
1001
+ exactly?: string[] | undefined;
1002
+ } | undefined;
718
1003
  roomId?: number | undefined;
719
1004
  phase?: string | undefined;
720
1005
  locationId?: string | undefined;
721
1006
  difficulty?: string | undefined;
722
1007
  variant?: string | undefined;
1008
+ equipped?: string | null | undefined;
723
1009
  };
724
1010
  times: number;
725
1011
  };
@@ -740,11 +1026,18 @@ export declare const VerifySpecSchema: z.ZodObject<{
740
1026
  min: number;
741
1027
  max: number;
742
1028
  }>;
1029
+ flags: Record<string, boolean>;
1030
+ inventory?: {
1031
+ has: string[];
1032
+ lacks: string[];
1033
+ exactly?: string[] | undefined;
1034
+ } | undefined;
743
1035
  roomId?: number | undefined;
744
1036
  phase?: string | undefined;
745
1037
  locationId?: string | undefined;
746
1038
  difficulty?: string | undefined;
747
1039
  variant?: string | undefined;
1040
+ equipped?: string | null | undefined;
748
1041
  };
749
1042
  memory: {
750
1043
  counter: string;
@@ -776,6 +1069,11 @@ export declare const VerifySpecSchema: z.ZodObject<{
776
1069
  }, {
777
1070
  game: string;
778
1071
  expect: {
1072
+ inventory?: {
1073
+ has?: string[] | undefined;
1074
+ lacks?: string[] | undefined;
1075
+ exactly?: string[] | undefined;
1076
+ } | undefined;
779
1077
  roomId?: number | undefined;
780
1078
  phase?: string | undefined;
781
1079
  locationId?: string | undefined;
@@ -785,6 +1083,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
785
1083
  min: number;
786
1084
  max: number;
787
1085
  }> | undefined;
1086
+ equipped?: string | null | undefined;
1087
+ flags?: Record<string, boolean> | undefined;
788
1088
  };
789
1089
  steps?: ({
790
1090
  press: string | string[];
@@ -795,6 +1095,11 @@ export declare const VerifySpecSchema: z.ZodObject<{
795
1095
  times?: number | undefined;
796
1096
  } | {
797
1097
  state: {
1098
+ inventory?: {
1099
+ has?: string[] | undefined;
1100
+ lacks?: string[] | undefined;
1101
+ exactly?: string[] | undefined;
1102
+ } | undefined;
798
1103
  roomId?: number | undefined;
799
1104
  phase?: string | undefined;
800
1105
  locationId?: string | undefined;
@@ -804,6 +1109,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
804
1109
  min: number;
805
1110
  max: number;
806
1111
  }> | undefined;
1112
+ equipped?: string | null | undefined;
1113
+ flags?: Record<string, boolean> | undefined;
807
1114
  };
808
1115
  times?: number | undefined;
809
1116
  } | undefined;
@@ -816,6 +1123,11 @@ export declare const VerifySpecSchema: z.ZodObject<{
816
1123
  times?: number | undefined;
817
1124
  } | {
818
1125
  state: {
1126
+ inventory?: {
1127
+ has?: string[] | undefined;
1128
+ lacks?: string[] | undefined;
1129
+ exactly?: string[] | undefined;
1130
+ } | undefined;
819
1131
  roomId?: number | undefined;
820
1132
  phase?: string | undefined;
821
1133
  locationId?: string | undefined;
@@ -825,6 +1137,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
825
1137
  min: number;
826
1138
  max: number;
827
1139
  }> | undefined;
1140
+ equipped?: string | null | undefined;
1141
+ flags?: Record<string, boolean> | undefined;
828
1142
  };
829
1143
  times?: number | undefined;
830
1144
  };
@@ -26,6 +26,18 @@ const ExpectSchema = z.object({
26
26
  variant: z.string().optional(),
27
27
  roomId: z.number().int().optional(),
28
28
  counters: z.record(z.string(), Expected).default({}),
29
+ /** what the inventory must hold, must not hold, or must hold exactly (any order) */
30
+ inventory: z
31
+ .object({
32
+ has: z.array(z.string()).default([]),
33
+ lacks: z.array(z.string()).default([]),
34
+ exactly: z.array(z.string()).optional(),
35
+ })
36
+ .optional(),
37
+ /** the equipped item, or null for nothing */
38
+ equipped: z.string().nullable().optional(),
39
+ /** flags that must read true or false (a flag the state doesn't report is a mismatch) */
40
+ flags: z.record(z.string(), z.boolean()).default({}),
29
41
  });
30
42
  /** Wait on the plugin's own state, for moments no fixed address shows (a PlayState that moves):
31
43
  * `{ "state": { "phase": "in_stage", "locationId": "lost_woods_intro" } }`. */
@@ -154,6 +166,38 @@ export function stateMismatches(expect, state) {
154
166
  else if (got < want.min || got > want.max)
155
167
  out.push(`counter ${id}: expected ${want.min}..${want.max}, got ${got}`);
156
168
  }
169
+ out.push(...inventoryMismatches(expect.inventory, state.inventory));
170
+ out.push(...equippedAndFlagMismatches(expect, state));
171
+ return out;
172
+ }
173
+ function equippedAndFlagMismatches(expect, state) {
174
+ const out = [];
175
+ if (expect.equipped !== undefined && expect.equipped !== (state.equipped ?? null))
176
+ out.push(`equipped: expected ${expect.equipped ?? 'nothing'}, got ${state.equipped ?? 'nothing'}`);
177
+ for (const [id, want] of Object.entries(expect.flags)) {
178
+ const got = state.flags[id];
179
+ if (got === undefined)
180
+ out.push(`flag ${id}: not reported`);
181
+ else if (got !== want)
182
+ out.push(`flag ${id}: expected ${String(want)}, got ${String(got)}`);
183
+ }
184
+ return out;
185
+ }
186
+ function inventoryMismatches(want, got) {
187
+ if (!want)
188
+ return [];
189
+ const held = new Set(got);
190
+ const out = [
191
+ ...want.has.filter(id => !held.has(id)).map(id => `inventory: missing ${id}`),
192
+ ...want.lacks.filter(id => held.has(id)).map(id => `inventory: has ${id}, expected not`),
193
+ ];
194
+ if (want.exactly) {
195
+ const expected = new Set(want.exactly);
196
+ const extra = got.filter(id => !expected.has(id));
197
+ const missing = want.exactly.filter(id => !held.has(id));
198
+ if (extra.length || missing.length)
199
+ out.push(`inventory: expected exactly [${want.exactly.join(', ')}], got [${got.join(', ')}]`);
200
+ }
157
201
  return out;
158
202
  }
159
203
  /** RetroArch's network command reading a value with RetroAchievements' addressing. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gameslate/sdk",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
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",
@@ -124,10 +124,21 @@ Mario Kart 64's verified addresses):
124
124
  }
125
125
  ```
126
126
 
127
+ It prints the table unless given `--out`, and it fails on any `${VAR}` in the spec that isn't
128
+ set (`CLANG_INCLUDE` is `$(clang-18 -print-resource-dir)/include`). Some decomps keep a symbol
129
+ only in the linker script, which the `.map` reader skips (F-Zero X's `gRacers`): find it in the
130
+ splat `symbol_addrs*.txt`, and confirm its size against the struct times the count.
131
+
127
132
  A decomp that generates headers at build time (Paper Mario's `item_enum.h`) needn't be built:
128
133
  list them in `"stubHeaders"` and the probe gets empty ones (a layout that really needs one still
129
134
  fails to compile). Constants come back signed.
130
135
 
136
+ **Always list `"expectSizes"`** for the structs you read, from the decomp's `// size = 0x…`
137
+ comments or a symbol's `size:` over its count: the run fails if the probe disagrees. And compile
138
+ the probe in the C standard the game was built with (`-std=gnu89` for IDO and KMC GCC games):
139
+ 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.
141
+
131
142
  For another revision add `"subtract": "0xA190"` (and check the delta against verified leads
132
143
  first). Commit the spec and the generated table; the decomp and ROM stay local.
133
144
 
@@ -221,7 +232,11 @@ Every image of a game uses one format. In the sandbox:
221
232
  the game's own minimap.
222
233
  7. **A game needs a registry entry** (`gameslate-registry/games/<id>/manifest.json`: title,
223
234
  capabilities with `map_2d`, difficulties, item names; locations empty) before the web app shows
224
- extracted maps. Doom's is the pattern; update `index.json` and `channels.json` hashes too.
235
+ extracted maps. Doom's is the pattern. Don't hand-edit `index.json` and `channels.json`: write a
236
+ spec (id, title, subtitle, romIds, capabilities, locations) from the plugin's own data and run
237
+ the gameslate repo's `yarn vite-node tools/registry-add-game.ts <spec.json>`, which writes the
238
+ manifest, keeps any hints, sets the index entry and rehashes channels with the registry
239
+ builders' own writers (gameslate-n64's `tools/registry-specs.ts` writes its specs).
225
240
 
226
241
  ## 6. Tests
227
242
 
@@ -262,6 +277,22 @@ plugin exactly as the core will before running it. Then bump `version`, tag `vX.
262
277
 
263
278
  ## Pitfalls seen in real plugins
264
279
 
280
+ **Add to this list as you go.** When a review, a route or a live run catches something a future
281
+ game could repeat, add it here (in `@gameslate/sdk`'s `template/claude/skills`, then copy it into
282
+ the plugin repos) in the same change as the fix. The next game should not have to find it again.
283
+
284
+ - **"Racing" is more than one state.** Wave Race 64 runs the race in its race state, then in five
285
+ more after the finish line, a retire or a quit, until the results (0x29-0x2D): reading only the
286
+ named race state dropped the final place as it was decided. Find the function that dispatches
287
+ on the game state and list every state it runs as the race.
288
+ - **Player arrays hold more than players.** Mario Kart 64's time-trial ghosts are human-flagged
289
+ karts with one extra bit (`PLAYER_INVISIBLE_OR_BOMB`), and a replay puts a ghost in slot 0.
290
+ Read every function that spawns into the array before deciding which slots are rivals, ghosts
291
+ or people.
292
+ - **CI must run the real check.** On a runner without the `packageManager` pin, `yarn` is Yarn 1
293
+ and plain `yarn check` is its built-in lockfile check: CI stayed green while running no tests.
294
+ Pin `packageManager` and run `yarn run check`.
295
+
265
296
  - **Texture packs:** a port's HD packs (`mods/*.o2r`) replace textures. Read them the way the game
266
297
  does: packs first, in name order, each preferring its `alt/` asset, then the base archive.
267
298
  Otherwise you overwrite HD output with vanilla.
@@ -271,9 +302,28 @@ plugin exactly as the core will before running it. Then bump `version`, tag `vX.
271
302
  emulator's command line, and the game must have booted. CIC-6103 and 6106 games (Paper Mario,
272
303
  Banjo-Kazooie) load below their header's entry point; the core works that out from the boot
273
304
  code's CRC.
305
+ - **A symbol may be a pointer, not the struct.** The gap to the next symbol in the map is its
306
+ size: Super Smash Bros.' `gSCManagerBattleState` is 4 bytes, a pointer that the opening movies
307
+ aim at their own staged fights. Read through it, and check the pointer lands in RAM.
308
+ - **The game's own mode variable can mislead.** Smash's 1P battle runs with the scene still
309
+ reading Title (the 1P intro sets it as its exit, and the battle starts without changing it).
310
+ Check each phase against the screen live, and combine signals (previous scene, which state a
311
+ pointer aims at) when one variable isn't enough.
312
+ - **Attract demos** run the real game loop with the demo's own data (Paper Mario's demo story,
313
+ Dr. Mario's demo bottles, Smash's auto-demo and openings): find the flag or scene that marks
314
+ them before trusting any value, and make them read as the title.
274
315
  - **The game mode can be a function pointer:** when the decomp keeps the current mode in a
275
316
  file-static the symbol maps don't list, read the mode table instead (Paper Mario:
276
317
  `gMainGameMode[0].step` equals a `state_step_*` symbol).
318
+ - **A field in the wrong place compiles and vanishes.** TypeScript's excess-property check
319
+ doesn't look inside a conditional spread (`...(x ? { roomId } : {})`), and the daemon's schema
320
+ drops unknown keys, so a room put beside `position` instead of inside it never arrives (Quest
321
+ 64's first route caught it; its unit test checked the same wrong place). Write state fields
322
+ directly, and let a route's `expect` check what the daemon actually sends.
323
+ - **Unnamed values and globals:** a decomp with few names (Kirby 64) still gives addresses: a
324
+ splat `D_<address>` is its address. Cite the function that reads it, and confirm each live.
325
+ - **Menus may read only the d-pad.** Gopher64's d-pad is `w` `a` `s` `d` and its arrows are the
326
+ stick (`~/.config/gopher64/config.json`); Kirby 64's menus ignore the stick.
277
327
  - **Menus remember:** many games save the last menu choices, so a route that only presses Start
278
328
  lands somewhere else next time. Pin each choice with the game's own menu variables.
279
329
  - **Prove it on real data before writing to a player's files.** Back up what's there before the
@@ -39,7 +39,14 @@ The steps:
39
39
  two contexts 0x30 bytes apart that sit just before them, each holding a framebuffer pointer.
40
40
  Grabbing an emulator's window can come back black (WSLg, GPU surfaces).
41
41
  4. **Press buttons:** XTEST key events into the emulator's window (Gopher64 maps Start to Return,
42
- A to Left Shift, B to Left Ctrl, Z to `z`, the stick to the arrows).
42
+ A to Left Shift, B to Left Ctrl, Z to `z`, the stick to the arrows). Those need the window to
43
+ have the keyboard, which an unattended WSLg run never gets. **RetroArch needs no focus:** its
44
+ network RetroPad takes `pad:` keys (`gameslate drive press pad:START 120 pad:B 6000`). Start it
45
+ with an appended config holding `network_remote_enable = "true"`,
46
+ `network_remote_enable_user_p1 = "true"` and `pause_nonactive = "false"`, and write the
47
+ route's `press` steps as `pad:` keys. With mupen64plus-next, RetroPad **B is the N64's A**
48
+ (confirms menus in Mario Kart 64 and F-Zero X, accelerates in F-Zero X) and RetroPad A is the
49
+ N64's B.
43
50
  5. **Wait on state, not time:** after each input, read until the game state you expect appears
44
51
  (for example "game state = racing"), with a timeout.
45
52
 
@@ -51,8 +58,11 @@ Script the route per game as inputs plus checks, such as "Start until game state
51
58
  (`.eep`/`.sra`) work across emulators. A save state is the last resort: tied to one emulator
52
59
  version, and it needs a person to make it. Keep saves and states out of the repo: they're game
53
60
  data.
54
- - **RetroArch** can load a state at start (`-e <slot>`) and answers network commands, but its
55
- N64 core crashed on one dev machine. Check that it boots a game before relying on it.
61
+ - **RetroArch** can load a state at start (`-e <slot>`), answers network commands and takes the
62
+ network RetroPad. Its mupen64plus-next core crashed on one dev machine with one build and ran
63
+ for an hour with another (`stable-cores`): check that it boots a game first. Under it,
64
+ `drive frame` comes back black (the renderer doesn't write the frame to RDRAM) and so do its own
65
+ screenshots under WSL: take frames from Gopher64, or check values with `peek` instead.
56
66
  - **PC games:** a save file at that moment, loaded by hand. Then the tool only reads; leave
57
67
  `retroarch` out of the spec.
58
68