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:
- fills a backdrop layer of 22 × 15 tiles with the floor and ceiling;
- 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;
- turns the two layers into pixels, tile by tile, from the VCN file;
- 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
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 blocks | Steps ahead a | Steps to the right l |
|---|---|---|
| 00 to 06 | 3 | −3 to +3 |
| 07 to 11 | 2 | −2 to +2 |
| 12 to 14 | 1 | −1 to +1 |
| 15, 16, 17 | 0 | −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
| Page | What it covers |
|---|---|
| Faces and drawing order | Which faces of the visible blocks are drawn, a corridor as an example, the order of walls and objects. |
| Where each face goes on the screen | The tile rectangle of each face, the VMP areas, doors and other special cases. |
| Screen coordinates, pixel by pixel | Pixel positions, copying the VMP entries, drawing the tiles, unusual values. |
| Spots and wall decorations | The five spots of a block, and where decorations go. |
| Items and flying objects | Items on the floor and in niches, objects in flight. |
| Monsters in the view | Frames, positions, decorations, flashes and petrified monsters. |
| Doors, teleporters and temporary walls | Rising and parting doors, sparkles, shimmering walls, released shapes. |
| Clipping, scaling and darkening | The columns each block can show; scale steps; darkening with distance. |
| Display modes | VGA, 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.