Vexx archives - A return to .TRE files (Turok Evolution)
Posted: Wed May 26, 2010 3:51 am
Hello everyone,
Just found this site today, and it's been quite a fruitful day!
I am currently working on the Acclaim game Vexx on the GameCube system. Its disc architecture is very similar to that of Turok Evolution (based upon what was reported here last year: viewtopic.php?f=10&t=3881&p=33441 ), in that almost all of the game's data is locked up in one Supertree0.tre cabinet file.
Not surprisingly, the .tre file follows the same protocol with regards to its header:
[NUM_FILES long] [offset long, size long, unk long, unk long] x 4213 total files
So the script documented in the Turok Evolution thread worked and was able to extract all 4213 files. The two unknown longs do not confer any information regarding file names, which is a pain in the rear across 4200-some files.
However, the second file in the .tre archive after the header, called tempfiles.txt, contains a list of every filename in the archive, and, surprisingly, in the order of appearance! But the offset/size pairs in the header are in a seemingly random order. This calls for a sort operation if we are to have properly named/placed files be output. Since the files are ordered in tempfiles.txt, as a temporary solution I chose to name the files by their offset, let Windows sort them by name and establish the name correlation. But manually changing 4213 file names isn't fun!
Now, my question to you guys is, how would I optimize the code so that the sort process is incorporated into the BMS script (running on quickbms)? The problem I encounter is the lack of versatility in both reading and appending secondary files using BMS scripts (granted, their primary role is to dump files from the file 0 archive, not manipulate temp files). Can the Log function output just variables into a temp file, instead of chunks of file 0? Or would it be better to break the script action into an offset script, a .BAT sort, then a dump script? It'd be nice to get the whole thing to work in one double-click though.
Here is some pseudocode:
PS. As a side note, there seems to be some encryption of various texture files, most of appear to be in the targa format .TGAX and some modified bitmap files .BMPX... Also there are other .tre files within the Supertree0.tre file, most notably containing the (playable!) .DSP music files, but no helpful tempfiles.txt file (and there's >10000 files in that secondary music .tre file!).
Just found this site today, and it's been quite a fruitful day!
I am currently working on the Acclaim game Vexx on the GameCube system. Its disc architecture is very similar to that of Turok Evolution (based upon what was reported here last year: viewtopic.php?f=10&t=3881&p=33441 ), in that almost all of the game's data is locked up in one Supertree0.tre cabinet file.
Not surprisingly, the .tre file follows the same protocol with regards to its header:
[NUM_FILES long] [offset long, size long, unk long, unk long] x 4213 total files
So the script documented in the Turok Evolution thread worked and was able to extract all 4213 files. The two unknown longs do not confer any information regarding file names, which is a pain in the rear across 4200-some files.
However, the second file in the .tre archive after the header, called tempfiles.txt, contains a list of every filename in the archive, and, surprisingly, in the order of appearance! But the offset/size pairs in the header are in a seemingly random order. This calls for a sort operation if we are to have properly named/placed files be output. Since the files are ordered in tempfiles.txt, as a temporary solution I chose to name the files by their offset, let Windows sort them by name and establish the name correlation. But manually changing 4213 file names isn't fun!
Code: Select all
Endian big
Get NUM_FILES long
For I = 0 < NUM_FILES
# File info
Get OFFSET long
Get SIZE long
Get UNK long
Get UNK long
# Extract file
Log OFFSET OFFSET SIZE
Next I
Here is some pseudocode:
Code: Select all
Endian big
Log TEMPORARY_FILE 0 0
Append
#append on
Get NUM_FILES long 0
For I = 0 < NUM_FILES
# Walk through all 4213 files' offsets and save them to temp
SavePos CurrentOffset 0
Get OFFSET long 0
Get SIZE long 0
Get UNK long 0
Get UNK long 0
# Save the two OFFSET/SIZE longs to temp file for later sorting
Log TEMPORARY_FILE CurrentOffset 0x8
Next I
Open "." TEMPORARY_FILE 1
# sort offsets/sizes so lowest offset appears first, corresponding to the correct order of files in the .tre archive
# sort code goes here
Append
#append off
#with the offsets sorted, dump files in order appearing in TEMPORARY_FILE, using the filenames after finding the tempfiles.txt offset
#locate tempfiles.txt offset
GoTo 0x0 0
FindLoc nameOffset string "C:\VexxDataGC_TreFiles" 0 ""
If nameOffset == ""
Clean Exit
EndIf
GoTo nameOffset 0
#nameOffset should be 0x00012473, the start of the tempfiles.txt file
GoTo 0x0 1
For I = 0 < NUM_FILES
Get OFFSET long 1
Get SIZE long 1
#step through the tempfiles.txt file, extracting the string for the folder\file.ext structure
#not a null-terminated string, will need a bit of coding and an iterative step to cleave off C:\VexxDataGC_TreFiles which precedes every file
GetDString NAME NAME_LENGTH 0
Log NAME OFFSET SIZE 0
Next I