View Single Post
  #2    
Old December 16th, 2011 (07:59 AM). Edited December 16th, 2011 by Shiny Quagsire.
Shiny Quagsire's Avatar
Shiny Quagsire Shiny Quagsire is offline
STOP HIM SAM, HE'S GONNA TELL US A STORY!!!
 
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 17
Gender: Male
Nature: Jolly
Posts: 689
Quote originally posted by Chaos Rush:
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:
http://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:
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@.@...Y.É.....
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.ÿÿÿÿÿÿÿÿ
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:
Code:
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@.@...Y.É.....
00800090  0a 68 01 68 10 1c 00 bd 08 47 00 00 30 50 00 00  .h.h...½.G..0P..
008000a0  31 50 00 00 32 50 00 00 33 50 00 00 34 50 00 00  1P..2P..3P..4P..
008000b0  35 50 00 00 ff ff 00 00 51 a0 11 08 13 df 1d 08  5P..ÿÿ..Q ...ß..
008000c0  5c 54 45 08 8c 54 45 08 ff ff ff ff ff ff ff ff  \TE..TE.ÿÿÿÿÿÿÿÿ
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:
Code:
001ddef0  99 ff 01 bc 00 47 00 00 00 b5 01 49 08 47 00 00  .ÿ.¼.G...µ.I.G..
001ddf00  01 00 80 08 00 00 00 00 00 00 00 00 00 00 00 00  ................
001ddf10  00 00 00 00 00 f0 a2 fb 01 bc 00 47 5c 54 45 08  .....ð¢û.¼.G\TE.

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?
First off, it works just fine. Chances are if there's an official or thoural document, it works. If it doesn't, that'd be your fault.

Second, it's not that easy to convert a routine to Ruby. Register variables may be different.
__________________



Reply With Quote