Skip to main content

Set walls or a direction

SCRIPT_SET · opcode 0xff · 2 to 6 bytes

Script virtual machine · Opcode list · Scripted wall assignment

Replaces the walls of a block, or one of its sides, with a given wall reference; a third form stores a direction value.

Encoding​

Offsets count from the opcode byte. Words are little-endian. The byte at offset 1 is a ScriptSetTarget and decides what follows.

SelectorByteOperands after the selectorSize
SCRIPT_SET_BLOCK_WALLS0xf7block: u16le, wall: u85 bytes
SCRIPT_SET_BLOCK_SIDE0xe9block: u16le, side: s8, wall: u86 bytes
SCRIPT_SET_DIRECTION0xeddirection: s83 bytes
Any other value—None2 bytes

Example (constructed, not from a level): ff f7 ab 00 1a gives all four sides of block 171 the wall reference 26, WALL_REFERENCE_CLEARED_ON_ENTRY of SpecialWallReference. Block 171 is position [11:05], with block = YY × 32 + XX.

Behavior​

  • All walls. wall is written to the four wall references of the block's LevelBlockRuntime.
  • One side. wall is written to the reference selected by side.
  • Direction. The sign-extended direction becomes the party's facing, the value the turn commands change and SCRIPT_EXPR_PARTY_DIRECTION reads. Unlike Turn, the instruction requests no redraw. Of the 90 reference instructions, 40 come right after a party move; the others are followed, within eight instructions of straight code, by a scene redraw (31), a dialogue (11), a party move (5) or a sequence (3).

After a wall write, the handler passes the block to a helper that marks the view for redrawing when the block is one of the 15 blocks in view ahead of the party. Neighboring blocks are not changed.1

The temporary level state saved on a level change collects these wall references, so a level restored from it keeps the changes; see scripted wall assignment.

Edge cases​

  • side is not range-checked: the handler writes wall at byte side of the block's LevelBlockRuntime entry, counted from its first wall and read as signed: 0–3 are the four walls, in the order of the structure page, and the other values from −128 to 127 reach the entry's other fields — 8 and 9 are its script_offset — and the ten-byte entries around it. The reference scripts use 0–3 only.
  • direction is not reduced to 0–3. Movement and drawing use the facing to index four-entry tables, which a value outside 0–3 reads past, until the next turn brings the facing back to 0–3. The reference scripts use 0 to 3 only.
  • The handler skips unlisted selectors after reading them. See also unexpected values.

Observed use​

The reference scripts use SCRIPT_SET_BLOCK_WALLS 592 times, SCRIPT_SET_BLOCK_SIDE 166 times and SCRIPT_SET_DIRECTION 90 times, with direction 0 (29 times), 1 (23), 2 (20) and 3 (18).

Sources​

Footnotes​

  1. Handler for 0xff, the block-update helper, the party direction and the block table. Comparative source: oeob_setWallType in REF-SCUMM-003. Statistics come from decoding the scripts reachable in the 16 reference INF files. ↩