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

My quickBMS scripts

Coders and would-be coders alike, this is the place to talk about programming.
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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! ;)
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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. :)
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
Mr.Mouse
Site Admin
Posts: 4073
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 450 times
Been thanked: 682 times
Contact:

Re: My quickBMS scripts

Post by Mr.Mouse »

AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post by AlphaTwentyThree »

Mr.Mouse wrote:Also put a spot light on Facebook http://www.facebook.com/permalink.php?s ... 8469022795
;-)
Yay! :)
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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
Last edited by AlphaTwentyThree on Tue Sep 25, 2012 10:46 pm, edited 1 time in total.
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
User avatar
Dinoguy1000
Site Admin
Posts: 786
Joined: Mon Sep 13, 2004 1:55 am
Has thanked: 154 times
Been thanked: 163 times

Re: My quickBMS scripts

Post by Dinoguy1000 »

AlphaTwentyThree wrote:

Code: Select all

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

Rules | Requests | Wiki | Discord

If you run across a post that breaks the rules, please report the post - a mod or admin will handle it from there.
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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! ;)
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post by AlphaTwentyThree »

Just added ogm video detection to my Unity3D engine script! :)
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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
Last edited by AlphaTwentyThree on Tue Oct 02, 2012 1:25 am, edited 2 times in total.
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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 =)
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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
Last edited by AlphaTwentyThree on Tue Oct 09, 2012 10:14 pm, edited 1 time in total.
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
AlphaTwentyThree
double-veteran
double-veteran
Posts: 982
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 76 times
Been thanked: 660 times

Re: My quickBMS scripts

Post 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!
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)
User avatar
Dinoguy1000
Site Admin
Posts: 786
Joined: Mon Sep 13, 2004 1:55 am
Has thanked: 154 times
Been thanked: 163 times

Re: My quickBMS scripts

Post 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?). =/
Welcome to Xentax!

Rules | Requests | Wiki | Discord

If you run across a post that breaks the rules, please report the post - a mod or admin will handle it from there.
Post Reply