Fancy Knowledge #3 - Using Two Different Musics In One Event
Many people were asking me how I did that "music replace" in zel's Shiny Gold hack. They
were wondering how it was possible for zel to use different musics for different battles. Well here is, how
it works. (On Fire Red US ONLY!!! You have to find the offsets for your desired version by yourself!!)
It looks like this:
00cffef0h: FE B4 05 1C 1B 48 20 49 00 F0 33 F8 00 22 90 42 ; ...H I.3."B
00cfff00h: 0B D0 03 88 1B 49 8B 42 07 D0 AB 42 05 D1 17 48 ; ...IB.ЫB..H
00cfff10h: 19 49 00 F0 26 F8 05 88 12 E0 13 48 16 49 00 F0 ; .I.&...H.I.
00cfff20h: 20 F8 00 22 90 42 0B D0 03 88 12 49 8B 42 07 D0 ; ."B...IB.
00cfff30h: AB 42 05 D1 0E 48 10 49 00 F0 13 F8 05 88 FF E7 ; B..H.I...
00cfff40h: 28 04 FE BC 0D 4A 04 B4 0D 4A 0E 49 40 0B 40 18 ; (..J..J.I@.@.
00cfff50h: 83 88 59 00 C9 18 89 00 89 18 0A 68 01 68 10 1C ; Y.....h.h..
00cfff60h: 00 BD 08 47 14 10 00 00 15 10 00 00 16 10 00 00 ; ..G............
00cfff70h: 17 10 00 00 FF FF 00 00 55 E4 06 08 0F D1 1D 08 ; ......U.....
00cfff80h: 9C 32 4A 08 CC 32 4A 08 00 00 00 00 00 00 00 00 ; 2J.2J.........
Insert it where you want. I used that adress only due to testing reasons. Little explanation:
(the first lines are the routine itself, the following words are data):
0xcfff64:
[14 10 00 00] // nr of 1st variable containing music number to replace
[15 10 00 00] // nr of 2nd variable containing music number to replace
[16 10 00 00] // nr of 1st variable containing the value to replace with
[17 10 00 00] // nr of 2nd variable containing the value to replace with
[FF FF 00 00] // value the vars have to be set to in order to disable the track loader
[55 E4 06 08] // std_func_getvaradress + 1; don't change it!
[0F D1 1D 08] // return adress + 1
[9C 32 4A 08] // channel table (usually you don't have to change it)
[CC 32 4A 08] // pointer to the music-pointer-table
To attach the script to the musicloader goto 0x1DD0F6 and replace the bytes from
0x1DD0F6 to 0x1DD10E with
01 49 08 47 00 00 [XX XX XX XX] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Replace the [XX XX XX XX] by the pointer to the location where you've inserted the
long script from above. (For me, it would be F1 FE CF 08)
The bytes after that location should be 00 F0 A2 FB 01 BC (of the original rom...)
That's how to insert it, but how does it work? Assuming, you're in Kanto
and you want to replace the normal wild battle music with the one of Kanto you would have to set the first
variable's value to the normal music-number (the one Sappy displays). I defined the first var
as var number 0x1014. So I would type in a normal pokescript something like "setvar 0x1014 #battlemusicnumber".
Then have I look for the new music-number in Sappy. The first var - containing the value to replace with - is
defined as var nr. 0x1016. I type "setvar 0x1016 #newbattlemusicnumber".
I'm using two pairs of variables since I thought it would be useful for you if you
want to replace e.g. the battle music AND the fanfare played afterwards. Pair 0x1015 and 0x1017 works like
pair 0x1014 and 0x1016. |