Page 23 of 33

Re: My quickBMS scripts

Posted: Mon Sep 17, 2012 2:14 pm
by AlphaTwentyThree
Just made a really extensive update for both the EA ast extractor and func_getTYPE.bms (faster and more sophisticated)! Extreme enhancements FTW! ;)

Re: My quickBMS scripts

Posted: Fri Sep 21, 2012 5:02 pm
by AlphaTwentyThree
The script for the Unity3D engine was somewhat faulty, so I made some major updates: viewtopic.php?f=13&t=4450&p=77959#p77959
I'm not sure about the internal "type", this could also be some folder because e.g. type 49 contains various types of files. Inside the script you find a list of types I've encountered so far and as I'm no specialist in this and don't recognize certain types, it would be cool if you contribute here and tell me some of the types I haven't adjusted the extraction process yet. :)

Re: My quickBMS scripts

Posted: Fri Sep 21, 2012 8:54 pm
by Mr.Mouse

Re: My quickBMS scripts

Posted: Sat Sep 22, 2012 4:06 pm
by AlphaTwentyThree
Mr.Mouse wrote:Also put a spot light on Facebook http://www.facebook.com/permalink.php?s ... 8469022795
;-)
Yay! :)

Re: My quickBMS scripts

Posted: Tue Sep 25, 2012 10:38 am
by AlphaTwentyThree
Raw Activision BAF extractor

This script will just append the data to the header info at the start of the baf archive and write it to disk for post-processing. This is practical if the audio format can't e played yet but you want to extract the baf files nevertheless, e.g. Sony ADPCM variant from 007: Blood Stone (PC).

Code: Select all

# raw Activision BAF extractor
# this script only extracts the raw data from baf files (header, cue markers, stream data)
# to be used for later post-processing of the contained audio files (saved as *.wavl)
# (c) 2012-09-25 by AlphaTwentyThree of XeNTaX

idstring "BANK"
get SINFO long
if SINFO != 0x34
	endian big
	reverselong SINFO
endif
get UNK long
get FILES long
goto SINFO
savepos HOFF
for i = 1 <= FILES
	idstring "WAVE"
	get HSIZE long
	get UNK0 long
	getDstring NAME 0x20
	get SOFF long # stream start
	math SOFF -= 8
	get SSIZE long
	set COFF HOFF
	math COFF += HSIZE
	goto COFF
	getDstring CID 4
	if CID == "CUE "
		get CSIZE long
	else
		set CSIZE 0
	endif
	set SIZE HSIZE
	math SIZE += CSIZE
	math SIZE += SSIZE
	putVarChr MEMORY_FILE SIZE 0
	log MEMORY_FILE 0 0
	goto HOFF
	getDstring HDATA HSIZE
	putDstring HDATA HSIZE MEMORY_FILE
	if CSIZE != 0
		goto COFF
		getDstring CDATA CSIZE
		putDstring CDATA CSIZE MEMORY_FILE
	else
		set CSIZE 0
	endif
	goto SOFF
	getDstring SDATA SSIZE
	putDstring SDATA SSIZE MEMORY_FILE
	string NAME += ".wavel"
	log NAME 0 SIZE MEMORY_FILE
	math HSIZE += CSIZE
	math HOFF += HSIZE
	goto HOFF
next i

Re: My quickBMS scripts

Posted: Tue Sep 25, 2012 8:56 pm
by Dinoguy1000
AlphaTwentyThree wrote:

Code: Select all

# (c) 2021-09-25 by AlphaTwentyThree of XeNTaX
Time traveling now, are we? ;)

Re: My quickBMS scripts

Posted: Tue Sep 25, 2012 10:46 pm
by AlphaTwentyThree
Dinoguy1000 wrote:
AlphaTwentyThree wrote:

Code: Select all

# (c) 2021-09-25 by AlphaTwentyThree of XeNTaX
Time traveling now, are we? ;)
See, THAT'S how advanced my scripts are! ;)

Re: My quickBMS scripts

Posted: Sun Sep 30, 2012 10:34 pm
by AlphaTwentyThree
Just added ogm video detection to my Unity3D engine script! :)

Re: My quickBMS scripts

Posted: Tue Oct 02, 2012 12:03 am
by AlphaTwentyThree
Turok: Evolution *.tre extractor

This doesn't look so special, but believe me, it was really some hazzle to figure out the format because the files in the TOC are sorted by file crc and din't have any names. I ran many many tests - and finally found a file with the file names (sorted by offset, so the new sortarray function came it pretty handy ;) )
This is a script I'm really really proud of! :)
(Just for your info: The old script from some years only extracted the files without names.)

Code: Select all

