I'm looking for a way to reliably convert the .tga files present in Chicken Invaders Universe's files to make them readable in editing software. Those .tga files are similar to regular ones, but their headers are messed up (they only contain texture size and the amount of bits per pixel). I already know how to make them readable through hex editing, but that method takes a while to do, which is why I'm looking for a script that would do it faster. I'll explain how to do it below:
First, here is an example header similar to what's used in the game's texture files.
Code: Select all
00 01 00 00 00 01 00 00 20 00 00 00
And here's the end result after converting the header to make the file readable in editing software.
Code: Select all
00 00 02 00 00 00 00 00 00 00 00 00 00 01 00 01 20 00
To convert the example header, first, the third, fourth, seventh, eighth, eleventh and twelfth bytes (0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B) need to be removed.
Code: Select all
00 01 '00 00' 00 01 '00 00' 20 00 '00 00'
That will leave you with six bytes. After that, twelve bytes need to be appended to the beginning of the header. The bytes that need to be appended depend on the ninth byte (0x08) in the example header. If that byte is set to 20, then the 12 bytes need to be appended like this:
Code: Select all
'00 00 02 00 00 00 00 00 00 00 00 00' 00 01 00 01 20 00
In this case, the twelve bytes are "00 00 02 00 00 00 00 00 00 00 00 00".
However, if the ninth byte (0x08) in the example header is set to 08, then the twelve bytes will be different:
Code: Select all
'00 00 03 00 00 00 00 00 00 00 00 00' 00 01 00 01 "08" 00
And in this case, the twelve bytes will be "00 00 03 00 00 00 00 00 00 00 00 00".
That's all the script needs to do. It would also be useful if this script could do that to multiple files in a folder instead of only one, and if there was another one for reverting the changes for easier reimporting.
EDIT: I forgot to include some example files to try the script on. You can get them here.