Rollcage 2 IMG: Difference between revisions

From XentaxWiki
Jump to navigation Jump to search
(→‎Format Specifications: Readability + bugfix (2^13 not 2^14))
Line 23: Line 23:
Compressed Data:
Compressed Data:
: uint32 {4}   - 'ControlBits'  
: uint32 {4}   - 'ControlBits'  
: char {X}     - Compressed Data
: char {X}     - Data Segment
: uint32 {4}   - 'ControlBits'
: uint32 {4}   - 'ControlBits'
: char {X}     - Compressed Data
: char {X}     - Data Segment
: ..
: ..


: The ControlBits say how to decompress the data.
 
:: If the Bit is 0 then the next Byte is not compressed, and copied directly from the Input buffer
* ControlBits occur in the Input Stream whenever the algorithm requires another Bit, not when the last Bit in the ControlBits has been read.
:: If the Bit is 1 then the next Bytes are compressed. The next ControlBit shows how it is compressed.
* Uncompressed Data is read verbatim from a Data Segment in the Input Stream, and placed in the Output Stream.
::: The Next Bit is 0:
* The Data Compression method is to copy previously decompressed bytes in the Output Buffer, to the Output Stream.
:::: The decompressor reads the next Byte from the Input buffer.
** This is always in the form of a negative Offset + Copy Count.
:::: This Byte-256 tells the decompressor how many bytes to go back in the Output buffer.
 
:::: From that position the decompressor copies 2 bytes to the end of the already decompressed Data.
 
:::: If the next ControlBit is 1 the decompressor copies 2 additional Bytes.
: The ControlBits are parsed starting with the least significant bit.
:::: If the next ControlBit is 1 the decompressor copies 1 additional Byte.
:: If the Bit is 0 then the next Byte is not compressed, and copied directly from the Input Stream
::: The Next Bit is 1:
:: If the Bit is 1 then the next Bytes are compressed.
:::: The decompressor reads the two next Bytes from the Input buffer.
::: The next ControlBit shows how to derive the Offset and Copy Count.
:::: The first three bits of theese is the number of bytes to copy-2.
::: If the Next Bit is 0:
:::: The remaining 13 bits-8192 tells the decompressor how many bytes to go back in the Output buffer.
:::: Read the next Byte from the Input Stream.
:::: If the number of bytes to copy is 0, the decompressor reads also the next byte from the Input buffer.
:::: This Byte-256 is the Offset.
::::: The first bit of this byte indicates that another 8192 should be deducated from the position from where the bytes have to be copied.
:::: From that position copy 2 bytes to the end of the already decompressed Data.
::::: The rest is the number of bytes to copy-2. If this is again 0, the decompressor have to read the next 2 bytes, which is the exact number of bytes to copy.
:::: If the next ControlBit is 1 copy 2 additional Bytes.
:::: If the next ControlBit is 1 copy 1 additional Byte.
::: If the Next Bit is 1:
:::: Read the next two Bytes from the Input Stream.
:::: The first three bits is the Copy Count-2.
:::: The remaining 13 bits-8192 is the Offset.
:::: If the Copy Count is 0, read the next Byte from the Input Stream.
::::: The most significant bit of this Byte (&128) indicates whether another 8192 should be deducted from the Offset
::::: The rest (&127) is the Copy Count-2.
::::: If this is again 0, read the next 2 Bytes, for the exact Copy Count.


Example:
Example:

Revision as of 15:54, 26 April 2012

Back to index | Edit this page

IMG + IDX

Format Specifications

// IDX FILE
// for each file
uint32 {4}   - File Offset
uint32 {4}   - Compressed File Length
uint32 {4}   - Decompressed File Length
uint32 {4}   - Unused

// IMG FILE

// for each file
char {4}     - File Header (GT20)
uint32 {4}   - Decompressed File Length
uint32 {4}   - Unused (Same as the Unused field in the IDX File)
uint32 {4}   - Length of additional Information
char {X}     - Additional Information
byte {X}     - Compressed Data

Compressed Data:

uint32 {4}   - 'ControlBits'
char {X}     - Data Segment
uint32 {4}   - 'ControlBits'
char {X}     - Data Segment
..


  • ControlBits occur in the Input Stream whenever the algorithm requires another Bit, not when the last Bit in the ControlBits has been read.
  • Uncompressed Data is read verbatim from a Data Segment in the Input Stream, and placed in the Output Stream.
  • The Data Compression method is to copy previously decompressed bytes in the Output Buffer, to the Output Stream.
    • This is always in the form of a negative Offset + Copy Count.


The ControlBits are parsed starting with the least significant bit.
If the Bit is 0 then the next Byte is not compressed, and copied directly from the Input Stream
If the Bit is 1 then the next Bytes are compressed.
The next ControlBit shows how to derive the Offset and Copy Count.
If the Next Bit is 0:
Read the next Byte from the Input Stream.
This Byte-256 is the Offset.
From that position copy 2 bytes to the end of the already decompressed Data.
If the next ControlBit is 1 copy 2 additional Bytes.
If the next ControlBit is 1 copy 1 additional Byte.
If the Next Bit is 1:
Read the next two Bytes from the Input Stream.
The first three bits is the Copy Count-2.
The remaining 13 bits-8192 is the Offset.
If the Copy Count is 0, read the next Byte from the Input Stream.
The most significant bit of this Byte (&128) indicates whether another 8192 should be deducted from the Offset
The rest (&127) is the Copy Count-2.
If this is again 0, read the next 2 Bytes, for the exact Copy Count.
Example:

MultiEx BMS

Not written yet

Notes and Comments

  • The *.IDX file contains the directory, the *.IMG file contains the data

Supported Programs

Navigation

Jump to a listing by...
All Formats - Common Formats - Standard Formats - Malformed Pages
Platforms
Microsoft:
Xbox
Xbox 360
Nintendo:
GameCube
DS
Desktop:
PC
Sega:
Dreamcast
Sony:
PlayStation
PlayStation 2
PlayStation 3
PlayStation Portable
Type
Animation - Archive - Audio - Image - Mesh - Miscellaneous - Model - Video
Endianness
Little-endian - Big-endian
BMS Scripts
Pages Without a BMS Script

All Pages with Scripts:
Recently Added Scripts

Program Support
No Known Support

MultiEx Commander - Game Extractor

Format Specification Completion
Work in Progress - Almost Done - Completed
Compression and Encryption
No Compression or Encryption Used - Unknown Compression or Encryption Used

One or Both Used:
Compression Used - Both Compression and Encryption Used