Skip to main content

The dungeon view

Home · The engine in ten minutes · The world · Wall layouts (VMP) · Dungeon tiles (VCN)

In brief​

The first-person view looks 3D, but the game computes no perspective. Whatever the level, it always shows the same 18 blocks around the party, and each face of each of these blocks always goes to the same place on the screen. The view is a grid of 22 × 15 tiles of 8 × 8 pixels, 176 × 120 pixels in all, in the top-left corner of the screen. To draw it, the game:

  1. fills a backdrop layer of 22 × 15 tiles with the floor and ceiling;
  2. empties a wall layer of the same size, then, for each visible wall from the farthest to the nearest, copies into it the tiles that the level's VMP file gives for that wall and that place, so nearer walls cover farther ones;
  3. turns the two layers into pixels, tile by tile, from the VCN file;
  4. draws the items, monsters and other objects of the visible blocks, again from the farthest to the nearest, and copies the finished view to the screen.

Positions are written [XX:YY], column then row, both counted from 00; block index = YY × 32 + XX. Directions are Direction values: 0 north, 1 east, 2 south, 3 west.

The 18 visible blocks​

The view covers four rows of blocks in front of the party: seven blocks three steps ahead, five two steps ahead, three one step ahead, and the party's own row, which holds the party's block and its two neighbors. The game numbers them 00 to 17, row by row, from the far left. The numbering is attached to the party, not to the map: block 00 is always the farthest block on the party's left, whatever direction the party faces.1

Top-down maps of the 18 visible blocks, for a party facing north and for a party facing east. Each block shows its number in the view and the offset added to the party's block index; the four rows are colored from light (three steps ahead) to dark (the party's row).
The game always draws the same 18 blocks around the party, numbered from the farthest one on the party's left.

For a block that is a steps ahead and l steps to the right (negative to the left), the block index is:

block = (party_block + a × step[d] + l × step[(d + 1) & 3]) & 1023
step = [−32, +1, +32, −1] # north, east, south, west
View blocksSteps ahead aSteps to the right l
00 to 063−3 to +3
07 to 112−2 to +2
12 to 141−1 to +1
15, 16, 170−1, 0, +1

The game keeps these offsets in a table, one row of 18 per direction, and recomputes the 18 blocks each time it redraws the view. The index is wrapped to the level's 1,024 blocks, so near the edge of a level the view can include blocks from the opposite side.1

The pages of this chapter​

PageWhat it covers
Faces and drawing orderWhich faces of the visible blocks are drawn, a corridor as an example, the order of walls and objects.
Where each face goes on the screenThe tile rectangle of each face, the VMP areas, doors and other special cases.
Screen coordinates, pixel by pixelPixel positions, copying the VMP entries, drawing the tiles, unusual values.
Spots and wall decorationsThe five spots of a block, and where decorations go.
Items and flying objectsItems on the floor and in niches, objects in flight.
Monsters in the viewFrames, positions, decorations, flashes and petrified monsters.
Doors, teleporters and temporary wallsRising and parting doors, sparkles, shimmering walls, released shapes.
Clipping, scaling and darkeningThe columns each block can show; scale steps; darkening with distance.
Display modesVGA, EGA and Tandy: how the layers become pixels.

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. List the visible blocks with its view offsets and the visible-block list; the neighbor routine. Comparative source: REF-SCUMM-016, assignVisibleBlocks. ↩ ↩2