• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Fire Red]: Controlling/Extending Trainer Encounter Music

Jambo51

Glory To Arstotzka
736
Posts
14
Years
  • Seen Jan 28, 2018
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).

Code:
.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:
Code:
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:

Code:
[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:
Code:
1B 01 1C 01 1D 01

Easy, isn't it!
 
Last edited:
142
Posts
15
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.
 

GoGoJJTech

(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
2,475
Posts
11
Years
How do you come up with this jambo?
You just keep proving yourself to be a guru ;)
 

Jambo51

Glory To Arstotzka
736
Posts
14
Years
  • Seen Jan 28, 2018
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:

Code:
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.
 
457
Posts
10
Years
  • Age 28
  • Seen Mar 17, 2024
How about controlling and extending VICTORY MUSIC? I want to make assigned victory themes for teams, E4, and champion. That's a last thing i need. Thanks.
 
Back
Top