The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
Research & Development programs in this forum are subject to moderator approval before they are displayed.


Reply
 
Thread Tools
  #1    
Old December 11th, 2011, 01:28 AM
Chaos Rush's Avatar
Chaos Rush
im sexy and i know it
 
Join Date: May 2007
Location: Taylor Swift
Gender: Male
Nature: Adamant
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):
Quote:
'---------------
#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?
__________________

The Chaos Emerald ROM Base (it's gonna take awhile)

DS-style 64x64 Pokémon Sprite Resource NOW COMPLETED
Custom Sugimori-style Pokémon Sprite Resource IN PROGRESS


My PM box is full and I am choosing to keep it that way.

Non-Pokémon hacks I support:
Sonic Classic Heroes
Sonic 3 Complete
Reply With Quote
  #2    
Old December 16th, 2011, 07:59 AM
Shiny Quagsire's Avatar
Shiny Quagsire
Being a Wizard
 
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 16
Gender: Male
Nature: Jolly
Quote:
Originally Posted by Chaos Rush View Post
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.
__________________




Last edited by Shiny Quagsire; December 16th, 2011 at 08:22 AM.
Reply With Quote
  #3    
Old December 16th, 2011, 08:38 AM
Jambo51's Avatar
Jambo51
Glory To Arstotzka
 
Join Date: Jun 2009
Gender: Male
Nature: Quiet
Actually, it doesn't work "fine". Or, to be more accurate, the version posted by MMX doesn't work fine because it uses variables which are also used by the ROM.

It uses variables 0x7030 - 0x7033 (if I remember correctly) which are "illegal" variables in FR. That is, they share RAM space with the PC box.

That said, the routine itself works fine, its just the variables chosen which cause the problem.

And I actually ported this routine to Ruby before, but have long since lost the code, and I can tell you, that the code was very similar to the original FR code. But that was by sheer coincidence - SQ is right, normally a routine will not use the same registers between 2 versions.
__________________
Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 04:43 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.