ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sat Oct 21, 2017 4:58 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: My QuickBMS scripts
PostPosted: Tue Oct 06, 2015 6:50 pm 

Joined: Sat Aug 09, 2014 11:21 am
Posts: 608
Hello fellow coders and modders!

As I have now completely moved here from XeNTaX, I'm now creating basically the same topic here. The one on XeNTaX is here: http://forum.xentax.com/viewtopic.php?f ... d7e4284bc8. You can find LOTS of scripts for multiple purposes there and this is also the archive for my basic scripts like gensplit/genscan, func_getTYPE or the header adding scripts.
From now on I'll post the scripts I write here. I've written quite a few in the last months so maybe I'll catch up later. ;)
For now, have fun! :D
I'll post the scripts and link to them in this first post.


Top
   
 Post subject: Re: My QuickBMS scripts
PostPosted: Tue Oct 06, 2015 6:55 pm 

Joined: Sat Aug 09, 2014 11:21 am
Posts: 608
Code:
# 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


Top
   
 Post subject: Re: My QuickBMS scripts
PostPosted: Mon Nov 23, 2015 10:11 pm 

Joined: Sat Aug 09, 2014 11:21 am
Posts: 608
Deus Ex: Human Revolution (Xbox 360)

I've written two scripts that convert the sound and cutscenes to xma, including the parse call and header adder. This applies to the *.mul files.
You'll need xma_parse (rename xma_test) from http://www.hcs64.com/vgm_ripping.html located in the same folder as the script.

1. The first script can be applied to all the mul files. The ones that can be processed will be processed, all others need the second script.
Code:
# (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


2. The second script is for all the cutscenes and some of the sounds.
Code:
# (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


Top
   
 Post subject: Re: My QuickBMS scripts
PostPosted: Fri May 13, 2016 6:48 pm 

Joined: Sat Aug 09, 2014 11:21 am
Posts: 608
EA mus (XAS container) - console version

Just encountered this in Boogie SuperStar for the Wii so I thought I'd write a script for this format. It automatically adds xas headers to the segments, which are supported by towav.

Code:
# extracts *.mus archives containing segmented EA XAS stream (only for console versions)
# 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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited