Magic The Gathering CAT

From XentaxWiki
Jump to: navigation, search

Choose archive extension:


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;

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



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"
# .WVL files (Magic: The Gathering)
  If FileHash = 0x00000100 Then
    String FileName += ".WVL"
  Log FileName FileOffs FileSize
  GoTo TOC
Next I

Compatible Programs

Other Games

These games also use this file format

  • Gunship!
  • Magic: The Gathering