save-selector script selection buffer and branch-state handlers
Selection buffer: context field 0x000000a8; values select one of 12 branch-state slots.
Pointer to a per-script selection buffer addressed by byte offsets from stream+2. Opcodes 0x11, 0x12, and 0x13 use stream+2 as an offset into this buffer; the resulting byte selects one of 12 branch-state table slots.
| opcode | handler | name | summary | signatures |
|---|---|---|---|---|
0x10 | 0x0040b49e | build branch-state table | Chooses primary/secondary branch-state table from stream+1, passes stream+2 to helper 0x00410c90, then advances the script stream by 4 bytes. | ok |
0x11 | 0x0040b4e6 | branch on selected state | Reads index (context+0xa8)[stream+2], then tests stateTable[index]. State value 1 falls through by 8 bytes; any other value jumps to dword [stream+4]. | ok |
0x12 | 0x0040b55f | select previous/next active state slot | Scans the 12-slot branch-state table for a nonzero entry, starting from (context+0xa8)[stream+2] when runtime flag 0x00457744 is set, stores the selected slot back into (context+0xa8)[stream+2], then advances by 4 bytes. | ok |
0x13 | 0x0040b696 | select matching runtime state slot | Computes the active slot base from 0x004576e9/0x00457750, clears (context+0xa8)[stream+2], scans 12 runtime slots, compares per-slot bytes from 0x0059e344 with slot fields +0x4a/+0x48, stores the matching slot index back into (context+0xa8)[stream+2], then advances by 4 bytes. | ok |
helper | 0x00410c90 | fill branch-state table | Dispatches by stream+2 value and fills a 12-byte state table. The simplest helper path writes 1 before the requested slot and 0 after it; later paths write 0/1/2 from party, menu, item, or progress-related runtime tables. | ok |
0: inactive/unavailable1: active/pass branch test2: visible but blocked or unmet conditionHelper jump table 0x00410db0 accepts cases 0x00..0x0b.
| case | entry | target | callee | argument | state values | pattern | persistence/reset note | verified |
|---|---|---|---|---|---|---|---|---|
0x00 | 0x00410db0 | 0x00410ca6 | 0x00410de5 | constant 2 | 1/0 | prefix fill: slots before N become 1, remaining slots become 0 | supports predecessor fill 0x00000210; produces slots 0..1 as 1 | True |
0x01 | 0x00410db4 | 0x00410cb9 | 0x00410de5 | constant 4 | 1/0 | prefix fill: slots before N become 1, remaining slots become 0 | would overwrite table with slots 0..3 as 1 | True |
0x02 | 0x00410db8 | 0x00410ccc | 0x00410de5 | constant 5 | 1/0 | prefix fill: slots before N become 1, remaining slots become 0 | would overwrite table with slots 0..4 as 1 | True |
0x03 | 0x00410dbc | 0x00410cdf | 0x00410de5 | constant 6 | 1/0 | prefix fill: slots before N become 1, remaining slots become 0 | would overwrite table with slots 0..5 as 1 | True |
0x04 | 0x00410dc0 | 0x00410cf2 | 0x00410de5 | byte 0x004576e8 | 1/0 | runtime prefix fill | runtime value can overwrite the prefix width | True |
0x05 | 0x00410dc4 | 0x00410d09 | 0x00410e40 | constant 6 | 0/1/2 | party/item threshold table; missing entries 0, insufficient entries 2, pass entries 1 | runtime party/item state can rewrite the first six slots | True |
0x06 | 0x00410dc8 | 0x00410d1c | 0x00410f23 | constant 6 | 0/1/2 | paired runtime flags at 0x004576ec/0x004576ed; writes 0/2/1 | runtime flags can rewrite the first six slots | True |
0x07 | 0x00410dcc | 0x00410d2f | 0x00410fc4 | constant 6 | 0/1 | indexed table using 0x0059e33e, 0x0059e344, and 0x0045779a | runtime table can rewrite the first six slots | True |
0x08 | 0x00410dd0 | 0x00410d42 | 0x00411068 | constant 5 | 1/0 | counts nonzero flags at 0x004576f8 and fills a derived prefix width | runtime count can rewrite the first five slots | True |
0x09 | 0x00410dd4 | 0x00410d55 | 0x00411138 | constant 6 | 0/1/2 | runtime group from 0x0059e345 plus paired flags at 0x004576f8/0x004576f9 | runtime flags can rewrite the first six slots | True |
0x0a | 0x00410dd8 | 0x00410d68 | 0x004111e5 | byte 0x004576e8 | 1/0 | compares object pointers from 0x0059db30 via helper 0x00433a30 | object comparison can rewrite a runtime-sized prefix | True |
0x0b | 0x00410ddc | 0x00410d7f | 0x0041127d | word 0x0059db28 | 0/1 | checks object table 0x0059db3c field +0x62 bit 0x80 | object flags can rewrite a runtime-sized prefix | True |