Skip to main content

The introduction

Overlay 255 · image 0x4d250–0x4efed (7,582 bytes) · 15 stub entries

All overlays · ← 254 · Transferring an Eye of the Beholder I party · 256 · The end of the game →

In brief​

Overlay 255 plays the introduction: the animated story shown before the start menu, and again when the player chooses RUN INTRODUCTION. One routine, 0x4e0b3, runs the whole sequence; the fourteen others form a small sequence player that loads scenes, runs animation lists read from tables, prints and fades texts, fades palettes, waits on the clock or on the music, and lets a key press skip everything. The introduction changes no game state. What the player sees and hears is described in the introduction.

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​

Only entry 2 is called from outside the overlay; the other fourteen are reached from inside it. Dashed boxes are outside this overlay.

Tables​

All in the data segment, read by the routines below:

LocationContents
DS:0x18eeSkip flag (word): set when a key skips the introduction; cleared when it starts.
DS:0x18f0Skip allowed (word): 0 in the file, set to 1 once the first scene is shown.
DS:0x18f244 far pointers to animation lists.
DS:0x19a213 far pointers, one per scene, to shape definitions; only scenes 0, 1, 4 and 7 have some.
DS:0x19d613 far pointers to the scene picture names, STREET1.CPS … KHELBAN6.CPS.
DS:0x1862–0x1874Far pointers to the buffers allocated for the introduction: three flash palettes, a palette copy and the fading tables.
DS:0x1876Far pointers to the cut shapes.

An animation list is a series of 11-byte records ended by 0xff:

OffsetSizeMeaning
0byteCommand, 0–7 (larger values are ignored)
1byteShape number, signed; for command 6 the sound number
2wordx, in pixels
4bytey
5byteDelay, in ticks of the free-running counter
6bytePalette (commands 0–2) or fading level (commands 3 and 4)
7byteSource column, command 5
8byteSource row, command 5
9byteWidth in 8-pixel columns, command 5
10byteHeight, command 5

A shape definition is a 6-byte record: a signed word shape number, then the column, row, width (in 8-pixel columns) and height of the shape in the scene picture; a width of 0 ends the list. A negative number cuts the shape through driver slot 28, a positive one through slot 27, the shape encoder.

Entry points​

Encoded entryTargetRole
0x7f8:0x2a (entry 2)0x4e0b3Play the introduction

Routines at a glance​

RoutineAddressStub entryStatus
Play the introduction0x4e0b32
Load a scene0x4d25011
Cut a scene's shapes0x4d4a510
Show the work page0x4d2b05
Run an animation list0x4d75713
Print a text0x4dcce14
Fade the text out0x4de318
Fade one colour to black0x4de5f3
Fade the palette0x4df020
Set the palette except colour 2550x4d68f6
Load or build the fading tables0x4d5d71
Scroll the street0x4d3589
Wait for a tick0x4d2f54
Test for a skip key0x4d3287
Play a sound0x4e09d12

Routines​

Play the introduction​

AddressRange
0x4e0b30x4e0b3–0x4efed

Entry 2, called only by the start menu at 0x47157. It allocates the introduction's buffers, loads PALETTE4.PAL, PALETTE3.PAL and PALETTE2.PAL for the palette flashes, loads the INTRO sound file through load the sound file, clears the skip flag and sets PALETTE1.PAL (display mode 3) or PALETTE0.PAL (other modes). Driver slot 14 (DS:0x655a), which clears the current page, is called at the start and at several scene changes. It then runs the sequence described in the introduction: 15 scene loads (13 pictures), 20 texts, 129 calls to animation lists, the street scroll and 8 waits on the music. Skipping is allowed from 0x4e2f7. At the end it plays sound 14 and, in mode 3, flashes the palette to white and fades it to black (0x4ee7b–0x4ef07), or plays sound 15 when the introduction was skipped (0x4ef38); it then frees the 30 shapes and the buffers. The music waits (0x4e361 and seven others) read the marker returned by the embedded music driver (0x10251) and run only when the sound selector DS:0x638a is 1.

Comparative source: REF-SCUMM-012, DarkMoonEngine::seq_playIntro.

Used by: The introduction, Images, palettes and fonts, Sound and music, Decoration, door and monster images, Dungeon graphics, Scenes and sequence pictures

Load a scene​

AddressRange
0x4d2500x4d250–0x4d2af

0x4d250(scene, page) loads picture scene of the table DS:0x19d6 through the CPS image loader, with a null palette, into page page + 1 (page | 1), cuts the scene's shapes (0x4d4a5) and copies page page + 1 to page page through driver slot 10. It does nothing once the introduction is skipped. The shapes come from the new picture although they are cut before the copy: both drivers' shape encoders read the page with bit 0 set, here page + 1 (VGA, EGA). In display mode 3 the two pages are the same memory, and the copy does nothing (VGA page copy).

Used by:

