ff3:ff3us:tutorial:music:songdata

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ff3:ff3us:tutorial:music:songdata [2018/02/22 08:06]
madsiur [Copying the song data]
ff3:ff3us:tutorial:music:songdata [2019/02/12 12:05]
Line 1: Line 1:
-===== Insert Manually a Song Available on the Forum ===== 
-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 [[https://www.ff6hacking.com/misc/songsdata/FF4_prologue.7z|"The Prologue"]] from our [[https://www.ff6hacking.com/forums/thread-2558.html|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 {{rh:util:hex:hxd_1.7.7.0.zip|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: 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-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 [[https://www.fantasyanime.com/extracted-game-music|extracted music tutorial]] at FantasyAnime.com.  **prologue_DATA.bin** and **prologue_INST.bin** 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 samll "p" 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 [[ff3:ff3us:doc:asm:rom_map:unused_space|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). 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. 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-pointers.png}} {{ff3:ff3us:tutorial:music:songdata:sd-song-pointers-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**\\ 
-{{ff3:ff3us:tutorial:music:songdata:sd-code-pointers.png}} 
- 
-**Modified code**\\ 
-{{ff3:ff3us:tutorial:music:songdata:sd-code-pointers-modified.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 **prelude_DATA.bin** 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. 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-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 [[ff3:ff3us:doc:asm:rom_map|ROM map]] to verify. All you have to do is add to your song offset the song legth and verify it is lower than next data. If you only replace a song by //The Prelude//, check the [[ff3:ff3us:doc:asm:list:music|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"//. 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-offset.png}} 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-calcl-room.png}} 
- 
-We are below the limit with our 0x044C bytes for //The Prelude// so we are ready to insert the song! 
- 
-==== 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 ed of the song pasted. 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-paste-start.png}} {{ff3:ff3us:tutorial:music:songdata:sd-song-paste-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. 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-paste-zero.png}} 
- 
-==== Changing the song pointer ==== 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-calc-ptr.png}} 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-song-pointer.png}} 
- 
-==== Changing the song instruments ==== 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-calc-inst.png}} 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-instrument-paste.png}} 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-instrument-new.png}} 
- 
-==== Details on song channels ==== 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-channel.png}} 
- 
-{{ff3:ff3us:tutorial:music:songdata:sd-channel-loop.png}} 
- 
-==== Conclusion ==== 
- 
-==== Result in-game ==== 
-{{ff3:ff3us:tutorial:music:songdata:sd-result.mp4?384x336}} 
  • ff3/ff3us/tutorial/music/songdata.txt
  • Last modified: 5 years ago
  • (external edit)