Skip to main content

Dialogues and scripted sequences

Overlay 252 · image 0x4a5f0–0x4be50 (6,241 bytes) · 29 stub entries

All overlays · ← 251 · Saved games and level records · 253 · Pixel dissolve →

In brief​

Overlay 252 holds what interrupts play to tell the story: dialogue windows with their text, pictures, wait prompts, buttons and choice menus; non-player characters who talk or join the party; parchments; the resurrection menu; and the scripted sequences — portal animation, dream and defeat scene. Level scripts reach it through dialogue and run a sequence.

Addresses

Every address on this page is a file offset in START.EXE; calls into resident code are given as analysis addresses. See how addresses are written.

How it fits together​

How the sequence dispatcher chooses a sequence from its selector. Dashed boxes are outside this overlay.

Entry points​

Stub entries whose target is resolved, from the stub bytes or another independent anchor, or through the portal reading.

Encoded entryTargetRole
:0x2f, :0x43, :0x48, :0x70, :0x7f, :0xa7, :0xac (segment 0x7e0 or 0x2af4)0x4a92e, 0x4b327, 0x4b3ce, 0x4b2d1, 0x4b19e, 0x4a7cd, 0x4b363See the routines
0x7e0:0x61, 0x7e0:0x980x4bcb2, 0x4af02Dream sequence; drop a copy of an item
entries 0x34, 0x4d, 0x66, 0x840x4ac57, 0x4ad0b, 0x4b20d, 0x4b625See the routines
0x2af4:0x7a (entry 18)0x4bd64Defeat scene

Routines at a glance​

RoutineAddress
Load the dialogue texts0x4a5f0
Show a character's figure0x4a77d
Cut and draw a figure0x4a671, 0x4a6ca
Set up a dialogue text window0x4a62a
Draw the dialogue box0x4a7cd
Wait prompt (mouse-pointer handling inferred)0x4a81c
Draw a button0x4a9b0
Dialogue0x4a92e, 0x4b2d1, 0x4b327, 0x4b363, 0x4b3ce
Choice menu0x4aa1a
Prepare a new party member0x4ac57, 0x4ad0b
Join the party0x4ae44
Drop a copy of an item in the party's block0x4af02
Non-player character dialogues0x4af5c, 0x4af92, 0x4b020
Non-player character sequence0x4b0bb
Sequence dispatcher0x4b19e
Read a parchment0x4b569
Character pick and resurrection menu0x4b20d, 0x4b625
Portal animation0x4b84a
Dream sequence0x4bcb2
Show a dream frame0x4bc6b
Defeat scene0x4bd64

Routines​

Load the dialogue texts​

AddressRange
0x4a5f0—

The first function of the overlay: opens TEXT.DAT and reads 0x7d00 bytes into the shared buffer.

Used by: Dialogue screen › Opening and closing the screen, Dialogue texts (TEXT.DAT) › Reading the file, Scripted characters, flags and messages › Messages, dialogue, sound and timing, Texts

Show a character's figure​

AddressRange
0x4a77d0x4a77d–0x4a7cc

Called only by the character sequence (0x4b0f6) with its selector. The sequence has loaded OUTTAKE.CPS into page 3 and saved the 22-column, 120-row view area of the screen into page 6 with the page copy (0x4b0ec, from page 0 to page 6); this routine copies it back from page 6 to the screen (0x4a795), then, for selectors 0, 1 and 2, it draws figure 0, 1 or 2 at position 0. Other selectors draw no figure.

Used by: Run a sequence › Conversations with characters

Cut and draw a figure​

AddressRange
0x4a671, 0x4a6ca0x4a671–0x4a6c9; 0x4a6ca–0x4a77c

The figures are 8-byte records at DS:0x1456: a word column, then bytes row, width (8-pixel columns) and height of the figure in the loaded picture, a signed x and y offset, and the next record (−1 ends). The file holds three records, each alone in its chain: 40 × 57 at (0, 0), 40 × 79 at (0, 100) and 48 × 43 at (0, 57), with no offset. 0x4a671(k) cuts record k into a shape with the shape encoder, with DS:0x62a5 set to 2 during the call; the encoder reads the odd page of that pair, page 3, which holds OUTTAKE.CPS. 0x4a6ca(first, position) cuts each record of the chain, draws it at x = DS:0x1476[position] − half its width + its offset and y = 104 − its height + its offset — centred on column 88 and standing on row 104 for position 0, the only one used — and frees it. DS:0x1476 also holds the x values 40, 166 and 221, which nothing reads: the only reader (0x4a6fd) is reached only with position 0.

Used by: Show a character's figure, Run a sequence

