Monster decoration entry
MonsterDecorationRuntime · 6-byte runtime structure
The engine in ten minutes · Monsters · DCR format
In brief
Some monsters are drawn with extra decoration shapes. When the game loads a DCR file, it cuts each described rectangle out of the source graphics and keeps, for each entry, a pointer to the extracted shape and where to draw it relative to the monster. The file descriptor and this memory entry are both six bytes, but the file's source rectangle is replaced in memory by a pointer.1
Layout
/* One decoration shape ready to draw (6 bytes, little-endian). */
typedef struct MonsterDecorationRuntime {
uint16_t shape_offset; /* Far pointer to the extracted shape: offset ... */
uint16_t shape_segment; /* ... and segment; both zero when there is no shape. */
int8_t offset_x; /* Horizontal position relative to the monster shape. */
int8_t offset_y; /* Vertical position relative to the monster shape. */
} MonsterDecorationRuntime;
There is no padding. The entries form one array in the data segment.
From the DCR file to memory
The loader skips a DCR descriptor whose width or height is zero, leaving a null shape in its entry. When drawing a monster, the game skips null shapes, scales the offsets with the monster's distance and takes horizontal mirroring into account.12
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references.