View Full Version : M4A build in assembler (Music)
ipatix
July 2nd, 2011, 08:24 PM
M4A build in assembler
I think everyone who already hacked music knows that the "main" tool Sappy is very buggy and some of them are really nasty.
So I thought about making my own tool and now I want to present it to you.
I think you also should know Sappy's button "Assemble song". My tool actually does exactly the same job than this function but it doesn't "destroy" your ROM and it has also compatiblity to 32MB ROMs.
*UPDATE* the tools now also deletes the old song!
This tool should work for all games that are using the M4A engine (also called sappy engine).
I already tried out Wario Land 4, Golden Sun, Kirby NID, and of course Pokemon.
So let's have a look to the GUI:
http://upload.pokefans.net/m29_54cl51aa4.gif
The steps how to insert a song:
1. Make sure the "MPlayDef.s" library is placed in the same folder than the program.
2. Selcect your mid2agb output (.s file) and your ROM.
3. Type in the track group. Huh, I think you even don't know what it is. Which values you have insert here depends on the game you are using and on the type of song. So if you're using Pokemon games insert "0" for normal song, "1" for a sound effect and "2" for a fanfare and "3" for sound map sound efect (like rain).
4. Type in the songpointer offset. The songpointer is an entry of the songlist and it is needed to change the songpointer that it'll point to your new song. The songpointer is calculated like this:
songpointer_offset = ( song_number * 0x8 ) + songlist_offsetI will post the songlist offsets of Pokemon games below.
5. Just type in an offset of free space (it has to be word aligned).
6. Specify your soundbank/voicegroup
7. Define the "delete byte". The tool will fill the area of the old song with this byte.
8. Than click on "build in this song" and you will finally have a new sequence build in the ROM.
Just note that there are ways to make the program crash or even the song you'll insert:
-The input file is not an mid2agb output or the song syntax is not correct.
-You don't have write access to the programs folder (it will store temporary files there).
Also note that I won't bring out any updates for this toll because it does its job and I'm working on a new uitility that will be a little bit more blind user firendly than this one and will also contain diffrent functions like a music player and such or maybe an instrument set editor.
You can donwload the program from the file attatchment.
It should work on any OS that supports .NET 3.5 ( I used VC# 2008)
So now here are the offset of the songlists:
BPRE: 0x4A32CC
BPGE: 0x4A2BA8
AXVE: 0x45548C
AXPE: 0x4554E8
BPEE: 0x6B49F0
BPRD: 0x4A18F0
AXVD: 0x463428
BPED: 0x6C5BDC
So I hope you'll enjoy the tool!
PS: Greetings from Germany ;)
PokémonShinySilver
July 3rd, 2011, 06:44 AM
Great, excellent! I am so glad we've finally gotten a better music assembler than what Sappy has. Sappy is rather unstable and can crash easily (and crash with certain loop points while testing out the song) and can only support a few .gba ROMs. I'm also looking forward to seeing a sound testing function on it so that anyone can test out their new song that they've inserted and being able to play every single soundbank in the ROM. Sappy could not support every single soundbank and some of them got replaced with simple beeps while testing out a song.
I would also like to suggest having a function that can edit the soundbank possitions and offsets and if there isn't a tool where you can convert a .wav file to a soundbank, then there should be a function in this tool to do so, that way anyone can record and convert their .wav to a soundbank. ;)
ilovecrumpet
August 7th, 2011, 01:19 PM
I'm a noob, so few questions if you don't mind.
1) 1. Make sure the "MPlayDef.s" library is placed in the same folder than the program.
What is this? I don't understand / I don't have a MPlayDef.s library? Where or how do I create one?
2) 6. Specify your soundbank/voicegroup
What is this? Is there a list of these anywhere? Or a method of locating them?
Thanks. All I wanna do is change a Pokémon battle theme x__X How difficult does this need to be D: I tried Sappy but it hates me.
agentgeo
August 7th, 2011, 07:56 PM
I'm a noob, so few questions if you don't mind.
1) 1. Make sure the "MPlayDef.s" library is placed in the same folder than the program.
What is this? I don't understand / I don't have a MPlayDef.s library? Where or how do I create one?
2) 6. Specify your soundbank/voicegroup
What is this? Is there a list of these anywhere? Or a method of locating them?
Thanks. All I wanna do is change a Pokémon battle theme x__X How difficult does this need to be D: I tried Sappy but it hates me.
1. MPlayDef.s is an asm file containing info for every music command. It comes with the tool Mid2Agb.
2. There is a thread posted somewhere with all the voicegroups for FireRed, but the only way is to check through sappy.
EDIT: For those who don't get what track group really is, you could also think of it as a "priority" property. The lower the number, the less precedence it has. For example BG music is 0 so that sfx can play over top of it.
ilovecrumpet
August 8th, 2011, 12:11 PM
Thanks so much, actually managed to get a song imported now.
One thing I can't figure out (my sappy doesn't work), could someone tell me the soundbank offset for the wild battle theme in pokemon ruby?
Appreciated.
WrathOfArceus
August 8th, 2011, 03:51 PM
It Does not Work for me. When i open a Rom or S.file i get an annoying error
Full Metal
August 8th, 2011, 04:03 PM
That's a pretty good indicator that you're doing something wrong.
You know what would be really helpful?
A screenshot, or even a description of what the error says.
...yup. Maybe then useful information can be given to you. (;
ruup20
August 8th, 2011, 07:20 PM
I have a problem. If I press "build in this song" it simply does nothing.
ipatix
August 10th, 2011, 08:25 AM
@ruup20:
Tell me exactly what you've done and can you upload your .s file?
@WrathOfArceus:
What kind of error message do you get?
Are all your offsets word aligned?
@ilovecrumpe:
You may tiy out the old Version of Sappy (2005), or the MIDI only version (1.6).
Sappy 2005: http://www.megaupload.com/?d=UYUJRP62
Sappy 1.6 (midi only): http://www.megaupload.com/?d=45LLIDH8
ruup20
August 10th, 2011, 11:36 AM
I just did what I had to do and nothing worked.
Full Metal
August 10th, 2011, 03:24 PM
I just did what I had to do and nothing worked.
Then wouldn't it make sense to say you did not do what you had to do so therefor nothing worked the way you thought it ought? Hm?
Perhaps a screenshot would be nice to have, followed by step-by-step informations of what excatly you did.
WrathOfArceus
August 10th, 2011, 03:38 PM
My error says Unhandled Exception has occurred in your application
Full Metal
August 10th, 2011, 03:56 PM
^that^ makes debugging so much easier, believe it or not.
All the writer needs to do is wrap his code in try/catch statements now, and then he can figure out where the error comes from. :)
ruup20
August 10th, 2011, 04:53 PM
okay now it just freeze... Or it just take much time to load.
ipatix
August 10th, 2011, 05:07 PM
@ruup20:
I'm sorry, the version I uploaded was out of date and didn't worked with .s with only 1 track.
I now uploaded a newer version!
@WrathOfArceus (http://www.pokecommunity.com/member.php?u=273657):
Can you give me your .s file or even tell me what kind of Unhandled Exception occurred (click on the details button).
Full Metal
August 10th, 2011, 05:37 PM
@ipatix - what language is this written in?
ruup20
August 10th, 2011, 06:08 PM
And how do I put it in a town/route?
Full Metal
August 10th, 2011, 06:32 PM
...You insert it into the correct spot... x)
ipatix
August 10th, 2011, 09:05 PM
@ipatix - what language is this written in?
Visual C# 2008 (.NET 3.5)
SK3
August 10th, 2011, 09:06 PM
Okay, so I loaded my ROM, loaded my .s file, put in the Song Pointer, the track data, and the soundbank offset. When I clicked assemble, I got the Unhandled Exception error, but I pressed continue, and the log continued to work. But then it got stuck on "Getting lengths of tracks". What did I do wrong?
Full Metal
August 10th, 2011, 09:38 PM
Visual C# 2008 (.NET 3.5)
I see.
I was going to ask to see the source, and maybe debug it with/for you. Unfortunately, I'm not so sharp at...C# ( no pun intended. x) )
WrathOfArceus
August 11th, 2011, 02:31 AM
Details Of My Error
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.BadImageFormatException: Retrieving the COM class factory for component with CLSID {DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7} failed due to the following error: 800700c1.
at System.Windows.Forms.OpenFileDialog.CreateVistaDialog()
at System.Windows.Forms.FileDialog.RunDialogVista(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
at WindowsFormsApplication1.Form1.button2_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4961 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
M4A build in Assembler
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Users/Owner/AppData/Local/Temp/Rar$EX83.752/M4A%20build%20in%20Assembler.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4961 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4957 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
ipatix
August 11th, 2011, 08:02 AM
Can you give me your .s file or the patch of your ROM?
That could help me!
WrathOfArceus
August 11th, 2011, 08:08 AM
there's the S. File i was trying to insert
ipatix
August 11th, 2011, 10:11 AM
@WrathofArceus:
Did you overwrite a song that was damaged?
Because it seems that the program has crashed after getting the length of the old trackdata to remove them.
@Full Metal:
Okay you can get the source code, but I can't give it to you now because my other PC got a virus.
I will tell you when I can give you the source ;-)
Full Metal
August 11th, 2011, 02:58 PM
Haha, okay. I really was going to just try and debug WOA's issue, but it looks like you've got it figured out. (:
Robey
August 11th, 2011, 03:15 PM
Yesss! Finally a replacement for sappy!
Just one part I don't understand though. Does the delete byte have to be anything in particular? If so, how do we know what it is?
ruup20
August 11th, 2011, 05:15 PM
You can find the voicegroups for FR here (http://www.pokecommunity.com/showthread.php?t=148811)
Oh, and is the delete byte just FF or 00? And I really don't know how to place it in a town like Pallet town. :(
WrathOfArceus
August 11th, 2011, 06:03 PM
No,But It dosen't work for me
ipatix
August 11th, 2011, 09:47 PM
For all people that don't understand: Your old trackdata will get filled with the value of "delete byte" for saving space.
So usually the delete byte is "0xFF" but you can use any other value you want!
SK3
August 11th, 2011, 10:06 PM
Okay I tried to replace Pallet Town, and I believe I put all of the right values, and the tool said song successfully imported, but when I opened my ROM Pallet Town still played? :(
ipatix
August 12th, 2011, 09:17 AM
I think you did use a not correct song pointer offset.
Make sure you did the calculation like I showed in the first post.
You can also look if some other songs now have changed!
SK3
August 12th, 2011, 11:50 PM
Yeah, I multiplied the Pallet Town song number (012C) by 0x8 and then added the songlist pointer to that, and then I completed the rest of the steps and nothing happened.
I'll check to see if the other songs changed though.
Edit: So the music that plays when Oak first confronts you changes to the song I inserted XD. I don't know how that happened.
johnr754
October 22nd, 2011, 04:34 PM
I did not try it out yet, but I hope I can import songs from Mother 1+2 and Mother 3 to my hack. If I can, I would change Pallet Town to.....let's just say Eagleland after defeating Giygas. And, several others. I would not do Sappy anyways. I guess Sappy is sappy right now!
supershadow64ds
December 9th, 2012, 05:08 AM
Alrighty, I can insert the song and it plays, however, the song is just on 1 channel, and it's just a "boop" noise, something that sounds like an undefined instrument. Is there something I'm doing wrong? Am I compiling the song wrong in MID2ABG?
If it helps, I don't strip the MIDI into seperate files for each track because I can't recompile the .s files into one large .s file.
Team Fail
December 9th, 2012, 04:41 PM
Alrighty, I can insert the song and it plays, however, the song is just on 1 channel, and it's just a "boop" noise, something that sounds like an undefined instrument. Is there something I'm doing wrong? Am I compiling the song wrong in MID2ABG?
If it helps, I don't strip the MIDI into seperate files for each track because I can't recompile the .s files into one large .s file.
One thing that could cause that is that you may be using the wrong voicegroup. Are you sure you're using the correct one?
Dylanrockin
December 23rd, 2012, 01:23 AM
I keep getting this error, I am not quite sure what this means or how to get around it. Deleting temporary files...
Running ARM Assembler...
Assembly failed!
Song import halted!