Difference between revisions of "Magic The Gathering"

From XentaxWiki
Jump to: navigation, search
 
(Notes and Comments: cleanup code)
 
(5 intermediate revisions by 3 users not shown)
Line 11: Line 11:
 
=== Format Specifications ===  
 
=== Format Specifications ===  
  
<tt><b>
+
{{GRAFPageFormat|1=
uint32 {4}&nbsp;&nbsp; - Number Of Files <br>
+
{{BlockDescription| // Archive Header }}
<br>
+
: uint32 {4} &nbsp; - Number Of Files
<font color="blue"> ''' // for each file ''' </font> <br>
+
: {{BlockDescription| // for each file}}
: uint32 {4}&nbsp;&nbsp; - <font color="red"> '' Unknown '' </font> <br>
+
:: uint32 {4} &nbsp; - File Hash
: uint32 {4}&nbsp;&nbsp; - Offset <br>
+
:: uint32 {4} &nbsp; - File Offset
: uint32 {4}&nbsp;&nbsp; - Size <br>  
+
:: uint32 {4} &nbsp; - File Length
<br>
+
 
</b></tt>
+
byte {X} &nbsp;&nbsp;&nbsp; - File Data}}
 +
 
 +
=== Notes and Comments ===
 +
 
 +
* The files in the directory are NOT in the same order as the files in the archive. ie. file 1 in the directory may actually be file 3827 in the archive, etc. Actually, all records sorted in ascending order of File Hash value.
 +
 
 +
* Hash routine in C++ code for Magic: The Gathering:
 +
<pre>unsigned int mtg_hash(char *s) {
 +
unsigned int i, hash, part[2];
 +
  hash = (s[0] ^ s[1]) << 24;
 +
  part[0] = 0;
 +
  part[1] = 0;
 +
  for (i = 0; i < strlen(s); i++) {
 +
    part[i&1] += tolower(s[i]) * (i + 3);
 +
  }
 +
  hash |= (part[0] * part[1]) & 0xffffff;
 +
  return(hash);
 +
}</pre>
 +
Note that names inside CAT from MtG can be brute forced by template:
 +
 
 +
yyyyz.wvl
 +
 
 +
where:
 +
 
 +
yyyy - number from 0000 till 9999
 +
 
 +
z - one of the character from list: 'abcdeftx'
 +
 
 +
This last character (z) may or may not exists, so first you should try all names from '0000.wvl' till '9999.wvl' and only if none of them match try '0000a.wvl' - '9999a.wvl', '0000b.wvl' - '9999b.wvl' and so on.
  
 
=== MultiEx BMS Script ===  
 
=== MultiEx BMS Script ===  
  
Not written yet<br><br>
+
<pre>ImpType Standard ;
 +
Get FN Long 0 ;
 +
For T = 1 To FN ;
 +
Get FID Long 0 ;
 +
SavePos FOO 0 ;
 +
Get FO Long 0 ;
 +
SavePos FSO 0 ;
 +
Get FS Long 0 ;
 +
Log "" FO FS FOO FSO ;
 +
Next T ;
 +
</pre>
 +
 
 +
Extended version:
 +
 
 +
<pre># QucikBMS script for unpacking .CAT files
 +
ImpType Standard
 +
Get FileCount Long
 +
For I = 1 To FileCount
 +
  Get FileHash Long
 +
  Get FileOffs Long
 +
  Get FileSize Long
 +
  SavePos TOC
 +
  String FileName p= "%08X" FileHash
 +
# read signature
 +
  GoTo FileOffs
 +
  Get FileHash Long
 +
# .PCX files (Gunship!)
 +
  If FileHash = 0x0801050A Then
 +
    String FileName += ".PCX"
 +
  EndIf
 +
# .WVL files (Magic: The Gathering)
 +
  If FileHash = 0x00000100 Then
 +
    String FileName += ".WVL"
 +
  EndIf
 +
  Log FileName FileOffs FileSize
 +
  GoTo TOC
 +
Next I</pre>
  
 
=== Compatible Programs ===  
 
=== Compatible Programs ===  
  
* [[Game Extractor|Game Extractor]]<br><br>
+
* [[Game Extractor|Game Extractor]]
 +
* [[MultiEx_Commander|MultiEx Commander]]
 +
* [http://www.ctpax-x.org/?goto=files&show=109 Magic: The Gathering image decoding tools] (with Delphi source codes)
  
 
=== Other Games ===  
 
=== Other Games ===  
  
 
These games also use this file format<br>
 
These games also use this file format<br>
* [[Gunship|Gunship!]]
+
* Gunship!
* [[Magic The Gathering| Magic: The Gathering]]
+
* Magic: The Gathering

Latest revision as of 06:13, 26 June 2014

Choose archive extension:

CAT


Format Specifications

// Archive Header
uint32 {4}   - Number Of Files
// for each file
uint32 {4}   - File Hash
uint32 {4}   - File Offset
uint32 {4}   - File Length
byte {X}     - File Data

Notes and Comments

  • The files in the directory are NOT in the same order as the files in the archive. ie. file 1 in the directory may actually be file 3827 in the archive, etc. Actually, all records sorted in ascending order of File Hash value.
  • Hash routine in C++ code for Magic: The Gathering:
unsigned int mtg_hash(char *s) {
unsigned int i, hash, part[2];
  hash = (s[0] ^ s[1]) << 24;
  part[0] = 0;
  part[1] = 0;
  for (i = 0; i < strlen(s); i++) {
    part[i&1] += tolower(s[i]) * (i + 3);
  }
  hash |= (part[0] * part[1]) & 0xffffff;
  return(hash);
}

Note that names inside CAT from MtG can be brute forced by template:

yyyyz.wvl

where:

yyyy - number from 0000 till 9999

z - one of the character from list: 'abcdeftx'

This last character (z) may or may not exists, so first you should try all names from '0000.wvl' till '9999.wvl' and only if none of them match try '0000a.wvl' - '9999a.wvl', '0000b.wvl' - '9999b.wvl' and so on.

MultiEx BMS Script

ImpType Standard ;
Get FN Long 0 ;
For T = 1 To FN ;
Get FID Long 0 ;
SavePos FOO 0 ;
Get FO Long 0 ;
SavePos FSO 0 ;
Get FS Long 0 ;
Log "" FO FS FOO FSO ;
Next T ;

Extended version:

# QucikBMS script for unpacking .CAT files
ImpType Standard
Get FileCount Long
For I = 1 To FileCount
  Get FileHash Long
  Get FileOffs Long
  Get FileSize Long
  SavePos TOC
  String FileName p= "%08X" FileHash
# read signature
  GoTo FileOffs
  Get FileHash Long
# .PCX files (Gunship!)
  If FileHash = 0x0801050A Then
    String FileName += ".PCX"
  EndIf
# .WVL files (Magic: The Gathering)
  If FileHash = 0x00000100 Then
    String FileName += ".WVL"
  EndIf
  Log FileName FileOffs FileSize
  GoTo TOC
Next I

Compatible Programs

Other Games

These games also use this file format

  • Gunship!
  • Magic: The Gathering