Let’s Make: Traffic Department 2192 – Part 5

Assets - Converting Face Files to Bitmaps

Traffic Department 2192 comes with 3 files named NEWFACES plus an extension identifying the episode where they're used. The files have variable length because they contain a different number of images. The file name should be a dead givaway about the information inside. We'll take a close look at these files with the hex editor. We need to get these data in to a common format, such as BMP, that we can easily handle with graphics libraries or a game engine.

Faces File Format

The faces file share a few things in common with the SCR files we analyzed last time. We see section breaks again at at the 0x300 offset in each file. However, the files are much too big to contain just one image. In the game itself, the faces in the briefing scenes appear to occupy a quarter of the screen. If we guess that we're dealing with images of size 160x100, we should check the appropriate offset (0x4180) in the file for changes. There are changes: We see the start of another 0x300 sized section and another long data block. A new palette and a new image to use with it. The Faces file essentially appends a series of smaller SCR files together to store the game faces.

Conversion Process

Scan through each image, reading in the palette and then the 16,000 bytes of color indices. 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. Be careful to calculate the proper position in the output surface since we can't directly stream to a sprite strip. This is done in lines 62-65 of the source code below.

Conversion process of Face files to bitmaps

C Source Code

We'll make a small C program that turns NEWFACES.TD, NEWFACES.TD2, and NEWFACES.TD3 in to bitmap files. In order to quickly reuse our SCRtoBMP code, we should rename the 3 files to have different names, such as NEWFACE1,TD1, NEWFACE2.TD2, and NEWFACE3.TD3 to avoid filename collisions after we change all extentions to .BMP. After testing the program one one file, run it against all the SCR files in the folder by redirecting the list of the names to the FCEtoBMP application.