How it works · write-up
ROM motion-script reader and core update
Working notes, rendered as they are: they were written while building the game, so expect ROM addresses, register names and references to source files that are not published.
rom-script-interpreter.ts translates the $159D bytecode reader. native-core-script.ts translates its $142E parent and the shared $00/$01 record paths. FirstSectionGame uses these same helpers for ordinary play and lab scenarios; scenarios supply initial state only.
Script format
A placement supplies two position bytes followed by a motion stream. scriptPointer is an absolute source address. A byte with low five bits other than $1F is a heading followed by a duration. Special bytes select the raw $15DE table:
| Byte | Reader effect |
|---|---|
| heading, duration | Set heading, pose heading, vector, phase $00 and timer. |
$1F |
Set timer to one and request the gate through scene gateRequest (E094). The next scripted pass consumes the request. |
$3F, speed |
Change the speed index without reloading the timer or recalculating the current vector. The parent decrements its zero timer to $FF. |
$5F |
Change subtype to $01, clear timer and skip the parent's decrement/movement via the source stack exit. The caller still accepts the retained candidate and may draw walking art. |
$7F, duration |
Aim from accepted whole coordinates toward the player, select vector, phase $03 and timer. |
$9F |
Select phase $04, timer $18. |
$BF |
Select phase $05, timer $40. |
$DF, duration |
Select phase $06 and timer. |
$FF |
Recalculate the current heading's vector, select phase $00, timer $FF, and leave the pointer on $FF for repetition. |
readRomScriptCommand() returns a new typed state and reads one command. The parent owns movement and decrements the resulting timer in the same update except after $5F. Phases $00/$01/$02/$03/$07 use candidate movement and shared fire; $04 draws the three hold bands and launches $0D when the decremented timer equals $08; $05 uses all eight offset-pose bands; $06 scrolls and attempts shared fire. Phase zero bypasses the $1444 table at $143C; its table entry is not a reachable selector outcome.
Owned state and ordered effects
Accepted coordinates (+$03/+$05) and retained candidates (+$07/+$09) are distinct typed fields. $1591 responds to any nonzero scroll pulse by subtracting one whole pixel from both X words. $1358 replaces the movement candidates; holds can retain them. $1388 checks subtype, grace, scenery and the background mask in source order, commits accepted candidates or accumulates a rejection flag. The exact returned accumulator controls the walking clock. A pending turn bypasses script timing; $FF rejection removes the record.
Pose $05 draws before candidate commit. Native sprites are authoritative for arcade presentation: partial writes, hidden Y fields and retained images are preserved. Death $1786 scrolls first, changes $3F to $20, sends sound $14 then the $1827 score request, and retains the preceding output on that update. Later draws use the previous state's parity. Release clears only the source fields and three sprite Y values.
The shared fire allocator and descending $E500 grenade allocator are invoked at their source points in the physical core-slot scan. Grenades use the origin before scroll and first move in the next scripted pass. Gameplay fields have typed owners; byte packing appears only in native snapshot tests.
Verification and scope
The existing routine_0F9E review holds the source audit; FIRST_SECTION_OBLIGATIONS.md is its generated report. native-core-script.test.ts compares 928 controlled MAME core passes, including full core/scripted/shot/scenery buffers, all sprite fields, command/sound rings and pointers, counters and ordered effects. The independently observed 126 applicable conditional outcomes and 17 selector cases reconcile with the audit. Four conditional outcomes and the phase-zero table selector have explicit source exclusions.
The matrix includes 32 controlled RAM script streams for $3F and phase aliases $01/$02/$07; these are helper verification, not evidence of natural first-section scripts. Existing eight-script and long-route selected-state comparisons remain useful within their narrower scope. Six runtime integration regressions and five HTTP lab scenarios check effect delivery, retained output, grenade timing, offset conversion, removal and physical firing priority. This audit does not certify other core kinds, other reader callers or whole-frame arcade fidelity. Evidence and source addresses are in RESEARCH.md.