# extracts the contents of the big STREE0.TRE archive from Turok: Evolution (PS2)
# note: CORRECT NAMES!!!
# (c) 2012-10-02 by AlphaTwentyThree of XeNTaX

get FILES long
for i = 0 < FILES
	get OFFSET long
	get SIZE long
	get DATA_CRC long
	get NAME_CRC long
	putArray 0 i OFFSET
	putArray 1 i SIZE
next i
print "sorting array"
sortarray 0 1
getArray NAMEOFF 0 2
goto NAMEOFF
for i = 0 < FILES
	getCT NAME string 0x0d
	get DUMMY byte
	getArray OFFSET 0 i
	getArray SIZE 1 i
	log NAME OFFSET SIZE
next i
Just for completeness' sake, here's the version for archives where no names are given. Note that sorting is still needed. Needs the newest func_getTYPE.bms (see link list)

Code: Select all

# extracts *.TRE archives from Turok: Evolution (PS2)
# note: for the main STREE.TRE use my other script!
# (c) 2012-10-02 by AlphaTwentyThree of XeNTaX

include "func_getTYPE.bms"
get FILES long
for i = 0 < FILES
	get OFFSET long
	get SIZE long
	get DATA_CRC long
	get NAME_CRC long
	putArray 0 i OFFSET
	putArray 1 i SIZE
	putarray 2 i NAME_CRC
next i
print "sorting array"
sortarray 0 1
get BNAME basename
string BNAME += "_"
for i = 0 < FILES
	getArray OFFSET 0 i
	getArray SIZE 1 i
	getArray CRC 2 i
	putVarChr MEMORY_FILE SIZE 0
	log MEMORY_FILE 0 0
	append
	log MEMORY_FILE OFFSET SIZE
	append
	string CRC p= "_0x%08x" CRC
	set NAME BNAME
	string NAME += i
	string NAME += CRC
	callfunction getTYPE 1
	if EXT != ""
		string NAME += EXT
	endif
	log NAME 0 SIZE MEMORY_FILE
next i

Re: My quickBMS scripts

Posted: Tue Oct 02, 2012 12:58 am
by AlphaTwentyThree
PS2 stereo vag (AAAp) to ss2 converter

I don't know the actual extension of the files (extracted, no names given), I guess it's also *.vag, only stereo. Could easily be included in vgmstream if someone knows the original extension.
Don't forget to put the func_header.bms (viewtopic.php?f=13&p=44717#p44717) in the same directory - as always. ;)

Code: Select all

# stereo vag to SS2 converter for PS2 games
# (c) 2012-10-02 by AlphaTwentyThree of XeNTaX

include "func_header_SS2.bms"
idstring "AAAp"
get INTERLEAVE short
get CH short
goto 0x1a
get FREQ short
reverseshort FREQ
set OFFSET 0x68
get SIZE asize
math SIZE -= OFFSET
set NAME ""
callfunction SS2 1

Re: My quickBMS scripts

Posted: Sun Oct 07, 2012 7:30 pm
by AlphaTwentyThree
Improvements never stop: Updated the Unit3D extractor by mp3 detection and included an archive variant sometimes used by the big resources.assets. Just encountered in Frederic: Resurrection of Music (Mac, 2012)
Find the updated script here: viewtopic.php?f=13&t=4450&p=77959#p77959 =)

Re: My quickBMS scripts

Posted: Mon Oct 08, 2012 7:47 pm
by AlphaTwentyThree
Electronic Arts *.big extractor

I know there are many different archives in use by EA - this is one of them at least (identifier "BE"). For the PC version, just delete the "endian big" - I guess. ;)
Nice example for the use of the array, which comes in quite handy here. Thanks Luigi for the implementation of the chunklzx unpack function. :)

Code: Select all

# extracts EA big archives with "EB" identifier
# tested with NHL 13 (X360)
# (c) 2012-10-08 by AlphaTwentyThree of XeNTaX

comtype xmemdecompress
idstring \x45\x42\x00\x03
endian big
goto 4
get FILES long
get UNK long # some size
get OFF_NAMES long # plus random bias of zeros
get SIZE_NAMES long
get NAMEL_FILE byte
get NAMEL_FOLDER byte
get ZERO byte
get FOLDERS byte
set OFF_FOLDERS FILES
math OFF_FOLDERS *= NAMEL_FILE
math OFF_FOLDERS += OFF_NAMES
math OFF_FOLDERS x= 0x10 # round to next 0x10 bytes
math NAMEL_FILE -= 2 # short for folder number

goto 0x30
for i = 1 <= FILES
	get OFFSET long
	math OFFSET *= 0x10
	get ZERO long
	get SIZE long
	get HASH long
	putArray 0 i OFFSET
	putArray 1 i SIZE
