---------------------------------------------------------------------------- | The Wing Commander Prophecy TRE Format | | By Mario "HCl" Brito | ---------------------------------------------------------------------------- Introduction This is probably the most well know TRE format around, since the WC editing community began to grow by the time Prophecy came out. This information below is doesn't bring much new compared to the small txt info i included with my small (2kb) WCP uncompressor, in wcpu1.zip, but that's because there's no need for more. The file compression mentioned below refers to the generic file compression routine used by WCP (the one i included with the source code of WCSO-RIP) but if a file seems uncompressed it doesn't necessarily mean that that file isn't compressed *at all*. As an example, MGI files seem uncompressed (more info below) but still they are compressed with the MGI algorithm, and upon extraction (without uncompressing with the algorithm used by WCSO-RIP) it must be uncompressed with MGI2WAV (a different uncompression routine). The info First of all, i'll give some info on the data types i'll use, so there's no confusion: byte = 1 byte word = 2 bytes dword = 4 bytes string = A space meant to hold a sequence of characters with a null (or \0) at the end. It's size is constant (pretty much like an array). Like most TRE files, this one is divided in 2: the Header and the Data section. The Data section will not be covered since it'll be raw file data referenced by the header. -> The Header data type | size | description ------------------------------------------------------------------------------ dword | 4 | Number of files in this TRE. ----------------|---------------|--------------------------------------------- dword | 4 | Unknown, it's almost always 0x1. ----------------|---------------|--------------------------------------------- dword | 4 | Unknown, it's always 0 ----------------|---------------|--------------------------------------------- dword | 4 | Unknown, it's always 0 ----------------|---------------|--------------------------------------------- The number of files in the TRE and the length of the header are defined. The below structure must be repeated for each file in the TRE: data type | size | description ------------------------------------------------------------------------------ dword | 4 | The CRC of the file: basically, just pass | | the string through the CRC generator also | | on the Information Area. Note that the files | | inside a TRE are ordered by CRC values, from | | smallest to larger. My theory is that it's | | to make file search faster, although i never | | checked the EXE. Of course, if you insert | | the CRC in the wrong place, it's likely to | | mess up other file searches. ----------------|---------------|--------------------------------------------- dword | 4 | The uncompressed file size. When extracting | | a file, you'll need to write the number of | | bytes mentioned here, no matter if it's | | compressed or not. ----------------|---------------|--------------------------------------------- dword | 4 | The offset on the TRE where the file starts. ----------------|---------------|--------------------------------------------- dword | 4 | The compressed size of the file. Notice | | that if this value is 0, the data is not | | compressed, which means you only dump it to | | a file (don't attempt to uncompress it). ----------------|---------------|--------------------------------------------- string | 256 | The name of the file ----------------|---------------|--------------------------------------------- You can find the source code of WCSO-RIP on the Information Area. -> Thanks go to Origin Systems INC for creating Wing Commander Prophecy and Wing Commander Secret Ops. The uncompression routine used to unpack the files stored inside a TRE was taken from Prophecy.exe, which was created by Origin: http://www.origin.ea.com Mario "HCl" Brito mbrito@student.dei.uc.pt