Cut a scene's shapes​

AddressRange
0x4d4a50x4d4a5–0x4d5d6

For each shape definition of the scene, frees the shape already stored under that number and encodes the new one from the picture into DS:0x1876.

Used by:

Show the work page​

AddressRange
0x4d2b00x4d2b0–0x4d2f4

In mode 3, sets the current palette except colour 255; then copies the 304 × 128 scene area of the page argument to (8, 8) on the screen.

Used by:

Run an animation list​

AddressRange
0x4d7570x4d757–0x4dccd

Runs list n of DS:0x18f2 record by record, through a jump table at 0x4dcbe, until the 0xff end mark or a skip:

CommandHandlerEffect
00x4d9a4Mode 3: set flash palette 1, 2 or 3 (PALETTE3, PALETTE2, PALETTE4); wait; set the normal palette back when a palette was given. Other modes: wait only.
10x4da23Draw the shape at (x, y) on page 0, flash, wait, then copy its rectangle back from page 2 (the shape disappears).
20x4db8bDraw the shape at (x, y) on the current page, flash, wait; the shape stays.
3, 40x4d7d0Mode 3: draw the shape through fading table level − 1 (driver slots 21, 31 and 47), or restore its background for level 0; wait. Other modes: draw it plainly for a nonzero level, restore it for 0, then wait 7 × delay ticks without testing the skip key.
50x4dc4bCopy a block of page 2 to (x, y) on the screen; wait.
60x4d7c3Play the sound; 255 becomes −1, which the sound routine ignores.
70x4db15Wait, then copy the shape's rectangle back from page 2.

Comparative source: REF-SCUMM-012, DarkmoonSequenceHelper::animCommand.

Used by: The introduction › Animations, The introduction › Display modes, Fading tables (FADING.DAT)

AddressRange
0x4dcce0x4dcce–0x4de30

0x4dcce(colour, text) selects text window 17. In mode 3 it copies palette entry colour into entry 255 and draws in colour 255; in the other modes it draws in colour 15. The text is split at carriage returns; each line is centred in the window, 9 rows below the previous one, and drawn through driver slot 52.

Used by: The introduction › Texts, Texts

Fade the text out​

AddressRange
0x4de310x4de31–0x4de5e

In mode 3, fades colour 255 to black (0x4de5f, step 2); then clears the text window in every mode.

Used by:

Fade one colour to black​

AddressRange
0x4de5f0x4de5f–0x4df01

Mode 3 only: lowers the three components of one palette entry by a step, sets that entry, and repeats until it is black.

Used by:

Fade the palette​

AddressRange
0x4df020x4df02–0x4e09c

0x4df02(palette, target, speed): in mode 3, moves every component of palette towards target by up to 5 per step, setting the palette (except colour 255) after each step, with the steps spread over time by speed; in the other modes it sets target at once.

Used by:

Set the palette except colour 255​

AddressRange
0x4d68f0x4d68f–0x4d756

Mode 3 only: sends to the palette, through driver slot 48, the runs of colours 0–254 that differ from the last palette set, and keeps a copy. Colour 255, the text colour, is never changed.

Used by:

Load or build the fading tables​

AddressRange
0x4d5d70x4d5d7–0x4d68e

Mode 3 only: reads the seven 256-byte tables of FADING.DAT when the file search finds the file (0x4d5eb); otherwise builds them with driver slot 12 (colour 18, weight 36 × (k + 1)) and writes them: it opens FADING.DAT in mode 2 (0x4d661) and calls the write helper 0x2e2be (0x4d67b) for 0x700 bytes from DS:0x1872. The read does not check how many bytes it got.

Used by: Fading tables (FADING.DAT)

Scroll the street​

AddressRange
0x4d3580x4d358–0x4d4a4

0x4d358(page, ticks) scrolls the street picture by 280 pixels. In modes 3 and 6: 94 steps of 3 pixels through driver slot 7, ticks per step, animation 42 at 96 pixels. In the other modes: 35 steps of 8 pixels, 2 × ticks per step, animation 42 at 96 pixels and sound 11 at 200 pixels (0x4d475–0x4d483). The modes 3 and 6 loop (0x4d37e–0x4d401) has no sound test.

Used by: The introduction, Anomalies and bugs

Wait for a tick​

AddressRange
0x4d2f50x4d2f5–0x4d327

Waits until the free-running counter reaches the deadline it is given, testing the skip key on every turn; returns 1 when the introduction is skipped.

Used by:

Test for a skip key​

AddressRange
0x4d3280x4d328–0x4d357

When skipping is allowed and not yet done, tests for a waiting input (look at the next key), takes it (0x32f20) and sets the skip flag. Returns the skip flag.

Used by: The introduction › Skipping

Play a sound​

AddressRange
0x4e09d0x4e09d–0x4e0b2

Calls the sound routine with its argument unless the introduction is skipped.

Used by:

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.