Skip to main content

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:

ModeDriverSETUP.EXE labelIn the reference collection
0cga.ovl—no
1tga.ovl—no
2ega.ovl—no
3mga.ovl"MCGA/VGA"yes, MGA.OVL
4vga.ovl—no
5xga.ovl"256K EGA"yes, XGA.OVL
6yga.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.

SlotGame variableRoleMGA.OVLXGA.OVL
0DS:0x6522Pointer to the font pointer (game data)gamegame
1DS:0x6526Pointer to the page segment table (game data)gamegame
2DS:0x652aPointer to the current page (game data)gamegame
3DS:0x652eAllocate memory (game routine); the encoders allocate their shapes with itgamegame
4DS:0x6532Game routine, not used by the driversgamegame
5DS:0x6536Game routine, not used by the driversgamegame
6DS:0x653aKeep the driver's display state (game routine)gamegame
7DS:0x653eCopy a rectangle given in pixels0x03d10x05ca
8DS:0x6542Restore a saved rectangle into the current page0x052b0x06ef
9DS:0x6546Restore a saved rectangle into page 0, the screen0x05460x0707
10DS:0x654aCopy an image page (EGA: into video memory)0x04f30x0623
11DS:0x654eSet the replacement colour table of the next shapes0x05e40x083f
12DS:0x6552Build a colour table0x06060x087b
13DS:0x6556Copy a rectangle between pages, in columns0x07460x09bb
14DS:0x655aClear the current page0x08050x0af5
15DS:0x655eDraw a shape through the replacement table0x0a1c0x0b15
16DS:0x6562Pointer to the replacement colour table0x270a (table)0x322b (table)
17DS:0x6566Draw a line0x0a340x0dde
18DS:0x656aDraw a shape0x0c460x10b5
19DS:0x656eNothing0x0f9b0x10bd
20DS:0x6572Nothing0x0f9c0x10be
21DS:0x6576Set the darkening level of the next shapes0x0f9d0x10bf
22DS:0x657aFill a rectangle0x0fb20x10d4
23DS:0x657eRead a pixel of the current page0x10b50x130f
24DS:0x6582Nothing0x11590x1491
25DS:0x6586Nothing0x115a0x1492
26DS:0x658aSave a rectangle of the current page0x115b0x1493
27DS:0x658eShape encoder0x117b0x14ab
28DS:0x6592Encode a shape without colour table0x12fc0x1621
29DS:0x6596Nothing (EGA: write colour pairs into video memory)0x14480x1706
30DS:0x659aNothing0x149e0x17d3
31DS:0x659eSet the pixel effect (EGA: nothing)0x149f0x17d4
32DS:0x65a2Nothing0x14b60x17db
33DS:0x65a6Nothing0x14b70x17dc
34DS:0x65aaNothing0x14b80x17dd
35DS:0x65aeNothing0x14b90x17de
36DS:0x65b2Write a pixel of the current page0x14ba0x17df
37DS:0x65b6Restore the drawing state after the mouse cursor0x14f20x1860
38DS:0x65baDraw a mirrored shape through the replacement table0x15190x1a25
39DS:0x65beDraw a mirrored shape0x17e50x1d0f
40DS:0x65c2Pointer to a table that mirrors a byte of pixels0x0113 (table)0x012c (table)
41DS:0x65c6Save the drawing state before the mouse cursor0x1c320x1d17
42DS:0x65caNothing0x1c750x1e5a
43DS:0x65ceScale a shape by one step0x1c820x1e5b
44DS:0x65d2Save a rectangle of page 0, the screen0x1d6d0x21b9
45DS:0x65d6Set the line rectangle0x1e2e0x229a
46DS:0x65daSet the shape window0x1e510x22c1
47DS:0x65deInstall a colour table0x1e740x23cb
48DS:0x65e2Set palette colours (EGA: match the palette to colour pairs)0x1e9f0x22e4
49DS:0x65e6Colour table of the Tandy mode, called only in mode 60x1eda0x23f6
50DS:0x65eaNothing0x1ee30x243e
51DS:0x65eeSize of a saved rectangle0x1ee40x243f
52DS:0x65f2Draw a line of text0x24360x2b09
53DS:0x65f6Pointer to a table of row offsets0x0233 (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 in EOSPREFS.DAT. The labels it prints for the three values are "Tandy 16 Color" (6, file offset 0x3d80), "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.