Important information: this site is currently scheduled to go offline indefinitely by end of the year.

GTA IV LZX compression on resource data

Read or post about compression. And decompression. Or ask questions how to decompress your files.
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Has thanked: 11 times
Been thanked: 58 times

GTA IV LZX compression on resource data

Post 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
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post 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.
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Has thanked: 11 times
Been thanked: 58 times

Re: GTA IV LZX compression on resource data

Post 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)
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post by Rheini »

http://www.gtaforums.com/index.php?showtopic=410041
At the bottom. You already posted in that thread it seems.
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Has thanked: 11 times
Been thanked: 58 times

Re: GTA IV LZX compression on resource data

Post 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"
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post by Rheini »

Yeah exactly that unlzx code.
You just need to adapt some things (OS and platform-specific stuff).
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Has thanked: 11 times
Been thanked: 58 times

Re: GTA IV LZX compression on resource data

Post 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.
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post by Rheini »

I'm too busy. Going through all that code takes some time.
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Has thanked: 11 times
Been thanked: 58 times

Re: GTA IV LZX compression on resource data

Post by Dageron »

Maybe a bit later? (Week/Mounth and etc?...) Want to hope because it is very important
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post by Rheini »

Years is more likely :wink:
User avatar
aluigi
VVIP member
VVIP member
Posts: 1916
Joined: Thu Dec 08, 2005 12:26 pm
Location: www.ZENHAX.com
Has thanked: 4 times
Been thanked: 664 times
Contact:

Re: GTA IV LZX compression on resource data

Post 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
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post by Rheini »

Maybe it's a variation of LZX.
User avatar
Gocha
veteran
Posts: 109
Joined: Fri Dec 12, 2008 8:16 pm
Location: Batumi, Georgia, GE
Has thanked: 57 times
Been thanked: 9 times
Contact:

Re: GTA IV LZX compression on resource data

Post 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]
Last edited by Gocha on Sat May 30, 2009 6:36 pm, edited 1 time in total.
My great respect and appreciation for them, who research game files! Special thanks to: aluigi, bacter, DerPlaya, Rick, Turfster, twig, Zench. Sorry if someone is missing in my list, I'll update when I'll notice it again
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: GTA IV LZX compression on resource data

Post by Rheini »

Learn english before speaking.
This is about the xbox version of gta.
AnthonyFiveSixTwo
ultra-n00b
Posts: 5
Joined: Fri Oct 24, 2008 4:52 am
Been thanked: 2 times

Re: GTA IV LZX compression on resource data

Post 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:
Last edited by AnthonyFiveSixTwo on Thu Jun 25, 2009 6:32 pm, edited 1 time in total.
Post Reply