.text
.align 2
.thumb
.thumb_func
.global battlemusichack
main:
ldr r0, battlebits
ldr r1, [r0, #0x0]
mov r0, #0x80
lsl r0, r0, #0x5
and r0, r1
cmp r0, #0x0
bne wild
mov r0, #0x80
lsl r0, r0, #0x7
and r0, r1
cmp r0, #0x0
bne later2
mov r0, #0x2
and r0, r1
cmp r0, #0x0
beq one
later2: mov r0, #0x85
lsl r0, r0, #0x1
b end
one: mov r0, #0x8
and r1, r0
cmp r1, #0x0
beq wild
ldr r2, table
ldr r2, [r2, #0x0]
ldr r0, ramoffset
ldrh r1, [r0, #0x0]
lsl r0, r1, #0x2
add r0, r0, r1
lsl r0, r0, #0x3
add r0, r0, r2
ldrb r0, [r0, #0x1]
cmp r0, #0x54
beq gym
cmp r0, #0x57
beq gym
cmp r0, #0x5A
beq champ
push {r2,r3}
ldr r3, terminate
ldr r1, classtable
loop: ldrh r2, [r1, #0x0]
cmp r2, r0
beq loadmusic
cmp r2, r3
beq trainer
add r1, #0x4
b loop
trainer: mov r0, #0x94
lsl r0, r0, #0x1
add r0, #0x1
pop {r2,r3}
b return2
loadmusic: ldrh r0, [r1, #0x2]
pop {r2,r3}
b return2
wild: mov r0, #0x95
lsl r0, r0, #0x1
b return2
gym: mov r0, #0x94
lsl r0, r0, #0x1
b return2
champ: mov r0, #0x95
lsl r0, r0, #0x1
add r0, #0x1
return2: pop {r1}
bx r1
.align
table: .word 0x08044028
battlebits: .word 0x02022B4C
ramoffset: .word 0x020386AE
terminate: .word 0x0000FEFE
classtable: .word 0x08FDFDFD
Create your trainer class table wherever you like (as long as it is 4 byte aligned - ie the location ends with a 0, 4, 8 or a C - so 0x76058C would be acceptable, while 0x741637 would not) in this format:
[Trainer Class - Byte] [00 (Padding) - Byte] [Music to Play - Half-Word (2 Bytes) Ensure it is in the correct format. If you wanted track 0x10D to play, it would be 0D 01]
And place a FEFE0000 at the end of it to signify you have completed the table. Then change the obvious pointer in the ASM I supplied (classtable: .word (Pointer goes here) to poin to your table. Now assemble the ASM using Hackmew's thumb compiler and insert it somewhere in your ROM.
Note the location of the inserted routine down. In your hex editor, navigate to 0x43FD6, and change the code to:
01 48 00 47 00 00 XX XX XX 08
Where the XX XX XX 08 = The pointer to the inserted routine + 1. Ie, if you put the routine at 0x760000, the pointer would be 01 00 76 08.
That should do it.