Skip to main content

Wait

SCRIPT_DELAY · opcode 0xe5 · 3 bytes

Script virtual machine · Opcode list · Sound and delay

Waits for a while before the script continues with the next instruction.

Encoding​

Offsets count from the opcode byte. Words are little-endian.

OffsetTypeFieldMeaning
0u8opcode0xe5
1s16leduration_rawSigned number of ticks to wait.

Behavior​

The handler sign-extends duration_raw to 32 bits, adds it to the current value of the game's free-running counter and loops until that counter is no longer below the sum (unsigned comparison). A tick lasts about 55 ms, so the wait lasts duration_raw × 55 ms.1

The loop is the whole wait: the game loop does not run, so monsters, flying objects and the other timed updates stand still. The shared counter of the game keeps advancing, unless it is paused, and the updates whose deadlines pass during the wait each run once afterwards.

Edge cases and unknowns​

  • The handler adds a signed value. With a negative value, the wait ends at once, unless the free-running counter is still below the value's magnitude, in the first half hour after the game starts, when the unsigned sum wraps and the wait would not end in practice. No reference script uses a negative value.

Observed use​

The reference scripts contain 251 instructions of this kind, waiting from 1 to 100 ticks, about 0.05 to 5.5 seconds; 5 and 6 are the most frequent values.

Sources​

Footnotes​

  1. Handler for 0xe5 and the free-running counter, advanced by the timer interrupt. Comparative source: oeob_delay in REF-SCUMM-003. Usage comes from decoding the scripts reachable in the 16 reference INF files. ↩