Users browsing this thread: 1 Guest(s)
Copying to your ROM a song available on the Forum

#1
Posts: 3,969
Threads: 279
Thanks Received: 236
Thanks Given: 57
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Insert Manually a Song Available on the Forum

The original tutorial can be found on the FF6 Hacking wiki.

In this tutorial we'll be importing in FF3us a song that is already in FF6 music format. There is no need for musical knowledge to be able to complete the following steps. The only things that will help is being familiar with the hexadecimal system as well as some basic ROM hacking knowledge like what is an offset, the difference between an absolute and HiROM offset and how to use an hex editor.

1. Getting the file and tool
We'll be using the FFIV song The Prologue from our Song Database. The other thing you will need is a hex editor. There are many you can choose from but I'd suggest one that has a copy selection, paste-write and paste-insert functionalities. One good all purpose hex editor is HxD and this is what has been used to take the screenshots below.

2. Files we will be importing
Extract the files from FF4_prologue.7z and you will see the following files:
[Image: fetch.php?media=ff3:ff3us:tutorial:music...folder.png]

**prologue.spc** is the song in SNES format. Those can be played with a SPC player or with winamp and a plug-in. For more info on SPC file and how to play them, use Google or check the great extracted music tutorial at FantasyAnime.com.  The DATA ans INST files are two binary files, the first has the music data in FF6 format and the other the instruments used in the song. The DATA and INST files do not contain instrument samples, those are in the game.

All songs in our song database have the three same files. Some songs, mostly done by tsushiy and having a "ᵖ" next to their title need the instrument patch, available in the same thread. This patch install new BRR samples in the game, giving access to a wider range of instruments to use in songs. Some songs instrument file use those added instruments.This is not the case of our prologue song.  

3. Choosing the right spot
The first thing that you have to ask yourself is "do I want to replace an existing song or expand the number of existing songs?" If you only want to replace a existing song you can skip to section 4. To expand the number of songs there are few thing to do. First you have to move the $C53E96-$C53F94 song pointers block because there is no room to add an extra one. To find a spot in non-expanded ROM, you can look here. The offsets in this list take in account the ROM header though while my whole tutorial assume you have a headerless ROM, so substract 0x200 from the offset you choose. You can also expand your ROM and put the pointers in the $FX banks.

I decided for the example to take the $EEAF01 spot, which has 767 free bytes, which is more than enough. As shown in the image below, I select with the mouse the pointer block, I do Ctrl+C, Ctrl+G to enter my destination (you can scroll a long time for the same result) and then Right-Click->Paste write. Now let's say I would put my song at $F30540 in expanded ROM, I would type 40 05 F3 at $EEB0000 (see right picture). You would use song ID $56 for your new song in game events as an example. As you have guessed pointers are always inverted whether they are two or three bytes long. As for the old pointer data copied, you can blank with 00 or FF all the data since you moved it, giving you room for other things if needed.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...inters.png] [Image: fetch.php?media=ff3:ff3us:tutorial:music...-reloc.png]

The next thing to do is to change the following code. It's the only place pointers are read and you have to modify each LDA instruction so new base offset, new base offset + 1, new base offset + 2. This is not an ASM course so I'm not explaining further except only mentioning you have a total of 9 bytes to change.

Original code
[Image: fetch.php?media=ff3:ff3us:tutorial:music...inters.png]

Modified code
[Image: fetch.php?media=ff3:ff3us:tutorial:music...dified.png]

Last thing to do is changing the total number of songs. The offset is $C53C5E. It's a single byte that should be $55. Increase it of one each time you add a new song (replacing an existing one does not count). So congratulation you have not expanded pointer and can add as much songs as you want up to a limit of 255!

4. Verifying the song length
The next thing to do is verifying if your song fit in the spot you have chosen. If you expanded the song pointers and put your song in expanded ROM, you'll likely won't have to consider the following but some info is still important. Open the DATA file with HxD. The first two bytes (inverted) are the amount of bytes the song take. In our case it is 0x044C bytes, as seen below.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...length.png]

You have to verify the song will not "hit" the next song or the data after. If you locate your song in regular non-expanded ROM but outside the songs block, refer to the ROM map to verify. All you have to do is add to your song offset the song length and verify it is lower than next data. If you only replace a song by The Prelude, check the song list. Song are in order that they appear in the ROM. You need to consider the song following yours. I decided we are replacing Another World of Beast.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...offset.png]

[Image: fetch.php?media=ff3:ff3us:tutorial:music...l-room.png]

We are below the limit with our 0x044C bytes for The Prelude so we are ready to insert the song!

5. Copying the song data
Copy all the content of prelude_DATA.bin (Ctrl+C) go to your ROM do Ctrl+G and enter 08EFA6. You'll land on the offset you need to paste the song data (Right-click->Paste-write). The below two screenshots are the beginning and end of the song pasted.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...-start.png] [Image: fetch.php?media=ff3:ff3us:tutorial:music...ending.png]

You can optionally put 00 or FF at the place of the rest of the old song. This way you can easily see where there is unused space.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...e-zero.png]

6. Changing the song pointer
If you have to put your song elsewhere in the ROM, you need to modify the pointer and you can calculate its position will the below formula. It's simply pointers base offset + (song ID multiplied by 3). The other method is doing a hex search in HxD with the old offset of the song. In the case of as an example $C8EFA6, search for A6EFC8.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...lc-ptr.png]

[Image: fetch.php?media=ff3:ff3us:tutorial:music...ointer.png]

7. Changing the instruments
Now the other part of the job is changing the song channels instruments. It's the same logic to calculate the beginning of a song instruments, except you multiply your song ID by 32 (0x20). The instruments file is 32 bytes in size (16 channels times 2 bytes per instruments). First byte is instrument ID, second byte is always 00.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...c-inst.png]

Once the instruments data is pasted, save your ROM. Note that you can save (Ctrl+S) anytime during the tutorial, it does not matter.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...-paste.png]

You'll notice The Prelude has 6 instruments. As mentioned previously some songs downloaded from the forum (not a majority) might have incorrect instruments. In such an event, you'll need to assign the correct instruments. There is a complete list of original instruments here. You'll need to identify each channel instrument and replace what you think are the wrong ones. A bit trial and error but you'll develop your music skills. If you have instruments IDs in your file from $40 and above it mean your song require the instrument patch available in the same thread as the songs. The songs requiring will have a "ᵖ" next to their name. The wrong assigned instruments are often those, because the author added more instruments in his hack without noticing the admins, resulting in instrument indexes above the limit of the patch.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...nt-new.png]

8. Details on song channels
A thing that differs between songs available on the forum and original songs are the channel pointers in the song. Below is a channel of The Prelude and the song at the end loop toward the beginning of the blue section. The last command is F6 02 04 which mean continue by going back to 0x0402 byte after the start of the song. Every song in the original game have these command relative to their offset in the ROM meaning this F6 command would look like as F6 8E F3 ($C8F38E). It would not be exactly this because a song don't redo the first channel commands twice but I talk about this because such a tutorial would not have been possible with an unmodified original song, because when you move it you need to change all the song loop commands and channel pointers at beginning of song data. By having the custom song channel pointers start at 00 00 and not the song offset last two bytes, we easy the process a lot.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...hannel.png]

Below, a loop command of an original song pointing at $C8F9B9. In the case of a custom song, we would see more or less F6 0X XX, likely a number below 0x0A00.

[Image: fetch.php?media=ff3:ff3us:tutorial:music...l-loop.png]

9. Conclusion

This tutorial was aimed at beginners. The rest of music hacking is harder and require some practice. However it is in the range of anyone having the time and patience to learn. As a conclusion I've made a small video showing the import and at the same time did a little tribute to those who contributed to the song database.

10. Result in-game
  Find
Quote  
[-] The following 1 user says Thank You to madsiur for this post:
  • SSJ Rick (02-23-2018)

#2
Posts: 315
Threads: 50
Thanks Received: 7
Thanks Given: 25
Joined: Feb 2012
Reputation: 4
Status
None
Thanx for posting this Mad! I would have given more info but I am at work and without access to my documents xD


[Image: 5452812CeqVF.png]
[Image: RoyakenGif_zpsacedef24.gif]
  Find
Quote  

#3
Posts: 47
Threads: 7
Thanks Received: 5
Thanks Given: 5
Joined: Aug 2014
Status
None
I have a questions where's the code of this theme:

Code:
C2/BF3B: 24 (Battle Theme)
C2/BF3C: 14 (Boss Theme)      
C2/BF3D: 33 (Atma Weapon)
C2/BF3E: 2E (Returner)        
C2/BF3F: 1A (Factory)          
C2/BF40: 3B (Final)          
C2/BF41: FF (current 1)
C2/BF42: FF (current 2)

I want to replace one of the battle song example I want to replace Returners' theme into Battle Scene 2 In FFII:dawn of soul, where's the song location of this 6 battle theme(except 2 FF "Both Current Song 1 and 2") music codes......?
  Find
Quote  

#4
Posts: 2,549
Threads: 98
Thanks Received: 147
Thanks Given: 158
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
In this tutorial there is a list of all the song addresses:
https://www.ff6hacking.com/forums/showth...ic+hacking


We are born, live, die and then do the same thing over again.
Quote  

#5
Posts: 47
Threads: 7
Thanks Received: 5
Thanks Given: 5
Joined: Aug 2014
Status
None
@Gi Nattak I saw the location song codes you gave sir Is this a header roms right!?Anyway thanks matee I learn step by step on how to replace the song but still I have to learn more Hold on.........
  Find
Quote  

#6
Posts: 3,969
Threads: 279
Thanks Received: 236
Thanks Given: 57
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Update 2018: I gave this tutorial a major facelift! Victory
  Find
