Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Alone In The Dark PC analyzation

Read or post about compression. And decompression. Or ask questions how to decompress your files.
Post Reply
OrangeC
double-veteran
double-veteran
Posts: 868
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 41 times

Alone In The Dark PC analyzation

Post by OrangeC »

The contents of this post was deleted because of possible forum rules violation.
qwerty
advanced
Posts: 54
Joined: Tue Mar 30, 2010 11:00 pm
Been thanked: 2 times

Re: Alone In The Dark PC analyzation

Post by qwerty »

.fat format is slightly different from TDU2 .map, but files in .big are compressed in 4096 b chunks, decompressing in bms script is pretty hard (but not impossible). maybe someday...
till then, script to extract compressed streams from fat+big:

Code: Select all

IDString "XMBF"
Open FDDE big 1
Endian little
GetDString DUMMY 12
Get OFFS long
GoTo OFFS
Get NUMHASHES long
Get HASHOFFSET long
Math HASHOFFSET += OFFS
Get NUMFILEREC long
Get FILERECOFFSET long
Math FILERECOFFSET += OFFS
If NUMHASHES != NUMFILEREC
  CleanExit
EndIf
For I = 0 < NUMHASHES
  GoTo HASHOFFSET
  Get HASH2 long
  Get HASH1 long
  String NAME p= "%08X%08X.bin" HASH1 HASH2
  SavePos HASHOFFSET
  GoTo FILERECOFFSET
  Get FILESIZE longlong
  Get DUMMY longlong # compressed size?
  Get DUMMY longlong # uncompressed size?
  Get FILEOFFSET longlong
  SavePos FILERECOFFSET
  Log NAME FILEOFFSET FILESIZE 1
Next I
use it on .fat file
OrangeC
double-veteran
double-veteran
Posts: 868
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 41 times

Re: Alone In The Dark PC analyzation

Post by OrangeC »

THANKS!!!!!
qwerty
advanced
Posts: 54
Joined: Tue Mar 30, 2010 11:00 pm
Been thanked: 2 times

Re: Alone In The Dark PC analyzation

Post by qwerty »

qwerty wrote:maybe someday...
Today is that day :D
The beta version of the script is ready. It unpacks (and decompress) files from the cut you provided. But there are only 5 files there, so now I'm downloading the full game to check if the script will work on it. If it will - I'll post the script. :)
qwerty
advanced
Posts: 54
Joined: Tue Mar 30, 2010 11:00 pm
Been thanked: 2 times

Re: Alone In The Dark PC analyzation

Post by qwerty »

Tested on russian version of the game - extracted 3 full fat+big files, with 1 minor bug fixed in the script :)
So, there is the script:

Code: Select all

IDString "XMBF"
Open FDDE big 1
Endian little
GetDString DUMMY 12
Get OFFS long
GoTo OFFS
Get NUMHASHES long
Get HASHOFFSET long
Math HASHOFFSET += OFFS
Get NUMFILEREC long
Get FILERECOFFSET long
Math FILERECOFFSET += OFFS
If NUMHASHES != NUMFILEREC
  CleanExit
EndIf
For I = 0 < NUMHASHES
  GoTo HASHOFFSET
  Get HASH2 long
  Get HASH1 long
  String NAME p= "%08X%08X.bnk" HASH1 HASH2
  SavePos HASHOFFSET
  GoTo FILERECOFFSET
  Get FILESIZE longlong
  Get DUMMY longlong # compressed size?
  Get DUMMY longlong # uncompressed size?
  Get FILEOFFSET longlong
  SavePos FILERECOFFSET
  #Log NAME FILEOFFSET FILESIZE 1
  CallFunction UnpackFile
Next I

########################
StartFunction UnpackFile
  Endian big
  ComType lzo
  Log MEMORY_FILE FILEOFFSET FILESIZE 1
  GoTo 0x10 MEMORY_FILE
  Get CHUNKSZ long MEMORY_FILE
  Get FATOFFSET long MEMORY_FILE
  Get ZDATAOFFSET long MEMORY_FILE
  Get DUMMY long MEMORY_FILE
  Get DATASIZE longlong MEMORY_FILE
  Get ZDATASIZE longlong MEMORY_FILE
  Get BUFFSIZE long MEMORY_FILE
  Math BUFF = ZDATAOFFSET
  Math BUFF += BUFFSIZE
  Math NUMCHUNKS = ZDATAOFFSET
  Math NUMCHUNKS -= FATOFFSET
  Math NUMCHUNKS /= 4
  Log MEMORY_FILE2 0 0
  PutVarChr MEMORY_FILE2 DATASIZE 0
  Log MEMORY_FILE2 0 0
  Append
  GoTo FATOFFSET MEMORY_FILE
  For J = 0 < NUMCHUNKS
    Get ZCHUNKSZ long MEMORY_FILE
    Math ZDATAOFFSET += ZCHUNKSZ
    If ZDATAOFFSET > BUFF
      Math ZDATAOFFSET -= ZCHUNKSZ
      Math ZDATAOFFSET x= 0x800
      Math BUFF = ZDATAOFFSET
      Math BUFF += BUFFSIZE
    Else
      Math ZDATAOFFSET -= ZCHUNKSZ
    EndIf
    If ZCHUNKSZ == 0
      Break
    ElseIf ZCHUNKSZ < CHUNKSZ
      CLog MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ CHUNKSZ MEMORY_FILE
    Else
      Log MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ MEMORY_FILE
    EndIf
    Math ZCHUNKSZ x= 0x10
    Math ZDATAOFFSET += ZCHUNKSZ
  Next J
  Append
  Log NAME 0 DATASIZE MEMORY_FILE2
  Endian little
