DiddyKong's BRSTM copier *NEW UPDATE 2015-3-09* SOURCE CODE RELEASED

Started by Diddy Kong, March 19, 2012, 12:09:47 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Quote from: DarkPika on March 19, 2013, 11:23:37 AM
I see...

dang if I was any good at GML or command-line programing, I'd have some suggestions for you >_<


if you like, you could help me help you out by building a BRSTM template for HexEdit.
that way, I could figure out the format of a BRSTM, and help you to encode it better. :)

I'll post the HexEdit link and tell you how to crack it if you're interested, but if not, or you're too busy, then I won't bug you. ;)
cant - in gml i can only parse / write one byte at a time, not a strand of them

because of this i couldnt make it read the two bytes that tell the frequency and just make it add 10KHz to it and write the new value


March 19, 2013, 08:40:17 PM #16 Last Edit: March 19, 2013, 08:41:58 PM by DarkPika
Quote from: Diddy Kong on March 19, 2013, 06:01:26 PM
cant - in gml i can only parse / write one byte at a time, not a strand of them

because of this i couldnt make it read the two bytes that tell the frequency and just make it add 10KHz to it and write the new value


well... that's easy to pass :)
can you bit-shift in GML?? (<< or >>)

these python functions might help explain that:

def bu16(): #read a 16bit big-endian value
   byte1 = file.read(1)
   byte2 = file.read(1)
   return byte1+( byte2<<8 )

def u16(): #read a 16bit little-endian value
   byte1 = file.read(1)
   byte2 = file.read(1)
   return byte2+( byte1<<8 )

little endian: '0100' = 1
big endian: '0001' = 1

for even more info, you can DL UMC dev4 and look at the __BIT() function in data/COMMON.py ;)

that function actually deals with ints and floats stored in multiple and ambiguous byte sizes. :)
(though in dev4 it can only write 32bit and 64bit floats)
^ it can read floats of any byte-size


everything starts out as an unsigned int and gets converted to a signed or float value based on the bit-format specs ;)


I don't rmbr exactly how I stored the file in memory, but I know it involved a u8() array.
(each byte as an 8bit int in either [77,68,76,48,...], or array('B',[77,68,76,48,...]) )

lol, take a guess at what those first 4 bytes are. :P

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

Quote from: DarkPika on March 19, 2013, 08:40:17 PM
well... that's easy to pass :)
can you bit-shift in GML?? (<< or >>)

these python functions might help explain that:

def bu16(): #read a 16bit big-endian value
   byte1 = file.read(1)
   byte2 = file.read(1)
   return byte1+( byte2<<8 )

def u16(): #read a 16bit little-endian value
   byte1 = file.read(1)
   byte2 = file.read(1)
   return byte2+( byte1<<8 )

little endian: '0100' = 1
big endian: '0001' = 1

for even more info, you can DL UMC dev4 and look at the __BIT() function in data/COMMON.py ;)

that function actually deals with ints and floats stored in multiple and ambiguous byte sizes. :)
(though in dev4 it can only write 32bit and 64bit floats)
^ it can read floats of any byte-size


everything starts out as an unsigned int and gets converted to a signed or float value based on the bit-format specs ;)


I don't rmbr exactly how I stored the file in memory, but I know it involved a u8() array.
(each byte as an 8bit int in either [77,68,76,48,...], or array('B',[77,68,76,48,...]) )

lol, take a guess at what those first 4 bytes are. :P

nope... its really limited to just byte overwriting on a per byte basis, and cannot do a strand of bytes at once, i struggled just to get the playback rate working

it returns the data in decimal so yah...:

ass=file_bin_open("Final_Lap.brstm",2)
file_bin_seek(ass,$064)
A=file_bin_read_byte(ass)
file_bin_seek(ass,$065)
B=file_bin_read_byte(ass)
C=A+B
if (C=315) {file_bin_seek(ass,$064);file_bin_write_byte(ass,$EA);file_bin_seek(ass,$065);file_bin_write_byte(ass,$60)}
if (C=125) {file_bin_seek(ass,$064);file_bin_write_byte(ass,$AB);file_bin_seek(ass,$065);file_bin_write_byte(ass,$E0)}
if (C=240) {file_bin_seek(ass,$064);file_bin_write_byte(ass,$DB);file_bin_seek(ass,$065);file_bin_write_byte(ass,$24)}

but can you bit-shift??

Eg:
0xff << 8 = 0xff00 | 0xfe =0xfffe = 65534

There's your 16bit value from 2 8bit values.

To write that:

Write( ( 65534 >> 8 ) & 0xff )
Write( 65534 & 0xff )

This is exactly what UMC does...

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

Quote from: DarkPika on March 20, 2013, 02:39:54 PM
but can you bit-shift??

Eg:
0xff << 8 = 0xff00 | 0xfe =0xfffe = 65534

There's your 16bit value from 2 8bit values.