Quote  

#7
Posts: 35
Threads: 2
Thanks Received: 0
Thanks Given: 0
Joined: Apr 2018
Reputation: 2
Status
Afterglow
I have a question about this. I was following the steps and I think I got it right so far. Since I have a headered rom, (thus adding 200 bytes to everything) I allocated C54096-C54194 to the $EEB101 spot, and I changed the place pointers of the 9 bytes mentioned in the tutorial. I changed the byes at $c53e5e from $55 to $56 and pasted the new song where i had blank space at $E4f32D and the pointer value should be 2df334.

Since 00 counts as a song and based on the music library I read, I figured song 56 should be 55 so I did the formula:
$EEB101+(0x55 times 0x03)=$EEB200 so there i put the pointer value 2df334 there

I tried to do the formula for the instrument pointer for said song C54195+(0x55 times 0x20)=C54C35

However I realized that I can't paste instruments there, can I? Since that song didn't exist, there's no data for it. Does that mean the instruments need to be allocated as well, if so how much of it, and where?

I decided to leave it out for the moment to test it. Since I have no idea how music gets called in the game, I attempted to use Zone Doctor and switch the music tab to 85___ thinking that's where it might be and saved it, but to my dismay when I entered the town, nothing was changed.

I've been trying to learn this stuff for the past 5 hours, and I feel like I'm close, but I need some direction here, if I may ask for some help on what to do, thank you.
  Find
Quote  

#8
Posts: 3,969
Threads: 279
Thanks Received: 236
Thanks Given: 57
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(04-27-2018, 04:54 PM)Mutteo Wrote: I changed the byes at $c53e5e from $55 to $56 and pasted the new song where i had blank space at $E4f32D and the pointer value should be 2df334.
 

Your pointer value will be 2DF3E4.

(04-27-2018, 04:54 PM)Mutteo Wrote: However I realized that I can't paste instruments there, can I?  Since that song didn't exist, there's no data for it.  Does that mean the instruments need to be allocated as well, if so how much of it, and where?

Usually one option can be to relocate instrument data right after song pointers ($C53F95-$C54A34), anywhere where you have space for all of them plus what you want tot add. One option can be to expand the ROM and use a F bank, as an example putting them at $F30000. That leaves you some room to write more song pointers but song pointers can be relocated as well like in the tutorial. It's not the way the tutorial was made so I might change this for the future. There's nothing telling the game something is out of range, so as long as you have room you can add instrument data.

I think only this instruction need to be changed if you relocate the instrument data:

Code:
C5/01E2:    BF953FC5    LDA $C53F95,X  (Table of Sample Indexes For Each Song, this determines which BRR samples to load)

It's nice to see people using the tutorial, don't give up!
  Find
Quote  

#9
Posts: 35
Threads: 2
Thanks Received: 0
Thanks Given: 0
Joined: Apr 2018
Reputation: 2
Status
Afterglow
Thank you. I have been at it for a while, and I really don't want to fail this one. I decided to start over and tried it a bit differently. Again I'm using a header for this. I used YS III The Boy who Had Wings for an Example, and used Zone Doctor afterward to change the song tab

So I took c54195-c54c34 (header) instrument index and pasted to FF0000 (header)
then at c503e2 (header): bf953fc5 change to BF00FEFE
changed C53E5E (header): 55 to 56
at C54195 I put in 2DF3F4
I pasted the song data to F4F32D and set the pointer at C54195 to 2DF3F4
Then I copied the instrument data at FF0AA0

So I loaded the game up, and I could tell it was trying to load the song but all I heard was a flatline buzzing sound. I feel like I'm missing something here.
  Find
Quote  

#10
Posts: 3,969
Threads: 279
Thanks Received: 236
Thanks Given: 57
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(04-28-2018, 12:31 AM)Mutteo Wrote: So I took c54195-c54c34 (header) instrument index and pasted to FF0000 (header)
then at c503e2 (header): bf953fc5 change to BF00FEFE
changed C53E5E (header): 55 to 56
at C54195 I put in 2DF3F4
I pasted the song data to F4F32D and set the pointer at C54195 to 2DF3F4
Then I copied the instrument data at FF0AA0

Ok, first three steps are good. You got a good understanding of the effect of an header. For 4th and 5th steps, if you put the song data at $F4F32D (header), pointer will need to point at $F4F12D (because you use a header), so pointer value at $C54195 will be 2DF1F4.

Finally instrument data is adding $20 bytes at $FF0AA0, so you instrument data will cover from $FF0AA0 to $FF0ABF. I think you got that right.

There isn't more than this to it except referencing song $56 in an event or in code, if you still got issue, something in the process is not done correctly. You might want to remove the header and re-attempt this, header are confusing and they serve no real purpose. If all fails, I could look at your ROM Sunday and find your error, you've done most of the process correctly from what you post.
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite