My QuickBMS scripts [AlphaTwentyThree]

Do you know a tool, link or website for working on a specific game files or to help game research? Let's collect them here!
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Hello everybody,

it's time to get my QuickBMS scripts out there. As many of you might know, a large collection of scripts can be found on XeNTaX but to be honest, I like it better here. :D
I'll post single scripts in single posts as attachments and keep a list in the first post here. I hope this will get some Google results. ;) Have fun.

Greetings, AlphaTwentyThree

Script list

Code: Select all

Common archives
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p68443 - 998 Studios - *.cat, *.kgb, *.v2k (music archives only)
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72212#p72212 - Curve Studios Limited - *.pak
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35698 - Electronic Arts (console) - *.mus extractor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69164#p69164 - Electronic Arts - *.sdh/*.sdt pairs
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72049#p72049 - Tt Fusion Ltd. - *.fmv audio extractor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68789#p68789 - Wii games - *.bin decompressor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35700 - Wwise sound engine - AKPK ident + bnk/txt - extractor/parser
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68466#p68466 - Xbox sound archives - *.xwb - extractor/converter


Stream processing
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p68463 - Electronic Arts (console) - *.mpc/*.mad/*.vp6 demultiplexer
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35701 - Gamecube VID movies - audio extractor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72055#p72055 - Gust Co. - gdv.dat/*.gvd
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68812#p68812 - Humongous Entertainment Inc. - add wave header
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69359#p68692 - channel-split ss2 mono to single stereo file
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68684#p68684 - *.ss2 re-interleave (PS2 ADPCM)
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72090#p72090 - wave format scanner (RIFF/RIFX)


PC
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35628 - Broken Sword: Secrets of the Ark (PC) - *.pak
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69388#p69388 - Elder Scrolls III, The: Morrowind (PC) - *.bsa
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69164#p69164 - Harry Potter and the Half-Blood Prince - *.sdh/*.sdt pairs

GC
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35823 - Army Men: Sarge's War (GC) - *.sti/*.stm
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35696 - Call of Duty: Big Red One (PS2, GC, Xbox) -  *.gcv, *.psv, *.xbv audio extractor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69359#p69359 - Lemony Snicket's A Series of Unfortunate Events (GC, PS2, Xbox) - streams.res

PS
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p68446 - Oddworld: Abe's Oddysee (PSX) - *.lvl

PS2
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35789 - Army Men: Sarge's War (PS2) -  *.msh/*.msb
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35696 - Call of Duty: Big Red One (PS2, GC, Xbox) -  *.gcv, *.psv, *.xbv audio extractor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69359#p69359 - Lemony Snicket's A Series of Unfortunate Events (GC, PS2, Xbox) - streams.res
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68543#p68543 - The Punisher (PS2) - *.peg
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68539#p68539 - The Punisher (PS2) - *.vpp

PS3
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68610#p68610 - Godfather II, The (PS3/X360) - *.viv
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69164#p69164 - Harry Potter and the Half-Blood Prince - *.sdh/*.sdt pairs

PSP
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72102#p72102 - Adventures to Go! (PSP) - data.dat
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72103#p72103 - After Burner: Black Falcon (PSP) - *.bag
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72136#p72136 - Arthur and the Invisibles (PSP) - *.kpp
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72139#p72139 - Asterix & Obelix XXL 2: Mission Wifix (PSP) - *.pak
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72012#p72012 - Astonishia Story 2/Crimson Gem Saga (PSP) - asto2.dat
https://zenhax.com/viewtopic.php?f=17&&t=7982p=72045#p72045 - Astonishia Story 2/Crimson Gem Saga (PSP) - *.evp/*.bvp
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72178#p72178 - Astro Boy: The Video Game (PSP) - FILE1/FILE2/FILE3
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72165#p72165 - Battle Dodge Ball 3 (PSP) - def_arc.irarc/.irlst
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72166#p72166 - The Bigs/The Bigs 2 (PSP) - *.big
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72184#p72184 - The Bigs/The Bigs 2 (PSP) - *.bcv
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72204#p72204 - Blitz: Overtime (PSP) - *.ms2/*.ms4
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72160#p72160 - Blood Bowl (PSP) - *.cat
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72179#p72179 - Brian Lara 2007 Pressure Play (PSP) - *.tar
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72181#p72181 - Brunswick Pro Bowling (PSP) - *.wad
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72014#p72014 - Burnout: Dominator (PSP) - *.fxp
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72206#p72206 - Bounty Hounds (PSP) - *.xpk
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72215#p72215 - Buzz! Concurso Universal (PSP) - *.flz
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72057#p72057 - Mahou Shoujo Lyrical Nanoha A's Portable DLCs (PSP) - main archives
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35724 - XI Coliseum (PSP) - *.arc

PS Vita
https://zenhax.com/viewtopic.php?f=17&t=7982&p=71979#p71979 - Disney Infinity 2.0 (PS Vita) - main archive
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72041#p72041 - DJMax Dechnika Tune (PS Vita) - *.pak
https://zenhax.com/viewtopic.php?f=17&t=7982&p=72093#p72093 - Imperial Navy Love Affection~Meiji Yokosuka March [帝国海軍恋慕情~明治横須賀行進曲](PS Vita) - *.hpac, *.hph, *.hgtc

Xbox
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35828 - Army Men: Sarge's War (Xbox) - *.sbr
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35696 - Call of Duty: Big Red One (PS2, GC, Xbox) -  *.gcv, *.psv, *.xbv audio extractor
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69359#p69359 - Lemony Snicket's A Series of Unfortunate Events (GC, PS2, Xbox) - streams.res

Xbox 360
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68463#p35697 - Deus Ex: Human Revolution (Xbox 360) - *.mul
https://zenhax.com/viewtopic.php?f=17&t=7982&p=68610#p68610 - Godfather II, The (PS3/X360) - *.viv
https://zenhax.com/viewtopic.php?f=17&t=7982&p=69164#p69164 - Harry Potter and the Half-Blood Prince - *.sdh/*.sdt pairs


Last edited by AlphaTwentyThree on Tue Jun 21, 2022 2:20 pm, edited 58 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts

Post by AlphaTwentyThree »

Broken Sword: Secrets of the Ark (PC) - *.PAK

Code: Select all

# game: Secrets of the Ark (PC, 2007)
# file types: *.pak
#
# script for QuickBMS http://quickbms.aluigi.org
# written by AlphaTwentyThree of Zenhax

idstring "EmPackFi"
goto 0xc
get DATASTART long
get FILES long
get UNK long # 4
for i = 1 <= FILES
   savepos GO
   get NAMEOFF long
   get SIZE long
   get OFFSET long
   xmath GO "GO + NAMEOFF"
   savepos MYOFF
   goto GO
   get NAME string
   goto MYOFF
   log NAME OFFSET SIZE
next i
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:23 pm, edited 4 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts

Post by AlphaTwentyThree »

Call of Duty: Big Red One (PS2, GC, Xbox) - *.gcv, *.psv, *.xbv movies audio extractor

Code: Select all

# game: Call of Duty: Big Red One (2005)
# file types: *.gcv, *.psv, *.xbv
# script type: demultiplexer
#
# written 2015-10-06 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "AFMV"
get SIZE long # file size
get VIDSIZE long # video data
get AUDSIZE long # audio data
putVarChr MEMORY_FILE SIZE 0
log MEMORY_FILE 0 0
putVarChr MEMORY_FILE2 SIZE 0
log MEMORY_FILE2 0 0
get NAME basename
string PNAME p= "%s.palette" NAME
log PNAME 0x10 0x80 # palette?
goto 0x90
for
   get BLOCKSIZE long
   get AUD_ID long
   getDstring DATA BLOCKSIZE
   if AUD_ID == 0x80
      putDstring DATA BLOCKSIZE MEMORY_FILE
   else
      putDstring DATA BLOCKSIZE MEMORY_FILE2
   endif
   savepos TEST
   if TEST >= SIZE
      break
   endif
next

get EXT extension
if EXT == "PSV"
   callfunction PS2 1
elif EXT == "xbv"
   callfunction XBOX 1
else
   string ANAME p= "%s.aud" NAME
   get SIZE asize MEMORY_FILE
   log ANAME 0 SIZE MEMORY_FILE
endif
   
get SIZE asize MEMORY_FILE2
if SIZE != 0
   if EXT == "PSV"
      string VNAME p= "%s.m2v" NAME
   else
      string VNAME p= "%s.vid" NAME
   endif
   log VNAME 0 SIZE MEMORY_FILE2
endif

startfunction PS2
   get SIZE asize MEMORY_FILE
   set MSIZE SIZE
   math MSIZE += 0x38
   putVarChr MEMORY_FILE3 MSIZE 0
   log MEMORY_FILE3 0 0
   set MEMORY_FILE3 binary "\x53\x53\x68\x64\x18\x00\x00\x00\x10\x00\x00\x00\xb0\x36\x00\x00\x02\x00\x00\x00\xc0\x2f\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x00\xe8\x11\x00"
   append
   log MEMORY_FILE3 0 SIZE MEMORY_FILE
   append
   
   putVarChr MEMORY_FILE3 0xc 44100 long
   putVarChr MEMORY_FILE3 0x10 2 byte
   putVarChr MEMORY_FILE3 0x14 0x400 long
   putVarChr MEMORY_FILE3 0x24 SIZE long
   string ANAME p= "%s.ss2" NAME
   get SIZE asize MEMORY_FILE3
   log ANAME 0 SIZE MEMORY_FILE3
endfunction

startfunction XBOX
   get SIZE asize MEMORY_FILE
   set MEMORY_FILE3 binary "\x52\x49\x46\x46\x18\x51\xa3\x0\x57\x41\x56\x45\x66\x6d\x74\x20\x14\x0\x0\x0\x69\x0\x2\x0\x44\xac\x0\x0\xcc\xc1\x0\x0\x48\x0\x4\x0\x2\x0\x40\x0\x64\x61\x74\x61\xf0\x50\xa3\x0"
   set RIFFSIZE SIZE
   math RIFFSIZE += 0x28
   set CH 2
   set FREQ 44100
   putVarChr MEMORY_FILE3 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE3 0x16 CH byte
   putVarChr MEMORY_FILE3 0x18 FREQ long
   set VAR1 0x3073
   math VAR1 *= CH
   if FREQ == 48000
      math VAR1 *= 44100
   else
      math VAR1 *= FREQ
   endif
   math VAR1 /= 22050
   putVarChr MEMORY_FILE3 0x1c VAR1 long   
   set VAR2 0x24
   math VAR2 *= CH
   putVarChr MEMORY_FILE3 0x20 VAR2 short
   putVarChr MEMORY_FILE3 0x2c SIZE long
   append
   log MEMORY_FILE3 OFFSET SIZE MEMORY_FILE
   append
   string ANAME p= "%s.lwav" NAME
   get SIZE asize MEMORY_FILE3
   log ANAME 0 SIZE MEMORY_FILE3
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:23 pm, edited 4 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts

Post by AlphaTwentyThree »

Deus Ex: Human Revolution (X360) - *.mul

Both scripts correspond to a number of *.mul files. Just try which one works.

Script 1:

Code: Select all

# game: Deus Ex: Human Revolution
# platform: Xbox 360
# file type: *.mul
# program needed: xma_parse (http://www.hcs64.com/vgm_ripping.html)
# script type: extractor (script 1)

# (c) by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

endian big
get FREQ long
get UNK long
get UNK long
get LAYERS long
get FSIZE asize
putVarChr MEMORY_FILE FSIZE 0
log MEMORY_FILE 0 0
for l = 0 < LAYERS
   putVarChr MEMORY_FILE FSIZE 0
   log MEMORY_FILE 0 0
   putVarChr MEMORY_FILE2 FSIZE 0
   log MEMORY_FILE2 0 0
   putVarChr MEMORY_FILE3 FSIZE 0
   log MEMORY_FILE3 0 0
   set OFFSET 0x800
   set EXTRA 0x10
   do
      goto OFFSET
      getDstring DUMMY EXTRA
      set EXTRA 0
      get SIZE long
      if SIZE > FSIZE # use the second script for these
         cleanexit
      endif
      get LAYER long
      get UNK longlong
      savepos OFFSET
      if LAYER == l
         append
         log MEMORY_FILE OFFSET SIZE
         append
      endif
      if LAYER == LAYERS # for the start of each cycle
         set EXTRA 0x10
      endif
      math OFFSET += SIZE
   while OFFSET < FSIZE
   endian little
   get SIZE asize MEMORY_FILE
   if SIZE != 0
      callfunction parse 1
      callfunction getXMACH 1
      get NAME basename
      xmath k "l + 1"
      string NAME p= "%s_%d.xma" NAME k
      callfunction XMA 1
   endif
   endian big
next l

startfunction parse
   endian little # just to be sure ;)
   set FUNCCALL string "xma_parse.exe #INPUT# -r #OUTPUT#"
   comtype EXECUTE FUNCCALL
   log MEMORY_FILE2 0 0
   clog MEMORY_FILE2 0 SIZE SIZE MEMORY_FILE # from mem [to temp] to mem2 (mem stays)
   encryption "" ""
endfunction

startfunction getXMACH # inside MEMORY_FILE!
   goto 7 MEMORY_FILE2
   get IDENT byte MEMORY_FILE2
   if IDENT == 1
      set CH 2
   elif IDENT == 3
      set CH 1
   elif IDENT == 0 # e.g. from multichannel stream
      set CH 2
   else
      print "ERROR: Not able to auto-determine channel count! Aborting all operations."
      cleanexit
   endif
endfunction

startfunction XMA # variant of standard function (mem2 to mem3)
   get MSIZE asize MEMORY_FILE2
   set RIFFSIZE MSIZE
   math RIFFSIZE += 0x34
   set PRESIZE RIFFSIZE # pre-alloc
   math PRESIZE += 0x38
   putVarChr MEMORY_FILE3 PRESIZE 0
   log MEMORY_FILE3 0 0
   set MEMORY_FILE3 binary "\x52\x49\x46\x46\xb8\x59\xa7\x00\x57\x41\x56\x45\x66\x6d\x74\x20\x20\x00\x00\x00\x65\x01\x10\x00\xd6\x10\x00\x00\x01\x00\x00\x03\xe3\x9a\x00\x00\x80\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x00\x64\x61\x74\x61\x00\x58\xa7\x00"
   putVarChr MEMORY_FILE3 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE3 0x24 FREQ long
   putVarChr MEMORY_FILE3 0x31 CH byte
   putVarChr MEMORY_FILE3 0x38 MSIZE long
   append
   log MEMORY_FILE3 0 MSIZE MEMORY_FILE2
   append
   get M3_SIZE asize MEMORY_FILE3
   log NAME 0 M3_SIZE MEMORY_FILE3
endfunction


Script 2:

Code: Select all

# game: Deus Ex: Human Revolution
# platform: Xbox 360
# file type: *.mul
# program needed: xma_parse (http://www.hcs64.com/vgm_ripping.html)
# script type: extractor (script 2)

# (c) by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

endian big
goto 0
get FREQ long
set OFFSET 0x800
get FSIZE asize
putVarChr MEMORY_FILE FSIZE 0
putVarChr MEMORY_FILE2 FSIZE 0
log MEMORY_FILE 0 0
log MEMORY_FILE2 0 0
do
   goto OFFSET
   get IDENT long
   get SIZE long # block size
   math SIZE x= 0x10 # for some cases
   get DUMMY longlong
   savepos OFFSET
   if IDENT == 0 # audio block
      append
      log MEMORY_FILE OFFSET SIZE
      append
   endif
   math OFFSET += SIZE
while OFFSET < FSIZE
get FSIZE asize MEMORY_FILE
putVarChr MEMORY_FILE2 FSIZE 0
putVarChr MEMORY_FILE3 FSIZE 0
putVarChr MEMORY_FILE4 FSIZE 0
log MEMORY_FILE2 0 0
log MEMORY_FILE3 0 0
log MEMORY_FILE4 0 0
set OFFSET 0
do
   goto OFFSET MEMORY_FILE
   get SIZE long MEMORY_FILE
   get IDENT long MEMORY_FILE
   get DUMMY longlong MEMORY_FILE
   savepos OFFSET MEMORY_FILE
   append
   if IDENT == 0
      log MEMORY_FILE3 OFFSET SIZE MEMORY_FILE
   elif IDENT == 1
      log MEMORY_FILE4 OFFSET SIZE MEMORY_FILE
   endif
   append
   math OFFSET += SIZE
while OFFSET < FSIZE
endian little
set CH 1
set BLOCKSIZE 0x8000

get SIZE asize MEMORY_FILE3
log MEMORY_FILE 0 0
append
log MEMORY_FILE 0 SIZE MEMORY_FILE3
append
callfunction parse 1
log MEMORY_FILE3 0 0 # clear now for header
get NAME basename
string NAME += "_1.xma"
callfunction XMA 1

get SIZE asize MEMORY_FILE4
if SIZE != 0
   log MEMORY_FILE 0 0
   log MEMORY_FILE2 0 0
   append
   log MEMORY_FILE 0 SIZE MEMORY_FILE4
   append
   callfunction parse 1
   log MEMORY_FILE3 0 0 # clear now for header
   get NAME basename
   string NAME += "_2.xma"
   callfunction XMA 1
endif

startfunction parse
   endian little # just to be sure ;)
   set FUNCCALL string "xma_parse.exe #INPUT# -r #OUTPUT#"
   comtype EXECUTE FUNCCALL
   log MEMORY_FILE2 0 0
   clog MEMORY_FILE2 0 SIZE SIZE MEMORY_FILE # from mem [to temp] to mem2 (mem stays)
   encryption "" ""
endfunction

startfunction XMA # variant of standard function (mem2 to mem3)
   get MSIZE asize MEMORY_FILE2
   set RIFFSIZE MSIZE
   math RIFFSIZE += 0x34
   set PRESIZE RIFFSIZE # pre-alloc
   math PRESIZE += 0x38
   putVarChr MEMORY_FILE3 PRESIZE 0
   log MEMORY_FILE3 0 0
   set MEMORY_FILE3 binary "\x52\x49\x46\x46\xb8\x59\xa7\x00\x57\x41\x56\x45\x66\x6d\x74\x20\x20\x00\x00\x00\x65\x01\x10\x00\xd6\x10\x00\x00\x01\x00\x00\x03\xe3\x9a\x00\x00\x80\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x00\x64\x61\x74\x61\x00\x58\xa7\x00"
   putVarChr MEMORY_FILE3 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE3 0x24 FREQ long
   putVarChr MEMORY_FILE3 0x31 CH byte
   putVarChr MEMORY_FILE3 0x38 MSIZE long
   append
   log MEMORY_FILE3 0 MSIZE MEMORY_FILE2
   append
   get M3_SIZE asize MEMORY_FILE3
   log NAME 0 M3_SIZE MEMORY_FILE3
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:22 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts

Post by AlphaTwentyThree »

Electronic Arts (console versions) - *.mus (archive)

Code: Select all

# game: various EA console games
# file type: *.mus (archive)
# script type: extractor
#
# written by AlphaTwentyThree of ZenHax
# script for QuickBMS http://quickbms.aluigi.org

endian big
get BNAME basename
goto 0xc
get FILES long
xmath FILES "(FILES - 8) / 0xc"
goto 0x8
set STOP 0
for i = 0 <= FILES
   get IDX short
   get DUMMY short
   get HEADERPOS long
   get OFFSET long
   savepos MYOFF
   get DUMMY longlong
   get SIZE long
   if SIZE == 0
      get SIZE asize
      set STOP 1
   endif
   math SIZE -= OFFSET
   goto HEADERPOS
   get INFO long
   goto MYOFF
   xmath PRESIZE "SIZE + 0x20"
   putVarChr MEMORY_FILE PRESIZE 0
   log MEMORY_FILE 0 0
   set MEMORY_FILE binary "\x03\x00\x00\x02\x8A\xEB\x02\x00\x20\x00\x00\x00\x00\x00\x00\x00\x04\x04\xBB\x80\x60\x8C\x2A\x00\x00\x00\x00\x00\x00\x00\x00\x00"
   putVarChr MEMORY_FILE 0x10 INFO long
   putVarChr MEMORY_FILE 0x14 SIZE long
   append
   log MEMORY_FILE OFFSET SIZE
   append
   string NAME p= "%s_%i.xas" BNAME IDX
   log NAME 0 PRESIZE MEMORY_FILE
   if STOP == 1
      cleanexit
   endif
next i
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:21 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts

Post by AlphaTwentyThree »

Wwise sound engine

file types: archives with AKPK identifier and *.bnk / *.txt and soundbanks.xml
script type: extractor / parser

Second script is for extraction, first script for name parsing.
To parse, keep all extracted files in the same folder as the *.txt and soundbanks.xml. Priority in parsing is always the soundbanks.xml. You can parse again with the txt files afterwards. After parsing, ALWAYS check with Anti-Twin (or similar) if there are files without name (which still have their IDX).

PARTLY REDUNDANT DUE TO Wwiser!!! (https://github.com/bnnm/wwiser)

Code: Select all

# file types: Wwise sound engine AKPK and BNK archives
# script type: extractor
# note 1: all files extracted as *.wem
# note 2: after extraction, parse with script
# for the soundbanks.xml or *.txt (if available)
#
# (c) by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get BNAME basename
getDstring IDENT 4
if IDENT == "AKPK"
   callfunction AKPK 1
elif IDENT == "1KCP" # The Saboteur (PC)
   callfunction AKPK 1
elif IDENT == "BKHD"
   callfunction BKHD 1
else
   print "Error: no valid Wwise sound pack"
   cleanexit
endif

startfunction AKPK
   set PC 0
   endian big
   get SIZE_HEADER long # data start offset
   get TEST long
   get FSIZE asize
   if TEST != 1
      reverselong SIZE_HEADER
      endian little
      set PC 1
   endif
   get BNAME basename
   string BNAME += " "

   goto 0xc
   get IDENT long
   set FOLDER_NAMES 1
   if IDENT == 0xc6
      set NBIAS 0x18
   elif IDENT == 0x14
      set NBIAS 0x1c
      set PC 1
   else
      set NBIAS 0x1c # also in PC versions
   endif
   goto NBIAS
   get NUM_FOLDERS long
   if NUM_FOLDERS > 10
      math NBIAS -= 4
      goto NBIAS
      get NUM_FOLDERS long
   endif
   savepos MYOFF
   set INFO NUM_FOLDERS
   math INFO *= 8
   math INFO += MYOFF # = start of names, will hold offset to jump to for TOC
   set ALLNAMES 0 # for ceil after names

   for i = 0 < NUM_FOLDERS
      goto MYOFF
      get OFF_NAME_FOLDER long
      math OFF_NAME_FOLDER += NBIAS
      get ID_FOLDER long
      savepos MYOFF
      goto OFF_NAME_FOLDER
      if PC == 0
         get NAME_FOLDER string
      else
         callfunction getPCstring 1
      endif
         strlen LENGTH NAME_FOLDER
         math ALLNAMES += LENGTH
         math ALLNAMES += 1
      string NAME_FOLDER += "/"
      string NAME_FOLDER += BNAME
      putArray 0 ID_FOLDER NAME_FOLDER
   next i
   if PC == 1
      math ALLNAMES *= 2
      math INFO += ALLNAMES
   else
      savepos INFO
      math INFO x= 4
   endif
   goto INFO
   set RUNS 1
   callfunction extract 1
   cleanexit
endfunction

startfunction BKHD
   get TEST short
   set REV 0
   if TEST == 0
      set REV 1
      endian big
   endif
   goto 4
   get SIZE_HEADER long
   savepos MYOFF
   math MYOFF += SIZE_HEADER
   get FSIZE asize
   if MYOFF == FSIZE
      print "bnk is empty"
      cleanexit
   endif
   goto MYOFF
   idstring "DIDX"
   get SIZE_DIDX long
   set FILES SIZE_DIDX
   math FILES /= 0xc
   set BIAS MYOFF # complete header
   math BIAS += SIZE_DIDX
   math BIAS += 16
   get BNAME basename
   for i = 1 <= FILES
      get DIDX long
      get OFFSET long
      math OFFSET += BIAS
      get SIZE long
      set NAME DIDX
      string NAME p= "%s.wem" DIDX EXT
      log NAME OFFSET SIZE
   next i
endfunction

startfunction getPCstring
   set NAME_FOLDER ""
   for s = 0
      get CHAR byte
      get NULL byte
      putVarChr NAME_FOLDER s CHAR
      if CHAR == 0
         break
      endif
   next s
endfunction
   
startfunction extract
   savepos INFO
   get NUM_FILES long
   if NUM_FILES == 0
      if RUNS == 1
         get NUM_FILES long
      else
         cleanexit
      endif
   endif
   print "extracting %NUM_FILES% files (number at offset %INFO%)"
   for i = 1 <= NUM_FILES
      get NAME_CRC long
      get MULTI long # in certain cases only
      get SIZE long
      if SIZE == 0
         get SIZE long
      endif
      get OFFSET long
      get ID_FOLDER long
      if OFFSET == 0
         set OFFSET ID_FOLDER
         get ID_FOLDER long
      endif
      #string NAME_CRC p= "0x%08x" NAME_CRC      
      if MULTI != 0
         math OFFSET *= MULTI
      endif
      savepos MYOFF
      if PC == 0
         endian big
      endif
      string NAME_CRC += ".wem"
      log NAME_CRC OFFSET SIZE
   next i
   math RUNS += 1
   callfunction extract 1
endfunction


Code: Select all

# file types: Wwise *.txt with same name as *.bnk files or soundbanks.xml
# script type: parser
# note 1: all *.wem files must be in the same folder as this script and the txt
# note 2: script will maintain the original folder structure
#
# (c) by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get EXT extension
if EXT == "txt"
   callfunction bnk_txt 1
elif EXT == "xml"
   callfunction soundbanks 1
else
   print "script only for txt and xml"
endif

startfunction bnk_txt
   callfunction getARRAYSIZE 1
   print "columns: %COLUMNS%, lines: %LINES%, %EMPTY% of which are empty"
   xmath LINES "LINES - EMPTY"
   goto 0
   set ARRAYLINE 0
   for i = 0 <= LINES
      set HEADERLINE 0
      for j = 0 < COLUMNS
         set NEWENTRY 0
         getCT FIELD string 0x09
         #print "(%i%, %j%): %FIELD%"
         if FIELD == "ID" # check for every line in case structure changes
            set C1 j
            set HEADERLINE 1 # don't enter data
         elif FIELD == "Wwise Object Path"
            set C2 j
            set HEADERLINE 1
         endif
         if HEADERLINE == 0
            if j == C1
               putArray 0 ARRAYLINE FIELD
               set NEWENTRY 1
               #print "enter ID %FIELD% at line %ARRAYLINE%"
            elif j == C2
               #print "enter path %FIELD% at line %ARRAYLINE%"
               putArray 1 ARRAYLINE FIELD
               set NEWENTRY 1
            endif
         endif
      next j
      getCT FIELD string 0x0d
      #print "(%i%, %j%): %FIELD%"
      get DUMMY byte
      if NEWENTRY == 1
         math ARRAYLINE += 1
      endif
      #print "line %i%: %NEWENTRY%"
   next i
   #print "entries: %ARRAYLINE%"

   for i = 0 < ARRAYLINE
      getArray IDX 0 i
      getArray NAME 1 i
      string NAME += ".wem"
      string IDX += ".wem"
      open FDSE IDX 1 EXIST
      if EXIST == 1
         get SIZE asize 1
         log NAME 0 SIZE 1
      endif
   next i
endfunction

startfunction getARRAYSIZE
   FindLoc SEARCHLINEEND string \x0d\x0a 0 ""
   getDstring FIRSTLINE SEARCHLINEEND
   strlen LENGTH FIRSTLINE
   set COLUMNS 0
   for i = 0 < LENGTH
      getVarChr TEST FIRSTLINE i byte
      if TEST == 0x09
         math COLUMNS += 1
      endif
   next i
   set LINES 0
   set LINEEND 0
   
   set EMPTY 0
   for
      goto LINEEND
      savepos MYOFF
      FindLoc LINEEND string \x0d\x0a 0 ""
      if LINEEND == ""
         break
      endif
      xmath TEST "LINEEND - MYOFF"
      math LINES += 1
      if TEST == 0
         print "line %LINES% is empty"
         math EMPTY += 1
      endif
      math LINEEND += 2
   next
   goto -4
   get TEST long
   if TEST == 0x0a0d0a0d
      math LINES -= 1
   endif
endfunction

startfunction soundbanks
   for i = 1
      FindLoc SEARCH string "<File Id=" 0 ""
      if SEARCH == ""
         cleanexit
      endif
      goto SEARCH
      getDstring DUMMY 10
      getCT DIDX string 0x22
      string DIDX += ".wem"
      getDstring TEST 3 # sometimes the file id tag is empty
      if TEST != " />"
         math SEARCH += 12
         goto SEARCH
         FindLoc SEARCH string "<Path>" 0 ""
         goto SEARCH
         getDstring DUMMY 6
         getCT FNAME string 0x3c
         string FNAME -= 13
         open FDSE DIDX 1 EXIST
         if EXIST == 1
            get SIZE asize 1
            log MEMORY_FILE 0 0
            log MEMORY_FILE 0 SIZE 1
            string FNAME += ".wem"
            log FNAME 0 SIZE MEMORY_FILE
         endif
      endif
      math SEARCH += 10
      goto SEARCH
   next i
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:21 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts

Post by AlphaTwentyThree »

GameCube *.VID movies - audio extractor

Code: Select all

# Audio extractor for *.vid movies (VID1 identifier)
#
# tested with:
# 007: Everything or Nothing (GameCube)
# Gun (GameCube)
# Tony Hawk's American Wasteland (GameCube)
#
# script for QuickBMS http://quickbms.aluigi.org
# written by AlphaTwentyThree of Zenhax

log MEMORY_FILE 0 0
endian big
idstring "VID1"
goto 0
getDstring DATA 0x2c
putDstring DATA 0x2c MEMORY_FILE
goto 0x24
get SIZE long
math SIZE -= 0x20
append
putVarChr MEMORY_FILE 0x24 SIZE long
append
get ZERO long
savepos MYOFF
idstring "VIDH"
get VHSIZE long
goto MYOFF
getDstring DATA VHSIZE
savepos MYOFF
getDstring AUDH 4
if AUDH != "AUDH"
   cleanexit
endif
get SIZE long
math SIZE += 0x14
goto MYOFF
getDstring DATA SIZE
putDstring DATA SIZE MEMORY_FILE
get FSIZE asize

for
   savepos OFFSET
   getDstring IDENT 4
   get SIZE long
   goto OFFSET
   if IDENT == "FRAM"
      getDstring DATA 0x20
      putDstring DATA 0x20 MEMORY_FILE
      savepos OFFSET
      getDstring IDENT 4
      get SIZE long
   endif
   goto OFFSET
   getDstring DATA SIZE
   if   IDENT == "AUDD"
      putDstring DATA SIZE MEMORY_FILE
   endif
   savepos OFFSET
   if OFFSET == FSIZE || IDENT == ""
      # get SIZE asize MEMORY_FILE
      # get NAME basename
      # string NAME += ".raw"
      # log NAME 0 SIZE MEMORY_FILE
      callfunction corr_fram 1
   endif
next

startfunction corr_fram
   get MSIZE asize MEMORY_FILE
   goto 0x20 MEMORY_FILE
   savepos MYOFF MEMORY_FILE
   getDstring IDENT 4 MEMORY_FILE
   get SIZE long MEMORY_FILE
   goto MYOFF MEMORY_FILE
   math MYOFF += SIZE
   goto MYOFF MEMORY_FILE
   set GO MYOFF
   for
      goto GO MEMORY_FILE
      getDstring IDENT 4 MEMORY_FILE
      if IDENT != "FRAM"
         print "no FRAM at %GO%"
         cleanexit
      endif
      savepos WRITE_TO MEMORY_FILE
      get FRAM_SIZE long MEMORY_FILE
      xmath GO "WRITE_TO + 0x1c"
      if GO >= MSIZE
         xmath SIZE "WRITE_TO - 4"
         callfunction wrapup 1
      endif
      goto GO MEMORY_FILE
      getDstring IDENT 4 MEMORY_FILE
      if IDENT == "FRAM" # last two empty FRAMs
         savepos SIZE MEMORY_FILE
         math SIZE -= 0x24
         callfunction wrapup 1
      endif
      get AUDD_SIZE long MEMORY_FILE
      xmath FRAM_SIZE "AUDD_SIZE + 0x20"
      putVarChr MEMORY_FILE WRITE_TO FRAM_SIZE long
      savepos MYOFF MEMORY_FILE
      xmath GO "MYOFF - 0x28 + FRAM_SIZE"
      if GO >= MSIZE
         get SIZE asize MEMORY_FILE
         callfunction wrapup 1
      endif
   next
endfunction

startfunction wrapup
   get NAME basename
   string NAME += ".logg"
   log NAME 0 SIZE MEMORY_FILE
   cleanexit
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:18 pm, edited 5 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

XI Coliseum (PSP) - *.arc (WpX identifier)

Code: Select all

# game: XI Coliseum (PSP)
# file type: *.arc (WpX identifier)
# script type: extractor
#
# script for QuickBMS http://quickbms.aluigi.org
# written by AlphaTwentyThree of Zenhax


idstring WpX
goto 8
get SIZE long
get ZSIZE long
set OFFSET 0x800
if SIZE == ZSIZE
   log MEMORY_FILE OFFSET SIZE
else
   comtype zlib
   clog MEMORY_FILE OFFSET SIZE ZSIZE
endif


idstring MEMORY_FILE "WILL"
get ZERO long MEMORY_FILE
get UNK long MEMORY_FILE
get FILES long MEMORY_FILE
for i = 1 <= FILES
   get NAMEOFF long MEMORY_FILE
   get OFFSET long MEMORY_FILE
   get SIZE long MEMORY_FILE
   get ZERO long MEMORY_FILE
   savepos MYOFF MEMORY_FILE
   goto NAMEOFF MEMORY_FILE
   get NAME string MEMORY_FILE
   goto MYOFF MEMORY_FILE
   log NAME OFFSET SIZE MEMORY_FILE
next i
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:18 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Army Men: Sarge's War (PS2) - *.msh/*.msb pairs

Code: Select all

# game: Army Men: Sarge's War (PS2)
# file type: *.msh/*.msb pairs
# script type: extractor
# note: ss2 mono headers are automatically added
#
# script for QuickBMS http://quickbms.aluigi.org
# written by AlphaTwentyThree of Zenhax

open FDDE MSH 0
open FDDE MSB 1
goto 0x8 0
get FILES long 0
get BNAME basename
for i = 1 <= FILES
   get SIZE long 0
   get ZERO long 0
   get OFFSET long 0
   get FREQ long 0
   string NAME p= "%s_%i.ss2" BNAME i
   set CH 1
   set INTERLEAVE 0x10
   callfunction SS2 1
next i

startfunction SS2
   endian little
   set MSIZE SIZE
   math MSIZE += 0x38
   putVarChr MEMORY_FILE MSIZE 0
   log MEMORY_FILE 0 0
   set MEMORY_FILE binary "\x53\x53\x68\x64\x18\x00\x00\x00\x10\x00\x00\x00\xb0\x36\x00\x00\x02\x00\x00\x00\xc0\x2f\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x00\xe8\x11\x00"
   append
   log MEMORY_FILE OFFSET SIZE 1
   append
   
   putVarChr MEMORY_FILE 0xc FREQ long
   putVarChr MEMORY_FILE 0x10 CH byte
   putVarChr MEMORY_FILE 0x14 INTERLEAVE long
   putVarChr MEMORY_FILE 0x24 SIZE long
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:17 pm, edited 2 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Army Men: Sarge's War (GC) - *.sti/*.stm

Code: Select all

# game: Army Men: Sarge's War (GameCube)
# file type: *.sti/*.stm pairs
# script type: extractor
# note 1: genh headers are automatically added
# note 2: format is big endian PCM
#
# script for QuickBMS http://quickbms.aluigi.org
# written by AlphaTwentyThree of Zenhax

open FDDE sti 0
open FDDE stm 1
endian big
goto 8 0
get FILES long 0
get UNK long 0
get BNAME basename
for i = 1 <= FILES
   get CRC long 0
   getDstring DUMMY 0xc 0
   get OFFSET long 0
   get SIZE long 0
   get DUMMY longlong 0
   get FREQ long 0
   getDstring DUMMY 0x30 0
   set CH 1
   xmath SAMPLES "SIZE / 4"
   string NAME p= "%s_%i_0x%08x.genh" BNAME i CRC
   callfunction GENH 1
   endian big
next i

startfunction GENH
   endian little
   log MEMORY_FILE 0 0
   putVarChr MEMORY_FILE 0 0x484e4547 long
   putVarChr MEMORY_FILE 4 CH long
   putVarChr MEMORY_FILE 0xc FREQ long
   putVarChr MEMORY_FILE 0x10 0xffffffff long
   putVarChr MEMORY_FILE 0x14 0xffffffff long
   putVarChr MEMORY_FILE 0x18 3 long
   putVarChr MEMORY_FILE 0x1c 0x60 long
   putVarChr MEMORY_FILE 0x20 0x60 long
   putVarChr MEMORY_FILE 0x40 SAMPLES long
   putVarChr MEMORY_FILE 0x50 SIZE long
   putVarChr MEMORY_FILE 0x5f 0 byte
   append
   log MEMORY_FILE OFFSET SIZE 1
   append
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:17 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Army Men: Sarge's War (Xbox)

note: Xbox ADPCM headers get automatically added (playable with vgmstream)

Code: Select all

# game: Army Men: Sarge's War (Xbox)
# file type: *.sbr
# script type: extractor
# note: Xbox ADPCM headers get automatically added
#      (playable with vgmstream)
#
# script for QuickBMS http://quickbms.aluigi.org
# written by AlphaTwentyThree of Zenhax

get SIZE asize
if SIZE < 0x50
   cleanexit
endif

get BASE_HEADER_SIZE long
get HEADER_SIZE long
get DATA_START long
get DATA_SIZE long
get NUMB1 long
get NUMB2 long
get FILES long
get OFF_SECT2 long
get OFF_SECT1 long
get OFF_SECT3 long

get BNAME basename

# for i = 1 <= NUMB1 # sect 1
   # get CRC long
   # get IDENT long # if file is written
   # get IDX long
   # get ZERO long
   # get UNK1 long
   # getDstring ZERO 0xc
   # get UNK2 long
   # get UNK3 long
   # get UNK4 long
   # get UNK5 long
   # get UNK6 long
# next i

goto OFF_SECT2

for i = 1 <= FILES # sect2
   get OFFSET long
   math OFFSET += DATA_START
   get SIZE long
   get ZERO long
   get UNK long
   savepos MYOFF
   goto OFFSET
   get CODEC short
   get CH short
   get FREQ long
   math OFFSET += 0x14
   math SIZE -= 0x14
   string NAME p= "%s_sfx_%i.lwav" BNAME i
   callfunction XADP 1
   goto MYOFF
next i

 for i = 1 <= NUMB2 # sect3
   get OFFSET long
   math OFFSET += DATA_START
   get SIZE long
   get ZERO longlong
   get CODEC short
   get CH short
   get FREQ long
   get COEFF1 long
   get INTERLEAVE short
   get BITS short
   get COEFF2 long
   string NAME p= "%s_mus_%i.lwav" BNAME i
   callfunction XADP 1
 next i

startfunction XADP
   set MEMORY_FILE binary "\x52\x49\x46\x46\x18\x51\xa3\x0\x57\x41\x56\x45\x66\x6d\x74\x20\x14\x0\x0\x0\x69\x0\x2\x0\x44\xac\x0\x0\xcc\xc1\x0\x0\x48\x0\x4\x0\x2\x0\x40\x0\x64\x61\x74\x61\xf0\x50\xa3\x0"
   set RIFFSIZE SIZE
   math RIFFSIZE += 0x28
   putVarChr MEMORY_FILE 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE 0x16 CH byte
   putVarChr MEMORY_FILE 0x18 FREQ long
   set VAR1 0x3073
   math VAR1 *= CH
   if FREQ == 48000
      math VAR1 *= 44100
   else
      math VAR1 *= FREQ
   endif
   math VAR1 /= 22050
   putVarChr MEMORY_FILE 0x1c VAR1 long   
   set VAR2 0x24
   math VAR2 *= CH
   putVarChr MEMORY_FILE 0x20 VAR2 short
   putVarChr MEMORY_FILE 0x2c SIZE long
   append
   log MEMORY_FILE OFFSET SIZE
   append
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:16 pm, edited 4 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

998 Studios
(https://www.mobygames.com/company/989-studios)

CAT extractor

Code: Select all

# 989 Studios *.cat extractor

# (c) 2021-12-21 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get SIZE asize
math SIZE -= 0xc
goto SIZE
get IDENT long
get FILES long
get UNK long
get BNAME basename
set OFFSET 0

for i = 1 <= FILES
   goto OFFSET
   get SIZE long
   get BIAS long
   math SIZE += BIAS
   string NAME P "%BNAME%_%i%.v2k"
   log NAME OFFSET SIZE
   math OFFSET += SIZE
   goto OFFSET
   do
      get TEST byte
   while TEST == 0
   if TEST == 0xcd
      do
         get TEST byte
      while TEST == 0xcd
   endif
   savepos OFFSET
   math OFFSET -= 1
next i


KGB extractor

Code: Select all

# 989 Studios *.kgb extractor

# (c) 2021-12-21 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "KGB"
goto 0x4
get FILES byte
set CD 0
goto 0x8
get TEST byte
if TEST == 0xcd
   set CD 1
endif
goto 0xc
set OFFSET 0x800
for i = 0 < FILES
   getDstring NAME 0xc
   get PRES byte
   get UNK threebyte
   get SIZE long
   get TOFFSET long
   if CD == 1
      savepos MYOFF
      log NAME OFFSET SIZE
      math OFFSET += SIZE
      goto OFFSET
      do
         get TEST byte
      while TEST == 0xcb
      savepos OFFSET
      math OFFSET -= 1
      goto MYOFF
   else
      log NAME TOFFSET SIZE
   endif
next i


V2K to ss2 converter (-> vgmstream)

Code: Select all

# 989 Studios *.v2k to *.ss2 converter

# (c) 2021-12-21 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get SIZE long
get CHECK long
if CHECK == 0x1000
   set FREQ 44100
else
   set FREQ 22050
endif
set OFFSET 0x800
get NAME basename
string NAME += ".ss2"
set CH 1
set INTERLEAVE 0x10

   set MEMORY_FILE binary "\x53\x53\x68\x64\x18\x00\x00\x00\x10\x00\x00\x00\xb0\x36\x00\x00\x02\x00\x00\x00\xc0\x2f\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x00\xe8\x11\x00"
   append
   log MEMORY_FILE OFFSET SIZE
   append
   putVarChr MEMORY_FILE 0x24 SIZE long
   putVarChr MEMORY_FILE 0xc FREQ long
   putVarChr MEMORY_FILE 0x14 INTERLEAVE long
   putVarChr MEMORY_FILE 0x10 CH byte
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:16 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Oddworld: Abe's Oddysee (Playstation)

Code: Select all

# game Oddworld: Abe's Oddysee (Playstation)
# format: *.LVL
# script type: extractor

# (c) 2021-12-32 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get DATASTART long
goto 0x10
get FILES long
goto 0x20
for i = 0 < FILES
   getDstring NAME 0xc
   get OFFSET long
   math OFFSET *= 0x800
   get UNK long
   get SIZE long
   log NAME OFFSET SIZE
next i
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:15 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Electronic Arts - *.MPC/*.MAD/*.VP6 movies demuxer

Code: Select all

# EA Games *.MPC/*.MAD movies demultiplexer

# (c) 2021-12-25 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get FSIZE asize
putVarChr MEMORY_FILE FSIZE 0
log MEMORY_FILE 0 0
putVarChr MEMORY_FILE2 FSIZE 0
log MEMORY_FILE2 0 0
set OFFSET 0
for i = 1
   goto OFFSET
   getDstring IDENT 2
   getDstring TEMP 2
   get SIZE long
   goto OFFSET
   getDstring DATA SIZE
   if IDENT == "SC"
      putDstring DATA SIZE MEMORY_FILE
   else
      putDstring DATA SIZE MEMORY_FILE2
   endif
   math OFFSET += SIZE
   if OFFSET == FSIZE
      break
   endif
next i
get SIZE asize MEMORY_FILE
get NAME basename
string NAME += ".sng"
log NAME 0 SIZE MEMORY_FILE

get SIZE asize MEMORY_FILE2
get NAME basename
string NAME += ".mov"
log NAME 0 SIZE MEMORY_FILE2
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:14 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

XWB/XSB pairs

procedure:
- move all files to the folder with the *.xwb files
- run batch file
- convert resulting *.xwb files (separate folder for each main xwb) to *.wav with script (still in beta mode - offset needs to be adjusted for every main container)

note: the names inside the XSB files don't correspond to the streams correctly.
note2: I've also attached the Xbox ADPCM codec below - right clock on the INF file and choose "Install". You can play the resulting wav files with every audio player afterwards.

Code: Select all

# CRI xwb extractor
#
# (c) 2021-12-25 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "WBND"
set FREQ 44100
set CH 2
get SIZE asize
set OFFSET 0x800
math SIZE -= OFFSET


set MEMORY_FILE binary "\x52\x49\x46\x46\x18\x51\xa3\x0\x57\x41\x56\x45\x66\x6d\x74\x20\x14\x0\x0\x0\x69\x0\x2\x0\x44\xac\x0\x0\xcc\xc1\x0\x0\x48\x0\x4\x0\x2\x0\x40\x0\x64\x61\x74\x61\xf0\x50\xa3\x0"
   xmath RIFFSIZE "SIZE + 0x28"
   putVarChr MEMORY_FILE 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE 0x16 CH byte
   putVarChr MEMORY_FILE 0x18 FREQ long
   set VAR1 0x3073
   math VAR1 *= CH
   if FREQ == 48000
      math VAR1 *= 44100
   else
      math VAR1 *= FREQ
   endif
   math VAR1 /= 22050
   putVarChr MEMORY_FILE 0x1c VAR1 long   
   set VAR2 0x24
   math VAR2 *= CH
   putVarChr MEMORY_FILE 0x20 VAR2 short
   putVarChr MEMORY_FILE 0x2c SIZE long
   append
   log MEMORY_FILE OFFSET SIZE
   append
   get NAME basename
   string NAME += ".wav"
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:14 pm, edited 2 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

The Punisher (PS2)

note: in case Luigi's script doesn't work, here's one that works on the rest of the files. Won't work on "MUSIC.VPP" or "VOICES.VPP", only the other files.

Code: Select all

# The Punisher (PS2)
# *.vpp extractor

# (c) 2021-12-29 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get UNK long
get VER long
get ENTRIES Long
get UNK long
get FILE_TABLE long
goto FILE_TABLE
xmath DATA_START "FILE_TABLE +(ENTRIES * 0x20)"
get FNAME basename

for a = 1 <= ENTRIES

   getDstring NAME 0x18
   get SIZE1 long
   get SIZE2 long
   string NAME P "%FNAME%\%NAME%"
   xmath DATA_START "((DATA_START/0x800)+1)*0x800"
   if SIZE1 == SIZE2
      log NAME DATA_START SIZE2
   else
      clog NAME DATA_START SIZE2 SIZE1
   endif
   math DATA_START + SIZE2
next a
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:12 pm, edited 3 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

The Punisher (PS2)

Code: Select all

# The Punisher (PS2)
# *.peg extractor

# (c) 2021-12-29 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "GEKV"
get VER long
get SIZE_TABLE long
goto 0x10
get FILES long
goto 0x20
get BNAME basename
for i = 0 < FILES
   get OFFSET long
   get UNK1 long
   get UNK2 long
   get UNK3 long
   getDstring NAME 0x18
   get SIZE long
   get UNK4 long
   string NAME P "%BNAME%\%NAME%"
   log NAME OFFSET SIZE
next i
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:11 pm, edited 2 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

The Godfather II (PS3, X360)

notes:
- no names given, only the CRC, so that's what you'll find in the names
- some file endings obviously aren't correct but if anyone wants to correct them, send me a note

Code: Select all

# *.VIV archives from "The Godfather II"
# (c) 2022-01-02 by AlphaTwentyThree of ZenHAX
#
# script for QuickBMS http://quickbms.aluigi.org

endian big
idstring "BIG"
get VER byte
get FSIZE long
get FILES long
get HSIZE long
get BNAME basename
for i = 0 < FILES

    get OFFSET long
    get SIZE long
   get CRC long
   if SIZE != 0
      savepos TMP
      goto OFFSET
      getDstring EXT 3
      if EXT == "SCH"
         set EXT "vp6"
      elif EXT == "MVh"
         set EXT "vp6"
      elif EXT == "ols"
         set EXT "gf2"
      else
         goto OFFSET
         get TYPE byte
         if TYPE == 3
            set EXT "exa.snu"
         endif
      endif
      goto TMP
      string NAME p "%s_0x%08x.%s" BNAME CRC EXT
      log NAME OFFSET SIZE
   endif
next i
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:11 pm, edited 2 times in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

PS2 ADPCM *.ss2 0x10 byte re-interleave

vgmstream somehow still doesn't play ss2 streams with incomplete last blocks correctly. This script will re-interleave those streams to ones that can be played correctly.
My old script in the "other" forum had some major problems, so please only use this one!
Very important script!

Code: Select all

# re-interleaves *.ss2 files with 0x10 bytes interleave
#
# (c) 2022-01-05 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "SShd"
goto 0xc
get FREQ long
get CH long
if CH == 1
   cleanexit
endif
goto 0x14
get INTERLEAVE long
set OFFSET 0x28
get STREAMSIZE asize
math STREAMSIZE -= OFFSET
xmath BLOCKS "STREAMSIZE / (INTERLEAVE * 2)" # cycles
xmath TEST "STREAMSIZE % (INTERLEAVE * 2)"
if TEST != 0
   xmath RES "TEST / 2" # single last block
else
   set REST 0
endif
callfunction deinterleave 1
callfunction reinterleave 1
callfunction addSS2header 1
get SIZE asize MEMORY_FILE4
get NAME basename
string NAME += "_0x10.ss2"
log NAME 0 SIZE MEMORY_FILE4

startfunction deinterleave
   xmath PSIZE "STREAMSIZE/2"
   putVarchr MEMORY_FILE SSIZE 0
   putVarchr MEMORY_FILE2 SSIZE 0
   log MEMORY_FILE 0 0
   log MEMORY_FILE2 0 0
   goto OFFSET
   for k = 0 < BLOCKS
      getDstring DATA INTERLEAVE
      putDstring DATA INTERLEAVE MEMORY_FILE
      getDstring DATA INTERLEAVE
      putDstring DATA INTERLEAVE MEMORY_FILE2
   next k
   getDstring DATA RES
   putDstring DATA RES MEMORY_FILE
   getDstring DATA RES
   putDstring DATA RES MEMORY_FILE2
   get SIZE asize MEMORY_FILE
endfunction

startfunction reinterleave
   putVarChr MEMORY_FILE3 STREAMSIZE 0
   log MEMORY_FILE3 0 0
   get SIZE1 asize MEMORY_FILE
   get SIZE2 asize MEMORY_FILE2
   xmath CYC "(SIZE1 / 0x10)"
   set OFFSET 0
   for i = 0 < CYC
      goto OFFSET MEMORY_FILE
      getDstring DATA 0x10 MEMORY_FILE
      putDstring DATA 0x10 MEMORY_FILE3
      goto OFFSET MEMORY_FILE2
      getDstring DATA 0x10 MEMORY_FILE2
      putDstring DATA 0x10 MEMORY_FILE3
      math OFFSET += 0x10
   next i
   get SIZE asize MEMORY_FILE3
endfunction

startfunction addSS2header
   set MEMORY_FILE4 binary "\x53\x53\x68\x64\x18\x00\x00\x00\x10\x00\x00\x00\xb0\x36\x00\x00\x02\x00\x00\x00\xc0\x2f\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x00\xe8\x11\x00"
   get SIZE asize MEMORY_FILE3
   do
      math SIZE -= 0x20
      goto SIZE MEMORY_FILE3
      get TEST long MEMORY_FILE3
   while TEST == 0
   math SIZE += 0x20
   do
      math SIZE -= 0x20
      goto SIZE MEMORY_FILE3
      get TEST long MEMORY_FILE3
   while TEST == 0xc
   math SIZE += 0x20
   append
   log MEMORY_FILE4 0 SIZE MEMORY_FILE3
   append
   putVarChr MEMORY_FILE4 0xc FREQ long
   putVarChr MEMORY_FILE4 0x10 CH byte
   set INTERLEAVE 0x10
   putVarChr MEMORY_FILE4 0x14 INTERLEAVE long
   putVarChr MEMORY_FILE4 0x24 SIZE long
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:10 pm, edited 1 time in total.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: My QuickBMS scripts [AlphaTwentyThree]

Post by AlphaTwentyThree »

Volition Inc.

note: all files stemming from *.vmu streams need to be re-interleaved with my script in order to be played correctly!

Code: Select all

# Volition games - audio converter
# files commonly inside *.vpp archives
#
# (c) 2022-01-05 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

get EXT extension
set INTERLEAVE 0x4000
if EXT == "vmu"
   set FREQ 22050
   set CH 2
elif EXT == "vse"
   set FREQ 44100
   set CH 1
else
   print "wrong format"
   cleanexit
endif
get SIZE asize
set OFFSET 0
get NAME basename
string NAME += ".ss2"
callfunction SS2 1

startfunction SS2
   set MEMORY_FILE binary "\x53\x53\x68\x64\x18\x00\x00\x00\x10\x00\x00\x00\xb0\x36\x00\x00\x02\x00\x00\x00\xc0\x2f\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x00\xe8\x11\x00"
   append
   log MEMORY_FILE OFFSET SIZE
   append
   putVarChr MEMORY_FILE 0x24 SIZE long
   putVarChr MEMORY_FILE 0xc FREQ long
   putVarChr MEMORY_FILE 0x14 INTERLEAVE long
   putVarChr MEMORY_FILE 0x10 CH byte
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
endfunction
Last edited by AlphaTwentyThree on Sun Jun 19, 2022 2:10 pm, edited 1 time in total.