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!