EndFunction
########################
You've got a lot of .bnk files in output folder, they can be unpacked using bnk script from tdu2.
To extract them all at once (it's a loooong process) just run

Code: Select all

quickbms.exe -o tdu2_bnk.bms d:\input_folder_with_all_bnks d:\output_folder
Some types of resources are in xmbf databases (with different extensions - xmt, xmm, xmg, xmi and others). I have no idea how to get them. But sounds, scripts and some other are in plain formats.
Last edited by qwerty on Fri Mar 04, 2011 6:21 am, edited 1 time in total.
OrangeC
double-veteran
double-veteran
Posts: 868
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 41 times

Re: Alone In The Dark PC analyzation

Post by OrangeC »

You are my hero :D

will try this out :)
OrangeC
double-veteran
double-veteran
Posts: 868
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 41 times

Re: Alone In The Dark PC analyzation

Post by OrangeC »

The contents of this post was deleted because of possible forum rules violation.
qwerty
advanced
Posts: 54
Joined: Tue Mar 30, 2010 11:00 pm
Been thanked: 2 times

Re: Alone In The Dark PC analyzation

Post by qwerty »

OrangeC wrote:any chance to support x360 version?
Yes! just change the endianess to big :)

Code: Select all

IDString "XMBF"
Open FDDE big 1
Endian big
GetDString DUMMY 12
Get OFFS long
GoTo OFFS
Get NUMHASHES long
Get HASHOFFSET long
Math HASHOFFSET += OFFS
Get NUMFILEREC long
Get FILERECOFFSET long
Math FILERECOFFSET += OFFS
If NUMHASHES != NUMFILEREC
  CleanExit
EndIf
For I = 0 < NUMHASHES
  GoTo HASHOFFSET
  Get HASH2 long
  Get HASH1 long
  String NAME p= "%08X%08X.bnk" HASH2 HASH1
  SavePos HASHOFFSET
  GoTo FILERECOFFSET
  Get FILESIZE longlong
  Get DUMMY longlong # compressed size?
  Get DUMMY longlong # uncompressed size?
  Get FILEOFFSET longlong
  SavePos FILERECOFFSET
  #Log NAME FILEOFFSET FILESIZE 1
  CallFunction UnpackFile
Next I

########################
StartFunction UnpackFile
  #Endian big
  ComType lzo
  Log MEMORY_FILE FILEOFFSET FILESIZE 1
  GoTo 0x10 MEMORY_FILE
  Get CHUNKSZ long MEMORY_FILE
  Get FATOFFSET long MEMORY_FILE
  Get ZDATAOFFSET long MEMORY_FILE
  Get DUMMY long MEMORY_FILE
  Get DATASIZE longlong MEMORY_FILE
  Get ZDATASIZE longlong MEMORY_FILE
  Get BUFFSIZE long MEMORY_FILE
  Math BUFF = ZDATAOFFSET
  Math BUFF += BUFFSIZE
  Math NUMCHUNKS = ZDATAOFFSET
  Math NUMCHUNKS -= FATOFFSET
  Math NUMCHUNKS /= 4
  Log MEMORY_FILE2 0 0
  PutVarChr MEMORY_FILE2 DATASIZE 0
  Log MEMORY_FILE2 0 0
  Append
  GoTo FATOFFSET MEMORY_FILE
  For J = 0 < NUMCHUNKS
    Get ZCHUNKSZ long MEMORY_FILE
    Math ZDATAOFFSET += ZCHUNKSZ
    If ZDATAOFFSET > BUFF
      Math ZDATAOFFSET -= ZCHUNKSZ
      Math ZDATAOFFSET x= 0x800
      Math BUFF = ZDATAOFFSET
      Math BUFF += BUFFSIZE
    Else
      Math ZDATAOFFSET -= ZCHUNKSZ
    EndIf
    If ZCHUNKSZ == 0
      Break
    ElseIf ZCHUNKSZ < CHUNKSZ
      CLog MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ CHUNKSZ MEMORY_FILE
    Else
      Log MEMORY_FILE2 ZDATAOFFSET ZCHUNKSZ MEMORY_FILE
    EndIf
    Math ZCHUNKSZ x= 0x10
    Math ZDATAOFFSET += ZCHUNKSZ
  Next J
  Append
  Log NAME 0 DATASIZE MEMORY_FILE2
  #Endian little
