Let’s Make: Traffic Department 2192 – Part 6

Assets - Converting BLK Files to Bitmaps

Traffic Department 2192 comes with 3 files with the BLK extension identifying the episode just like the NEWFACES files. Also, the lengths differ because they are also packed files. As usual, we need to get these files in to BMP format.

BLK File Format

The BLKs share several points in common with both the Faces and SCR files, but this time there's one important difference: There isn't any palette data embedded with the color indices. However, these clearly are still indices so we have to find another palette. The original game comes with a default palette in the file TD.PAL which is conventiently 768 bytes. Using a hex editor on the BLK files, we can see that there are clear breaks and they happen every 1,024 bytes. This number happens to have a convenient root in 32x32. We can make an educated guess that if we process these files with dimension 32x32 using the default palette, we'll arrive at the target sprite strip. Let's do it.

Conversion Process

Read in the default palette from TD.PAL. Scan through each 32x32 image (each 1,024 block). Match each index to an RGB triple in the palette. Write the resulting set colors to the output container to build a horizontal sprite strip. Just like with the Faces file, we have to calculate the proper position in the output surface to correctly form the strip. This is done in lines 72-75 of the source code below.

Conversion process of BLK files to bitmaps

C Source Code

We'll make a small C program that turns a BLK file in to a bitmap. Run the application with the BLK file as the first argument.