Display modes
The dungeon view · Display drivers · Palettes
In brief
The game draws the same view in every display mode: the same blocks, the same entries, the same objects. The modes differ in how the tile layers become pixels. VGA draws one byte per pixel at 320 × 200; EGA shows each game pixel as two screen pixels at 640 × 200, with its own palettes; the Tandy driver is not in the collection. Two anomalies concern the video mode put back at the end and the EGA backdrop.
The three modes
How the EGA driver programs the video card is not examined: it changes the pixels on the screen, not what the game draws.
The display mode is the first word of EOSPREFS.DAT, which SETUP.EXE
writes. The setup program knows three modes, and the game loads the
display driver of the mode:
| Mode | Setup label | Driver | Palettes | In the collection |
|---|---|---|---|---|
| 3 | "MCGA/VGA" | MGA.OVL | .PAL files | yes (the reference EOSPREFS.DAT selects it) |
| 5 | "256K EGA" | XGA.OVL | .EGA files | yes |
| 6 | "Tandy 16 Color" | yga.ovl | .PAL files | no |
The executable also names drivers for modes 0, 1, 2 and 4, and its tile drawing has branches for modes 0 and 1. The setup program cannot select these modes and their drivers are not in the collection; what those branches draw is unknown.
At start-up the game asks the BIOS for the current video mode and keeps it.
When it sets up the display, it switches to the BIOS mode of the display
mode: 0x13 (320 × 200, 256 colours) for mode 3, 0x0e (640 × 200,
16 colours) for mode 5 and 0x09 for mode 6. When the program ends, or
cannot load its driver or font, it puts the start-up mode back
(BIOS video modes).1
Bug: the mode put back at the end is compared with a word past the
table. To put the start-up mode back, the game asks for "mode 9", which
takes the saved mode, but it then decides whether to call the BIOS by
comparing the saved mode with the tenth entry of the nine-entry mode table,
a word that is always 0. If the computer was in video mode 0 (40-column
text) when the game started, the game therefore does not switch back and
leaves the screen in its graphics mode (inferred: not observed). A
faithful reimplementation restores the start-up mode in every case.
(ANOMALY-121)
Everything the game decides is the same in every mode: which blocks are visible, which VMP entries are copied where, where objects go, and how they are reduced and darkened. The modes differ in how the tile layers become pixels.
- VGA (mode 3). The game draws each tile itself, one byte per pixel, as described in screen coordinates.
- EGA (mode 5). The level palette comes from the
.EGAfile of the same name, for exampleFOREST.EGAinstead ofFOREST.PAL. The driver shows each of the 256 colours as a pair of side-by-side pixels of the card's 16 colours, so the screen is 640 pixels wide and each game pixel is two pixels. When the level is loaded, the game colours each VCN block once, for good. Blocks that the backdrop uses get the backdrop colours, the others the wall colours. It stores the coloured blocks in video memory through the driver, and also keeps a mask of the pixels whose value is not 0. Drawing the view then copies these blocks into place, and a block drawn over the backdrop shows the backdrop where its mask is clear. - Tandy (mode 6). The game replaces colours 1 to 15 of both VCN colour tables through a table supplied by the driver, then draws the tiles as in VGA mode. The driver is not in the collection, so the rest is unknown.
With the game's own files the EGA view shows the same blocks with the same colours as the VGA view. The game's choices differ only for data that no original file contains:
- the colour table goes with the block, not with each use of it: in VGA mode a block used both in the backdrop and in a wall takes the colours of each use, in EGA mode always the backdrop colours;
- only the first 1,000 blocks can get the backdrop colours, and only the first 2,000 blocks are loaded at all;
- a pixel of a wall block drawn over the backdrop is transparent when its value is 0, while VGA mode tests its wall colour: the two differ only when the wall colour table maps a nonzero value to colour 0;
- two unusual entry values give different results in the two modes.
ANOMALY-80 — In EGA mode, the game marks the backdrop's blocks in a
table of 2,000 bytes indexed by the backdrop's VMP entries without removing
their flag bits. For a backdrop entry with the mirror bit, it writes a byte
16 KB after the start of the table and does not mark the block. CRIMSON,
DUNG and MEZZ have such entries, 47, 3 and 12 of them. Every block
concerned also appears unmirrored in the backdrop, so the colours are right
with the original files.
The table lies in the game's work area,
inside the program's first code segment, and 16 KB further on is the
program's own code: each stray byte replaces a byte of the
handler that DOS calls on a critical error,
such as a disk that is not ready. Loading a level drawn with CRIMSON sets
44 of its 56 bytes to 1, and the first byte of the routine that installs
it; MEZZ sets three of its bytes and DUNG one; the handler was
installed at start-up and is not restored. A later critical error would
therefore run damaged code, which would most likely crash the game
(inferred: not observed in play). A faithful reimplementation gives the
backdrop colours only to blocks that an unflagged backdrop entry uses, so
that a block the backdrop uses only mirrored gets the wall colours, as in
the game; it has no reason to reproduce the damage to the handler.
The EGA driver's scale step gives some reduced shapes one more column than the VGA driver. Darkening works the same way in both drivers, before the EGA driver turns the colour into its pair of pixels.2
Sources
Locations refer to the game executable reference;
comparative sources are listed in the technical references.
The figures are drawn from the values listed on these pages, with no game
graphics, by make_view_figures.py.