Darkstone: Difference between revisions

From XentaxWiki
Jump to navigation Jump to search
imported>WATTO
No edit summary
 
imported>Ikskoks
No edit summary
 
(8 intermediate revisions by 3 users not shown)
Line 19: Line 19:
: byte {1}&nbsp;&nbsp;&nbsp;&nbsp; - null Filename Terminator <br>  
: byte {1}&nbsp;&nbsp;&nbsp;&nbsp; - null Filename Terminator <br>  
: uint32 {4}&nbsp;&nbsp; - Data Offset <br>  
: uint32 {4}&nbsp;&nbsp; - Data Offset <br>  
: uint32 {4}&nbsp;&nbsp; - <font color="red"> '' File Length? '' </font> <br>  
: uint32 {4}&nbsp;&nbsp; - Decompressed File Length <br>  
<br>
<br>
byte {X}&nbsp;&nbsp;&nbsp;&nbsp; - 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}&nbsp;&nbsp;&nbsp;&nbsp; - Magic ID for compressed data <font color="purple">(174 or 175)</font> <br>
: byte {1}&nbsp;&nbsp;&nbsp;&nbsp; - Magic ID for compressed data <font color="purple">(190)</font> <br>
: byte {2}&nbsp;&nbsp;&nbsp;&nbsp; - <font color="red">''Unknown''</font>  <br>
: uint32 {1}&nbsp;&nbsp; - Number of data blocs <br>
: uint32 {1}&nbsp;&nbsp; - <font color="red">''Flags ?''</font> <br>
<br>
byte {X}&nbsp;&nbsp;&nbsp;&nbsp; - 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/>
: &nbsp;&nbsp;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><b>07 0C</b></tt> means X = 3 and Y = 7 <tt>-></tt> <tt><b><font color="green">AA BB CC DD EE FF</font> 99 <font color=red>AA BB CC DD EE FF</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>
 
 
[[Category:File Format]]

Latest revision as of 15:12, 3 January 2021

Choose archive extension:

MTF


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 Length


// 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, 07 0C means X = 3 and Y = 7 -> AA BB CC DD EE FF 99 AA BB CC DD EE FF

MultiEx BMS Script

Not written yet

Compatible Programs