Skip to main content

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 display modes that the setup program offers. Mode 3, MCGA/VGA: driver MGA.OVL, .PAL palettes, BIOS mode 0x13 at 320 by 200 in 256 colours, one screen pixel per game pixel. Mode 5, 256K EGA: driver XGA.OVL, .EGA palettes, BIOS mode 0x0e at 640 by 200 in 16 colours, each game pixel shown as two screen pixels. Mode 6, Tandy: driver yga.ovl, .PAL palettes, BIOS mode 0x09; the driver is not in the collection. The game draws the same view in every mode.
Only the way the view becomes pixels changes from one mode to another.

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:

ModeSetup labelDriverPalettesIn the collection
3"MCGA/VGA"MGA.OVL.PAL filesyes (the reference EOSPREFS.DAT selects it)
5"256K EGA"XGA.OVL.EGA filesyes
6"Tandy 16 Color"yga.ovl.PAL filesno

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

Anomaly

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 .EGA file of the same name, for example FOREST.EGA instead of FOREST.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

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.

Footnotes​

  1. Read and set the BIOS video mode, called through call a software interrupt, and the display mode setup. ↩

  2. SETUP.EXE display choices, the display mode and the driver names; the level palette; the tile drawing and its EGA branch; the VCN loader, the EGA block colouring (which carries the faulty instructions of ANOMALY-80) and the EGA block masks; the EGA driver's page conversion and colour pairs. ↩