EndFunction
########################
but xbox bnks are different too (maybe just endianess, like in .fat, maybe not), so tdu2_bnk script won't work. :(

UPDATE: Yes, it's just big endian, so I modified tdu2_bnk script. All 3 scripts are in attachment: two scripts for PC and X360 versions of big+fat, and one universal bnk script for both platforms :)
You do not have the required permissions to view the files attached to this post.
OrangeC
double-veteran
double-veteran
Posts: 868
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 41 times

Re: Alone In The Dark PC analyzation

Post by OrangeC »

Once again you saved!! :D

thanks!!
User avatar
NewHewkas
ultra-n00b
Posts: 1
Joined: Sat Jun 18, 2011 5:11 pm
Has thanked: 1 time

Re: Alone In The Dark PC analyzation

Post by NewHewkas »

Hi!

I'm new here, so i hope this is the right topic to ask.

I used your script on AITD 5's big files to .bnks then i extract them with the tdu2's script. Now, i have the files what i would like to have (the language files .lng), but how can I find the fonts, in which file(s)?

Can you help me, please?
chronicle
ultra-n00b
Posts: 2
Joined: Thu May 17, 2012 3:24 am

Re: Alone In The Dark PC analyzation

Post by chronicle »

Can anyone help with script for .bnk files after when extracted .big files?
I tryed this code

Code: Select all

Set FULLNAME string ""
Set NAME string ""
Log MEMORY_FILE 0 0
PutVarChr MEMORY_FILE 0 4 long
GetDString DUMMY 8
GetDString ID 4
If ID != "KNAB"
  CleanExit
EndIf
GoTo 0x28
Get NUMFILES long
Get DUMMY long
Get FATOFFSET long
Math FATOFFSET += 8
Get DUMMY long
Get NAMESOFFSET long
Math NAMESOFFSET += 8
Get FILESORDER long
Math FILESORDER += 8
PutVarChr MEMORY_FILE 0 FILESORDER long
GoTo NAMESOFFSET
If NUMFILES != 0
  CallFunction Parser
EndIf

StartFunction Parser
  Get NAMESZ byte
  If NAMESZ > 0x7F
    String FULLNAME += NAME
    String FULLNAME += \
    Get FOLDERS byte
   If FOLDERS > 0x7F
     Get TMP byte
     Math TMP < 7
     Math FOLDERS & 0x0000007F
     Math FOLDERS | TMP
#     Print %FOLDERS%
   EndIf
    Math NAMESZ ^= 0xFF
    Math NAMESZ += 1
    GetDString NAME NAMESZ
    For I = 0 < FOLDERS
      CallFunction Parser
    Next I
  Else
    GetDString BASENAME NAMESZ
    String FULLNAME += BASENAME
    String FULLNAME += NAME
#   Print %FULLNAME%
   SavePos NAMESOFFSET
   GetVarChr FILESORDER MEMORY_FILE 0 long
   GoTo FILESORDER
   If NUMFILES > 0x100
     Get FILENUMBER word
   Else
     Get FILENUMBER byte
   EndIf
   SavePos FILESORDER
   PutVarChr MEMORY_FILE 0 FILESORDER long
   Math FILENUMBER *= 0x14
   Math FATOFFSET += FILENUMBER
   GoTo FATOFFSET
   Get OFFSET long
   Get SIZE long
   GetDString DUMMY 12
    Log FULLNAME OFFSET SIZE
   GoTo NAMESOFFSET
  EndIf
EndFunction Parser
but when I use it quickbms write me 0 files found
michalss
Moderator
Posts: 954
Joined: Sun Mar 27, 2011 8:42 pm
Has thanked: 10 times
Been thanked: 161 times

Re: Alone In The Dark PC analyzation

Post by michalss »

NewHewkas wrote:Hi!

I'm new here, so i hope this is the right topic to ask.

I used your script on AITD 5's big files to .bnks then i extract them with the tdu2's script. Now, i have the files what i would like to have (the language files .lng), but how can I find the fonts, in which file(s)?

Can you help me, please?
yeah i would like to know this as well? :)
Quick BMS Editor GUI - simple easy to use
Goto : viewtopic.php?uid=34229&f=29&t=6797&start=0

Downloads from DropBox : https://dl.dropboxusercontent.com/u/
Post Reply