Darkstone: Difference between revisions
imported>WATTO No edit summary |
imported>Elbereth (Completed specification with compression information) |
||
| Line 19: | Line 19: | ||
: byte {1} - null Filename Terminator <br> | : byte {1} - null Filename Terminator <br> | ||
: uint32 {4} - Data Offset <br> | : uint32 {4} - Data Offset <br> | ||
: uint32 {4} - | : uint32 {4} - Decompressed File <br> | ||
<br> | <br> | ||
byte {X} - File Data <br> | <font color="blue"> ''' // Data can be compressed ''' </font> <br> | ||
<font color="blue"> ''' // If compressed the start of the data contains a 12 bytes header: ''' </font> <br> | |||
<br> | |||
: byte {1} - Magic ID for compressed data <font color="purple">(174 or 175)</font> <br> | |||
: byte {1} - Magic ID for compressed data <font color="purple">(190)</font> <br> | |||
: byte {2} - <font color="red">''Unknown''</font> <br> | |||
: uint32 {1} - Number of data blocs <br> | |||
: uint32 {1} - <font color="red">''Flags ?''</font> <br> | |||
<br> | |||
byte {X} - File Data (compressed or not) <br> | |||
<br> | <br> | ||
</b></tt> | </b></tt> | ||
=== Decompression Pseudo-Code === | |||
''Decompression code based on information by '''Guy Ratajczak''' ''<br/><br/> | |||
First byte of each chunk describes what to do with next data you read.<br/> | |||
You need to check every bit:<br/> | |||
: If bit=1 then just copy 1 byte from compressed buffer to decompressed buffer<br/> | |||
: If bit=0 then read 10 bits for X and 6 bits for Y<br/> | |||
: copy X+3 bytes from offset Y of decompressed buffer at the end of decompressed buffer<br/> | |||
This is repeated until decompressed buffer reach the <tt><b>Decompressed File Length</b></tt> in MTF header.<br/> | |||
Example:<br/> | |||
Source data: <tt><b>7F AA BB CC DD EE FF 99 07 0C ...</b></tt> | |||
Decompressed data:<br/> | |||
Step 1: Bit 0 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA</b></tt><br/> | |||
Step 2: Bit 1 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA BB</b></tt><br/> | |||
Step 3: Bit 2 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA BB CC</b></tt><br/> | |||
Step 4: Bit 3 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA BB CC DD</b></tt><br/> | |||
Step 5: Bit 4 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA BB CC DD EE</b></tt><br/> | |||
Step 6: Bit 5 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA BB CC DD EE FF</b></tt><br/> | |||
Step 7: Bit 6 of <tt><b>7F</b></tt> is 1 <tt>-></tt> <tt><b>AA BB CC DD EE FF 99</b></tt><br/> | |||
Step 8: Bit 7 of <tt><b>7F</b></tt> is 0 <tt>-></tt> <tt><b><font color="green">AA BB CC</font> DD EE FF 99 <font color=red>AA BB CC</font></b></tt><br/><br/> | |||
=== MultiEx BMS Script === | === MultiEx BMS Script === | ||
| Line 31: | Line 64: | ||
=== Compatible Programs === | === Compatible Programs === | ||
* [[Game Extractor|Game Extractor]]<br> | * [[Game Extractor|Game Extractor]] | ||
* [[Dragon_Unpacker|Dragon UnPACKer]]<br> | |||
Revision as of 11:59, 20 May 2005
Choose archive extension:
MTF
- Format Type : Archive
- Endian Order : Little Endian
Format Specifications
uint32 {4} - Number Of Files
// for each file
- uint32 {4} - Filename Length (not including null)
- char {X} - Filename
- byte {1} - null Filename Terminator
- uint32 {4} - Data Offset
- uint32 {4} - Decompressed File
// Data can be compressed
// If compressed the start of the data contains a 12 bytes header:
- byte {1} - Magic ID for compressed data (174 or 175)
- byte {1} - Magic ID for compressed data (190)
- byte {2} - Unknown
- uint32 {1} - Number of data blocs
- uint32 {1} - Flags ?
byte {X} - File Data (compressed or not)
Decompression Pseudo-Code
Decompression code based on information by Guy Ratajczak
First byte of each chunk describes what to do with next data you read.
You need to check every bit:
- If bit=1 then just copy 1 byte from compressed buffer to decompressed buffer
- If bit=0 then read 10 bits for X and 6 bits for Y
- copy X+3 bytes from offset Y of decompressed buffer at the end of decompressed buffer
This is repeated until decompressed buffer reach the Decompressed File Length in MTF header.
Example:
Source data: 7F AA BB CC DD EE FF 99 07 0C ...
Decompressed data:
Step 1: Bit 0 of 7F is 1 -> AA
Step 2: Bit 1 of 7F is 1 -> AA BB
Step 3: Bit 2 of 7F is 1 -> AA BB CC
Step 4: Bit 3 of 7F is 1 -> AA BB CC DD
Step 5: Bit 4 of 7F is 1 -> AA BB CC DD EE
Step 6: Bit 5 of 7F is 1 -> AA BB CC DD EE FF
Step 7: Bit 6 of 7F is 1 -> AA BB CC DD EE FF 99
Step 8: Bit 7 of 7F is 0 -> AA BB CC DD EE FF 99 AA BB CC
MultiEx BMS Script
Not written yet