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.
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:
| Location | Contents |
|---|---|
DS:0x18ee | Skip flag (word): set when a key skips the introduction; cleared when it starts. |
DS:0x18f0 | Skip allowed (word): 0 in the file, set to 1 once the first scene is shown. |
DS:0x18f2 | 44 far pointers to animation lists. |
DS:0x19a2 | 13 far pointers, one per scene, to shape definitions; only scenes 0, 1, 4 and 7 have some. |
DS:0x19d6 | 13 far pointers to the scene picture names, STREET1.CPS … KHELBAN6.CPS. |
DS:0x1862–0x1874 | Far pointers to the buffers allocated for the introduction: three flash palettes, a palette copy and the fading tables. |
DS:0x1876 | Far pointers to the cut shapes. |
An animation list is a series of 11-byte records ended by 0xff:
| Offset | Size | Meaning |
|---|---|---|
| 0 | byte | Command, 0–7 (larger values are ignored) |
| 1 | byte | Shape number, signed; for command 6 the sound number |
| 2 | word | x, in pixels |
| 4 | byte | y |
| 5 | byte | Delay, in ticks of the free-running counter |
| 6 | byte | Palette (commands 0–2) or fading level (commands 3 and 4) |
| 7 | byte | Source column, command 5 |
| 8 | byte | Source row, command 5 |
| 9 | byte | Width in 8-pixel columns, command 5 |
| 10 | byte | Height, 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 entry | Target | Role |
|---|---|---|
0x7f8:0x2a (entry 2) | 0x4e0b3 | Play the introduction |
Routines at a glance
| Routine | Address | Stub entry | Status |
|---|---|---|---|
| Play the introduction | 0x4e0b3 | 2 | |
| Load a scene | 0x4d250 | 11 | |
| Cut a scene's shapes | 0x4d4a5 | 10 | |
| Show the work page | 0x4d2b0 | 5 | |
| Run an animation list | 0x4d757 | 13 | |
| Print a text | 0x4dcce | 14 | |
| Fade the text out | 0x4de31 | 8 | |
| Fade one colour to black | 0x4de5f | 3 | |
| Fade the palette | 0x4df02 | 0 | |
| Set the palette except colour 255 | 0x4d68f | 6 | |
| Load or build the fading tables | 0x4d5d7 | 1 | |
| Scroll the street | 0x4d358 | 9 | |
| Wait for a tick | 0x4d2f5 | 4 | |
| Test for a skip key | 0x4d328 | 7 | |
| Play a sound | 0x4e09d | 12 |
Routines
Play the introduction
| Address | Range |
|---|---|
0x4e0b3 | 0x4e0b3–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
| Address | Range |
|---|---|
0x4d250 | 0x4d250–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
| Address | Range |
|---|---|
0x4d4a5 | 0x4d4a5–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
| Address | Range |
|---|---|
0x4d2b0 | 0x4d2b0–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
| Address | Range |
|---|---|
0x4d757 | 0x4d757–0x4dccd |
Runs list n of DS:0x18f2 record by record, through a jump table at
0x4dcbe, until the 0xff end mark or a skip:
| Command | Handler | Effect |
|---|---|---|
| 0 | 0x4d9a4 | Mode 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. |
| 1 | 0x4da23 | Draw the shape at (x, y) on page 0, flash, wait, then copy its rectangle back from page 2 (the shape disappears). |
| 2 | 0x4db8b | Draw the shape at (x, y) on the current page, flash, wait; the shape stays. |
| 3, 4 | 0x4d7d0 | Mode 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. |
| 5 | 0x4dc4b | Copy a block of page 2 to (x, y) on the screen; wait. |
| 6 | 0x4d7c3 | Play the sound; 255 becomes −1, which the sound routine ignores. |
| 7 | 0x4db15 | Wait, 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)
Print a text
| Address | Range |
|---|---|
0x4dcce | 0x4dcce–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
| Address | Range |
|---|---|
0x4de31 | 0x4de31–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
| Address | Range |
|---|---|
0x4de5f | 0x4de5f–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
| Address | Range |
|---|---|
0x4df02 | 0x4df02–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
| Address | Range |
|---|---|
0x4d68f | 0x4d68f–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
| Address | Range |
|---|---|
0x4d5d7 | 0x4d5d7–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
| Address | Range |
|---|---|
0x4d358 | 0x4d358–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
| Address | Range |
|---|---|
0x4d2f5 | 0x4d2f5–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
| Address | Range |
|---|---|
0x4d328 | 0x4d328–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
| Address | Range |
|---|---|
0x4e09d | 0x4e09d–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.