- 1,315
- Posts
- 17
- Years
- Seen Jun 11, 2024
One thing that bugs me is that we don't know how to choose which song that plays during a battle on Ruby, but we can in FireRed, thanks to this:
https://sfc.pokefans.net/lesson.php?id=13&lang=en
But that's for FireRed. I want to do it on Ruby.
Anyways, first of all, the code that's posted on that website actually doesn't work on FireRed at all (I tried it and it just freezes), but I noticed that hacks that have that feature actually has a slightly different code that's no where on that website (why is that broken code even on the website?) So going to the music loader offset in both ShinyGold and AzureHorizons, I calculated the offset of the piece of code that actually works for the music hack, and it looks like this:
(this is Pokemon ShinyGold)
It's a little different from the one posted on the website, the difference is that the one on the website doesn't work at all, but this apparently newer routine used in ShinyGold and AzureHorizons works just fine.
So here's what I did to port it to Ruby:
1. First of all, I inserted the main routine at 0x800000:
The underlined bytes are the ones that I changed to adapt to Ruby, which are the variables determining the music hack (since Ruby doesn't go up to 0x7000), and the corresponding pointers towards the end.
2. Then at 0x1DDEFA, I changed the bytes to:
3. Then in a trainer script I have this (copy + paste from XSE's guide lol, but with the music variables added in):
But it doesn't work. The battle music is just the same old generic R/S/E battle music. Does anyone know why?
https://sfc.pokefans.net/lesson.php?id=13&lang=en
But that's for FireRed. I want to do it on Ruby.
Anyways, first of all, the code that's posted on that website actually doesn't work on FireRed at all (I tried it and it just freezes), but I noticed that hacks that have that feature actually has a slightly different code that's no where on that website (why is that broken code even on the website?) So going to the music loader offset in both ShinyGold and AzureHorizons, I calculated the offset of the piece of code that actually works for the music hack, and it looks like this:
(this is Pokemon ShinyGold)
Code:
[FONT="Courier New"]00890a00 fe b4 05 1c 25 48 2c 49 00 f0 46 f8 00 22 90 42 þ´..%H,I.ðFø.".B
00890a10 0b d0 03 88 27 49 8b 42 07 d0 ab 42 05 d1 22 48 .Ð..'I.B.ЫB.Ñ"H
00890a20 25 49 00 f0 39 f8 05 88 25 e0 1d 48 22 49 00 f0 %I.ð9ø..%à.H"I.ð
00890a30 33 f8 00 22 90 42 0b d0 03 88 1e 49 8b 42 07 d0 3ø.".B.Ð...I.B.Ð
00890a40 ab 42 18 d1 19 48 1c 49 00 f0 26 f8 05 88 12 e0 «B.Ñ.H.I.ð&ø...à
00890a50 14 48 19 49 00 f0 20 f8 00 22 90 42 0b d0 03 88 .H.I.ð ø.".B.Ð..
00890a60 14 49 8b 42 07 d0 ab 42 05 d1 11 48 12 49 00 f0 .I.B.ЫB.Ñ.H.I.ð
00890a70 13 f8 05 88 ff e7 28 04 fe bc 10 4a 04 b4 10 4a .ø..ÿç(.þ¼.J.´.J
00890a80 10 49 40 0b 40 18 83 88 59 00 c9 18 89 00 89 18 .I@[email protected].É.....
00890a90 0a 68 01 68 10 1c 00 bd 08 47 00 00 30 70 00 00 .h.h...½.G..0p..
00890aa0 31 70 00 00 32 70 00 00 33 70 00 00 34 70 00 00 1p..2p..3p..4p..
00890ab0 35 70 00 00 ff ff 00 00 55 e4 06 08 0f d1 1d 08 5p..ÿÿ..Uä...Ñ..
00890ac0 9c 32 4a 08 cc 32 4a 08 ff ff ff ff ff ff ff ff .2J.Ì2J.ÿÿÿÿÿÿÿÿ[/FONT]
So here's what I did to port it to Ruby:
1. First of all, I inserted the main routine at 0x800000:
Code:
[FONT="Courier New"]00800000 fe b4 05 1c 25 48 2c 49 00 f0 46 f8 00 22 90 42 þ´..%H,I.ðFø.".B
00800010 0b d0 03 88 27 49 8b 42 07 d0 ab 42 05 d1 22 48 .Ð..'I.B.ЫB.Ñ"H
00800020 25 49 00 f0 39 f8 05 88 25 e0 1d 48 22 49 00 f0 %I.ð9ø..%à.H"I.ð
00800030 33 f8 00 22 90 42 0b d0 03 88 1e 49 8b 42 07 d0 3ø.".B.Ð...I.B.Ð
00800040 ab 42 18 d1 19 48 1c 49 00 f0 26 f8 05 88 12 e0 «B.Ñ.H.I.ð&ø...à
00800050 14 48 19 49 00 f0 20 f8 00 22 90 42 0b d0 03 88 .H.I.ð ø.".B.Ð..
00800060 14 49 8b 42 07 d0 ab 42 05 d1 11 48 12 49 00 f0 .I.B.ЫB.Ñ.H.I.ð
00800070 13 f8 05 88 ff e7 28 04 fe bc 10 4a 04 b4 10 4a .ø..ÿç(.þ¼.J.´.J
00800080 10 49 40 0b 40 18 83 88 59 00 c9 18 89 00 89 18 .I@[email protected].É.....
00800090 0a 68 01 68 10 1c 00 bd 08 47 00 00 [U][B]30 50[/B][/U] 00 00 .h.h...½.G..0P..
008000a0 [U][B]31 50[/B][/U] 00 00 [U][B]32 50[/B][/U] 00 00 [U][B]33 50[/B][/U] 00 00 [U][B]34 50[/B][/U] 00 00 1P..2P..3P..4P..
008000b0 [U][B]35 50[/B][/U] 00 00 ff ff 00 00 [U][B]51 a0 11[/B][/U] 08 [U][B]13 df 1d[/B][/U] 08 5P..ÿÿ..Q ...ß..
008000c0 [U][B]5c 54 45[/B][/U] 08 [U][B]8c 54 45[/B][/U] 08 ff ff ff ff ff ff ff ff \TE..TE.ÿÿÿÿÿÿÿÿ[/FONT]
2. Then at 0x1DDEFA, I changed the bytes to:
Code:
[FONT="Courier New"]001ddef0 99 ff 01 bc 00 47 00 00 00 [B][U]b5 01 49 08 47 00 00[/U][/B] .ÿ.¼.G...µ.I.G..
001ddf00 [B][U]01 00 80 08 00 00 00 00 00 00 00 00 00 00 00 00[/U][/B] ................
001ddf10 [B][U]00 00 00 00[/U][/B] 00 f0 a2 fb 01 bc 00 47 5c 54 45 08 .....ð¢û.¼.G\TE.[/FONT]
3. Then in a trainer script I have this (copy + paste from XSE's guide lol, but with the music variables added in):
'---------------
#org 0x900000
setvar 0x5030 0x1CB
setvar 0x5033 0x1CA
trainerbattle 0x0 0x89 0x0 0x890002C 0x890005A
msgbox 0x890006C MSG_FACE '"Battle at first sight XD"
setvar 0x5030 0x1CA
setvar 0x5033 0x1CB
end
'---------
' Strings
'---------
#org 0x90002C
= Yo, you must be a new trainer.\nLet's battle
#org 0x90005A
= You're not new?
#org 0x90006C
= Battle at first sight XD
But it doesn't work. The battle music is just the same old generic R/S/E battle music. Does anyone know why?