Wall decorations (DEC)
File formats · Field reference · Schema
In brief
A DEC file describes the decorations that can be drawn on the walls of one dungeon style. For each decoration, it says which rectangles to cut out of a decoration image and where to paste them, for each of ten positions in the 3D view. A level's INF file names its decoration image and DEC file together, and its wall mappings select decorations by number.
There are six DEC files: AZURE, BROWN, CRIMSON, FOREST, MEZZ and
SILVER. For example, LEVEL1.INF pairs the images brown1 and brown2
with brown.dec, and LEVEL4.INF pairs forest with forest.dec.
Organization
| Part | Size | Contents |
|---|---|---|
| Decorations | count, then 52 bytes each | For each decoration: a rectangle choice and a placement for each of ten view positions, a link to another decoration and a flags byte. |
| Rectangles | count, then 8 bytes each | Position and size of each rectangle in the decoration image. |
A rectangle choice of −1 means nothing is drawn at that position.1 Decorations can be chained: the link names the next decoration, and zero ends the chain.1
The ten entries are ten places in the dungeon view:
the party's own block, the front faces one, two and three steps ahead, then
the side faces from the party's row outwards. Placements are pixels from the
top-left corner of the 176 × 120 view; rectangles give x and width in
8-pixel columns and y and height in pixels.2 Placements are signed:
the drawing clips a negative position to the view. SILVER.DEC contains
fa ff, −6, the only placement with its high bit set in the six files.
Flags and links
Only three flag bits have an effect, and only on the party's block and the front faces (positions 1 to 4); side faces ignore the flags:2
| Bit | Effect | Records in the six files |
|---|---|---|
0x01 | Always drawn mirrored. | 83 |
0x02 | Mirrored when the floor and ceiling backdrop is drawn mirrored. | 0 |
0x04 | Shifted by the centre spot of the block instead of the block's offset. | 61 |
The other five bits have no known effect and are clear in every record; a record has flags 0, 1, 4 or 5.
A link is the number, counted from 0, of the next decoration of the same file; 0 ends the chain, so decoration 0 can start a chain but never follow another. Links in the files are at most 76, below their file's count, and no chain loops. The game reads a link as a signed byte and gives values of 128 and above no special meaning: 128 to 254 would make it copy data from before the file, and 255 would end the copy while still pointing to a following decoration.
Reading the file
The wall section of a sublevel record of the level's INF file mixes two kinds of entries: one that names a decoration image and its DEC file, and the wall mappings. While the game loads the level, the first kind loads the image and reads the DEC file into a shared buffer, where the records stay in file form; the wall mappings that follow pick decorations from them.1 When a level assigns a decoration to a wall, the game copies the whole chain into its own table of at most 60 decorations per sublevel, one copy per wall mapping, and cuts each rectangle out of the decoration image the first time a decoration uses it.1
What it becomes in memory
The copies form the level's decoration table, of at most 60 entries, with the shapes cut from the image.3 Drawing the view takes the chain of each decorated face in sight and draws its rectangles at the placements of the face's view position.2
Example
The first 32 bytes of FOREST.DEC:
offset bytes meaning
0000 03 00 3 decorations
0002 00 01 02 03 ff ff ff ff ff ff rectangles for the ten positions; ff = none
000c 00 link: end of chain
000d 04 flags
000e 46 00 3a 00 48 00 50 00 00 00 … horizontal placements: 70, 58, 72, 80, 0, …
The rectangle list starts at offset 0x009e with a count of 11, and the file
ends exactly after the eleventh rectangle.
Details and edge cases
Unchecked rectangle numbers (ANOMALY-78). When the game copies a
decoration, it cuts the shapes of its ten rectangles into a table of 301
entries, then checks that the rectangle number is at most 300 — but only for
the tenth position, and only after the shapes are stored. A larger number at
any of the first nine positions would be written past the table unchecked;
at the tenth, it is written, then reported as "Too many decoration shapes
loaded!". With the original files nothing happens: the largest rectangle
number is 241. Number 300, which passes the check, is also the one shape that
the release at each sublevel record leaves in place, since it frees the first
300. A faithful reimplementation needs no shape table beyond 301
entries for the original data; rejecting larger numbers at every position
before cutting changes nothing for it.3
Click test and drawing disagree (ANOMALY-79). When the player clicks
a decorated wall in front of the party, the game tests the click against the
position-2 rectangle of each decoration of the chain. It mirrors that
rectangle for bit 0x01 but ignores bit 0x02, which the drawing applies,
and it does not skip a rectangle choice of −1, which the drawing skips: it
then reads the size of a shape that does not exist. With the original files
this has no effect: no decoration sets bit 0x02, and the only chain with a
decoration lacking a position-2 rectangle (a wall of the first sublevel of
LEVEL1.INF) is on a wall that does not react to clicks. A faithful
reimplementation mirrors the click region for bit 0x01 only; with the
original data, skipping decorations with no position-2 rectangle, as the
drawing does, gives the same result.4
- The game reports "Too many decoration types loaded!" when the walls of a
sublevel need more than 60 decoration copies. The first sublevel of
LEVEL6.INFneeds exactly 60.3 - A rectangle is cut once per sublevel, from the decoration image current when it is first used; a later wall using the same rectangle number after another image has been named reuses the first cut. The original levels never use a rectangle number under two images.1
Related pages
- Level data (INF): where decoration images, DEC files and wall mappings are named.
- Decoration, door and monster images: the six files, their decoration images and the levels that use them.
- The world.
Sources
Locations refer to the game executable reference;
comparative sources are listed in the technical references
(REF-MW-009, REF-SCUMM-006).