Tiles

Back to the Game FIles

# allhtdsX files

Each of the two allhtds files contains the **tiles** for drawing the world of Wasteland. A tile may be a wall, a door, a floor, whatever. Each tile is 16x16 pixels large. Tiles are organized in tilesets (maybe because in this way they are easier to handle for the game). The allhtds1 file contains four tilesets while allhtds2 contains five tilesets. Each tileset is in its own MSQ block. The block data is huffman compressed and the uncompressed data are just the tiles in the standard PIC format. So parsing the file may look like this (in a pseudo programming language)

foreach (msqblock)

{

    huffman\_uncompress msqblock;

    number\_of\_tiles = uncompressed\_size \* 2 / 16 / 16;

    foreach (tile)

    {

        // Do something with the tile which is now in raw PIC format

        // which must be vertical xor decoded first.

    }

}

## MSQ block format

The MSQ block format is the same as in the end.cpa and allpicsX files. Each block begins with a 32 bit value which is the size of the data in the MSQ block when it's uncompressed. Then follows three characters "msq" and after this a 0x00 byte (allhtds1) or 0x01 byte (allhtds2). Then follows immediately the data which is the huffman tree data directly followed by the huffman bitstream.

## MSQ block offsets

The offsets to the MSQ blocks are hardcoded in wl.exe so the game can quickly seek to the position of a block. If the tiles are changed then the offsets will most likely differ from the original ones because of the huffman compression. So the offsets need to be corrected in wl.exe after a new allhtds1 or allhtds2 file has been composed.
The offsets for allhtds1 starts in the unpacked EXE file at position 0x18ccc. Each offset is a 32 bit value.

The offsets for allhtds2 starts in the EXE file at position 0x18cdc. Directly after the offsets for allhtds1. But be aware: The offsets here are not directly the offsets in the file. They are the file offset plus the value 0x8603 which is the size of the allhtds1 file. I think this is because allhtds2 is loaded into memory directly after allhtds1 and so both tileset files share the same base (which is the beginning of the first tileset of allhtds1). So if you want to change the offsets of allhtds2 tilesets then remember to add 0x8603 to the real offsets. This fact also leads to a possible problem: When you compose a new allhtds1 file which is larger then the original file then the end of the file may be overwritten by the allhtds2 file in memory which may produce strange errors in the game. So I think it's a good idea to make sure your custom allhtds1 file will not be larger then the original one. You may achieve this by having fewer tiles in it (which only works if the maps were changed also so they don't use the removed tiles) or by using simpler tiles which can be compressed better.

## How this was found

Even if the format is really simple I found it just by accident. While I was working on the decoder for the base frame of the end.cpa file I just thought "What might happen if use the same decoder with the allhtds files?" I knew that the tiles are 16 pixels wide so I set the decoder to decode the picture with this width. And the result was a PNG with a size of 16x1056 pixels. I opened the PNG in a graphic viewer and found the tiles. But only the few first tiles were correct. The other tiles had wrong colors. But this was just because my decoder expected ONE picture and so applied the vertical XOR decoding at all tiles without resetting the XOR decoding to 0 after each tile. After telling the decoder that the MSQ block does not contain one large picture but instead contains 66 small 16x16 pictures the decoding worked perfectly. I decoded the other MSQ blocks in the same way and so found out about the tilesets.

The offsets in the EXE file for allhtds1 were easy to find just by a simple search. But the offsets for allhtds2 were hard to find because it's not possible to find them with a simple search. But it was just logical that these offsets were located directly after the offsets of allhtds1 so I looked deeper into them and saw that the offsets had the correct difference and I only had to subtract 0x8603 from them to get the offsets I searched for.

## The tilesets

NOTE: Tiles in the allhtdsX files start with id 10 (0Ah). The first ten tiles are the sprites coming from the IC0\_9.WLF file.
Tiles numbered in hex