@wasm-gaming/rsdkv4-wasm 0.1.5 → 0.2.1

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.
@@ -1,99 +1,507 @@
1
- // Engine-specific options for RSDKv4.
2
- //
3
- // This is the authoritative description of what `EngineConfig.options` accepts
4
- // for this engine. It provides both:
5
- // - `Rsdkv4Options` — the compile-time type (for TS hosts/launchers)
6
- // - `RSDKV4_OPTIONS_SCHEMA` — the JSON Schema mirrored into manifest.json's
7
- // `options` (for runtime host UI + validation)
8
- // - `DEFAULT_RSDKV4_OPTIONS` — defaults the SDK falls back to.
9
- //
10
- // At runtime these options are serialized into RSDKv4's `settings.ini` (see the
11
- // SDK's settings serializer) when the host does not pass an explicit `settings`
12
- // asset.
13
-
14
- import type { JSONSchema } from '@wasm-gaming/engine-specs';
1
+ /**
2
+ * What this engine's four payloads accept, and the {@link RSDKV4_SPEC} that describes
3
+ * them to a host.
4
+ *
5
+ * ```ts
6
+ * import type { Rsdkv4Config, Rsdkv4Options } from '@wasm-gaming/rsdkv4-wasm/options';
7
+ * ```
8
+ *
9
+ * The contract's own module documents *how* the four payloads behave — they read as
10
+ * descriptors and write as patches, and `live` says whether a key reaches a running
11
+ * engine. This module is only the part that is RSDKv4's: which keys exist, what they
12
+ * mean here, and what the engine does with them.
13
+ *
14
+ * The split between the first two is the whole design:
15
+ *
16
+ * - {@link Rsdkv4Config} is **the engine**. It is serialized into RSDKv4's
17
+ * `settings.ini` and read once, at boot — so none of it is `live`.
18
+ * - {@link Rsdkv4Options} is **the session**: which character, which save slot, which
19
+ * stage. That is what a `restart()` reopens. It also carries the engine's own GAME
20
+ * OPTIONS rows, which *are* `live` — and which are not declared here at all, because
21
+ * they differ between Sonic 1 and Sonic 2 and are only knowable once the pack is
22
+ * loaded.
23
+ *
24
+ * @module
25
+ */
15
26
 
