gamesharkhacker
SupremoHack Entertainment Inc.
- 47
- Posts
- 15
- Years
- In a massive hole :)
- Seen Jun 23, 2012
![[PokeCommunity.com] GSH's GBA Music Knowledge [PokeCommunity.com] GSH's GBA Music Knowledge](https://supremohackentertainmentinc.yolasite.com/resources/GSH's%20GBA%20Music%20Knowledge%20logo.png)
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.
<<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:
![[PokeCommunity.com] GSH's GBA Music Knowledge [PokeCommunity.com] GSH's GBA Music Knowledge](https://supremohackentertainmentinc.yolasite.com/resources/GSH's%20ELF%20Method%20for%20Music%20Inserting%20logo.png)
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...
![[PokeCommunity.com] GSH's GBA Music Knowledge [PokeCommunity.com] GSH's GBA Music Knowledge](https://supremohackentertainmentinc.yolasite.com/resources/GSH's%20ELF%20Method%20for%20Music%20Inserting%20pic%201.png)
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...
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...
![[PokeCommunity.com] GSH's GBA Music Knowledge [PokeCommunity.com] GSH's GBA Music Knowledge](https://supremohackentertainmentinc.yolasite.com/resources/GSH's%20ELF%20Method%20for%20Music%20Inserting%20pic%202.png)
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.
<<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.
Last edited: