Offtopic: Into Commodore 64 (6502) coding, pixeling or music?
Xentax is looking for new members for the C64 activities!
Just drop us a message at forum@xentax.com and join the Scene Team!

Forum rules: Click here

My quickBMS scripts

Coders and would-be coders alike, this is the place to talk about programming.
Researchman
mega-veteran
mega-veteran
Posts: 314
Joined: Fri Jun 11, 2010 12:08 pm
Has thanked: 78 times
Been thanked: 21 times

Re: My quickBMS scripts

Post by Researchman » Mon Nov 29, 2010 6:37 pm

The contents of this post was deleted because of possible forum rules violation.

User avatar
Mr.Mouse
Site Admin
Posts: 4041
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 412 times
Been thanked: 561 times
Contact:

Re: My quickBMS scripts

Post by Mr.Mouse » Mon Nov 29, 2010 11:45 pm

Hehe that FileLoc in MultiEx Commander's MexScript used to be

Code: Select all

FindFileID <string> <variable>:
-------------------------------

This command searches the file from the current fileposition for a
<string> of max 40 length and saves the position (when found) in
<variable>. This way, if you know that a datafile contains only
a certain type of file with a set ID you can get the OFFSET of this
file that way. Just search for the ID and let MEX save its pos in FILEOFF.
in the DOS version in 1998.

AlphaTwentyThree
double-veteran
double-veteran
Posts: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Tue Nov 30, 2010 4:30 am

The contents of this post was deleted because of possible forum rules violation.
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 ;)

Researchman
mega-veteran
mega-veteran
Posts: 314
Joined: Fri Jun 11, 2010 12:08 pm
Has thanked: 78 times
Been thanked: 21 times

Re: My quickBMS scripts

Post by Researchman » Tue Nov 30, 2010 5:01 pm

Google solves the problem with .at3 files. Now KMPlayer play at3 files from Battle Fantasia, Puzzle Fighter and Street Fighter. Zhal no aa3 decoder(Tekken: Dark Resurrection).
Sonic Ultimate Gensesis Collection is PS2 ADPCM (seemingly mono), starting at 0x40. Will implement that into my script soon.
I will be wait.

AlphaTwentyThree
double-veteran
double-veteran
Posts: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Wed Dec 01, 2010 12:46 am

Researchman wrote:Zhal no aa3 decoder(Tekken: Dark Resurrection).
I already referred to Sony SoundForge - it's the only of three Sony programs that can decode atrac3+. You may also try Sonic Stage with HiMDRenderer (both free), but it doesn't support all at3+ formats.
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 ;)

Researchman
mega-veteran
mega-veteran
Posts: 314
Joined: Fri Jun 11, 2010 12:08 pm
Has thanked: 78 times
Been thanked: 21 times

Re: My quickBMS scripts

Post by Researchman » Wed Dec 01, 2010 3:31 pm

I`m mean aa3 plugin for winamp or aa3 acm or something codec. Сurrently remains SoundForge.

AlphaTwentyThree
double-veteran
double-veteran
Posts: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Wed Dec 01, 2010 8:28 pm

Researchman wrote:I`m mean aa3 plugin for winamp or aa3 acm or something codec. Сurrently remains SoundForge.
There is none. SoundForge is pretty much the only possibility to decode them.
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 ;)

mauzerX
advanced
Posts: 57
Joined: Thu Jul 01, 2010 1:48 pm
Has thanked: 22 times
Been thanked: 10 times

Re: My quickBMS scripts

Post by mauzerX » Sun Dec 05, 2010 12:13 pm

The contents of this post was deleted because of possible forum rules violation.

AlphaTwentyThree
double-veteran
double-veteran
Posts: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Sun Dec 05, 2010 9:28 pm

The contents of this post was deleted because of possible forum rules violation.
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 ;)

OrangeC
double-veteran
double-veteran
Posts: 860
Joined: Sun Apr 20, 2008 2:58 am
Has thanked: 5 times
Been thanked: 33 times

Re: My quickBMS scripts

Post by OrangeC » Sun Dec 19, 2010 2:47 am

Alpha your rsf script problem might be multichannel related. in the file's header i see either 8 or 6 channels,but not 02 channels. I have converted a 2ch file and it worked. but when i converted a multichannel file the script still outputs the file as two channels and changing the channel count in the RIFF header doesn't work either.

http://www.megaupload.com/?d=O0R0B0TW

AlphaTwentyThree
double-veteran
double-veteran
Posts: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Mon Dec 20, 2010 2:10 am

OrangeC wrote:Alpha your rsf script problem might be multichannel related. in the file's header i see either 8 or 6 channels,but not 02 channels. I have converted a 2ch file and it worked. but when i converted a multichannel file the script still outputs the file as two channels and changing the channel count in the RIFF header doesn't work either.

http://www.megaupload.com/?d=O0R0B0TW
I know that it doesn't read the channels because the standard atrac format only support stereo - or at least SoundForge only supports stereo files... I'm a bit confused of all these mono and multichannel atrac files. I currently don' know how to handle them, maybe there's a way to split the channels. Will try around with them some day.
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: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Fri Dec 24, 2010 5:26 pm

nonconform_XMA_to_XMA.bms
This script removes the seek and fact section of XMA files so that toWAV supports these afterwards. Good example are XMA files from fsb containers that have been extracted with "fsbext -a [name].fsb"

Code: Select all

