Print a message
SCRIPT_PRINT_MESSAGE · opcode 0xf8 · 5 bytes
Script virtual machine · Opcode list · Messages and scene redraw
Prints one of the level's messages in the message area, in a chosen color.
Encoding
Offsets count from the opcode byte. Words are little-endian.
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u8 | opcode | 0xf8 |
| 1 | u16le | string_index | Index in the level's message table. |
| 3 | s8 | color_raw | Color number of the message in the current palette. |
| 4 | u8 | unknown | Skipped without being read; preserve it. |
Example: f8 00 00 0f 00 prints message 0 in color 15. Levels 2, 6 and 15
use exactly these bytes in a shared routine at buffer offset 2, followed by
Return from a call.
The original scripts use colors 15 (white), 6 (light red), 5 (yellow), 9 (light cyan), 1 (magenta) and 4 (light green), which are the same in every dungeon palette (palettes).
The message table
The first word of the level's runtime script buffer gives the offset, within
the buffer, of a sequence of zero-terminated strings. string_index counts
strings from the start of that sequence; the index −1 gives no
string. The table is the string part of the level's script data in the
INF file, copied unchanged.1
Behavior
- The current text color is replaced by
color_raw. - A party member is chosen: the character selected by the running script if
there is one; otherwise a random slot, from which the handler searches
cyclically for a member that is present and not dead
(
CHARACTER_ELIGIBLE_PRESENTandCHARACTER_ELIGIBLE_NOT_DEADofCharacterEligibilityMask). - The message is passed to the text-output routine together with that member's name.
- The previous color is restored and a carriage return is printed.2
Edge cases and unknowns
- The index is not checked against the number of strings. In the reference files every index is valid.
- The member is chosen for every message, whether or not its text uses a name.
- The message is the format of the game's text printer, and the member's
name is its only argument.
%s(upper or lower case) inserts the name and%dprints a number argument. Any other character after%leaves the%in the text, and a%in the name is printed as is. In the original files, 100 messages contain exactly one%seach and no other directive. A second directive, or%d, would print data that is not the name (inferred). - A character selected by the run is used without any check.
ANOMALY-82. The search for a member has no end condition. When no
character has been selected by the run and no party slot is both present and
not dead, it tries the six slots in turn forever and the game stops
responding. The searches of the condition tokens give up after six slots. The
party's defeat is detected by the game loop, between runs, so a script that
kills every character and then prints a message before its run ends hangs
the game. The reference scripts contain at least one such sequence, in
level 11: damage to the whole party followed by a message; it would hang
only if that damage leaves no character present and not dead (inferred). A
faithful reimplementation searches in the same way; any rule that ends the
search departs from the original.2
Observed use
The reference scripts contain 920 instructions of this kind.