Skip to main content

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.

Left: the 22 by 15 tile grid of the view, 176 by 120 pixels in the top-left corner of the screen; tile (3, 2) covers the pixels x 24 to 31 and y 16 to 23. Right: how one tile is drawn from its two layers. A wall entry of 0 shows the backdrop tile; a wall entry with the over-backdrop bit draws the backdrop, then the wall block over it, skipping colour 0; any other wall entry draws the wall block alone.
Each tile shows its wall block, its backdrop, or the wall over the backdrop.

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.

OrderFaceOn screen: x, y, width × heightFull areaVMP entries
—backdrop0, 0, 176 × 120same330 entries before the group of wall reference 1
100 right-hand0, 24, 8 × 40−16, 24, 24 × 40102 to 116
206 left-hand, mirrored168, 24, 8 × 40168, 24, 24 × 40102 to 116
301 right-hand16, 24, 24 × 40same102 to 116
405 left-hand, mirrored136, 24, 24 × 40same102 to 116
502 right-hand64, 24, 8 × 40same97 to 101
604 left-hand, mirrored104, 24, 8 × 40same97 to 101
701 front0, 24, 16 × 40−32, 24, 48 × 40129 to 158
805 front160, 24, 16 × 40160, 24, 48 × 40129 to 158
902 front16, 24, 48 × 40same129 to 158
1004 front112, 24, 48 × 40same129 to 158
1103 front64, 24, 48 × 40same129 to 158
1207 right-hand0, 24, 16 × 48same117 to 128
1311 left-hand, mirrored160, 24, 16 × 48same117 to 128
1408 right-hand48, 16, 16 × 64same81 to 96
1510 left-hand, mirrored112, 16, 16 × 64same81 to 96
1608 front0, 16, 48 × 64−32, 16, 80 × 64159 to 238
1710 front128, 16, 48 × 64128, 16, 80 × 64159 to 238
1809 front48, 16, 80 × 64same159 to 238
1912 right-hand24, 8, 24 × 96same45 to 80
2014 left-hand, mirrored128, 8, 24 × 96same45 to 80
2112 front0, 8, 24 × 96−104, 8, 128 × 96239 to 430
2214 front152, 8, 24 × 96152, 8, 128 × 96239 to 430
2313 front24, 8, 128 × 96same239 to 430
2415 right-hand0, 0, 24 × 120same0 to 44
2517 left-hand, mirrored152, 0, 24 × 120same0 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.

EntryVGA modeEGA mode
Mirror bit only, block 0The backdrop tile, always mirrored, whatever its own mirror bitSame
Over-backdrop bit only, block 0The backdrop onlyThe backdrop, then block 0 under its mask
Over-backdrop bit in a backdrop entryNo effectDraws 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 fileReads whatever follows the blocks; nothing is checkedSame

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.

Footnotes​

  1. The scene redraw, the VMP area copy, the tile layers, the tile drawing and its VGA tile compositor. Comparative source: REF-SCUMM-016, generateVmpTileData, generateVmpTileDataFlipped and EoBCoreEngine::drawScene. ↩ ↩2

  2. The view setup, the VMP area copy and the wall-to-VMP mapping, written only by the wall mapping assignment and by True Seeing. The mappings of the sixteen level files were read with the INF schema. ↩

  3. The tile compositor, the EGA branch of the tile drawing and the VMP area copy. All entries of the five VMP files were read with the VMP schema layout. ↩