Script data
Data · Routines · Address index
The opcode handler tables, level and global flags, the script buffer and stacks, and the state of a script run. The data page explains how the entries are written.
DS:0x5a75 — Handler cells
- Layout: 4-byte far pointers
- Role: Table of handlers. Cells 0–9 serve the record runner; the opcode handler table starts at cell 15.
- Used by: Wall interaction types, Values passed on to other routines › The routines, The world
DS:0x5aa5 — Indirect handler table
- Layout: three far pointers (cell 12 of the handler cells), followed directly by the opcode handler table
- Role: The monster image loaders of the monster-resource form of the
0xechandler, indexed at0x27344: stub entries0x2ae3:0x2a,0x2ae3:0x39and0x2ae3:0x2f, that is the monster image loaders0x47dfa,0x47e98and0x47f36, the same as the monster loader table. The handler calls them with the name, 18 × bank and 1 (decorations), after the release of the bank at0x27320. - Used by: Change level or load monster resources › Behavior, Decoding status and unexpected values › Unexpected values, Change level or load monster resources › Monster-resource loading, Values passed on to other routines › The routines
DS:0x5ab1 — Opcode handler table
- Layout: 30 far pointers (file offsets
0x33e11–0x33e88) - Role: Handler of each script instruction, at index
-(command + 1); see the opcode handlers. - Used by: Script instructions, Decoding status and unexpected values › Decoding status, Instruction encoding › Commands and operands, Events that start scripts, Values passed on to other routines › The routines
DS:0x6d7c — Script run variable
- Layout: byte
- Role: Read by expression token
0xe4; a dialogue stores the chosen answer plus one in it. - Used by: Clear a flag › Encoding, Condition expression tokens › How the encodings were checked, How the systems affect one another › Scripts started by scripts, How a script runs › Scripts and the game's state, Set a flag › Behavior
DS:0x6de2 — Level flags
- Layout: one dword per level, at
0x6de2 + 4 × level - Role: Flags set and tested by scripts for each level.
- Used by: Clear a flag › Encoding, Scripted characters, flags and messages › Flags and resting, Set a flag › Behavior, Saved games (SAV), Level 11: reference tables
DS:0x6e26 — Global script flags
- Layout: dword
- Role: Flags shared by all levels; see
ScriptGlobalFlags. The party status check tests bit 20 (0x10of the high wordDS:0x6e28, at0x1ff85–0x1ff95) to choose the defeat scene; the hand drawing of the portraits tests bit 31 (0x8000of the high word,0x29a41–0x29a51) and then draws the shapeDS:0xd082for an empty first hand instead of the usual one (DS:0xd03a). The other direct accesses: the monster code sets bits 18 and 27 (0x19bf6–0x19c11), the dialogues of overlay 252 set bits 3, 5 and 6, Insal's departure clears bits 1 and 2, the set and clear instructions write the bits they name (0x26435,0x2656b) and the script test reads them (0x269fe). - Status: register-computed reads other than the save block copies
(overlay code at file offsets
0x49a06,0x49cb1) were not searched. - Used by: The game loop › When the party is defeated, Clear a flag › Encoding, Global script flags, Monster state flags › Provoked monsters, Resting: special cases › Insal leaves, Run a sequence › Conversations with characters, Set a flag › Behavior, Level 15: reference tables › Level flags, Saved games (SAV), Level 12: reference tables › Khelben's vision, Level 2: reference tables › Shorn
DS:0x71af and DS:0xe445 — Character-pair tables of the text output
- Layout: 16 bytes at
DS:0x71af; 128 bytes atDS:0xe445 - Role: The character reader of the text output
replaces a byte c from
0x80up byDS:0x71af[(c >> 3) & 15] (0x32399) followed byDS:0xe445[c &0x7f] (0x3238e). Both tables are zero in the executable image (physical0x3550fand0x3c7a5), and these two reads are the only literal references to them, so the game has no character pairs to expand and such a byte gives no character (see the character reader for where it is skipped and where it ends the text). Nothing writes them with the original data: only out-of-range values would, a monster slot 30 initialized from level data (which coversDS:0x71af) or a block number from 1,661 to 1,673 (whose bytes coverDS:0xe445). - Used by: Initial items (ITEM.DAT) › Who uses it
DS:0x71c4 — Script buffer
- Layout: far pointer
- Role: The level's scripts; the first word of the buffer is the offset of
its message table. The pointer is set once, at
0x18b84–0x18b88, which leaves0x1d54(7,508) bytes before the next area it carves. Its readers are the dispatcher, the jump and call handlers (0x266cb,0x26788,0x270ef), the message lookups (0x26345,0x2775d–0x2782a) and the INF copy. - Used by: Call a subroutine › Behavior, Jump › Behavior, Level data (INF) › Organization, Print a message › The message table, Decoding status and unexpected values › Unexpected values, Script virtual machine
DS:0x92da, DS:0x946c — Expression stack
- Layout: words; index
- Role: Value stack of script condition expressions and its index:
word i is at
DS:0x92da+ 2 i. Every access to the index is in the0xeehandler (push0x270ac–0x270b6, operators from0x26e9f, final pop0x270cf–0x270d9). The index is zero in the program image, never reset, not saved with a game and not bounds-checked. No other code found addresses the first 30 words; word 30 overlapsDS:0x9316andDS:0x9317, word 33DS:0x931c, word 200 the stop flag and word 201 the index; word −1 isDS:0x92d8, a byte written at overlay0x47066and read at0x29796. - Used by: Condition expression tokens, Test a condition › Behavior, Test a condition › The expression stack
DS:0x931c — Character selected by a script
- Layout: byte
- Role: Character chosen by the running script;
0xffmeans none. - Used by: Condition expression tokens › Operand layouts, How the systems affect one another › Scripts started by scripts, Print a message › Behavior, How a script runs › Scripts and the game's state, Test a condition › Behavior, Test a condition › The expression stack
DS:0x946a — Script stop flag
- Layout: flag
- Role: Stops the current script run.
- Used by: Change level or load monster resources › Behavior, End the script › Behavior, How the systems affect one another › Scripts started by scripts, Test a condition › The expression stack
DS:0xa2ce — Block of the current event
- Layout: word
- Role: The block whose event is being processed.
- Used by: How the systems affect one another › Scripts started by scripts, How a script runs › Scripts and the game's state, Turn the party or flying objects › Behavior, Monsters in the view › Drawing a monster
DS:0xdf2a — Last spell cast
- Layout: signed byte
- Role: The definition number of the last spell cast, written only by the
cast routine at
0x2253c; pushed by expression token0xdf,SCRIPT_EXPR_LAST_CAST_SPELL, and also read at0x21630and0x2494c. The cast routine compares it with 62, Turn undead, to skip the spell-slot update. - Comparative source: REF-SCUMM-003,
_activeSpellinoeob_eval_v2. - Used by: Condition expression tokens › Operand layouts, Level 11: reference tables › The carvings and Dispel Magic
DS:0xe4d4 — Script call stack
- Layout: far pointers, at
0xe4d4 + 4 × depth - Role: Return addresses of script calls.
- Used by: Call a subroutine › Behavior, Return from a call › Behavior, Control flow
DS:0xe59e — Script call depth
- Layout: signed word
- Role: Current depth of script calls; at most 10. Written by the
end (0), return (−1 when
nonzero) and call (+1 below 10) handlers, the
level change (0,
0x272fe) and the party move (restored,0x25f86); the dispatcher does not reset it when a run starts. - Used by: Call a subroutine › Behavior, End the script › Behavior, Return from a call › Behavior, Control flow, Return from a call › Edge cases and unknowns
DS:0xe5a6 — Level loaded during the run
- Layout: flag
- Role: Set when a level was loaded during the current script run.
- Used by: Change level or load monster resources › Behavior, Move the party, monsters or items › Moving the party
DS:0xee22 — Event mask of the current run
- Layout: word
- Role: Event mask of the running script, read by expression token
0xe0. - Used by: Condition expression tokens › How the encodings were checked, How the systems affect one another › Scripts started by scripts, How a script runs › Scripts and the game's state