Set up a dialogue text window​

AddressRange
0x4a62a0x4a62a–0x4a670

Arguments: a window number and a clear flag. Turns page waits on, gives the window the interface background colour (DS:0xe606), selects it, then clears it or only resets its cursor, and makes the wait prompt the page-wait routine (0x4a662, 0x7e0:0x25, stub entry 1). Dialogue initialization uses window 9 without clearing; parchments use window 12 with clearing.

Used by: Dialogue screen › Opening and closing the screen, Dialogue screen › Text window and pages

Draw the dialogue box​

AddressRange
0x4a7cd0x4a7cd–0x4a81b

Draws a framed box from (0, 121) to (319, 199) in the colours DS:0xeef0, DS:0xe5c2 and DS:0xe606, then clears the active text window. Called by the dialogue-box command and at the end of the choice menu.

Used by: Dialogue screen › Opening and closing the screen, Dialogue screen › Answer buttons

Wait prompt​

AddressRange
0x4a81c0x4a81c–0x4a92d

That the pointer calls keep the mouse pointer visible is inferred.

Draws a button labelled with the prompt label at the position chosen by DS:0xdf4e in the button position tables, empties the input queue (0x4a866) and reads events (0x4a88d) until key 61, 43 or 52 (Space, Enter, M) or a mouse-button press (0x41, 0x42) inside the button (rectangle test, 0x4a8cd); the codes are masked with 0x8ff, which drops Shift, Ctrl and Alt and keeps the release bit. It then fills the button with DS:0xe606 and clears the text window (0x4a91e). Nothing else runs in the loop.

Used by: Dialogue screen › Waiting for the player, Dialogue screen › Waiting for the player, Scripted characters, flags and messages

Draw a button​

AddressRange
0x4a9b00x4a9b0–0x4aa19

Arguments: x, y, colour and label. Draws a framed box from (x, y) to (x + 94, y + 8), then the label through driver slot 52 at x + 48 − 3 × its length, y + 2, in the given colour. A null label has length 0, since the length helper tests for it, and is passed unchanged to slot 52 (0x4aa0f).

Used by: Dialogue screen › Waiting for the player, Dialogue screen › Answer buttons

Dialogue​

AddressRange
0x4a92e, 0x4b2d1, 0x4b327, 0x4b363, 0x4b3ce—

Show dialogue text (0x4a92e), initialize a dialogue (0x4b2d1), restore the screen after it (0x4b327), offer a choice (0x4b363) and draw a dialogue bitmap (0x4b3ce). The text routine prints through the text output into the active window and calls the wait prompt for a non-empty prompt. The bitmap routine indexes its tables with the sign-extended frame without a bound check (0x4b4c9–0x4b52c) and loads pictures through the CPS loader (0x20:0x5c8). See SCRIPT_DIALOGUE.

Comparative source: REF-SCUMM-012, dialogue functions.

Used by: Dialogue commands, Dialogue picture frames, Dialogue picture options, Dialogue screen › Asking for a choice, Dialogue screen › Displaying a text, Dialogue screen › Drawing a picture, Dialogue screen › Opening and closing the screen, Dialogue screen › Opening and closing the screen, Scripted characters, flags and messages › Messages, dialogue, sound and timing, Dialogue screen › Edge cases and unknowns, Dialogue texts (TEXT.DAT) › Reading the file, Sound effects, Texts

Choice menu​

AddressRange
0x4aa1a0x4aa1a–0x4ac48; key table 0x4ac49

Arguments: first position, count and labels. Draws one button per entry at the answer positions indexed from the first position, on a row 4 pixels below the line after the active window's cursor line; the selected entry has colour 9, the others 15. For each input event it first selects the entry under the mouse pointer, if any, then acts on the key: 43, 61 or 97 (Enter, Space, keypad 5) choose the selected entry; a mouse-button press chooses the entry under it; 92 and 102 (keypad 4 and 6) step back and forward, wrapping within the first three entries (0x4aba8, 0x4abcd); 96 and 98 (keypad 8 and 2) move by three entries. Then it draws the dialogue box and returns the chosen entry, numbered from 0. The rules of ANOMALY-81 are at these locations: key 102 resets to 0 when sel > 2 (0x4abd0); key 96 tests sel − 3 > 0 (0x4ac09–0x4ac2b); key 98 (0x4abe7–0x4ac05) continues into the key-96 rule through the jump at 0x4abfb and the fall-through at 0x4ac05.

Used by: Dialogue screen › Asking for a choice, Dialogue screen › Answer buttons, Dialogue screen, Run a sequence › Conversations with characters, Scripted characters, flags and messages › Special events and sequences, Scripted characters, flags and messages, Anomalies and bugs

