Chicken Invaders Universe .tga

Textures, recreate headers, conversions, algorithms and parsing of image files
EmeraldPlay
Posts: 8
Joined: Sun Jan 06, 2019 1:22 am

Chicken Invaders Universe .tga

Post by EmeraldPlay »

Hello,
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.
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Chicken Invaders Universe .tga

Post by Acewell »

this bms script will write new headers to your tga samples. :D

Code: Select all

# script for QuickBMS http://aluigi.altervista.org/quickbms.htm

get NAME basename
string NAME + _fixed.tga
get WIDTH long
get HEIGHT long
get TYPE long
savepos OFFSET
get SIZE asize
math SIZE - OFFSET
log memory_file 0x0 0x12
if TYPE == 0x8
    put 0x0 short -1
    put 0x3 short -1
    put 0x0 long -1
    put 0x0 long -1
    put WIDTH short -1
    put HEIGHT short -1
    put 0x8 byte -1
    put 0x8 byte -1
elif TYPE == 0x20
    put 0x0 short -1
    put 0x2 short -1
    put 0x0 long -1
    put 0x0 long -1
    put WIDTH short -1
    put HEIGHT short -1
    put 0x20 byte -1
    put 0x0 byte -1
endif
log NAME 0x0 0x12 -1
append
log NAME OFFSET SIZE
append
EmeraldPlay
Posts: 8
Joined: Sun Jan 06, 2019 1:22 am

Re: Chicken Invaders Universe .tga

Post by EmeraldPlay »

Thanks.
mohammad as
Posts: 5
Joined: Thu Aug 06, 2020 6:11 am

Re: Chicken Invaders Universe .tga

Post by mohammad as »

How do I use codes?