DAT Format (The Lost Vikings)
|Max files||1,073,741,823 (230 - 1)|
|File Allocation Table (FAT)||Beginning|
The DAT format is used by The Lost Vikings to store game data in DATA.DAT. This file contains pointers to data with LZSS compression.
There is no signature, so the file offsets must be checked for validity. Each offset must be larger than the previous one (otherwise the file sizes would be negative), and must not point past the end of the archive file.
Note that any file that starts with the bytes 00 00 00 04 will look like a valid archive containing a single large file, so some format misidentification is unavoidable. Some example archives that are misdetected as Lost Vikings are Death Rally BPA Format archives containing four files, and Terminal Velocity POD Format archives also containing four files.
The beginning of the file contains a list of offsets for each file.
|UINT32LE[fileCount]||offsets||Array of offsets, one per file.|
|BYTE[...]||content||File content starts immediately after last offset.|
To calculate the file count, read the first offset and divide it by 4.
To calculate the file sizes, subtract the following file's offset from the current file's offset. For the last file (where there is no following offset) use the size of the archive file.
Immediately after the list of offsets, at the first offset given, the data for the first file begins.
Most files are compressed. Those files that are not compressed are those at these indexes: 0, 1, 380, 384, 529, 530, 531, 534 (with 0 being the first file). There doesn't appear to be any way to identify which files are and aren't compressed, other than hard-coding a list.
For those files that are compressed, they begin with a single UINT16LE containing the decompressed file size, followed by the compressed data using LZSS compression with the following properties:
- Size of LZSS "length" field: 4 upper bits
- Size of LZSS "offset" field: 12 lower bits (making the window size 4096 bytes)
- Minimum length to write lookback: 3 bytes
- Window prefill byte: 0x00
- Initial window position: 0
- Endian/swap: Read bytes "AB CD" into an integer of value 0xCDAB.
Note that the 16-bit value for the decompressed size means that no file can exceed 65,535 bytes in length.
First image in menu ("Interplay (tm)" splashscreen):
- 390: Pointers to the other chunk IDs (81 B)
- 388: Tiles (9024 B = 141 tiles * 64 B) (tiles is 8 x 8)
- 385: Palette (384 B = 80 colors * 3 B)
- 386: Tilemap (560 B = 20 x 14 metatiles * 2 B). 52 unique metatiles (each metatile is 16 x 16 and consist of 4 tiles)
- 387: Metatiles (4 tiles forms 1 metatile) (416 B = 52 * 8 B)
- 394: Tiles for 2nd splashscreen in the menu
The following tools are able to work with files in this format.
|Name||Platform||Extract files?||Decompress on extract?||Create new?||Modify?||Compress on insert?||Access hidden data?||Edit metadata?||Notes|
|Blizzard DATA unpacker||Windows||Yes||Yes||No||No||No||N/A||N/A||partial support|
|Lost Vikings data extractor||Windows||Yes||Yes||No||No||No||N/A||N/A|
This file format was reverse engineered by Eirik. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)