The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.


Reply
 
Thread Tools
  #1    
Old February 18th, 2011, 05:34 AM
gamesharkhacker's Avatar
gamesharkhacker
SupremoHack Entertainment Inc.
 
Join Date: Jun 2009
Location: In a massive hole :)
Gender: Male
Nature: Careful

Info on Tables and Header in GBA music:
Spoiler:

For this tutorial i'll use the Champion Battle Theme out of Pokemon FireRed.
<<TABLES>>
 
The table for the whole game is a list of pointers to the headers of songs. A table for one particular song is simply just a pointer. But Sappy likes to call it a table. So we don't get confused, we'll call it the "song pointer".
The pointer needs to be rearranged like so:
The 4 bytes look like this:
E0 CF 6D 08
Rearrange it, like this:
08 6D CF E0
Put it together, like this:
086DCFE0
Then get rid of the "08" byte and replace it with "0x". It should then look like this:
0x6DCFE0
There you go. That is the "song pointer" to the header of the song.
 
<< HEADERS >>
Ok, the next thing in the song is the songs header. The first two digits (the first byte) is the number of tracks in the song in hex.
In the Champion Battle Theme the first two digits are "0A" which when translated into decimal, means "10". This tells us that this song has 10 tracks in it. The next two bytes are both "00" which are not important in the song. The next byte "B2" is a byte that.. well.. Just don't touch it. Last time I touched it, it stuffed up the song.
The following 4 bytes is the offset to the voicegroup. In order to read them properly we need to rearrange each byte.
 
For example:
The 4 bytes look like this:
78 88 49 08
But when rearranged, it should look like this:
08 49 88 78
Which when put together looks like this:
08498878
Then get rid of the "08" byte and replace it with "0x". It should then look like this:
0x498878
Voila! The offset to the voicegroup. If you want proof, you can have look in Sappy. It is EXACTLY the same.
The following bytes after that, are the offsets to each track eg. Track 1 then track 2, track 3 etc. In order to read them properly we need to rearrange each byte just like we did for the voicegroup.
 
For example:
The 4 bytes look like this:
38 A8 6D 08
Rearrange it again:
08 6D A8 38
Then put it together:
086DA838
Replace the "08" byte with "0x":
0x6DA838
That, my friend, is the offset to the first track. The same method applies to the tracks after it.

My ELF Method for inserting Pokemon Music:
Spoiler:



Do not do any of the following to your ROM. Instead use a clean ROM.
This tutorial is only up for experimental purposes and it may destroy your
ROM. Proceed with caution.
 
For this tutorial i'll be inserting a custom Champion Battle Theme into Pokemon FireRed.
 
<<TOOLS>>
Anvil Studio 2011 - link
The Midi2Agb set - no link
Cygnus Hex Editor FREE - link
Sappy 2005 - link
A midi file to insert - no link
 
<<SPLITTING YOUR MIDI FILE>>
First, you need to split your MIDI file into seperate MIDI files for each track. Use Anvil Studio to save each track into seperate files.
This may be boring and repetative, but trust me, its worth it.
Once you have done this, cut or copy your MIDI files into the "mid" folder which is in the "Mid2AGB" folder that you would've downloaded from somewhere.
 
<<MIDI FILE TO GBA FILE CONVERSION>>
Open the program named "tr.exe" or "tr". Then click on the "??" button.
After that the files should be converted and a window should appear that has some jibberish letters in it. Click "OK".
 
<<EDITING AND SAVING THE CONVERTED GBA FILES>>
Next, head over to a folder called "out" in the Mid2AGB folder. There should be several files in that folder
called "pat0.o", "pat1.o", "pat2.o", "pat3.o", and so on. Open each file in Cygnus Hex Editor. You should see a bunch of hex bytes (obviously).
Next you need to select a certain amount of bytes...


