ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Mon Mar 25, 2019 3:39 am

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jan 11, 2019 8:19 pm 

Joined: Sun Jan 06, 2019 1:22 am
Posts: 6
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:
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:
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:
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:
'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:
'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.


Top
   
PostPosted: Sat Jan 12, 2019 5:10 am 
User avatar

Joined: Fri Aug 08, 2014 1:06 am
Posts: 583
this bms script will write new headers to your tga samples. :D
Code:
# 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

_________________
Quickbms.com link thread
Search bms scripts


Top
   
PostPosted: Sun Jan 13, 2019 12:34 am 

Joined: Sun Jan 06, 2019 1:22 am
Posts: 6
Thanks.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited