Magic The Gathering CAT: Difference between revisions
Jump to navigation
Jump to search
imported>Mr.Mouse |
imported>Ikskoks m (Ikskoks moved page Magic The Gathering to Magic The Gathering CAT) |
||
| (11 intermediate revisions by 4 users not shown) | |||
| Line 11: | Line 11: | ||
=== Format Specifications === | === Format Specifications === | ||
{{GRAFPageFormat|1= | |||
uint32 {4} | {{BlockDescription| // Archive Header }} | ||
: uint32 {4} - Number Of Files | |||
: {{BlockDescription| // for each file}} | |||
: uint32 {4} | :: uint32 {4} - File Hash | ||
: uint32 {4} | :: uint32 {4} - File Offset | ||
: uint32 {4} - | :: 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: | |||
<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 === | ||
| Line 34: | Line 62: | ||
Next T ; | Next T ; | ||
</pre> | </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 === | ||
| Line 39: | Line 93: | ||
* [[Game Extractor|Game Extractor]] | * [[Game Extractor|Game Extractor]] | ||
* [[MultiEx_Commander|MultiEx Commander]] | * [[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! | ||
* | * Magic: The Gathering | ||
[[Category:File Format]] | |||
Latest revision as of 13:58, 10 January 2021
Choose archive extension:
CAT
- Format Type : Archive
- Endian Order : Little Endian
Format Specifications
// Archive Header
- uint32 {4} - Number Of Files
- // for each file
- uint32 {4} - File Hash
- uint32 {4} - File Offset
- uint32 {4} - File Length
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
- Game Extractor
- MultiEx Commander
- Magic: The Gathering image decoding tools (with Delphi source codes)
Other Games
These games also use this file format
- Gunship!
- Magic: The Gathering