Script interpreter routines
Routines · Data · Address index
The block event dispatcher, the opcode handlers and the helpers they call. The routines page explains how the entries are written.
0x27aa9 — Block event dispatcher
- Role: Single entry point of the script interpreter, reached from 23
far call sites. It applies the event gating, starts a script run and
executes its command loop. At
0x27ab2–0x27ac3it copies the 30 handler pointers of the opcode handler table; at0x27b37–0x27b67it dispatches each command byte from-1to-30to the handler at index-(command + 1). It has no re-entry guard: a run keeps its command position in its own frame, but resets the run variable, block, event mask, stop flag, selected character and level-load flag when it starts (0x27b08–0x27b21) and does not restore them. It does not reset the call depth: a nested run inherits the pending calls of the outer one (ANOMALY-83, missing reset in0x27b08–0x27b21). Its timer, step-count, party-move, level-change and level-settle callers all pass a block, so every run starts at a block's script offset. The block index is multiplied by 10 without a range check (0x27ac8–0x27ad1), and a nonzero script offset is added to the script buffer without one (0x27b27–0x27b34). Command bytes0x00–0xe1are skipped one at a time (0x27b43–0x27b4a); the loop ends only when the stop flag or the level-load flag is set. - Comparative source: REF-SCUMM-003,
EoBInfProcessor::run. - Used by: Block events, Block state flags › The gating rule, Block state flags, Condition expression tokens › How the encodings were checked, Direction change targets, The engine › How the systems connect, How the systems affect one another › Scripts started by scripts, Level block › In brief, Level data (INF) › Organization, Move the party, monsters or items › Moving the party, Level records and level changes › Settling the level, Script instructions, Instruction encoding › Commands and operands, How a script runs › Conditions, Events that start scripts, How a script runs › A run, Events that start scripts › Monsters entering and leaving blocks, How a script runs › Scripts and the game's state, Events that start scripts › Which events a block accepts, Timed scripts › Timed block scripts, Script virtual machine › How a run starts, Control flow, Decoding status and unexpected values › Unexpected values, Values passed on to other routines › The routines, Loading, failures and the end of the game, Level maps, Level 1: reference tables, Level 2: reference tables, Level 12: reference tables, Level 14: reference tables, Anomalies and bugs, Level 15: reference tables › Stairs
Opcode handlers
The table lists the handler of each script instruction, as read from the opcode handler table. A located handler does not mean that every path through it has been examined: Partial in the coverage column means that only selected paths were examined; for the other handlers, the control flow was followed. Each instruction's page describes its encoding and effects.
0x27236 — Load a level or monster resources
- Range:
0x27236–0x27368 - Anomaly:
ANOMALY-155: the party's block is written at0x27291, before the call at0x2729fthat settles the old level; the level number passed at0x272a4is read after it. - Role: Handler of opcode
0xec, also stored as cell 34 of the handler cell table. With selector0xe5it loads a level through the overlay routines0x49fa5,0x493caand the INF level loader; other selectors go to0x27308–0x27368, which releases the 18 shapes of one monster graphics bank (0x27320) and calls a monster image loader with the name, the bank's first entry and 1 (0x27344); the selector byte itself is not passed on. After loading a level, it calls the dialogue restore when the dialogue-active flag is set (0x272d1–0x272d8), then places the party on the arrival block with move the party (0x272e2–0x272e4) and sets the stop flag (0x272e9). Both forms first close the inventory panel and the spell book (0x1ed9b,0x27249). The level form also turns page waits off (0x272af), selects the message window (0x272b8), calls the empty routine0x3f807(0x272dd) and redraws every portrait (0x272f9). Because the party's block is written at0x27291, the party move sends the leave event, then the enter event, to the arrival block. The monster form ends with rebuild the play screen (0x27354). - Used by: Change level or load monster resources › Behavior, Facing after a level load, Changing level › When the game loads a level, Changing level › Returning to a level, Changing level › When the game loads a level, Load instruction targets, Monster slot › Copying runtime state, Level records and level changes › Changing level, Scripted movement, monsters and items › Moving the party, monsters and items, Scripted movement, monsters and items › Moving the party, monsters and items, Scripted movement, monsters and items › Moving the party, monsters and items, Dialogue screen › Edge cases and unknowns, Script virtual machine › How a run starts, Decoding status and unexpected values › Unexpected values, Change level or load monster resources › Monster-resource loading, Values passed on to other routines › The routines, Change level or load monster resources, Anomalies and bugs, Level 7: reference tables › Arrival and the way down, Level 13: reference tables › The glass trap, Level 14: reference tables › The pits to level 11
0x27174 — Count monsters for a condition
- Range:
0x27174–0x271c4 - Role: Helper of the condition evaluator: counts the monsters
matching the values listed in a condition and adds them to the result.
Only monsters whose slot byte
+0x1dequals the current sublevel are counted (0x2719d–0x271a6); this is the only reader of that byte in the resident image and the overlays. - Comparative source: REF-SCUMM-003,
oeob_eval_v2. - Used by: Sublevels › The two records, Test a condition › Monster counts