Screen coordinates, pixel by pixel
The dungeon view · Where each face goes · Dungeon tiles (VCN)
In brief
The view is built off screen and copied to the top-left corner of the screen, 176 × 120 pixels; tile (column, row) covers 8 × 8 pixels from (8 × column, 8 × row). Each face is copied entry by entry from its VMP area into a wall layer, mirrored when needed; the backdrop layer holds the floor and ceiling. Each tile is then drawn from its VCN block, over the backdrop when its entry asks for it.
From tiles to pixels
The view occupies the top-left corner of the screen, from pixel (0, 0) to pixel (175, 119). The game builds it off screen and copies it there in one piece: 22 columns of 8 pixels by 120 rows, from position (0, 0) of the off-screen page to position (0, 0) of the screen. Tile (column, row) of the view covers the pixels x = 8 × column to 8 × column + 7 and y = 8 × row to 8 × row + 7.1
Every wall image of the view is drawn at one of the positions below, in this order. x, y is the top-left pixel, from the top-left corner of the view and therefore of the screen. "On screen" is the part actually drawn; "full area" gives the whole rectangle when it extends beyond the view. "VMP entries" are the entries of the wall's group used for that face.
| Order | Face | On screen: x, y, width × height | Full area | VMP entries |
|---|---|---|---|---|
| — | backdrop | 0, 0, 176 × 120 | same | 330 entries before the group of wall reference 1 |
| 1 | 00 right-hand | 0, 24, 8 × 40 | −16, 24, 24 × 40 | 102 to 116 |
| 2 | 06 left-hand, mirrored | 168, 24, 8 × 40 | 168, 24, 24 × 40 | 102 to 116 |
| 3 | 01 right-hand | 16, 24, 24 × 40 | same | 102 to 116 |
| 4 | 05 left-hand, mirrored | 136, 24, 24 × 40 | same | 102 to 116 |
| 5 | 02 right-hand | 64, 24, 8 × 40 | same | 97 to 101 |
| 6 | 04 left-hand, mirrored | 104, 24, 8 × 40 | same | 97 to 101 |
| 7 | 01 front | 0, 24, 16 × 40 | −32, 24, 48 × 40 | 129 to 158 |
| 8 | 05 front | 160, 24, 16 × 40 | 160, 24, 48 × 40 | 129 to 158 |
| 9 | 02 front | 16, 24, 48 × 40 | same | 129 to 158 |
| 10 | 04 front | 112, 24, 48 × 40 | same | 129 to 158 |
| 11 | 03 front | 64, 24, 48 × 40 | same | 129 to 158 |
| 12 | 07 right-hand | 0, 24, 16 × 48 | same | 117 to 128 |
| 13 | 11 left-hand, mirrored | 160, 24, 16 × 48 | same | 117 to 128 |
| 14 | 08 right-hand | 48, 16, 16 × 64 | same | 81 to 96 |
| 15 | 10 left-hand, mirrored | 112, 16, 16 × 64 | same | 81 to 96 |
| 16 | 08 front | 0, 16, 48 × 64 | −32, 16, 80 × 64 | 159 to 238 |
| 17 | 10 front | 128, 16, 48 × 64 | 128, 16, 80 × 64 | 159 to 238 |
| 18 | 09 front | 48, 16, 80 × 64 | same | 159 to 238 |
| 19 | 12 right-hand | 24, 8, 24 × 96 | same | 45 to 80 |
| 20 | 14 left-hand, mirrored | 128, 8, 24 × 96 | same | 45 to 80 |
| 21 | 12 front | 0, 8, 24 × 96 | −104, 8, 128 × 96 | 239 to 430 |
| 22 | 14 front | 152, 8, 24 × 96 | 152, 8, 128 × 96 | 239 to 430 |
| 23 | 13 front | 24, 8, 128 × 96 | same | 239 to 430 |
| 24 | 15 right-hand | 0, 0, 24 × 120 | same | 0 to 44 |
| 25 | 17 left-hand, mirrored | 152, 0, 24 × 120 | same | 0 to 44 |
Inside an area of w × h tiles starting at tile (x, y), the entries are taken row by row:
for i in 0 .. h − 1: # rows of the area
for j in 0 .. w − 1: # columns of the area, left to right
column = x + j
if column < 0 or column > 21: continue # outside the view
if not mirrored: e = entry[area + i × w + j]
else: e = entry[area + i × w + (w − 1 − j)]
if e != 0: e.horizontal_flip = not e.horizontal_flip # mirror the tile
if e != 0: wall_layer[y + i][column] = e # 0 leaves the tile as it is
where entry[area + k] is entry 330 + (g − 1) × 431 + area + k of the
VMP file, g being the wall's VMP group. The backdrop layer is filled the
same way from the 22 × 15 entries that precede the group of wall reference 1,
mirrored when the party's row + column + direction is odd. With the
executable's initial wall table, these are the file's first 330 entries.
Only the wall layer is emptied before each redraw: a zero entry in the backdrop
would leave the previous frame's tile in place.
The backdrop follows whatever VMP group wall reference 1 uses. Only a level's wall mappings and the True Seeing spell (reference 46) ever change that table, and the sixteen level files map references 25 to 74 only. Reference 1 therefore keeps group 1, and every level draws its backdrop from the first 330 entries of its VMP file. A level file that mapped reference 1 to group g would take the 330 entries just before group g instead, and with group 0 the backdrop layer would not be refreshed at all.2
Each of the 22 × 15 tiles is then drawn at its pixel position:
e = wall_layer[row][column]; b = backdrop_layer[row][column]
if e == 0: draw_block(b, backdrop colours)
elif e.composite_bit: draw_block(b, backdrop colours)
draw_block(e, wall colours, skipping colour 0)
else: draw_block(e, wall colours)
# draw_block(v): VCN block v.tile_index, mirrored left to right when v.horizontal_flip
The VCN file gives the blocks and the two 16-entry colour
tables; tile_index, horizontal_flip and composite_bit are the parts of a
VMP entry. These rules cover
the walls, floor and ceiling of the VGA view; display modes
describes the EGA view, and spots and wall decorations
places the decorations, items, monsters and flying objects.1
Unusual entry values
No original VMP file contains the values below, but the drawing code gives them a definite result. "Block 0" is an entry whose block number is 0.
| Entry | VGA mode | EGA mode |
|---|---|---|
| Mirror bit only, block 0 | The backdrop tile, always mirrored, whatever its own mirror bit | Same |
| Over-backdrop bit only, block 0 | The backdrop only | The backdrop, then block 0 under its mask |
| Over-backdrop bit in a backdrop entry | No effect | Draws from the wrong memory, except where no wall covers the tile and the entry also has the mirror bit |
| Block number past the end of the VCN file | Reads whatever follows the blocks; nothing is checked | Same |
The mirrored copy of a wall area changes two of these values before they are drawn. An entry with only the mirror bit becomes 0 and is still stored: the tile shows the backdrop the normal way round and hides any farther wall drawn there. An entry with only the over-backdrop bit gains the mirror bit, which in VGA mode draws the backdrop and then block 0 mirrored over it. Block 0 is blank in all five VCN files, so drawing it over the backdrop changes nothing with the original files.3
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.