View Single Post
Old June 26th, 2013, 09:24 AM
du bist n00b
Join Date: Nov 2011
Location: A tree
Gender: Male
Nature: Bold
Hello. In this post, I am going to show you the easiest way possible to extend the songtable of any GBA game.

What we need:
- Sappy
- A Hex Editor (I'll be using HxD but any editor would work)
- A brain

Getting our songtable offset

FireRed: 4A32CC
LeafGreen: 4A2BA8
Ruby: 45548C
Sapphire: 4554E8
Emerald: 6B49F0
2. Navigating to our songtable

Let's say I am using FireRed.

I am opening my ROM with a hex editor.

I am going to the songtable offset, which is 4A32CC is my case.

Mark every byte there is until the end of the songtable (consecutive 00s). In FireRed, the end of the songtable is exactly at:
(In a case you didn't change it)

Now, copy all the bytes you marked and navigate to any free space after:
I'll be using offset
Paste the bytes and remember the offset you pasted the bytes to. Now, go to the start of the NEW songtable and search the bytes:
8C BE 6F 08
. After those bytes, write
00 00 00 00 8C BE 6F 08

Now, Open the sappy.xml file and change the songtable of the free space offset you picked up, make sure you change the songtable to the correct game code.

Now, open up sappy and play song 347. You should hear Teachy TV song. That's good.
If you don't, you probably did something wrong.

Now, close sappy and open up the hex editor. Click CTRL+F and search the bytes: Your songtable in reserve hex. Reserve hex is simple, in my case, the songtable is
, so this offset in reserve hex is CC 32 4A. If you found the right bytes, there should be CC 32 4A 08. Simply overwrite the CC 32 4A to the NEW songtable in reserve hex.
in reserve hex is
 00 00 96
But if you might notice there are MULTIPLE CC 32 4As around there. overwrite ALL OF THEM.

Open up Sappy and navigate to the last song. In FireRed, it's songnumber
Click on the right arrow to navigate to the next song.

Click on assemble song and choose in a random song.

Change the followings:

Base destination offset: Free space to import the song to.
Voicegroup offset: The voicegroup offset...
MST Offset: It will probably be on 347, but if it's not, change it to 347.
Song groups: ALL to 0
. Assemble it and play song 347. You should hear the new song! Congratulations! But, hey, we didn't finish yet!

Go to advance map and change the map music of any place you want to:
15A + M
. Where the M variable stands, put the number of the new song you inserted. Example, if it is the first song I added, I will replace M with 1, if second, I will replace M with 2, if 30, I will replace M with 30, etc.

Now, open the hex editor and navigate to the end of the new songtable. After the new song you inserted's pointer, type:
00 00 00 00
If you won't do that, it won't play ingame!

Now, test that in-game, and if you hear the new song you assembled, congratulations! You extented the songtable!

To make the access to this song easier, open up sappy.xml and navigate to your ROM's songtable. Copy the last song's FULL line and copy it to the next line. If it's teachy TV's line, it should look like that:
            <song track="0x15A">Teachy TV</song>

Simply check out your song's number on sappy (in my case, it's 347), open up Caculator and convert the number 347 from Dec to Hex. You should get 15B. Now, when you got the hex number of the song, simply change the line to:
             <song track="0x15B">New Song W00T!</song>

Let's test!

Yay :<

That's it! Simple, isn't it?

Now, this is for people wants to know how it works:

The 00 00 00 00 8C BE 6F 08 we put contains a pointer. Let me show you:
00 00 00 00 ' I am not sure, I think it is the space between two song pointers.
8C BE 6F ' Teachy TV's location in the ROM, in reverse hex ofcourse.
08 ' It tells the game that the offset we put before is in the ROM.
Now, when we went to song number 347, Sappy was looking for the 8C BE 6F 08 we put before, and as I mentioned earlier, it's the pointer to Teachy TV's song.
Now, once you have assembled a song as song number 347, Sappy replaced the pointer to the Teachy TV's song we put after the 00 00 00 00 with the pointer to our new song's first track!

I hope it helped you!

- Gal

Last edited by xGal; August 16th, 2013 at 03:03 AM. Reason: Le Update