Skip to main content

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.

OffsetTypeFieldMeaning
0u8opcode0xf8
1u16lestring_indexIndex in the level's message table.
3s8color_rawColor number of the message in the current palette.
4u8unknownSkipped 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​

  1. The current text color is replaced by color_raw.
  2. 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_PRESENT and CHARACTER_ELIGIBLE_NOT_DEAD of CharacterEligibilityMask).
  3. The message is passed to the text-output routine together with that member's name.
  4. 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 %d prints 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 %s each 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

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.

Sources​

Footnotes​

  1. String lookup, the script buffer pointer and the overlay routine that copies the INF scripts. Comparative source: getString in REF-SCUMM-003. ↩

  2. Handler for 0xf8, the text output helper, the eligibility test, the dice roll and the selected character. Comparative source: oeob_printMessage_v2 in REF-SCUMM-003. Usage comes from decoding the scripts reachable in the 16 reference INF files. ↩ ↩2