Male
Seen January 28th, 2018
Posted December 6th, 2015
736 posts
14.3 Years
Have you ever noticed that FireRed only has 3 pieces of encounter music for trainerbattles? How limiting! Even using Mastermind_X's code doesn't improve things that much, since it requires careful setting and clearing of variables.

Have you ever wished that you could just define which "Music" number in A-Trainer applied to which track in the ROM?

If so, this hack is for you!

Firstly, assemble this code, remembering to change the YY to the number of encounter tracks you will have - 1 (That is, if you have encounter tracks 0-7 (a total of 8), you would put 7 as the YY number).

.text
.align 2
.thumb
.thumb_func
.global exclaimhack

main:
ldr r1, table // Creates a new table for the music to be put on
cmp r0, #0xYY /*This is the number of encounter music track you want
to have. If you use a value above this, it loads slot 3 of the table as a
failsafe*/
ble back
mov r0, #0x0 // If the slot the game is trying to load is too large, defaults to this slot to prevent crashes
back: lsl r0, r0, #0x1 // Multiplies the slot ID by 2
add r1, r0, r1 // Adds the Slot ID to the Table location
ldrh r0, [r1, #0x0] // Loads the actual song ID from the table
ldr r1, place // Returns to normal execution
bx r1
.align
place: .word 0x080806BB
table: .word 0x08FFFFFF
Then, in a hex editor, navigate to 0x80650, and overwrite the data there with this:
00 49 08 47 XX XX XX 08
Where the XX's stand for the pointer to the new routine plus 1.

All this does is reads the "music" byte which accompanies every trainer battle, and reads a newly created table. This table should have a half word for each entry. Which represents which music slot will be played for that music byte. Create your table wherever you like, then change the table: .word 0x08FFFFFF to be a pointer to this new table.

Build the table like so:

[Track to Play 0][Track to Play 1]
putting in as many entries as you defined above (so, using my earlier example, entries 0 to 7.

So, if you wanted 0x11B to be Encounter 0, 0x11C to be 1 and 0x11D to be 2 (as an example), your table would be:
1B 01 1C 01 1D 01
Easy, isn't it!
Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

RPD490

Male
Blackthorn City, Johto
Seen 1 Week Ago
Posted May 1st, 2023
142 posts
14.7 Years
Makes me curious, what exactly are the numbers for the Music function in A-Trainer, I mean there isn't any guide or references to tell you what number goes to what theme. It is rather annoying.
This signature has been disabled.
Signature is over 600px wide :(
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.

GoGoJJTech

(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)

Age 24
Female
Earth
Seen December 9th, 2016
Posted December 5th, 2016
2,475 posts
10.9 Years
How do you come up with this jambo?
You just keep proving yourself to be a guru ;)
I believe in Jesus Christ my Savior. If you do too, and aren't scared to admit it, then copy and paste this into your signature.
The HGSS Music Patch - The BW/2 Music Patch - ASM: Switch Music Based on Seasons
Romhack.me Profile - Pokecommunity Profile - Youtube Channel

Support me at my site!
Pokémon Platinum Red and Blue
Male
Seen January 28th, 2018
Posted December 6th, 2015
736 posts
14.3 Years
Makes me curious, what exactly are the numbers for the Music function in A-Trainer, I mean there isn't any guide or references to tell you what number goes to what theme. It is rather annoying.
It's defined by ASM in the background to be (basically) this:

if (musicNumber == 1)
{
    return 0x11C;
}
else if (musicNumber == 0)
{
    return 0x11D;
}
else
{
    return 0x11B;
}
Which works for FR's setup, but isn't much good for what we need to do with it in hacking terms. There are other numbers which refer to the music tracks of course, but largely what I showed above is accurate.

How do you come up with this jambo?
Usually boredom combined with an annoyance at a limitation of the engine.

You just keep proving yourself to be a guru ;)
No, just... no. Lol.
Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!