To write that:

Write( ( 65534 >> 8 ) & 0xff )
Write( 65534 & 0xff )

This is exactly what UMC does...
nope

actually... I've just thought...
Windows calculator can bit-shift...

Meaning you should be able to bit-shift in GML...

are you sure you can't, or you just havn't tried??

Try this:
Var = 1 << 8

And output Var to the console

If you get an error, or 256 doesn't show...
I'll accept that you can't bit-shift.

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

March 21, 2013, 06:11:15 PM #21 Last Edit: March 21, 2013, 06:15:27 PM by Diddy Kong
Quote from: DarkPika on March 20, 2013, 08:58:45 PM
actually... I've just thought...
Windows calculator can bit-shift...

Meaning you should be able to bit-shift in GML...

are you sure you can't, or you just havn't tried??

Try this:
Var = 1 << 8

And output Var to the console

If you get an error, or 256 doesn't show...
I'll accept that you can't bit-shift.
you know i left a debug feature in the copier right? it lets you fiddle with GML within the program


press spacebar to pull up the code execution box   ,  to display the variable, run

wd_message_simple(var)

at the end of the code


you can run or execute pretty much anything i didnt code into the program, including entering 3d view and drawing polygons, but thats not the main purpose of it, and this isnt a 3d viewing program

** var is a variable/function thingy already assigned to something in GML, you cant use it, neither can i before compiling


globals you can't use:
sd
ass
autohex
pitch
mb
gb
kb
tb
from
track

these variables are all used by the program already, changing them can cause weird things to happen when the program wants to read them
including freaking out the drive meter


local variables ar ejust the variable IDs and dont have global. before them

March 22, 2013, 01:38:09 PM #22 Last Edit: March 22, 2013, 01:44:02 PM by DarkPika
on wii again... yay ^_^

diddy I'm going to try to write a function in GML that will both read and write a bu32 value from a supplied file.

if's going to follow the same format that UMC 2x followed:
reading:
value = bu32( '' )

writing:
bu32( int(value) )


IDK how to name a script in GML so I can't test if this will work or not...
(no scripts to back-track on either)
^ I'm hitting this completely blind-sided with horrible documentation (the help file)... heh

script "bu32":
argument0 = file
argument1 = offset
argument2 = value
{
 f = argument0; o = argument1; v = argument2 //shortening the variables
 if (v=='')
 {
   file_bin_seek(f,o)
   b1=file_bin_read_byte(f)
   file_bin_seek(f,o+1)
   b2=file_bin_read_byte(f)
   file_bin_seek(f,o+2)
   b3=file_bin_read_byte(f)
   file_bin_seek(f,o+3)
   b4=file_bin_read_byte(f)
   return (b1<<24)|(b2<<16)|(b3<<8 )|b4
 }
 else
 {
   b1=(v>>24)&255
   b2=(v>>16)&255
   b3=(v>>8 )&255
   b4=v&255
   file_bin_seek(f,o)
   file_bin_write_byte(f,b1)
   file_bin_seek(f,o+1)
   file_bin_write_byte(f,b2)
   file_bin_seek(f,o+2)
   file_bin_write_byte(f,b3)
   file_bin_seek(f,o+3)
   file_bin_write_byte(f,b4)
 }
}


usage should be easy:

value=bu32(file,offset,'')
bu32(file,offset,value)

let me know if that works ;)

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

March 22, 2013, 06:59:50 PM #23 Last Edit: March 22, 2013, 07:12:04 PM by Diddy Kong
Quote from: DarkPika on March 22, 2013, 01:38:09 PM
on wii again... yay ^_^

diddy I'm going to try to write a function in GML that will both read and write a bu32 value from a supplied file.

if's going to follow the same format that UMC 2x followed:
reading:
value = bu32( '' )

writing:
bu32( int(value) )


IDK how to name a script in GML so I can't test if this will work or not...
(no scripts to back-track on either)
^ I'm hitting this completely blind-sided with horrible documentation (the help file)... heh

script "bu32":
argument0 = file
argument1 = offset
argument2 = value
{
 f = argument0; o = argument1; v = argument2 //shortening the variables
 if (v=='')
 {
   file_bin_seek(f,o)
   b1=file_bin_read_byte(f)
   file_bin_seek(f,o+1)
   b2=file_bin_read_byte(f)
   file_bin_seek(f,o+2)
   b3=file_bin_read_byte(f)
   file_bin_seek(f,o+3)
   b4=file_bin_read_byte(f)
   return (b1<<24)|(b2<<16)|(b3<<8 )|b4
 }
 else
 {
   b1=(v>>24)&255
   b2=(v>>16)&255
   b3=(v>>8 )&255
   b4=v&255
   file_bin_seek(f,o)
   file_bin_write_byte(f,b1)
   file_bin_seek(f,o+1)
   file_bin_write_byte(f,b2)
   file_bin_seek(f,o+2)
   file_bin_write_byte(f,b3)
   file_bin_seek(f,o+3)
   file_bin_write_byte(f,b4)
 }
}


