Overlays
The game executable · Memory map · Routines · Data
In brief
Part of the code of the DOS START.EXE identified in the
file inventory is not loaded with the rest
of the program. It is stored at the end of the file in thirteen overlays,
numbered 244 to 256, each loaded when one of its routines is needed. The
overlays hold whole features of the game: drawing the dungeon view, creating
the party, the camp menu, resting, loading levels, saving, dialogues and the
end of the game.
Overlay code has no fixed address once loaded: where the game places it at
run time is not established. Its locations are therefore given as physical
file offsets in START.EXE, and its anchors start with o-. See
how addresses are written.
The thirteen overlays
Each documented overlay has its own page, with a diagram of how its routines fit together, its entry points and its routines.
| Overlay | What it holds | Image size | Stub entries | Documented addresses |
|---|---|---|---|---|
| 244 | Drawing the dungeon view: visible blocks, walls, objects, monsters, doors, compass | 8,497 bytes | 22 | 26 |
| 245 | Creating a party: creation screen, race, class, attributes, portraits, names | 10,250 bytes | 25 | 29 |
| 246 | Setting up the new party: starting items and spells, release of the creation images | 1,687 bytes | 8 | 9 |
| 247 | Camp menu and spells: menus, questions, memorize, pray, scrolls | 9,807 bytes | 8 | 19 |
| 248 | Resting: rest steps, recovery, Insal, DRANX | 5,357 bytes | 11 | 14 |
| 249 | Start-up and start menu: item data, interface colours, start menu, protection | 3,418 bytes | 11 | 11 |
| 250 | Loading a level: the INF loader, its sections, the play screen | 6,850 bytes | 24 | 37 |
| 251 | Saved games and level records: LEVELS.TMP, save files, slot menus | 5,147 bytes | 15 | 17 |
| 252 | Dialogues and scripted sequences: dialogue, NPCs, dream, sequences | 6,241 bytes | 29 | 30 |
| 253 | Pixel dissolve: pictures revealed dot by dot | 432 bytes | 1 | 1 |
| 254 | Transferring an Eye of the Beholder I party: conversion, character choice | 4,200 bytes | 12 | 12 |
| 255 | The introduction: scenes, animations, texts, music waits | 7,582 bytes | 15 | 15 |
| 256 | The end of the game: FINAL.SAV, the ending, the credits | 9,088 bytes | 10 | 19 |
Documented addresses count the anchored addresses on each page: routine
starts and the parts of routines described with their own address. Two kept
anchors are not counted: 0x3f659, an older anchor of the compass routine
of overlay 244, and 0x431ec, a branch inside a routine of overlay 247.
Every function prologue (55 8b ec) of the thirteen images has an entry. An
overlay can hold more routines than its stub has entries: most are called
only from inside the overlay.
When the game uses them
The overlays follow the life of a game session. This diagram shows only the calls established on the overlay pages; dashed boxes are resident code.
How calls reach an overlay
A call never jumps straight into an overlay. It goes through the overlay's
stub, a small block kept in the resident image, whose entries hand the
call to the overlay manager with the target's offset in the overlay image. How
the overlay manager, reached by INT 3Fh, loads an image is outside the
scope of this reference.
- Stubs. The thirteen stubs are stored at file offsets
0x2dda0–0x2e35f, just before the data segment. Each starts with a 32-byte header, followed by its entries. - Resident callers call a stub's paragraph directly, for example
0x2ae3:0x7ffor entry 19 of overlay 250. - Overlay callers use a portal segment
0x7a0 + 8nfor stub n. The portal is an index into the segment table at file offset0x2d520, whose entry holds the stub's paragraph. All 46 portal call sites land on function prologues, which corroborates this reading. - Images. The overlay images follow the
FBOVmarker at file offset0x3d6d0, contiguous from0x3d6e0to0x51470. Each image is followed by its fixups, then zero bytes up to the next image; the fixups of overlay 256 lie after the image area, at0x51470–0x515ed, followed by 34 zero bytes up to the end of the file.
Inside a stub
Byte offsets within a stub. Entry k sits at stub offset 0x20 + 5k as the
five bytes cd 3f <word> 00; the word is the entry's offset in the overlay
image. Bytes 10–11 give the size in bytes of the fixups that follow the
image, for all thirteen overlays: each fixup is a word, the offset in the
image of a segment word to adjust, that of a far call (9a) or of a segment
loaded as an immediate operand. Overlay 244, for example, has 30 fixups: 28 far
calls and two segment immediates in the
teleporter drawing, at image offsets 0x1ceb
and 0x1cc8 (file offsets 0x3f3cb, 0x3f3a8), which load the segment of the
sparkle points. Together they name nine segments: 0x20, 0x90,
0xa8, 0xd8, 0xf0, 0x170, 0x178, 0x208 and 0x250.
Stub, portal and image of each overlay
| Overlay | Stub (file offset) | Stub paragraph | Portal | Image start | Length | Fixups after image | Entries |
|---|---|---|---|---|---|---|---|
| 244 | 0x2dda0 | 0x2aba | 0x7a0 | 0x3d6e0 | 0x2131 | 0x3c at 0x3f811 | 22 |
| 245 | 0x2de30 | 0x2ac3 | 0x7a8 | 0x3f860 | 0x280a | 0x180 at 0x4206a | 25 |
| 246 | 0x2ded0 | 0x2acd | 0x7b0 | 0x42210 | 0x697 | 0x20 at 0x428a7 | 8 |
| 247 | 0x2df20 | 0x2ad2 | 0x7b8 | 0x428d0 | 0x264f | 0x190 at 0x44f1f | 8 |
| 248 | 0x2df70 | 0x2ad7 | 0x7c0 | 0x450e0 | 0x14ed | 0x170 at 0x465cd | 11 |
| 249 | 0x2dfd0 | 0x2add | 0x7c8 | 0x46760 | 0xd5a | 0x8c at 0x474ba | 11 |
| 250 | 0x2e030 | 0x2ae3 | 0x7d0 | 0x47550 | 0x1ac2 | 0xc6 at 0x49012 | 24 |
| 251 | 0x2e0d0 | 0x2aed | 0x7d8 | 0x490e0 | 0x141b | 0xda at 0x4a4fb | 15 |
| 252 | 0x2e140 | 0x2af4 | 0x7e0 | 0x4a5f0 | 0x1861 | 0x136 at 0x4be51 | 29 |
| 253 | 0x2e200 | 0x2b00 | 0x7e8 | 0x4bf90 | 0x1b0 | 0x4 at 0x4c140 | 1 |
| 254 | 0x2e230 | 0x2b03 | 0x7f0 | 0x4c150 | 0x1068 | 0x8e at 0x4d1b8 | 12 |
| 255 | 0x2e290 | 0x2b09 | 0x7f8 | 0x4d250 | 0x1d9e | 0xe4 at 0x4efee | 15 |
| 256 | 0x2e300 | 0x2b10 | 0x800 | 0x4f0f0 | 0x2380 | 0x17e at 0x51470 | 10 |
Image starts and lengths are file offsets and byte counts; fixup sizes are byte counts, from bytes 10–11 of the stub.
Resolved entries
The stub entries whose target is resolved are listed under Entry points on each overlay's page. Two overlays are entered from a single place:
- Entry 3 of overlay 249, the start menu,
is called only by the resident program start-up, as
0x2add:0x2fat0x18c55; no portal call0x7c8:0x2fexists. - Overlay 256 is entered only from kill a monster
(
0x1abde,0x1abe3), and calls entry 8 of overlay 251 from0x4f0f0.
The resident call 0x2ae3:0x66 at 0x27320, in the
level-change command, is entry 14 of overlay 250: the
stub bytes cd 3f 0c 05 00 at file offset 0x2e096 lead to
release monster shapes, 0x47a5c.
Calls into resident code
Overlay code calls resident routines through segments fixed up at load time:
the encoded segment is an index into the segment table at file offset
0x2d520, whose entry gives the paragraph. These calls are resolved:
| Calling overlay | Encoded | Resident target | Role |
|---|---|---|---|
| 247, 252 | 0x50:0x148, 0x50:0x212, 0x50:0x43c, 0x50:0x686, 0x50:0x6e9, 0x50:0x869 | 0x1e388, 0x1e452, 0x1e67c, 0x1e8c6, 0x1e929, 0x1eaa9 | Inventory, party and string helpers |
| 248 | 0x50:0x1be, 0x50:0xbf9, and the six above except 0x50:0x212 | 0x1e3fe, 0x1ee39 | Ring search, remove items from the party |
| 249, 250, 251 | 0xf8:0x107, 0xf8:0x406, 0xf8:0x44e, 0xf8:0x5de | 0x2dde7, 0x2e0e6, 0x2e12e, 0x2e2be | File open, close, read and write |
250 at 0x4822b | 0x00a8:0x0380 | 0x2aa00 | Colour-table fill |
250 at 0x48d0f | — | 0x1afb2 | Monster slot initialization |
251 at 0x491a7, 0x492e0 | segment 0x01f8 | 0x33744 | Far copy |
249 at 0x47431 | 0x20:0x0ac3 | 0x19833 | Program exit |
252 at 0x4b3ce | segment 0x0 | 0x17540 | String compare |
253 at 0x4bfea, 0x4c041 | 0x138:0x4 | 0x30644 | Random number in a range |
| 244, 249, 251 | 0x170:0x9 | 0x310c9 | Set a text window's bounds |
| 247, 249, 250, 251, 256 | 0xd8:0xa | 0x2d92a | Copy a page area |
| 245, 247, 251 | 0xe0:0x3 | 0x2d9b3 | Wait for screen refreshes |
252 at 0x4b196, 0x4b341 | 0x50:0xb88 | 0x1edc8 | Rebuild the play screen |
251, end of 0x49b60 | 0x18:0x197, 0x40:0x1d4 | 0x18c77, 0x1cdb4 | Unidentified call; item-chain insertion |
Sources
The executable is identified in the file inventory; its layout is described on the memory map. Comparative sources are listed in the technical references.