Prepare a new party member​

AddressRange
0x4ac57, 0x4ad0b0x4ac57–0x4ad0a; 0x4ad0b–0x4ae43

Make room in the party or delete items (0x4ac57), and initialize a preset non-player character (0x4ad0b): the 0x159-byte record of the chosen preset, stored at file offset 0x279a0 + 0x159 × preset (six records, see the presets), is copied into the first free character slot. 0x4ac57(type, value) counts the characters with status_flags bit 0; with six, it shows "You may only have six characters in your party. Select the one you wish to drop." and the six names with CANCEL, which returns 0. It then deletes the items of the given type and value and, for a full party, removes the chosen character; it returns 1. 0x4ad0b(preset) takes the first slot whose bit 0 is clear, copies the preset over it while keeping the slot's face_image pointer (0x4ad45–0x4ad85), recomputes the defense, replaces each item of inventory slots 0–24 by a copy of that template (0x4ad91–0x4adcd), and draws portrait preset of OUTPORTS into the face image. No range check is made on preset (0x4ad60–0x4ad70).

Comparative source: REF-SCUMM-009, prepareForNewPartyMember, initNpc.

Used by: Recruiting and dismissing characters › Recruiting and dismissing characters, Recruiting and dismissing characters, Run a sequence › Joining a full party, Run a special event › Recruit a character (event 4), Character record › Unused bytes, Characters of the game

Join the party​

AddressRange
0x4ae440x4ae44–0x4af01

Shared routine for a non-player character joining the party; arguments: the preset, the question text, the text for yes and the text for no. Yes shows its text (or "name joins the party." when that text is −1, which no known caller passes), then calls make room with type 33 and the preset plus one and, when it returns 1, initializes the preset. It returns its result XOR 1.

Comparative source: REF-SCUMM-009, npcJoinDialogue.

Used by: Recruiting and dismissing characters › Recruiting and dismissing characters, Run a sequence › Joining a full party, Scripted sequences, Texts

Drop a copy of an item in the party's block​

AddressRange
0x4af020x4af02–0x4af5b

Stub entry 24 (0x7e0:0x98), called only by overlay 248 when Insal leaves (0x46235). It duplicates the given item, rolls 1d2 − 1 (roll dice) to choose the front-left or front-right floor position for the party's facing, and inserts the copy into the party's block at that position. It returns the new item, or 0 when no item entry is free; it does not test that result, but the insertion ignores item 0.

Used by:

Non-player character dialogues​

AddressRange
0x4af5c, 0x4af92, 0x4b020—

Dialogues 0, 1 and 2 with non-player characters. The answer buttons are far-pointer arrays of the data segment: "yes"/"no" at DS:0x146e for the join question (0x4ae65), "talk"/"leave" at DS:0x14a7 (0x4afb7) after TEXT.DAT text 4, and "release him"/"leave" at DS:0x14af (0x4b045) after text 8; Shorn's random branch shows text 9 with the "OK" button DS:0x162b (0x4b07a).

Used by: Global script flags, Run a sequence › Conversations with characters, Scripted sequences, Sound effects, Level 2: reference tables › Shorn

Non-player character sequence​

AddressRange
0x4b0bb—

Dialogue sequence with a non-player character, using the OUTTAKE graphics.

Comparative source: REF-SCUMM-009, npcSequence.

Used by: Run a sequence › Conversations with characters

Sequence dispatcher​

AddressRange
0x4b19e—

Runs a sequence by selector: −2 the portal animation, −1 the copy-protection check, others the non-player character sequence. See ScriptSequenceSelector. Before any sequence it closes the inventory panel and the spell book, hides the pointer and redraws the scene; it saves the selected inventory slot and restores it only after the portal (0x4b1e2); at the end it selects the message window and shows the pointer. For a selector without a character, the non-player sequence loads OUTTAKE and TEXT.DAT, sets up the dialogue window and restores the view without a figure or a dialogue, then calls rebuild the play screen.

Used by: Run a sequence › Behavior, Scripted sequences, Scripted characters, flags and messages › Special events and sequences

Read a parchment​

AddressRange
0x4b5690x4b569–0x4b624 (stub entry 25, 0x2af4:0x9d)

Argument: the item's value. Opens the dialogue window; a value of 0 or more shows text value + 1 of TEXT.DAT with an "OK" button (DS:0x165e); a value of −1, −2 or −3 draws one of three parts of MAP (tables DS:0x14c7, DS:0x14d3, DS:0x14d6), without a bound check, and waits for a key or a click with no delay; then restores the screen. Called by the use routine for item kind 11.