16
- export interface Rsdkv4Options {
27
+ import type { EnginePayloads, EngineSpec } from '@wasm-gaming/engine-specs';
28
+
29
+ /** Bytes a host can hand over for an asset. */
30
+ export type Rsdkv4AssetData = Uint8Array | ArrayBuffer | ArrayBufferView | string;
31
+
32
+ /**
33
+ * An asset, eagerly or on demand.
34
+ *
35
+ * The thunk form is what the old `dataProvider` / `settingsProvider` config fields
36
+ * were: `assets({ data: () => fetch(url).then((r) => r.arrayBuffer()) })`. See
37
+ * {@link Rsdkv4Assets} for when each one is actually called — they differ, and the
38
+ * difference is tens of megabytes.
39
+ */
40
+ export type Rsdkv4Asset = Rsdkv4AssetData | (() => Rsdkv4AssetData | Promise<Rsdkv4AssetData>);
41
+
42
+ /**
43
+ * The engine, as `settings.ini` — read once at boot, which is why nothing here is
44
+ * `live`. Change any of it and the engine has to come back up: `destroy()` and a new
45
+ * factory, not `restart()`.
46
+ *
47
+ * Regenerated on every boot, and that is safe: RSDKv4's `writeSettings()` is inside
48
+ * `#ifndef __EMSCRIPTEN__`, so this build never writes the file back and there is
49
+ * nothing of the player's in it to overwrite. A host that wants its own file hands one
50
+ * over as `assets.settings` instead, and then this payload is ignored.
51
+ */
52
+ export interface Rsdkv4Config {
17
53
  /**
18
- * RSDKv4's native in-canvas Dev Menu. Kept off by default: the launcher owns
19
- * the debug/stage-select UI (via `instance.devMenu`), and leaving this on has
54
+ * VSync the engine's SDL window.
55
+ *
56
+ * @defaultValue `true`
57
+ */
58
+ vsync?: boolean;
59
+ /**
60
+ * RSDKv4's native in-canvas Dev Menu. Off by default: a host that wants a
61
+ * debug/stage-select UI draws it from `play.devMenu`, and leaving this on has
20
62
  * historically produced a native menu-like screen at boot.
63
+ *
64
+ * @defaultValue `false`
21
65
  */
22
66
  devMenu?: boolean;
23
- /** RSDKv4 EngineDebugMode — enables the web devmenu embind bridge hooks. */
67
+ /**
68
+ * RSDKv4 `EngineDebugMode`. In this build it gates the engine's log output and
69
+ * nothing else — `play.devMenu` and `play.game` are embind bridges the wasm installs
70
+ * unconditionally, so they work either way.
71
+ *
72
+ * @defaultValue `true`
73
+ */
24
74
  engineDebugMode?: boolean;
25
- /** VSync the engine's SDL window. */
26
- vsync?: boolean;
27
75
  /**
28
- * Skip RSDKv4's in-canvas Start Menu (save select / character select / game
29
- * options). Set this when the host draws those screens itself from
30
- * `instance.game` — otherwise the engine's own menu runs underneath.
31
- */
32
- skipStartMenu?: boolean;
33
- /** Boot directly into a stage: 0-based stage-list category. */
34
- startingCategory?: number;
35
- /** Boot directly into a stage: 0-based scene within the category. */
36
- startingScene?: number;
37
- /** Starting player/character index. */
38
- startingPlayer?: number;
76
+ * Who draws the save-select / character-select / game-options screens.
77
+ *
78
+ * `'native'` leaves RSDKv4's own in-canvas Start Menu on. `'host'` skips it, for a
79
+ * host that renders those screens itself from `play.game` — otherwise the engine's
80
+ * menu runs underneath the host's.
81
+ *
82
+ * This is the old `skipStartMenu` boolean, the right way up: the inverted name meant
83
+ * `false` had to be read twice to mean "yes, show it".
84
+ *
85
+ * @defaultValue `'native'`
86
+ */
87
+ startMenu?: 'native' | 'host';
88
+ /**
89
+ * Where to load the Emscripten glue from. Defaults to `./rsdkv4.js` next to the
90
+ * built SDK, which is where `make build` puts it.
91
+ */
92
+ jsUrl?: string;
93
+ /** Where to load the wasm from. Defaults to `./rsdkv4.wasm` next to the built SDK. */
94
+ wasmUrl?: string;
95
+ }
96
+
97
+ /**
98
+ * A stage, as the engine's two-level stage list indexes it.
99
+ *
100
+ * `name` is **read-only**: the descriptors {@link Rsdkv4Options.stage} reports back
101
+ * carry one so a host can paint a stage picker straight from `options()`, but writing
102
+ * it is ignored — `category` and `scene` are what reach the engine.
103
+ */
104
+ export interface Rsdkv4Stage {
105
+ /** 0-based category, as ordered by `play.devMenu.getStageList()`. */
106
+ category: number;
107
+ /** 0-based scene within the category. */
108
+ scene: number;
109
+ /** `"<Category> · <Scene>"`, filled in by the SDK. Ignored on write. */
110
+ name?: string;
111
+ }
112
+
113
+ /**
114
+ * RSDKv4's fourteen buttons, in the engine's own `InputButtons` order.
115
+ *
116
+ * The order is not cosmetic: it is the bit order of the mask the SDK hands the
117
+ * engine once per tick, so this array is the wire format and not merely a list.
118
+ *
119
+ * Sonic 1 and Sonic 2 read only the four directions, A, B, C and start. The other
120
+ * six exist in the engine and are free for a host to do as it likes with.
121
+ */
122
+ export const RSDKV4_BUTTONS = [
123
+ 'up',
124
+ 'down',
125
+ 'left',
126
+ 'right',
127
+ 'a',
128
+ 'b',
129
+ 'c',
130
+ 'x',
131
+ 'y',
132
+ 'z',
133
+ 'l',
134
+ 'r',
135
+ 'start',
136
+ 'select',
137
+ ] as const;
138
+
139
+ /**
140
+ * One button, spelled as {@link RSDKV4_BUTTONS} spells it.
141
+ *
142
+ * Derived from the array rather than declared beside it, so there is one list and
143
+ * not two to drift apart — and so a typo in a `buttons` literal is a compile error
144
+ * rather than a button that silently never fires.
145
+ */
146
+ export type Rsdkv4Button = (typeof RSDKV4_BUTTONS)[number];
147
+
148
+ /**
149
+ * Every button as a boolean — what a host hands over to {@link Rsdkv4Options.buttons}
150
+ * and keeps writing to for as long as it holds the claim.
151
+ *
152
+ * All fourteen are required. A key that is merely absent reads as `false` on every
153
+ * tick, which is a dead button and no error anywhere; requiring the whole set is what
154
+ * turns that into something the compiler catches.
155
+ */
156
+ export type Rsdkv4Buttons = Record<Rsdkv4Button, boolean>;
157
+
158
+ /**
159
+ * What the engine binds each button to by default, for a host that has taken input
160
+ * over and now has to bind them itself.
161
+ *
162
+ * Not engine configuration — nothing here is read by the engine, and writing to it
163
+ * changes nothing. It is a starting table, so a host that claims input can offer the
164
+ * bindings a player already knows instead of inventing its own.
165
+ */
166
+ export interface Rsdkv4InputDefaults {
167
+ /** `KeyboardEvent.code` values, as `settings.ini`'s `[Keyboard 1]` binds them. */
168
+ keyboard: Record<Rsdkv4Button, string>;
169
+ /**
170
+ * Indices into `Gamepad.buttons` under the browser's **standard mapping**.
171
+ *
172
+ * These are translated, not copied: `settings.ini`'s `[Controller 1]` holds
173
+ * SDL's `SDL_CONTROLLER_BUTTON_*` values, and those are different numbers — SDL's
174
+ * left shoulder is 9, where the browser's is 4. A host polling the Gamepad API
175
+ * wants the browser's, so that is what this carries.
176
+ *
177
+ * `null` where the engine's default has no standard-mapping button: `select` is
178
+ * bound to SDL's GUIDE, which this build's own web-gamepad mapping never wires
179
+ * up, so it is dead on a pad in the engine too. `y` and `z` are the analog
180
+ * triggers (the engine reads them past a deadzone, as ZL/ZR).
181
+ */
182
+ gamepad: Record<Rsdkv4Button, number | null>;
39
183
  }
40
184
 
41
185
  /**
42
- * RSDKv4 reads 255 as "not set" for the starting stage/player (see Userdata.cpp:
43
- * anything else — **including 0** — makes Engine::Init skip the start-menu flow
44
- * and force InitStartingStage). So "boot normally" has to be 255, not 0.
186
+ * The engine's own default bindings. See {@link Rsdkv4InputDefaults}.
187
+ *
188
+ * Directions are the arrow keys. This build's `ProcessInput()` also reads `KeyW`,
189
+ * `KeyA`, `KeyS` and `KeyD` as a second set of them, and takes those three scancodes
190
+ * off `x`, `y` and `z` to do it — so the table below is what a *claiming* host should
191
+ * bind, and the engine under SDL polling answers to both.
192
+ *
193
+ * This replaces the old `RSDKV4_KEYMAP`, which nothing read and which was wrong in
194
+ * three ways for want of ever being checked against the engine: it listed 9 of the
195
+ * 14 buttons, and bound `select` to `ShiftLeft` where the engine's default is `Tab`.
45
196
  */
46
- export const RSDKV4_UNSET = 255;
47
-
48
- export const DEFAULT_RSDKV4_OPTIONS: Required<Rsdkv4Options> = {
49
- devMenu: false,
50
- engineDebugMode: true,
51
- vsync: true,
52
- skipStartMenu: false,
53
- startingCategory: RSDKV4_UNSET,
54
- startingScene: RSDKV4_UNSET,
55
- startingPlayer: RSDKV4_UNSET,
197
+ export const RSDKV4_INPUT: Rsdkv4InputDefaults = {
198
+ keyboard: {
199
+ up: 'ArrowUp',
200
+ down: 'ArrowDown',
201
+ left: 'ArrowLeft',
202
+ right: 'ArrowRight',
203
+ a: 'KeyZ',
204
+ b: 'KeyX',
205
+ c: 'KeyC',
206
+ x: 'KeyA',
207
+ y: 'KeyS',
208
+ z: 'KeyD',
209
+ l: 'KeyQ',
210
+ r: 'KeyE',
211
+ start: 'Enter',
212
+ select: 'Tab',
213
+ },
214
+ gamepad: {
215
+ up: 12,
216
+ down: 13,
217
+ left: 14,
218
+ right: 15,
219
+ a: 0,
220
+ b: 1,
221
+ c: 2,
222
+ x: 3,
223
+ y: 6,
224
+ z: 7,
225
+ l: 4,
226
+ r: 5,
227
+ start: 9,
228
+ select: null,
229
+ },
56
230
  };
57
231
 
58
- export const RSDKV4_OPTIONS_SCHEMA: JSONSchema = {
59
- type: 'object',
60
- additionalProperties: false,
61
- properties: {
232
+ /**
233
+ * The session — what a `restart()` reopens.
234
+ *
235
+ * **Absence is the neutral value.** The old `RSDKV4_UNSET = 255` sentinel is gone:
236
+ * leaving a key out means "boot the way the engine normally would", and there is no
237
+ * longer a number that quietly means something else. (In particular `player: 0` used
238
+ * to be indistinguishable from "unset" in the ini, which is why it was a footgun.)
239
+ *
240
+ * The index signature is not laziness. The engine's GAME OPTIONS rows — spin dash,
241
+ * item-box set, and whatever else the loaded pack declares — are keys neither this
242
+ * package nor the host can know ahead of time. They come back from `options()` as
243
+ * descriptors with their own labels and choices, `live: true`, and are written back
244
+ * the same way. That is what lets a host paint a settings screen without knowing a
245
+ * single key name.
246
+ */
247
+ export interface Rsdkv4Options {
248
+ /**
249
+ * The character to start a *new* game as, by the name the pack reports — the
250
+ * `enum` of this key's descriptor is exactly `play.game.players()`, so a host paints
251
+ * a character picker from it and writes one of the values straight back. Matched
252
+ * case-insensitively; an unknown name is an error rather than a silent Sonic.
253
+ *
254
+ * Continuing a slot that already has a save ignores this: the save carries its own
255
+ * character.
256
+ */
257
+ player?: string;
258
+ /**
259
+ * Which of RSDKv4's four save slots (0-3) the session runs on. `null` plays without
260
+ * saving, as the native menu's NO SAVE does.
261
+ *
262
+ * A slot with data continues it; an empty slot starts a new game as {@link player}.
263
+ */
264
+ slot?: number | null;
265
+ /**
266
+ * Jump straight to a stage, skipping wherever the session would otherwise open.
267
+ *
268
+ * Applied through the engine's own stage loader after boot, not through
269
+ * `settings.ini`'s `Starting*` trio — which is why it works on a `restart()` of a
270
+ * running engine and not only on the first one.
271
+ */
272
+ stage?: Rsdkv4Stage;
273
+ /**
274
+ * Take input over: hand the engine a live object of fourteen booleans and it stops
275
+ * polling SDL, reading yours instead — touch buttons, rebinding, netplay, a test
276
+ * that drives a stage from a script.
277
+ *
278
+ * ```ts
279
+ * const buttons = { up: false, down: false, ...rest, select: false }; // all 14
280
+ * play.options({ buttons }); // claim
281
+ * play.options({ buttons: null }); // release — the engine polls SDL again
282
+ * ```
283
+ *
284
+ * **Read once per tick, from wherever it lives.** The engine calls in at the top of
285
+ * its input pass and the SDK reads the object at that moment, so a plain object and
286
+ * a reactive store both work and neither one needs the SDK to know which it is.
287
+ * Whatever is `true` when the engine asks is what the engine sees.
288
+ *
289
+ * Three things become the host's the moment it claims:
290
+ *
291
+ * - **Keyup on focus loss.** SDL resets its keyboard when the window loses focus; a
292
+ * host that owns input inherits that job (`blur`, `visibilitychange`) or a held
293
+ * arrow strands the player mid-run.
294
+ * - **The gamepad, entirely.** The engine stops polling it, so a host that wants one
295
+ * polls the Gamepad API itself — deadzones and the D-pad-from-axes fallback
296
+ * included. {@link RSDKV4_INPUT} is the table to start from.
297
+ * - **Releasing.** Absence means "leave the claim as it is"; only `null` releases.
298
+ * A component that claims and then unmounts without releasing leaves the engine
299
+ * pulling at an object nobody writes to any more.
300
+ *
301
+ * Not persistable, and not a settings row: it reads back from `options()` as `null`
302
+ * whether or not a claim is held, so that `JSON.stringify(await play.options())`
303
+ * cannot sweep fourteen transient booleans into a host's saved settings. Ask
304
+ * `play.input.claimed` for the claim state.
305
+ *
306
+ * `play.input.claim(buttons)` and `play.input.release()` are the same thing, named.
307
+ */
308
+ buttons?: Rsdkv4Buttons | null;
309
+ /**
310
+ * The engine's GAME OPTIONS rows. See the note on the interface: these are declared
311
+ * by the loaded pack, not here.
312
+ *
313
+ * A `boolean` row reads and writes as a boolean, an enum row as one of its choice
314
+ * labels; the raw engine-side number is accepted on write too.
315
+ */
316
+ [key: string]: unknown;
317
+ }
318
+
319
+ /**
320
+ * The two files the engine reads out of its working directory.
321
+ *
322
+ * Neither is `live`: they are read while the engine comes up, so a patch after that
323
+ * lands in the state a *future* engine would boot from.
324
+ */
325
+ export interface Rsdkv4Assets {
326
+ /**
327
+ * The `Data.rsdk` pack — the whole game, and what decides *which* game: one
328
+ * game-agnostic wasm runs both Sonic 1 and Sonic 2, the pack is the difference.
329
+ *
330
+ * Precedence, and the reason the thunk form exists: bytes handed over here win;
331
+ * otherwise a copy already persisted in this storage namespace is reused; only if
332
+ * there is neither is a thunk called. That is what keeps a host from re-fetching
333
+ * tens of megabytes it already has. With none of the three, `start()` fails.
334
+ */
335
+ data?: Rsdkv4Asset;
336
+ /**
337
+ * A ready-made `settings.ini`, for a host that would rather write the file itself
338
+ * than describe it through {@link Rsdkv4Config}. Given one, the config payload is
339
+ * not serialized at all.
340
+ *
341
+ * Unlike `data`, a thunk here is called on **every** boot rather than only on a
342
+ * cache miss — the file is a few hundred bytes, and re-reading it is what makes the
343
+ * host's copy authoritative instead of whatever an earlier session left behind.
344
+ */
345
+ settings?: Rsdkv4Asset;
346
+ }
347
+
348
+ /** Where this engine's files live, and whether they outlive the page. */
349
+ export interface Rsdkv4Storage {
350
+ /**
351
+ * Per-game folder for the pack, the settings and the save file, so two games do not
352
+ * overwrite each other. Examples: `"sonic1"`, `"rsdkv4/Sonic2"`.
353
+ *
354
+ * It is a path under the engine's working root *and* the OPFS directory the SDK
355
+ * mirrors save data into, which is what lets a host read `<namespace>/SData.bin`
356
+ * itself. Anything that is not a usable relative path normalises to `"default"` —
357
+ * including the object you get from interpolating a game record by mistake.
358
+ *
359
+ * @defaultValue `"default"`
360
+ */
361
+ namespace?: string;
362
+ /**
363
+ * What the engine's working directory is backed by.
364
+ *
365
+ * `'opfs'` forces a persistent mount and warns if it cannot have one; `null` means
366
+ * the host wants nothing kept, which switches off the save mirror as well; leaving
367
+ * it out picks OPFS when the page is cross-origin isolated.
368
+ *
369
+ * Worth knowing: on every build without Asyncify/JSPI — today's included — the mount
370
+ * itself cannot be OPFS, so the working dir is in-memory whatever this says. Saves
371
+ * survive anyway, because the SDK mirrors `SData.bin` into
372
+ * `<namespace>/` through the host-side OPFS API. `null` is what turns that off.
373
+ */
374
+ persist?: 'opfs' | null;
375
+ }
376
+
377
+ /** One of RSDKv4's four save slots, as the engine's own save-select screen sees it. */
378
+ export interface RsdkSaveSlot {
379
+ /** 0-3. */
380
+ slot: number;
381
+ /** No game stored here — starting it means picking a character first. */
382
+ empty: boolean;
383
+ /** Character index into `play.game.players()`: 0 Sonic, 1 Tails, 2 Knuckles, 3 both. */
384
+ character: number;
385
+ lives: number;
386
+ score: number;
387
+ emeralds: number;
388
+ /** Stage list the save resumes into (1 regular, 3 special), or -1 when empty. */
389
+ list: number;
390
+ /** 0-based scene within `list` — index it against `play.devMenu.getStageList()`. */
391
+ zone: number;
392
+ }
393
+
394
+ /**
395
+ * What this engine announces on top of the contract's core set (`start`, `error`,
396
+ * `exit`, `pause`, `resume`).
397
+ */
398
+ export interface Rsdkv4Events {
399
+ /**
400
+ * The save file changed, with every slot as it now stands.
401
+ *
402
+ * Emitted when the SDK has just written `<namespace>/SData.bin` out of the wasm and
403
+ * the bytes are not what they were — on its slow timer, on a pause, and on the way
404
+ * down. A host painting save slots subscribes to this instead of polling.
405
+ */
406
+ saves: RsdkSaveSlot[];
407
+ }
408
+
409
+ /** The four payloads, closed — the single type parameter everything else takes. */
410
+ export interface Rsdkv4Payloads extends EnginePayloads {
411
+ config: Rsdkv4Config;
412
+ options: Rsdkv4Options;
413
+ assets: Rsdkv4Assets;
414
+ storage: Rsdkv4Storage;
415
+ events: Rsdkv4Events;
416
+ }
417
+
418
+ /**
419
+ * Everything the engine declares about its own properties, as data.
420
+ *
421
+ * `default` appears here and nowhere else: the contract's base class seeds the
422
+ * starting state from it, so there is no second table of defaults to drift out of
423
+ * agreement with this one — which is exactly what the old
424
+ * `DEFAULT_RSDKV4_OPTIONS`-alongside-a-JSON-Schema pair did.
425
+ *
426
+ * What is missing from `options` is deliberate: `player` and `stage` get their `enum`
427
+ * filled in from the loaded pack, and the GAME OPTIONS rows are added outright, when a
428
+ * running engine is asked to describe itself.
429
+ */
430
+ export const RSDKV4_SPEC: EngineSpec<Rsdkv4Payloads> = {
431
+ config: {
432
+ vsync: { default: true, live: false, description: 'VSync the engine window.' },
62
433
  devMenu: {
63
- type: 'boolean',
64
434
  default: false,
65
- description:
66
- "RSDKv4's native in-canvas Dev Menu. The launcher provides its own overlay via instance.devMenu, so keep this off.",
435
+ live: false,
436
+ description: "RSDKv4's native in-canvas Dev Menu. Hosts draw their own from play.devMenu.",
67
437
  },
68
438
  engineDebugMode: {
69
- type: 'boolean',
70
439
  default: true,
71
- description: 'Enables the web devmenu embind bridge (stage list / warp / pause).',
440
+ live: false,
441
+ description: "Gates the engine's log output. The embind bridges are installed either way.",
72
442
  },
73
- vsync: { type: 'boolean', default: true },
74
- skipStartMenu: {
75
- type: 'boolean',
76
- default: false,
443
+ startMenu: {
444
+ default: 'native',
445
+ enum: ['native', 'host'],
446
+ live: false,
77
447
  description:
78
- "Skip the engine's own save/character/options screens — set it when the host renders them from instance.game.",
448
+ "Who draws save/character/options: the engine's own menu, or the host from play.game.",
449
+ },
450
+ jsUrl: { live: false, description: 'Emscripten glue URL. Defaults to ./rsdkv4.js.' },
451
+ wasmUrl: { live: false, description: 'WASM URL. Defaults to ./rsdkv4.wasm.' },
452
+ },
453
+ options: {
454
+ // No `default` on any of the three: absence is what "boot normally" means here,
455
+ // and a default would take that away.
456
+ player: {
457
+ live: false,
458
+ description: 'Character for a new game, by name. Choices arrive once the pack is loaded.',
459
+ },
460
+ slot: {
461
+ enum: [null, 0, 1, 2, 3],
462
+ live: false,
463
+ description: 'Save slot 0-3, or null to play without saving.',
79
464
  },
80
- startingCategory: {
81
- type: 'integer',
82
- minimum: 0,
83
- default: RSDKV4_UNSET,
84
- description: '0-based stage-list category; 255 = unset (normal boot flow).',
465
+ stage: {
466
+ live: false,
467
+ description: 'Jump straight to a stage. Choices arrive once the pack is loaded.',
85
468
  },
86
- startingScene: {
87
- type: 'integer',
88
- minimum: 0,
89
- default: RSDKV4_UNSET,
90
- description: '0-based scene in the category; 255 = unset (normal boot flow).',
469
+ // No `default`, for the same reason as the three above: absence is what "the
470
+ // engine polls SDL as usual" means, and only `null` is a release.
471
+ //
472
+ // `live` because it is the one option that reaches a running engine directly
473
+ // rather than through a restart — and the description says the rest out loud,
474
+ // because the contract has no flag for "transient, do not paint, do not
475
+ // persist" and a host reading descriptors to build a settings screen would
476
+ // otherwise put fourteen booleans on it.
477
+ buttons: {
478
+ live: true,
479
+ description:
480
+ 'Host-driven input: a live object of 14 booleans the engine reads once per tick, or null to hand input back. Transient — not a settings row, not persistable, and it always reads back as null.',
481
+ },
482
+ },
483
+ assets: {
484
+ data: {
485
+ allowedTypes: ['.rsdk'],
486
+ live: false,
487
+ description: 'The RSDKv4 game data pack. Selects the game; required to start.',
488
+ },
489
+ settings: {
490
+ allowedTypes: ['.ini'],
491
+ live: false,
492
+ description: 'A ready-made settings.ini. Omitted, one is generated from config.',
493
+ },
494
+ },
495
+ storage: {
496
+ namespace: {
497
+ default: 'default',
498
+ live: false,
499
+ description: "Folder for this game's pack, settings and save file.",
91
500
  },
92
- startingPlayer: {
93
- type: 'integer',
94
- minimum: 0,
95
- default: RSDKV4_UNSET,
96
- description: 'Player/character index; 255 = unset (normal boot flow).',
501
+ persist: {
502
+ enum: ['opfs', null],
503
+ live: false,
504
+ description: "'opfs' forces persistence, null keeps nothing, absent auto-detects.",
97
505
  },
98
506
  },
99
507
  };