Secret Files: Tunguska (Demo) SPR

From XentaxWiki
Revision as of 20:47, 6 August 2007 by DenizOezmen (talk | contribs) (added format description)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to index | Edit this page

SPR

Format Specifications

char {4}     - ID (SPCD)

uint32 {4}   - Unknown
uint32 {4}   - Unknown
uint32 {4}   - Decryption key seed
uint32 {4}   - Unknown
uint32 {4}   - Unknown
uint32 {4}   - Number of strings
uint32 {4}   - String table offset
uint32 {4}   - String table size
uint32 {4}   - Number of files
uint32 {4}   - File table offset
uint32 {4}   - File table size
uint32 {4}   - Unknown
uint32 {4}   - Number of directories
uint32 {4}   - Directory table offset
uint32 {4}   - Directory table size
byte {x}     - File data
// string table data (encrypted)

// for each string
uint16 {2}   - String length
// for each string
char {x}     - String data

// directory table data (encrypted)

// for each directory
uint32 {4}   - Directory name (index into string table)
uint32 {4}   - Parent directory (index into directory table, 0x1effffff for root)

// file table data (encrypted)

// for each file
uint32 {4}   - Parent directory (index into directory table)
uint32 {4}   - Name prefix (index into string table)
uint32 {4}   - Name suffix (index into string table)
uint32 {4}   - CRC32 of uncompressed data
// file date (as Windows _SYSTEMTIME type)
uint16 {2}   - Year
uint16 {2}   - Month
uint16 {2}   - Day of week
uint16 {2}   - Day
uint16 {2}   - Hour
uint16 {2}   - Minute
uint16 {2}   - Second
uint16 {2}   - Millisecond
uint32 {4}   - Size of uncompressed data
uint32 {4}   - Compression header offset (0xffffffff if file uncompressed)
uint32 {4}   - Compression header size (0 if file uncompressed)
uint32 {4}   - File data offset
uint32 {4}   - File data size

Notes and Comments

Table decryption

Each of the three structure tables has been xor-encrypted. The decryption depends on the seed value given in the header as well as a partly fixed key domain value. The decryption key will change for each byte in the buffer (depending on the previously seen bytes), as shown in this pseudo code:


KeyDomain := 0xbebe2 * Seed;
Key := ((Seed shl 8) or ((not Seed) and 0xff));

for i := 0 to Length(Data) - 1 do
begin

Key := (Key * Key) mod KeyDomain;
Buffer[i] := Buffer[i] xor (Key and 0xff);
Key := Key + Buffer[i] + 1;

end;

Data decompression

In cases of compressed file data, the compression header offset and size values will be set to appropriate values. Note that the data offset value will then point to the compressed data block, which is prepended by a uint32 containing the uncompressed size. (This size value is not present if the data is not compressed.) The compression header itself might look different for various compression techniques, but only one is known to be used in the game.

SLZX

The compression header of the SLZX method is constructed by a four-char identifier (SLZX) followed by a uint32 value storing the uncompressed data size. (Please note that this results in three distinct places where the uncompressed size can be found: The file table entry, the SLZX compression header and the beginning of the compressed data block.)

The compression technique itself is a variant of the common LZSS in the following sense:

  • The interpretation of the bit flags is reversed (0 indicates a literal copy, while 1 indicates a buffer reference).
  • An offset/length pair is given by a little-endian uint16 value. The uppermost five bits store the length, while the lower 11 bits contain the offset value. After each such offset/length pair there follows exactly one additional literal character.
  • The history buffer (2048 bytes in size) is not circular, but slides along the output. All offsets are absolute buffer references. (Please note that the buffer "window" only starts sliding forward as soon as 2048 bytes of data have been output.)

MultiEx BMS Script

None written yet.

Supported by Programs

Links

None

Games

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