DAT Format (Dark Legions)

From ModdingWiki
Jump to: navigation, search

Graphics data archives for Dark Legions, containing sprites and other graphics, are paired with separate header files and come in three variants that differ only slightly from each other:

  • .DAT archives with .DMP header files - standard version
  • .DAC archives with .DMC header files - compressed or transparent sprites (C for "compressed"?)
  • .BDT archives with .BDM header files - large graphics (B for "big"?)

It is easy to tell which archives pair with which headers as they will use the same file name, save for the extension.

DMP and DMC headers

Offset Type Purpose
0x0000 ! INT32LE? ! Unknown
0x0004 ! INT32LE? ! Unknown, usually (always?) identical to the value at 0x0000
0x0008 Array of indices See below

The files generally have some NULL padding after the valid index entries; checking for the end of the index can be done by stopping when an index with a zero offset and zero graphic size is reached.


Type Purpose
UINT32LE Offset of graphic (see notes)
UINT8 Graphic width (pixels)
UINT8 Graphic height (pixels)
! UINT8? ! X offset?
! UINT8? ! Y offset?
! UINT8? ! mirrored X offset?
! UINT8? ! mirrored Y offset?

For DAC/DMC pairs, the graphic offsets apply to the decompressed data. To read the sprites, a memory block sufficient to hold the sum of the width × height of each graphic in the index should be allocated, and the .DAC decompressed into memory. The .DMC index's offsets can then be added to the pointer to the start of the memory block.

BDM headers

Offset Type Purpose
0x0000 UINT32LE ! X offset modifier (not fully understood)
0x0004 UINT32LE ! Y offset modifier (not fully understood)
0x0008 Array of indices See below


Type Purpose
UINT32LE Offset of graphic (in decompressed data)
UINT16LE Graphic width (pixels)
UINT16LE Graphic height (pixels)
UINT16LE X drawing offset
UINT16LE Y drawing offset

As with .DAC files, .BDT files should be decompressed to memory first before using the index offsets to find the individual graphics.

! While the X and Y offset modifiers are not fully understood, they might define a center point around which the graphic is drawn?

Beware that if the graphic's offsets end up directing the game to draw outside of the screen area, severe errors will likely result (sufficient to crash a DOSBox session that the game is running in). It would be prudent for tool authors to include checks against writing a file that could cause such errors.

DAT / DAC / BDT data

! Need to confirm if .DAT files are compressed - probably the difference between DAT and DAC is that DACs need to be decompressed as a block for the index offsets to be valid, but DAT offsets are used first and the data blocks decompressed individually.

The data archives use a minor compression scheme reminiscent of RLE compression. When decompressing, if a byte's value is 0x00, then the next byte is a count of how many times to repeat the 0x00 value. All other values should be copied through unchanged. The decompressed data is a simple array of VGA 256-color pixel values to be interpreted using the header metadata; SK00.COL is a sensible default palette to use for interpreting them in most situations. ! 0x00 is probably considered transparent for sprites, although this needs to be confirmed.