Welcome to the PokéCommunity!

Hi there! Thanks for visiting PokéCommunity. We’re a group of Pokémon fans dedicated to providing the best place on the Internet for discussing ideas and sharing fan-made content. Welcome! We’re glad you’re here.

In order to join our community we need you to create an account with us. Doing so will allow you to make posts, submit and view fan art and fan fiction, download fan-made games, and much more. It’s quick and easy; just click here and follow the instructions.

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.

<<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.

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...

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?

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 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.

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.

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?

The PokéCommunity

Meta

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, or The Pokémon Company International. We just love Pokémon.