• 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?".
  • 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]: Class Based Trainer Battle Music

1
Posts
9
Years
    • Seen Mar 1, 2015
    I don't know what the second half of that post actually means, as to the title screen freezing (or earlier) that could only happen if there's some sort of conflict with another existing hack, or if you screwed up somewhere, since this is the same code that runs in LC (and runs fine, I may add).

    Hello happens to me something like that in my case only begins the battle but no music.
     

    Bela

    Banned
    262
    Posts
    15
    Years
  • Touched wrote an asm routine for me that lets you play custom victory music for a Trainer based on its class, mimicking the format of Jambo's routine here. I'm posting it here because he's too lazy to do it. =P

    Code:
    .thumb
    .align 2
    
    main:
        lsl r0, r1, #2
        add r0, r1
        lsl r0, #3
        add r0, r2
        ldrb r0, [r0, #1]
    
        mov r1, r0
        push {r1-r3}
        bl search
        pop {r1-r3}
        cmp r0, #0
        bne play_custom
    
        mov r0, r1
        ldr r1, =(0x0801570E + 1)
        bx r1
    
    play_custom:
        ldr r1, =(0x080722A0 + 1)
        bl linker
        ldr r1, =(0x0801576E + 1)
        bx r1
    
    linker:
        bx r1
    
    search:
        ldr r3, =0xFEFE
    
        ldr r2, victory_table
    
    search_loop:
        ldrh r1, [r2]
        cmp r1, r3
        beq search_return_none
    
        cmp r1, r0
        beq search_found
    
        add r2, #4
        b search_loop
    
    search_return_none:
        mov r0, #0
        b search_return
    
    search_found:
        ldrh r0, [r2, #2]
    
    search_return:
        bx lr
    
    .align 2
    victory_table: .word 0x08AAAAAA
    So, following what Jambo did with his routine, you would create a table in this format:

    [Trainer Class - Byte][00 - Byte][Song to play - Half-Word]

    So, for example, say you want the Team Aqua class to have track 0x130 as the victory theme to play when you beat them. You would put the following set of bytes into the table:

    Code:
    03 00 30 01
    As before, you must do this for every class you wish to have custom music.

    When you're done with this, place:

    FE FE at the end of the table (as opposed to FEFE0000 like Jambo had you do with his routine). So to finish the example, it would be:

    Code:
    03 00 30 01 FE FE
    Take the offset of your table and replace it with the 0x8AAAAAA you see in the routine. So if your table offset is say 0x845670, you would write 0x8845670 into the routine instead.

    Now you need to hook your routine so the game will read it. To do this, go to offset 0x15704 and write the following:

    Code:
    00 48 00 47 XX+1 XX XX 08
    Where the XXs are your routine +1. So in our example, you would put the following at 0x15704:

    Code:
    00 48 00 47 71 56 84 08
    And there you go!
     
    4
    Posts
    8
    Years
    • Seen Jun 27, 2019
    I wanted to do this with Team Rocket as well as a few other trainer classes. When I tried doing this with the Rival battle music after the Team Rocket one, it still played the normal trainer theme. Is it possible to do this with more than one theme at a time?
     

    Child Amnesiac

    Ever changing
    341
    Posts
    5
    Years
  • If you're still having problems adding extra classes or you don't understand ASM watch this tutorial. Hex editing knowledge is all you need since the ASM is already compiled here:
    https://www.youtube.com/watch?v=iM0PZN1u4GU

    I followed your tutorial to the letter, but every time I trigger a battle: the music cuts out, and the game locks up. What am I doing wrong here? Is it my computer?
     

    Child Amnesiac

    Ever changing
    341
    Posts
    5
    Years
  • I tired it with another Rom, the game locked up. But the music didn't cut out.
    I'm going to try a clean ROM this time.
    Edit: I don't think it's going to work, I think ASM works only when it wants to.
    Edit 2: I think I found the problem, I forgot a 08
     
    Last edited:
    2
    Posts
    4
    Years
    • Seen Jun 18, 2023
    Can i do this with another class?

    i plan on changing my..

    rival class,
    legendary class,
    elite four class

    i also want to add champion theme for hoenn and sinnoh.

    is it possible to edit all trainer classes or just one?
     
    13
    Posts
    11
    Years
    • Seen Sep 24, 2023
    i followed the guide and the custom music worked just fine, but every other battle theme in the game including wild battles are silent and have no music
     
    13
    Posts
    3
    Years
    • Seen May 3, 2024
    Hi, I was wondering if this routine could be configured for "emerald". I tried it myself (I have very basic ASM knowledge, but I don't know how to write asm scripts or anything, just compile, offsets...), but this is not like other routines where looking for offsets depending on which roms you can make the transition.

    I am surprised at the same time that this is not something more generalized (it is an old publication and there is not much more information on the internet about the topic of music according to the kind of trainer), since it seems to me something that offers a very important added value in the game you are creating.

    I would appreciate any kind of help, best regards.
     

    TaviTurnip

    Artist and Streamer | Also a turnip
    96
    Posts
    6
    Years
    • Seen Apr 26, 2024
    Hi, I was wondering if this routine could be configured for "emerald". I tried it myself (I have very basic ASM knowledge, but I don't know how to write asm scripts or anything, just compile, offsets...), but this is not like other routines where looking for offsets depending on which roms you can make the transition.

    I am surprised at the same time that this is not something more generalized (it is an old publication and there is not much more information on the internet about the topic of music according to the kind of trainer), since it seems to me something that offers a very important added value in the game you are creating.

    I would appreciate any kind of help, best regards.

    Did you ever figure this out? I just came to this thread to refresh myself on class music and attempt it in Emerald myself, and have gotten held up on the very first step. I figured I could reverse engineer the instructions from FireRed to Emerald, but the HEX string that you replace [00 28 04 D0 85 20 40 00 39 E0 <-- at offset 0x43FF2] does not resemble anything inside Emerald's code, nor does it seem to contain a pointer to an offset itself, so I've immediately become lost lol

    I'm sure this technology can be used for Hoenn games but at least at the time of posting it's currently over my head, ahaha.
     
    135
    Posts
    4
    Years
    • Seen Apr 26, 2024
    I'm wondering about an Emerald port, too.

    I think the place to insert bytes would be around here:
    Code:
    06E42C:
        push  {lr}
        ldr   r0, [pc, <06E444>]
        ldr   r1, [r0, #0]
        mov   r0, #128
        lsl   r0, r0, #5
        and   r0, r1
        cmp   r0, #0
        beq   <06E448>
        mov   r0, #240
        lsl   r0, r0, #1
        b     <06E646>
     
    9
    Posts
    3
    Years
  • Hi! i tried applying this routine to change the rival battle theme, but i don't know why, it didn't work

    is it possible to change the rival or is it hard coded?

    Edit: i don't remember what i changed but it works now
     
    Last edited:
    Back
    Top