The TP4 file contains a bit map image. The file has 52,000 bytes. The file contains a 400 byte header followed by the image. The image is 200 pixels high by 254 pixels wide. Each row contains 4 flag bytes in addition to the data. The header is the same for all files and contains no useful information. The values in the header can be generated with the following algorithm.
countby2 = 0x90
// a single byte variable
countby1 =
1 //
a single byte variable
for i = 1 to
200 // loop two
hundred times
write_one_byte countby2
write_one_byte countby1
countby2 =
countby2 + 2
// overflow is ignored (0xFE + 2 becomes
0x00)
if countby2 =
0
then
countby1 = countby1
+ 2
else countby1
= countby1 + 1
// end of "for loop"
The results are: 90, 01, 92, 02, 94, 03 ... FE, 38, 00, 3A, 02, 3B ...
Each row of image data begins with a two byte flag: 7F 00. After this initial flag, there are 127 pixel values.Then the two byte flag FF 7F is encountered. After that flag, there are another 127 pixel values.This completes a row of 254 pixels. Each pixel value is a one-byte palette index.