Difference between revisions of "RenderWare"

From GTAMods Wiki
Jump to navigation Jump to search
m (The hero moved page Renderware to RenderWare)
Line 42: Line 42:
 
The content depends on the type and parent chunks.
 
The content depends on the type and parent chunks.
  
  4 byte - RwUInt32 - type
+
  uint32 - type
  4 byte - RwUInt32 - size, including child chunks and/or data
+
  uint32 - size, including child chunks and/or data
  4 byte - RwUInt32 - library ID stamp
+
  uint32 - library ID stamp
  
 
The library ID stamp contains the version and build number of the RW library that wrote the file.
 
The library ID stamp contains the version and build number of the RW library that wrote the file.
Line 56: Line 56:
 
Version <code>0x36003</code> build <code>0xFFFF</code> for instance is encoded as <code>0x1803FFFF</code>.
 
Version <code>0x36003</code> build <code>0xFFFF</code> for instance is encoded as <code>0x1803FFFF</code>.
  
Before version 3.2 Renderware had no build number and the library ID stamp was just <code>0x00000VJN</code> (no <code>0x30000</code> subtracted).
+
Version 3.1.0.0 and before had no binary revision and build number and the library ID stamp was just <code>0x00000VJN</code> (no <code>0x30000</code> subtracted).
 
Version 3.1.0.0 for instance would be encoded as <code>0x00000310</code>.
 
Version 3.1.0.0 for instance would be encoded as <code>0x00000310</code>.
 +
Version 3.1.0.1 (used in some GTA III files, build <code>FFFF</code>) on the other hand is encoded as <code>0x0401FFFF</code>.
 
To find out what version a file has when reading, RW checks the upper 16 bits and assumes the old format when they're zero.
 
To find out what version a file has when reading, RW checks the upper 16 bits and assumes the old format when they're zero.
  
Line 66: Line 67:
 
libraryIDPack(RwUInt32 version, RwUInt32 build)
 
libraryIDPack(RwUInt32 version, RwUInt32 build)
 
{
 
{
if(version < 0x32000)
+
if(version <= 0x31000)
 
return version>>8;
 
return version>>8;
 
return (version-0x30000 & 0x3FF00) << 14 | (version & 0x3F) << 16 |
 
return (version-0x30000 & 0x3FF00) << 14 | (version & 0x3F) << 16 |

Revision as of 05:07, 17 August 2015

Renderware (RW for short) is the graphics engine used by GTA III, Vice City and San Andreas. For general information see [1] and for a list of games using it [2].


Versions

The versions of Renderware the games are linked against are the following:

III Vice City San Andreas
PS2 3.1.0.0 3.3.0.2 3.6.0.3
PC 3.3.0.2 3.4.0.3 3.6.0.3
Xbox 3.5.0.0 3.5.0.0 3.6.0.3
Android 3.4.0.5 3.4.0.5 3.6.0.3

Binary Streams

RW streams are split up into chunks. Each section has a 12 byte header and can either be empty, contain data or more child chunks. The content depends on the type and parent chunks.

uint32 - type
uint32 - size, including child chunks and/or data
uint32 - library ID stamp

The library ID stamp contains the version and build number of the RW library that wrote the file.

The library version is a hexadecimal number and has the form 0xVJNBB where V (3 bits) is the Renderware version, J (4 bits) is the major revision, N (4 bits) is the minor revision and B (6 bits) is the binary revision. Version 3.6.0.3 for instance would be encoded as 0x36003.

The library build is 0xFFFF in all versions used by GTA.

To make the library ID stamp, 0x30000 is subtracted from the version first and then packed as follows (where D is the 16 bit build number):

VVJJ JJNN NNBB BBBB DDDD DDDD DDDD DDDD

Version 0x36003 build 0xFFFF for instance is encoded as 0x1803FFFF.

Version 3.1.0.0 and before had no binary revision and build number and the library ID stamp was just 0x00000VJN (no 0x30000 subtracted). Version 3.1.0.0 for instance would be encoded as 0x00000310. Version 3.1.0.1 (used in some GTA III files, build FFFF) on the other hand is encoded as 0x0401FFFF. To find out what version a file has when reading, RW checks the upper 16 bits and assumes the old format when they're zero.

These C example functions pack and unpack library ID stamps:

RwUInt32
libraryIDPack(RwUInt32 version, RwUInt32 build)
{
	if(version <= 0x31000)
		return version>>8;
	return (version-0x30000 & 0x3FF00) << 14 | (version & 0x3F) << 16 |
	       (build & 0xFFFF);
}

RwUInt32
libraryIDUnpackVersion(RwUInt32 libid)
{
	if(libid & 0xFFFF0000)
		return (libid>>14 & 0x3FF00) + 0x30000 |
		       (libid>>16 & 0x3F);
	return libid<<8;
}

RwUInt32
libraryIDUnpackBuild(RwUInt32 libid)
{
	if(libid & 0xFFFF0000)
		return libid & 0xFFFF;
	return 0;
}

Basic structure

The basic structure of DFF and TXD files is given below. The Extensions are given as empty, their contents depend on the plugins and plugin data of the object they belong to. These are described elsewhere.

DFF

TXD

PS2 TXD

* These chunks can appear multiple times. The count is usually given in the parent's struct.

See RenderWare binary stream file for further information.