Display drivers
The game executable · Routines · Data · File inventory
START.EXE does not draw shapes itself. When it sets its display mode, it
loads a display driver, a small separate program named after the mode,
and calls the driver's routines through a table of far pointers in its data
segment. The reference collection holds two drivers, identified by their
SHA-256 hashes in the file inventory:
MGA.OVL, the VGA driver of display mode 3, which draws one byte per pixel;XGA.OVL, the 256K EGA driver of display mode 5, which draws each game pixel as two screen pixels in the card's 16 colours.
Each driver page describes every routine of the file, how the driver stores the picture and the anomalies found in it. This page describes how the game loads a driver and what each slot of the table is for. How the drivers program the video card is described only as far as it shapes what the game draws.
Addresses
A driver is an MZ program with a 512-byte header. Locations in a driver are
given as driver image offsets: the file offset minus 0x200, which is
also the offset in the driver's code segment once loaded. Anchors are the
driver's name followed by the image offset, for example
mga-1c82.
Locations in SETUP.EXE, the setup program identified in the
file inventory, are physical file
offsets; their anchors start with setup-. Its data segment begins at
file offset 0x3600, so DS:0xb1 there is file offset 0x36b1.
Loading a driver
The display-mode routine takes a mode number and loads the matching driver name:
| Mode | Driver | SETUP.EXE label | In the reference collection |
|---|---|---|---|
| 0 | cga.ovl | — | no |
| 1 | tga.ovl | — | no |
| 2 | ega.ovl | — | no |
| 3 | mga.ovl | "MCGA/VGA" | yes, MGA.OVL |
| 4 | vga.ovl | — | no |
| 5 | xga.ovl | "256K EGA" | yes, XGA.OVL |
| 6 | yga.ovl | "Tandy 16 Color" | no |
The mode is the first word of EOSPREFS.DAT, read into the
display mode at start-up; the reference file holds 3. The
setup program writes only modes 3, 5 and 6 (setup-36b1).
Mode 8 loads no driver. Otherwise the game's loader (0x33d2d) allocates a
64,000-byte block and has DOS load the driver's image into it with the
function that loads an overlay (0x33d12–0x33d15). Each driver file
lists 48 relocation items in its header: the segment words of slots 7 to 53
of its own table, and the segment that slot 12 returns. The loader leaves
the relocation factor, the word at DS:0x666c, at its initial 0, so these
words keep the value 0 they have in the file.
The loader then calls the driver's first byte, a jump to its entry routine,
which returns in BX the number of 16-byte paragraphs the driver needs and in
AX the offset of its install routine. It resizes the block to that size with
the game's block-resize routine (0x2d274, called at 0x33d81) and calls the
install routine with the far address of the game's
driver function table. A driver starts with that jump,
followed at image offset 3 by its own table of 54 far pointers, whose count
is the word at image offset 0xdb. The install routine walks this table
together with the game's: where the game's slot already holds a pointer
(slots 0 to 6), the driver takes it; otherwise the driver writes its own
routine, with its code segment, into the game's slot, and fails if it has
none. The game then calls slot k through DS:0x6522 + 4 k.
The game's own slots 0 to 2 point to its data: slot 0 to the far pointer
at DS:0xf090, through which both drivers read the
current font, slot 1 to the table of page
segments at DS:0x62a7, one word per page, and slot 2 to the
current page. Slots 3 to 6 are game routines: the shape
encoders allocate their shapes through slot 3, and the EGA driver passes its
display state to slot 6 when it is installed. No
driver uses slots 4 and 5.
Slots
Every slot of the table, with the routine or table each driver puts there. Both drivers take the same arguments in every slot the game calls.
| Slot | Game variable | Role | MGA.OVL | XGA.OVL |
|---|---|---|---|---|
| 0 | DS:0x6522 | Pointer to the font pointer (game data) | game | game |
| 1 | DS:0x6526 | Pointer to the page segment table (game data) | game | game |
| 2 | DS:0x652a | Pointer to the current page (game data) | game | game |
| 3 | DS:0x652e | Allocate memory (game routine); the encoders allocate their shapes with it | game | game |
| 4 | DS:0x6532 | Game routine, not used by the drivers | game | game |
| 5 | DS:0x6536 | Game routine, not used by the drivers | game | game |
| 6 | DS:0x653a | Keep the driver's display state (game routine) | game | game |
| 7 | DS:0x653e | Copy a rectangle given in pixels | 0x03d1 | 0x05ca |
| 8 | DS:0x6542 | Restore a saved rectangle into the current page | 0x052b | 0x06ef |
| 9 | DS:0x6546 | Restore a saved rectangle into page 0, the screen | 0x0546 | 0x0707 |
| 10 | DS:0x654a | Copy an image page (EGA: into video memory) | 0x04f3 | 0x0623 |
| 11 | DS:0x654e | Set the replacement colour table of the next shapes | 0x05e4 | 0x083f |
| 12 | DS:0x6552 | Build a colour table | 0x0606 | 0x087b |
| 13 | DS:0x6556 | Copy a rectangle between pages, in columns | 0x0746 | 0x09bb |
| 14 | DS:0x655a | Clear the current page | 0x0805 | 0x0af5 |
| 15 | DS:0x655e | Draw a shape through the replacement table | 0x0a1c | 0x0b15 |
| 16 | DS:0x6562 | Pointer to the replacement colour table | 0x270a (table) | 0x322b (table) |
| 17 | DS:0x6566 | Draw a line | 0x0a34 | 0x0dde |
| 18 | DS:0x656a | Draw a shape | 0x0c46 | 0x10b5 |
| 19 | DS:0x656e | Nothing | 0x0f9b | 0x10bd |
| 20 | DS:0x6572 | Nothing | 0x0f9c | 0x10be |
| 21 | DS:0x6576 | Set the darkening level of the next shapes | 0x0f9d | 0x10bf |
| 22 | DS:0x657a | Fill a rectangle | 0x0fb2 | 0x10d4 |
| 23 | DS:0x657e | Read a pixel of the current page | 0x10b5 | 0x130f |
| 24 | DS:0x6582 | Nothing | 0x1159 | 0x1491 |
| 25 | DS:0x6586 | Nothing | 0x115a | 0x1492 |
| 26 | DS:0x658a | Save a rectangle of the current page | 0x115b | 0x1493 |
| 27 | DS:0x658e | Shape encoder | 0x117b | 0x14ab |
| 28 | DS:0x6592 | Encode a shape without colour table | 0x12fc | 0x1621 |
| 29 | DS:0x6596 | Nothing (EGA: write colour pairs into video memory) | 0x1448 | 0x1706 |
| 30 | DS:0x659a | Nothing | 0x149e | 0x17d3 |
| 31 | DS:0x659e | Set the pixel effect (EGA: nothing) | 0x149f | 0x17d4 |
| 32 | DS:0x65a2 | Nothing | 0x14b6 | 0x17db |
| 33 | DS:0x65a6 | Nothing | 0x14b7 | 0x17dc |
| 34 | DS:0x65aa | Nothing | 0x14b8 | 0x17dd |
| 35 | DS:0x65ae | Nothing | 0x14b9 | 0x17de |
| 36 | DS:0x65b2 | Write a pixel of the current page | 0x14ba | 0x17df |
| 37 | DS:0x65b6 | Restore the drawing state after the mouse cursor | 0x14f2 | 0x1860 |
| 38 | DS:0x65ba | Draw a mirrored shape through the replacement table | 0x1519 | 0x1a25 |
| 39 | DS:0x65be | Draw a mirrored shape | 0x17e5 | 0x1d0f |
| 40 | DS:0x65c2 | Pointer to a table that mirrors a byte of pixels | 0x0113 (table) | 0x012c (table) |
| 41 | DS:0x65c6 | Save the drawing state before the mouse cursor | 0x1c32 | 0x1d17 |
| 42 | DS:0x65ca | Nothing | 0x1c75 | 0x1e5a |
| 43 | DS:0x65ce | Scale a shape by one step | 0x1c82 | 0x1e5b |
| 44 | DS:0x65d2 | Save a rectangle of page 0, the screen | 0x1d6d | 0x21b9 |
| 45 | DS:0x65d6 | Set the line rectangle | 0x1e2e | 0x229a |
| 46 | DS:0x65da | Set the shape window | 0x1e51 | 0x22c1 |
| 47 | DS:0x65de | Install a colour table | 0x1e74 | 0x23cb |
| 48 | DS:0x65e2 | Set palette colours (EGA: match the palette to colour pairs) | 0x1e9f | 0x22e4 |
| 49 | DS:0x65e6 | Colour table of the Tandy mode, called only in mode 6 | 0x1eda | 0x23f6 |
| 50 | DS:0x65ea | Nothing | 0x1ee3 | 0x243e |
| 51 | DS:0x65ee | Size of a saved rectangle | 0x1ee4 | 0x243f |
| 52 | DS:0x65f2 | Draw a line of text | 0x2436 | 0x2b09 |
| 53 | DS:0x65f6 | Pointer to a table of row offsets | 0x0233 (table) | 0x0438 (table) |
No call from the game is known for slots 0–6, 16, 24, 25, 29, 30, 40, 45, 50
and 53; the game reads the pointer in slot 53 to reach its table
(0x2b6ff). The sites of the other slots are listed under
game call sites.
The setup program's display choices
SETUP.EXE file offset 0x36b1 — Display choices
- Layout: 3 bytes,
06 05 03 - Role: The setup program turns the number of the chosen graphics option
into a display mode through this table (code at file offset
0x118d–0x1196) and saves it inEOSPREFS.DAT. The labels it prints for the three values are "Tandy 16 Color" (6, file offset0x3d80), "256K EGA" (5,0x3d93) and "MCGA/VGA" (3,0x3da0). The menu examined offers the last two; how the Tandy entry is offered is not examined. - Used by: Display drivers › Loading a driver, Display modes › The three modes, Settings (EOSPREFS.DAT)
Sources
The game's side of the loading (display-mode routine, driver names, function table) is in the routines and data references. Comparative sources are listed in the technical references.