Used by: Using items › Food and other uses, Using items, Dialogue texts (TEXT.DAT) › Reading the file, Texts, Resting: special cases, Anomalies and bugs, Level 4: reference tables › The old woman

Character pick and resurrection menu​

AddressRange
0x4b20d, 0x4b625—

Pick a character (special event 1) and show the resurrection menu (special event 3). See ScriptSpecialEvent. The resurrection menu lists every type-33 item carried or held without checking its value v: it names it from preset v − 1 (0x4b6e3–0x4b702, held item 0x4b75e–0x4b77d) and, when chosen, calls make room and initializes preset v − 1 (0x4b7fd–0x4b82d). The name offset is the 16-bit v × 0x159 + 0xfea9, so a value of 0 gives offset 0xfea9 in the segment of operand 0x2a8. Bones are taken from every member passing eligibility mask 1 (0x4b69b) and coded as −v (0x4b70e–0x4b71c); dead members are coded by their slot, so a value of 0 takes the dead-member branch (0x4b7f1) and is handled as party slot 0, with no deletion of the bones (0x4b834–0x4b83e; ANOMALY-77). The list is written into stack arrays of 20 entries without a bound (0x4b687, 0x4b71f, 0x4b79a, ABORT 0x4b7be; ANOMALY-134).

Used by: Run a special event › Choose a party member (event 1), Run a special event › Resurrection (event 3), Recruiting and dismissing characters, Characters of the game, Anomalies and bugs, Level 5: reference tables › Resurrection altars, Level 11: reference tables › Alain

Portal animation​

AddressRange
0x4b84a0x4b84a–0x4bc6a

First releases the door shapes (0x4b863), all 36 monster shapes (0x4b86f) and the decoration shapes (0x4b877), the same three calls as the ending in overlay 256 (0x4f29a–0x4f2ae), then plays the portal animation with the PORTALA and PORTALB graphics and the portal image pairs, frees its temporary buffers and returns (0x4bc6a). Its only direct data write is DS:0x62a5; it calls neither the level loader nor the level-change command.

Comparative source: REF-SCUMM-009, seq_portal.

Used by: Run a sequence › Portal animation, Scripted sequences, Scripted characters, flags and messages › Special events and sequences, Doors, teleporters and temporary walls › Released shapes, Sound effects, Images, palettes and fonts, Decoration, door and monster images, Dungeon graphics, Scenes and sequence pictures, Level 3: reference tables › The portal, Level 6: reference tables › The portal, Level 14: reference tables › The portal

Dream sequence​

AddressRange
0x4bcb20x4bcb2–0x4bd63

Called by the rest routine on level 3 instead of resting: a dialogue with the DREAM picture, sound effect 0x36, dialogue text 99 without a wait, a wait of 12 ticks, an animation of 13 dream frames, then dialogue text 20 with an "ok" button. It keeps the current font and restores it at the end. Before the dialogue it restores the strip below the view saved by the camp menu (0x7b8:0x2f), and after it saves the strip again (0x7b8:0x2a). The 13 frames last 116 ticks, about 6.4 seconds.

Comparative source: REF-SCUMM-019, restParty_extraAbortCondition (seq_nightmare).

Used by: Resting: special cases › Anomalies while resting, Resting › Resting, Resting › Whether the party can rest, Sound effects, Texts

Show a dream frame​

AddressRange
0x4bc6b0x4bc6b–0x4bcb1

Not a stub entry; called only by the dream sequence (0x4bd25). 0x4bc6b(frame) draws one 160 × 96 part of DREAM in the picture area — source column 0 or 20 and row 0 or 96 — then waits a number of ticks. The tables are outside the data segment:

FrameSource columnSource rowTicks
00012
12007
20967
3209612

The columns, rows and ticks are at file offsets 0x281c0, 0x281d0 and 0x281e0; the frame order, at 0x281f0, is 1, 2, 3, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0, ended by 0xff: 116 ticks in all.

Used by: Dream sequence

Defeat scene​

AddressRange
0x4bd640x4bd64–0x4be50

Entry 18 of the overlay, called only by the party status check (0x1ff97) when bit 20 of the global flags, set by Khelben's vision on level 12, is set. A dialogue with the KHELDRAN picture: a line of text, dialogue text 20 with a "MORE" button, sound effect 0x38, three more frames of the picture separated by waits, then dialogue text 76 with an "OK" button. It changes no game state.

Used by: The game loop › When the party is defeated, Sound effects, Global script flags, Level 12: reference tables › Khelben's vision

Sources​

The executable is identified in the file inventory; the overlay layout is described on the overlays page. Comparative sources are listed in the technical references.