Quantcast

Jump to content

» «
Photo

[Q] RSC File headers

3 replies to this topic
REspawn
  • REspawn

    REgent

  • Members
  • Joined: 06 Jul 2002
  • None

#1

Posted 31 December 2008 - 05:54 PM

So the RSC files hold compressed data, there is a 12 byte header followed by compressed data.
Texture archives are an example of RSC files (Type 8).
CODE

4 bytes - Magic number
4 bytes - Type
4 bytes - Flags


The flags value hold the segment sizes, these can be obtained with the following code by listner...
CODE

uint systemSegSize = (flags & 0x7FF) << (((flags >> 11) & 0xF) + 8);
uint gpuSegSize = ((flags >> 15) & 0x7FF) << (((flags >> 26) & 0xF) + 8);


But the problem is recreating the flags value from the systemSegSize and the gpuSegSize, can anyone help with this?
We need to be able to take the systemSegSize and the gpuSegSize and create the flags value from them.
Here are some sample values....
QUOTE

hud.wtd
† flags 3558574104 unsigned int
† systemSegSize 12288 unsigned int
† gpuSegSize 450560 unsigned int

cashmachine.wtd
† flags 3490185232 unsigned int
† systemSegSize 4096 unsigned int
† gpuSegSize 65536 unsigned int

network.wtd
† flags 3557656592 unsigned int
† systemSegSize 8192 unsigned int
† gpuSegSize 221184 unsigned int

loadingscreens.wtd
† flags 3834806288 unsigned int
† systemSegSize 4096 unsigned int
† gpuSegSize 38404096 unsigned int

water.wtd
† flags 3490185232 unsigned int
† systemSegSize 4096 unsigned int
† gpuSegSize 65536 unsigned int

weblctnews_0.wtd
† flags 3557556240 unsigned int
† systemSegSize 4096 unsigned int
† gpuSegSize 196608 unsigned int

radio_hud.wtd
† flags 3558737936 unsigned int
† systemSegSize 8192 unsigned int
† gpuSegSize 491520 unsigned int

steve-m
  • steve-m

  • Feroci
  • Joined: 26 Jul 2002

#2

Posted 31 December 2008 - 09:32 PM

Here is some Delphi/Pascal code to convert those two sizes into the flag value:

CODE
function getCompactSize(size: longword): word;
var
 i: word;
begin
 // sizes must be multiples of 256!
 Assert(size mod 256 = 0);
 size := size shr 8;

 i := 0;
 while (size mod 2 = 0) and (size >= 32) and (i < 15) do begin
   i := i + 1;
   size := size shr 1;
 end;

 result := ((i and $F) shl 11) or (size and $7FF);
end;

function getFlags(sysSegSize, gpuSegSize: longword): longword;
begin
 result := (getCompactSize(sysSegSize) and $7FFF)
        or (getCompactSize(gpuSegSize) and $7FFF) shl 15
        or 3 shl 30;
end;


For the more than 100 files which I tested this on, only about 60% of the calculated flags are identical (see test cases). But since they are technically correct, i.e. encode the same sizes, just with different multipliers, they might still work. REspawn tested this for radio_hud.wtd and the game didn't crash...

gtaps2modder
  • gtaps2modder

    Crackhead

  • Members
  • Joined: 13 Feb 2009

#3

Posted 11 March 2009 - 01:29 PM

Do you know Xbox360 RSC compression type?

Dageron RUS
  • Dageron RUS

  • Members
  • Joined: 28 Apr 2009
  • Belarus

#4

Posted 18 May 2009 - 01:21 PM Edited by |Dageron|, 18 May 2009 - 01:37 PM.

Hello smile.gif

I am working on yet another tool to deal with RSC data. Much more useful than aru`s Resoursaur, but still WIP...
user posted image

I took procedure of flag re-calculating from steve-m post, so you can re-calculate it in my tool, or enter flags yourself, or dont touch it. smile.gif

And also, does somerbody know how to work with LZX compression? I found only a little info in SparkIV sources. Main code had been removed.

(I know "some X360 reasons" why you, gtaF tool developers, dont want to share this knowledge, but anyway, I ask for help or problem explanation...)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users