Let’s Make: Traffic Department 2192 – Part 4

Assets - Converting SCR Files to Bitmaps

We will spend the next half-dozen videos pulling the graphics assets out of the original game archive. All the graphics are stored in a custom, but simple format that we can quickly extract by making small C utilities for each case. We'll begin with the most numerous of the assets: The SCR files.

Traffic Department 2192 comes with 44 files with the extension SCR. Each file is exactly 64,768. We can make an educated guess that SCR is related to the screen and the size is consistent with a graphics asset. The issue is that this is a custom format that isn't readily handled by any application. 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.

SCR File Format

Reviewing several files in a hex editor, we see section break at offset (0x300). This means that we have two sections of size 768 bytes and 64k bytes. We know the screen resolution of the game is 320x200 which means that one screen has 64,000 pixels. If we suppose that each pixel is stored as 1 byte, then we know that we need to reference color values elsewhere. The top 768 bytes is probably the custom palette for each image, which is also consistent with the dithering we noted in the playthrough. We can store 1 byte for each channel (Red, green, and blue) for each of the 256 colors using exactly 768 bytes. Interestingly, these palette bytes in the SCR file only use the least-significant 6-bits of the byte to store values (range is 0 through 63 in decimal). Let's use this information to convert an SCR file to BMP with the SDL data structure, SDL_Surface and the function SDL_SaveBMP.

Conversion Process

Scan through each of the 64,000 color indices in row-major. Match each index to an RGB triple in the palette. Write the resulting set colors to the output container.

Conversion process of SCR files to bitmaps

C Source Code

We'll make a small C program that performs the task on one SCR file provided as an argument. 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 SCRtoBMP application. This program has several issues noted in the comments and in the videos, but it does the job.