Let’s Make: Traffic Department 2192 – Part 7

Assets - Converting PIC Files to Bitmaps

Traffic Department 2192 includes 9 PIC files, all from the first episode. All of them differ significantly in size, which will make this the biggest challenge so far. We can assume that they will basically function the same as the other graphics assets, we just have to deal with more unknowns this time.

PIC File Format

The crux of the problem underlying the PIC files are their arbitrary resolutions without header information to give us a clue. Of course, we can try all the usual suspects such as powers of 2, or multiples of the screen size. That works on just one of the files though. We have a couple of options. The first is to perform a statistical analysis focusing on autocorrelation and we'd probably happen upon the row size quickly. We don't have tools for that and it's not really in theme with this project so we'll move on the option 2. We could use the IDA Pro disassembler to see how the game binary treats the files. Specifically, find the syscall that opens the file with those names and trace the invarients of the next double-nested loop to detect the dimensions of the buffer. Sounds like a mouthful, but it's easier than option 3: Try every width by hand in the hex editor until we spot something that looks good.

The second problem we find is that some of the files have their own palette, but some rely on the default palette. This is easy to see with a hex editor, although it's visible in IDA as well. (Is TD.PAL opened along with the PIC file?)

The good news is that these are all single image assets. No need to manage sprite strip output.

The results of our investigation from IDA are as follows:

File Dimensions Custom Palette
SECRET.PIC 320x32 Yes
TD1-13.PIC 202x86 Yes
TD1-14.PIC 200x200 Yes
TD1-15.PIC 255x121 Yes
TD1-16.PIC 150x170 Yes
TD1-17.PIC 320x90 No
TD1-18.PIC 170x104 Yes
TD1-19.PIC 320x72 No
TD1-20.PIC 320x100 Yes

Conversion Process

The process for the PIC blends the variations we've seen in the SCR, Faces, and BLK files. Set basic dimension variables based on input file name. Read in the palette either from PIC file or TD.PAL. Match each index to an RGB triple in the palette. Write the resulting set colors to the output container.

Conversion process of PIC files to bitmaps

C Source Code

We'll do the work in C and pass each PIC file in as the only argument.