Then, press ctrl+c or right click > copy. Then click: File > New, to create a new file. Next, paste the copied hex data into the new file.
Finally, click: File > Save As... Save it in the directory of the ROM you will insert it into. Also, call it something easy to remember like:
towntheme1, battletheme1 or fanfare1, or anything that you think is best. In my case, i will call my file "championbattle1".
For the rest of the tracks, change the number according to the track number. Repeat this for each track.
 
<LOOPING YOUR TRACKS (OPTIONAL)>>
OK, first open up your track files in Cygnus Hex Editor. Go to the very end of the file, where it says "B1". Then...

 

Save the file, and do the same for the rest of the tracks. Done! Your files are now looped.

<<INSERTING YOUR SONG>>
First find some free space. There is heaps of free space starting at 0x71A240 in Pokemon FireRed.
Open your track 1 file in Cygnus Hex Editor. Once loaded, press ctrl+A to Select All then copy the selected hex data.
Copy the data into the free space of your ROM. Just right click where you want it to go and press Paste.
At this point, I strongly recommend that you should open Notepad and copy your offsets down into it because it can get very confusing while copying your tracks in, and you will need the offsets later anyway.
At the byte right after "B1", which is the end of your first track, copy your second track in the same way as you did for the first.
Keep inserting the tracks one after another to the ROM, and make sure you keep COPYING DOWN THE TRACKS OFFSETS INTO NOTEPAD.
When your done, make sure to press Save.
 
<<EDITING THE POINTERS TO THE TRACKS>>
Now, open up your copy of Sappy 2005 and go to the song you are currently working on.
Press ctrl+G and copy the offset after "Header", from Sappy. In my case, the offset is 0x6DCFE0.
 
<<END>>
 
Note: I may put this up as a tutorial if someone can help me figure out why it destroys the ROM and can help me figure out how to fix it. As of now, this tutorial actually kinda works for putting music into a ROM but as you can see it is unfinished, and destroys your ROM. Anyone is welcome to help me out with fixing this tutorial, so just reply to this thread.
Thanks, GSH.

Thanks everyone for reading. From GSH.
__________________
I'm BACK!!!!

GSH - Owner and Creator of
Pokemon PoisonedPyrite/ParalysisPyrite



GSH - Music creator/hacker of
Pokemon Morganite

Last edited by gamesharkhacker; June 8th, 2011 at 08:11 PM.
Reply With Quote
  #2    
Old February 20th, 2011, 06:01 AM
ipatix's Avatar
ipatix
Music Hacking Freak
 
Join Date: May 2008
Location: Germany
Gender: Male
Nature: Relaxed
Does it destroy the whole ROM or does it only destroy your song?

If it destroys only your song I think I know the reason.
When you convert your midis using midi2agb and you have two measures that are exactly the same (which happens usually) there is a command that calls a subsection (byte 0xB3) and after that the pointer to the subsection follows and the pointer depends on where you have placed the track in you ROM (the same can happens when you want to loop the song with the byte 0xB2).
So if you have placed your track to the offset 0x800000 you have to add it to all of the pointers, so if you have a pointer in your song that looks like this 0x8000100 you just add your offset where you saved the track => 0x8800100.

But when you import the tracks using Sappy it does that for you automatically.

I hoped I help you...

If this doesn't helped I cannot help anymore because I have never used this method...
__________________
I'm sorry for my bad English. I'm German...
Visit my YouTube channel (music hacking and other stuff): http://www.youtube.com/user/theipatix

Last edited by ipatix; February 20th, 2011 at 06:07 AM.
Reply With Quote
  #3    
Old April 23rd, 2012, 11:22 AM
supershadow64ds's Avatar
supershadow64ds
Confused GBA Hacker
 
Join Date: Aug 2011
Gender: Male
Nature: Quiet
Unfortunately, Sappy 200X only works for older 64-bit computers. Most people today use 32x computers. Do you happen to know what the header is for the Wild Battle? And if not, could you create a tutorial with using Song Inserter?
__________________
We all live in the network...
Reply With Quote
  #4    
