DAT Format (The Lost Vikings)
Format type | Archive |
---|---|
Max files | Unknown |
File Allocation Table (FAT) | Beginning |
Filenames? | No |
Metadata? | None |
Supports compression? | Yes |
Supports encryption? | No |
Supports subdirectories? | No |
Hidden data? | No |
Games |
The DAT format is used by The Lost Vikings to store game data in DATA.DAT. This file contains pointers to data with LZ77-based compression.
Contents
File format
Signature
There is no known signature for this format, except the filename itself.
File entry
The beginning of the file contains 32-bit pointers to compressed chunks. There are 535 chunks. Data follows, in order, immediately after the pointers.
Format:
0..3: Offset to start of chunk 4..7: Offset to start of next chunk (also indicates where the previous chunk stops) ...
Compression
Each chunk is LZ77-compressed. Window size is 4096 bytes.
Chunk overview:
0..1: Uncompressed size (minus 1 - add 1 to this number) 2: Bitmask of the next 8 elements (raw (1) or dictionary (0)) 3..x: 8 elements x: Bitmask of the next 8 elements x-y: 8 elements ...
For each element:
If raw: 0: Raw byte (append to output and to sliding window/dictionary) If dictionary: 0..1: len+offset (4b len (3-18), 12b absolute window offset)
Copy data, byte for byte, from window, to both output and window/dictionary
Note: Sliding window is 4096 bytes, and initialized to 0 before decompressing. When decompressing, offset starts on 0 and increments.
Data overview
There are 535 chunks of compressed data with various length.
The game also operates with distinct "game screens", each with an index.
Game screens:
0: First level 1: Second level ... 36: Last level 37: Death screen 38: Menu, screen 3 39: Menu, screen 1 40: Menu, screen 2 41: Galaxy fall (between levels) 43: Intro level (demo) 44: Intro level part 2 45: Game complete 46: Game complete 2 47: Credits screen
Each screen have a screendata chunk, which is mapped as following (2 byte (LSB) index for each):
19F0:940C C6 00 C8 00 CA 00 CC 00 28 00 2A 00 2C 00 2E 00 ........(.*.,... 19F0:941C 30 00 32 00 34 00 4B 00 4D 00 4F 00 51 00 53 00 0.2.4.K.M.O.Q.S. 19F0:942C 55 00 72 00 74 00 76 00 78 00 7A 00 7C 00 7E 00 U.r.t.v.x.z.|.~. 19F0:943C 80 00 9C 00 9E 00 A0 00 A2 00 A4 00 A6 00 A8 00 ................ 19F0:944C AA 00 CE 00 D0 00 D2 00 D4 00 71 01 7D 01 86 01 ..........q.}... 19F0:945C 8C 01 92 01 7E 01 AF 01 B0 01 B1 01 B2 01 DA 00 ....~...........
Screendata contents:
22: Index of next gamescreen 28: Type? (1: level) 41: Tilemap width 46..47: Chunk ID with tilemap 48..49: Chunk ID with tile definitions (pixels) 50..51: Chunk ID with metatile definitions (4 tiles) 67: N chunks of unknown type, length 14, terminated by FF FF 67+N*14+2: N chunks of palette data, length 3, terminated by FF FF
Offset 67 (unknown data):
0..1: Chunk ID? (list terminates if this is FFFF) 2..13: Unknown data
Offset 67+N*14+2 (palette):
0..1: Chunk ID (list terminates if this is FFFF) 2: First color index (multiply this with 3 and copy data to that destination, palette is 256*3 bytes
Palette setup:
1: Prepare array with 3x256 bytes 2: Load each chunk to its location (several chunks with different sizes may be written to the same index) 3: Set color 16, 32, 48, 64, ..., 240 to [0,0,0] (black) 4: Color 4 is special (transparent/background/...?)
Known chunks:
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
Tile format
Each tile is 8 x 8 pixels, with 256 colors (using a palette).
Pixels are organised as following:
0: Pos 0/0 1: Pos 4/0 2: Pos 0/1 3: Pos 4/1 4: Pos 0/2 ... 14: Pos 0/7 15: Pos 4/7 16: Pos 1/0 17: Pos 5/0 ... 62: Pos 3/7 63: Pos 7/7
Metatile format
Each metatile consist of 2 x 2 tiles (16 x 16 pixels).
Metatiles:
0..1: Upper left tile 2..3: Upper right tile 4..5: Lower left tile 6..7: Lower right tile
Each tile in this list is 16 bit LSB.
Bit 4: Horizontal flip Bit 5: Vertical flip Bit 6..15: Tile index
Tilemap format
Tilemap have 2 bytes (LSB) for each metatile.
Bit 0..8: Metatile index
Tools
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 |
---|---|---|---|---|---|---|---|---|---|
Camoto | Linux/Windows | No | No | No | No | No | No | No | |
Wombat | Windows | No | No | No | No | No | No | No | |
Blizzard DATA unpacker | Windows | Yes | Yes | No | No | No | No | No | partial support |
Lost Vikings data extractor | Windows | Yes | Yes | No | No | No | No | No |
Credits
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!)