usage should be easy:

value=bu32(file,offset,'')
bu32(file,offset,value)

let me know if that works ;)
lol idk what im going to be looking for :P
which var will be the file?  i dont see the file bin open code in there
:P

here is a snapshot of when scripts or written code is launched

when i said it was mostly drag and drop, i wasn't kidding :P
what that block there contains is the code to run, scrips can be added, and called from another action, but asks for arguments instead which affect the script's values where set

March 22, 2013, 08:08:55 PM #24 Last Edit: March 22, 2013, 08:18:35 PM by DarkPika
that code is ment to be ran with specific arguments when called...

the file is the first
the offset of the 32bit value is the 2nd
and the 3rd is a value that tells the function weather to read or write...

example:

myfile = file_bin_open("filedir") //file to read from

value1 = bu32( myfile, 0, '' )
value2 = bu32( myfile, 4, '' )


file2 = file_bin_open("file") //file to write to

bu32( file2, 0, value1 )
bu32( file2, 4, value2 )

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

Quote from: DarkPika on March 22, 2013, 08:08:55 PM
that code is ment to be ran with specific arguments when called...

the file is the first
the offset of the 32bit value is the 2nd
and the 3rd is a value that tells the function weather to read or write...

example:

myfile = file_bin_open("filedir") //file to read from

value1 = bu32( myfile, 0, '' )
value2 = bu32( myfile, 4, '' )


file2 = file_bin_open("file") //file to write to

bu32( file2, 0, value1 )
bu32( file2, 4, value2 )
I can use the file open dialog box to set that file to use argument during runtime

Quote from: Diddy Kong on March 22, 2013, 08:54:25 PM
I can use the file open dialog box to set that file to use argument during runtime
??

we're talking about encoding the brstm,
and being able to read/write large ints :/

that function reads '00 0F 30 26' and returns 995366
or input 995366 and write it to a specified file as '00 0F 30 26'

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

Quote from: DarkPika on March 22, 2013, 09:06:24 PM
??

we're talking about encoding the brstm,
and being able to read/write large ints :/

that function reads '00 0F 30 26' and returns 995366
or input 995366 and write it to a specified file as '00 0F 30 26'

what do you want me to put as the file to use argument?

i said i can make it so the user gets to browse and pick the file it will  deal with

March 22, 2013, 09:58:26 PM #28 Last Edit: March 22, 2013, 11:01:07 PM by DarkPika
what?? no...
no no...

this is ment to be used to encode your data to increase the volume of a brstm and that sort of stuff :/

the stuff you didn't know how to (or thought you couldn't) do before...

EDIT: we srsly need to find a chat that works through VTunnel >_<
my shoutbox just takes you to the top of the page -.-*


proboards must be having problems again...


EDIT2:
if I were you diddy,
I've only worked on the bu32 function for you...

big-endian unsigned 32bit structure

I don't think you'll need to use little-endian handling as Nintendo generally sticks to big-endian. (so I've heard)

apparently that little 'FE FF' in brres files means big-endian...
'FF FF' means little-endian... :-\


anyways...
the other byte structures for big-endian are:
unsigned intergers:
bu64
bu32 (already have)
bu24
bu16
bu8 (don't need unless you want)

signed intergers:
bs64
bs32
bs24
bs16
bs8 (you might need this)

IEEE754 floating point (decimal) format:
bf64
bf32
bf16 (maybe)


if you need some coding reference,
my '__BIT' function in UMC dev4 handles all of those and more.

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

Quote from: DarkPika on March 22, 2013, 09:58:26 PM
what?? no...
no no...

this is ment to be used to encode your data to increase the volume of a brstm and that sort of stuff :/

the stuff you didn't know how to (or thought you couldn't) do before...

EDIT: we srsly need to find a chat that works through VTunnel >_<
my shoutbox just takes you to the top of the page -.-*


proboards must be having problems again...


EDIT2:
if I were you diddy,
I've only worked on the bu32 function for you...

big-endian unsigned 32bit structure

I don't think you'll need to use little-endian handling as Nintendo generally sticks to big-endian. (so I've heard)

apparently that little 'FE FF' in brres files means big-endian...
'FF FF' means little-endian... :-\


anyways...
the other byte structures for big-endian are:
unsigned intergers:
bu64
bu32 (already have)
bu24
bu16
bu8 (don't need unless you want)

signed intergers:
bs64
bs32
bs24
bs16
bs8 (you might need this)

IEEE754 floating point (decimal) format:
bf64
bf32
bf16 (maybe)


if you need some coding reference,
my '__BIT' function in UMC dev4 handles all of those and more.
so that code amplifies?  i stil cant parse data yet and for the target file to affect, you want this to be fixed? or variable (based on user input)