set MEMORY_FILE 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"
goto 0x16
get CH short
get FREQ long
FindLoc DAT string "data" 0 ""
math DAT += 4
goto DAT
get SIZE long
savepos OFFSET

get NAME basename
string NAME += ".xma"
set RIFFSIZE SIZE
math RIFFSIZE += 0x34
putVarChr MEMORY_FILE 0x04 RIFFSIZE long
putVarChr MEMORY_FILE 0x24 FREQ long
putVarChr MEMORY_FILE 0x31 CH byte
putVarChr MEMORY_FILE 0x38 SIZE long

append
log MEMORY_FILE OFFSET SIZE
append
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: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Sun Dec 26, 2010 6:05 pm

Playstation ADPCM 0x10 bytes re-interleave
As the title says, this script de-interleaves a PS2 ss2 file and re-interleaves it with a 0x10 byte interleave. Apparently, the PS ADPCM plugin for vgmstream has a staggering problem with incomplete last interleave blocks. As those occur very often there's no other possibility than to re-interleave the files.
The new version 1.1 automatically deletes end silence (if the file has no stop marker). Next version will also remove silence of streams with different markers.
But another GREAT use for this script is the possibility of joining segments with different interleaves with the little script below that deletes the 0x28 size headers.
What I normally do to join files on Windows 7:
- select all files I want to join
- press F2 (rename)
- write down a single name and press Enter (Windows 7 will automatically number the files)
- use Flexible Renamer (google it!) to rename the files to the format [name].001, [name].002 and so on
- use 7zip or WinRAR to join the files
Afterwards you can just re-add a correct SS2 header with my other script.
Of course this is also very practical to split ss2 files practically everywhere. =)

Code: Select all

# re-interleaves *.ss2 files with 0x10 bytes interleave
# needed to prepare streams for joining or cutting (without decoding)

idstring "SShd"
goto 0xc
get FREQ long
get CH long
if CH == 1 # no re-interleave needed
	cleanexit
endif
goto 0x14
get INTERLEAVE long
set OFFSET 0x28
get STREAMSIZE asize
math STREAMSIZE -= OFFSET
set SBLOCK INTERLEAVE
math SBLOCK *= 2 # stereo block
set BLOCKS STREAMSIZE
math BLOCKS /= SBLOCK
set RES STREAMSIZE
math RES %= SBLOCK
math RES /= 2 # size of single channel of last block
callfunction deinterleave 1
	get SIZE1 asize MEMORY_FILE
	get SIZE2 asize MEMORY_FILE2
	if SIZE1 != SIZE2
		print "error: memory files are of different size!"
		cleanexit
	endif
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
	log MEMORY_FILE 0 0
	log MEMORY_FILE2 0 0
	set DEOFF OFFSET
	append
	for k = 1 <= BLOCKS
		log MEMORY_FILE DEOFF INTERLEAVE
		math DEOFF += INTERLEAVE
		log MEMORY_FILE2 DEOFF INTERLEAVE
		math DEOFF += INTERLEAVE
	next k
	log MEMORY_FILE DEOFF RES # write last residual block
	log MEMORY_FILE2 DEOFF RES
	append
endfunction

startfunction reinterleave
	set SIZE SIZE1
	set OFFSET 0
	append
	do
		log MEMORY_FILE3 OFFSET 0x10 MEMORY_FILE
		log MEMORY_FILE3 OFFSET 0x10 MEMORY_FILE2
		math OFFSET += 0x10
	while OFFSET < SIZE
	append
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 Thu Dec 30, 2010 10:54 pm, edited 4 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: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Tue Dec 28, 2010 2:17 pm

baf_extract.bms (X360 only!)
Extracts the XMA files from sound banks and adds a valid header for toWAV. Frequency and channels is taken from the file info table of course.

Code: Select all

idstring "BANK"
endian big
get UNK long
get UNK long
get FILES long
goto 0x34

for i = 1 <= FILES
	savepos OFF
	idstring "WAVE"
	get INFOSIZE long
	get HEADERSIZE long
	getDstring NAME 0x20
	string NAME += ".xma"
	get OFFSET long
	get SIZE long
	get UNK long
	get UNK long
	get FREQ long
	get UNK long
	get CH long
	endian little
	callfunction addXMAheader 1
	endian big
	get SIZE asize MEMORY_FILE
	log NAME 0 SIZE MEMORY_FILE
	math OFF += INFOSIZE
	goto OFF
next i

startfunction addXMAheader
	set MEMORY_FILE 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"
	set RIFFSIZE SIZE
	math RIFFSIZE += 0x34
	putVarChr MEMORY_FILE 0x04 RIFFSIZE long
	putVarChr MEMORY_FILE 0x24 FREQ long
	putVarChr MEMORY_FILE 0x31 CH byte
	putVarChr MEMORY_FILE 0x38 SIZE long
	append
	log MEMORY_FILE OFFSET SIZE
	append
endfunction
Last edited by AlphaTwentyThree on Tue Sep 25, 2012 10:37 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: 984
Joined: Mon Aug 24, 2009 10:55 pm
Has thanked: 75 times
Been thanked: 626 times

Re: My quickBMS scripts

Post by AlphaTwentyThree » Thu Dec 30, 2010 10:49 pm

Just updated the 0x10-byte re-interleaver with automatic end silence removal. Will update it frequently when I encounter files that need script enhancement.
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 ;)

Post Reply