Old June 15th, 2012, 05:24 AM
gamesharkhacker's Avatar
gamesharkhacker
SupremoHack Entertainment Inc.
 
Join Date: Jun 2009
Location: In a massive hole :)
Gender: Male
Nature: Careful
Quote:
Originally Posted by supershadow64ds View Post
Unfortunately, Sappy 200X only works for older 64-bit computers. Most people today use 32x computers. Do you happen to know what the header is for the Wild Battle? And if not, could you create a tutorial with using Song Inserter?
I've been using Sappy 2006 mod 15 lately... linkylinky
And what Wild Battle theme? Would you like the Pokemon Green, Red, Blue, Yellow, Ruby, Sapphire, Gold, Crystal, Silver, Emerald, FireRed, LeafGreen, Diamond, Pearl, Platinum, Black, or White offset?
__________________
I'm BACK!!!!

GSH - Owner and Creator of
Pokemon PoisonedPyrite/ParalysisPyrite



GSH - Music creator/hacker of
Pokemon Morganite
Reply With Quote
  #5    
Old June 16th, 2012, 08:03 AM
Valor
Beginning Trainer
 
Join Date: Jul 2011
Gender: Male
I added a new song using sappy, but I would like a certain trainer class to play that particular song. Unfortunately I can't find the pointer from the trainer class to the song it plays( since each trainer class has it's predetermined song while battling them, like a leader and the champion). Do you happen to know how to change the pointer to your own song.

P.S. I added a song in sappy, I didn't erase any. It's not my intention to overwrite the song since other trainer classes should still be able to use them.
Reply With Quote
  #6    
Old June 19th, 2012, 06:46 PM
thanethane98's Avatar
thanethane98
Self Proclaimed Expert
 
Join Date: Jun 2012
Nature: Relaxed
Quote:
Originally Posted by Valor View Post
I added a new song using sappy, but I would like a certain trainer class to play that particular song. Unfortunately I can't find the pointer from the trainer class to the song it plays( since each trainer class has it's predetermined song while battling them, like a leader and the champion). Do you happen to know how to change the pointer to your own song.

P.S. I added a song in sappy, I didn't erase any. It's not my intention to overwrite the song since other trainer classes should still be able to use them.
Yeah, I'm trying to find out the same thing. I can't seem to find anything on it anywhere.
Reply With Quote
  #7    
Old June 23rd, 2012, 10:29 AM
gamesharkhacker's Avatar
gamesharkhacker
SupremoHack Entertainment Inc.
 
Join Date: Jun 2009
Location: In a massive hole :)
Gender: Male
Nature: Careful
Quote:
Originally Posted by thanethane98 View Post
Yeah, I'm trying to find out the same thing. I can't seem to find anything on it anywhere.

If your talking about having different songs for say, a Youngster and a like Electrician, its impossible, well its possible, but i dont suppose you guys know anyone whos willing to do some severe ASM hacking?
__________________
I'm BACK!!!!

GSH - Owner and Creator of
Pokemon PoisonedPyrite/ParalysisPyrite



GSH - Music creator/hacker of
Pokemon Morganite
Reply With Quote
  #8    
Old December 8th, 2012, 08:05 PM
supershadow64ds's Avatar
supershadow64ds
Confused GBA Hacker
 
Join Date: Aug 2011
Gender: Male
Nature: Quiet
Quote:
Originally Posted by gamesharkhacker View Post
I've been using Sappy 2006 mod 15 lately... linkylinky
And what Wild Battle theme? Would you like the Pokemon Green, Red, Blue, Yellow, Ruby, Sapphire, Gold, Crystal, Silver, Emerald, FireRed, LeafGreen, Diamond, Pearl, Platinum, Black, or White offset?
I apologize for not specifying, but I require the Fire Red both Wild, and Trainer battle themes.

And please do not say "Google is your friend" or any statement similar, Google is not helpful.
__________________
We all live in the network...
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 06:47 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.