There is a new compression format for TR9. But before continuing, let's see the layout of a CDRM file (which was intrudced in TRU, TMYK!).
Code: Select all
CDRM Header
u32 magic; // Always "CDRM", so 0x4344524d in BE, 0x4d524443 in LE
u32 version; // Always 0 for TR9? Was 0x2 for some files in DX3 I think.
u32 count; // number of blocks
u32 pad; // pretty much everything is 16 byte aligned
CDRM BlockHeader (repeaded "count" times, 16 byte aligned at the end)
u32 var1
24 MSB = uncompressedSize; //size of uncompressed data chunk, max 0x40000
8 LSB = blockType; // 1 is uncompressed, 2 is zlib, 3 is the new one
u32 compressedSize; //size of the compressed data block
Data blocks (of "compressedSize" length, "count" number of blocks, each 16 byte aligned between each other)
You see that there is one block of type 3, with uncompressed size of 28952 bytes, and a compressed size of 20552 bytes.
If you look at offset 0x20, it's the start of the data. We obviously see that it's not a valid zlib header; it starts with 0xFF. But we see that the first 3 bytes are very similar to the bytes of the uncompressed size, just one line over (well except for 0x00 that became 0xFF). I looked at a bunch of CDRM files (not all) and they all share that pattern.
Let's look at another CDRM header.
This one has 2 blocks, the first one with the max uncompressed size of 0x40000. For the first block, the observation I previously made does't work. But it does work for the last block, which isn't the max uncompressed size! Look:
0x004158 <-> 0xFF4158
I tried to see if I could reconstruct the zlib header without success. So now the question is, what is it? What other compression method is usually used in game archives?
(I posted extracts of the game files as images, I hope it's OK )