next i
goto OFF_NAMES
for i = 1 <= FILES
	get FOLDER_NUMBER short
	getDstring NAME NAMEL_FILE
	savepos MYOFF
	set OFF_FOLDERNAME FOLDER_NUMBER
	math OFF_FOLDERNAME *= NAMEL_FOLDER
	math OFF_FOLDERNAME += OFF_FOLDERS
	goto OFF_FOLDERNAME
	getDstring FOLDER NAMEL_FOLDER
	set FNAME FOLDER
	string FNAME += "/"
	string FNAME += NAME
	getArray OFFSET 0 i
	getArray SIZE 1 i
	goto OFFSET
	getDstring COMP 8
	if COMP == "chunklzx"
		callfunction unpack 1
		log FNAME 0 SIZE MEMORY_FILE
	else
		log FNAME OFFSET SIZE
	endif
	goto MYOFF
next i

startfunction unpack # (c) Luigi Auriemma
    get DUMMY long
    get FULLSIZE long
    get SIZE long
    get CHUNKS long
    get DUMMY long
    get DUMMY long
    get DUMMY long
    get DUMMY long
    log MEMORY_FILE 0 0
    append
    savepos OFFSET
    for j = 0 < CHUNKS
        math OFFSET x= 0x8
        for # very lame, made on the fly
            math T = OFFSET
            math T %= 0x10
            if T == 8
                break
            endif
            math OFFSET += 8
        next
        goto OFFSET
        get ZSIZE long
        get DUMMY long
        savepos OFFSET
        clog MEMORY_FILE OFFSET ZSIZE SIZE
        math OFFSET += ZSIZE
    next j
    append
    get MYSIZE asize MEMORY_FILE
    if MYSIZE != FULLSIZE
        print "Alert: MEMORY_FILE %MYSIZE% != %FULLSIZE%"
    endif
	set SIZE FULLSIZE
endfunction

Re: My quickBMS scripts

Posted: Tue Oct 09, 2012 3:05 pm
by AlphaTwentyThree
The Amazing Spider-Man *.pkz decompressor

Decompresses the pkz archives from the game and writes the header and decompressed data to disk. I can't make any sense of the given offsets in the header, but if anyone wants to take a look, I can provide a sample.
Nothing special here, so again, it's just another example for the QuickBMS-curious (comments provided). ;)

Code: Select all

# decompresses the *.pkz files from The Amazing Spider-Man (PC)
# no extraction of individual files at the moment (TOC offsets don't fit)
# (c) 2012-10-09 by AlphaTwentyThree of XeNTaX

comtype zlib_noerror
get IDENT long
if IDENT == 0xb0b1bEbA
	endian big
elif IDENT == 0xbabeb1b0
else
	cleanexit
endif
get DATA_OFF long              # start of compressed data
get NAME basename
string NAME += ".header"
log NAME 0 DATA_OFF            # write header to disk for later research
get BLOCKSIZE long             # length of one zlib block
get LOOPS asize                # calculate the number of loops
math LOOPS -= DATA_OFF
math LOOPS /= BLOCKSIZE
# memory pre-allocation
get SIZE asize
math SIZE -= DATA_OFF
math SIZE *= 10
putVarChr MEMORY_FILE SIZE 0
log MEMORY_FILE 0 0
set OFFSET DATA_OFF  # initialize first offset
set SIZE BLOCKSIZE
math SIZE *= 10      # set decompressed size to some default
append
for i = 1 <= LOOPS
	clog MEMORY_FILE OFFSET BLOCKSIZE SIZE # decompress block to memory
	math OFFSET += BLOCKSIZE               # jump to next block
next i
append
get NAME basename
string NAME += ".decomp"
get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE

Re: My quickBMS scripts

Posted: Tue Oct 09, 2012 3:53 pm
by AlphaTwentyThree
Found a quite stupid mistake in my generic splitter which I won't explain any further. ;)
Be sure to grab the updated script here: viewtopic.php?f=13&t=4450&p=45460#p45460!

Re: My quickBMS scripts

Posted: Tue Oct 09, 2012 10:05 pm
by Dinoguy1000
AlphaTwentyThree wrote:

Code: Select all

set BIAS OFF_FOLDERS
math BIAS %= 0x10
if BIAS != 0
	math OFF_FOLDERS /= 0x10
	math OFF_FOLDERS += 1
	math OFF_FOLDERS *= 0x10
endif
I have a feeling that there's some better way to do this (since, according to my understanding, it's basically just a ceil() function with a custom "cutoff"), but my maths isn't strong enough to pick it out (I think bit-shifting would play a role, though... does QuickBMS actually support bit-wise manipulations?). =/