Page 1 of 2

GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 8:45 am
by Dageron
I want to ask help for solving Xbox360 resource compression problem, it is very important to me...

Every GTAIV resource (xtd-textures for example) has got following stucture:
4 bytes - Magic ('RSC')
4 bytes - Type (version - textures has "7")
4 bytes - Flags
<<Data in ZLIB on PC and LZX on XBox360>>
From 'flags' value can be calculated sizes of SysSegment and GpuSegment of unpacked data.
Delphi:

Code: Select all

 CpuSegSiz := (flags and $7FF) shl (((flags shr 11) and $F) + 8);
 GpuSegSiz := ((flags shr 15) and $7FF) shl (((flags shr 26) and $F) + 8);
C#:

Code: Select all

uint systemSegSize = (flags & 0x7FF) << (((flags >> 11) & 0xF) + 8);
uint gpuSegSize = ((flags >> 15) & 0x7FF) << (((flags >> 26) & 0xF) + 8);
Of course on PC everything is very easy because of primitive compression, but I dont know how to work with X360 data. Here it is archive which includes three examples of texture RSC.
http://www.sendspace.com/file/u4dk34

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 11:33 am
by Rheini
So why don't you just write an extractor if you already know that it is LZX?
Already seen some C code for decompression.

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 12:25 pm
by Dageron
Unfortunally I am not so strong in C++/C#, it is the reason of my ask.
Anyway, I will be happy to look at decompress code (can not found it)

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 12:28 pm
by Rheini
http://www.gtaforums.com/index.php?showtopic=410041
At the bottom. You already posted in that thread it seems.

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 12:41 pm
by Dageron
This is not decompress code, this is code for segment sizes calculation. Tool "unlzx" is not useful.
But I found some info about decompression in SparkIV source:
http://www.google.com/codesearch/p?hl=r ... ZXCodec.cs
Major part removed - it "is ommitted due to licensing issues".
Nobody of gtaF knows how to work with LZX, and who know will not tell because of some "staff agreement"

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 12:46 pm
by Rheini
Yeah exactly that unlzx code.
You just need to adapt some things (OS and platform-specific stuff).

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 1:15 pm
by Dageron
No future... :( If you could help me with decompressor writing it will be more than good, for all people who interested in X360 GTAIV.

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 1:34 pm
by Rheini
I'm too busy. Going through all that code takes some time.

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 1:36 pm
by Dageron
Maybe a bit later? (Week/Mounth and etc?...) Want to hope because it is very important

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 1:47 pm
by Rheini
Years is more likely :wink:

Re: GTA IV LZX compression on resource data

Posted: Mon May 25, 2009 3:19 pm
by aluigi
are you really sure that it's a LZX block?
I have tried to use the m$ lzx decompression which comes in libmspack but it doesn't work.

*edit*: with "doesn't work" I mean that the input data is not accepted as valid by the lzx_decompressor function ("bad block type") and even scanning the first bytes there are ever errors reported

Re: GTA IV LZX compression on resource data

Posted: Fri May 29, 2009 5:53 pm
by Rheini
Maybe it's a variation of LZX.

Re: GTA IV LZX compression on resource data

Posted: Fri May 29, 2009 6:19 pm
by Gocha
Are you kidding people?!! There are a lot of tools at the moment about editing the game such is GTA4! Where are you searching it? Through the Internet or into the Jungles? :D

[Edited, sorry for bad English]

Re: GTA IV LZX compression on resource data

Posted: Sat May 30, 2009 4:29 pm
by Rheini
Learn english before speaking.
This is about the xbox version of gta.

Re: GTA IV LZX compression on resource data

Posted: Mon Jun 22, 2009 7:58 am
by AnthonyFiveSixTwo
Well today I got around to looking at the xtd files that were posted and I was able to decompress them. I will make a tool to do it later on once we get a bit more info on the actual format of the decompressed data.

Im kinda tired right now but maybe tomorrow ill post some more info. :wink: