• 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.

Research: Animation Script Commands

Touched

Resident ASMAGICIAN
625
Posts
9
Years
    • Age 122
    • Seen Feb 1, 2018
    While working on Megas, I started writing a list of all the animation commands. While I still don't understand exactly what many of them do, I have compiled an accurate list of all the commands and the arguments they take. This should be enough information to get a basic animation script decompiler working, and therefore allowing research into what moves use which commands. This will help in understanding each commands functionality.

    The table of commands are at 083ADF5C in FireRed, 08525E98 in Emerald and 083ADF3C in LeafGreen (Lost Heart).
    There are 0x2F commands in all versions.
    Each command seems to be responsible for advancing the cursor itself.
    This allows commands to wait and re-execute themselves (like wait animation). This also seems to make the nops cmd6 and cmd7 broken, as they just return without adjusting the cursor.

    All addresses referenced in the document below are for FireRed.

    Code:
    00: Load Graphics
        short: graphics
    
    01: Unload graphics
        short: graphics
    
    02: Load Template
        long: template - Pointer to the template to load
        byte: ?
        byte: argc - Argument Count
        short * argc: argv - Vardiac Arguments - copied to 
              ma02_t0_02037F02
    
    03: Launch Task
        long: funcptr (void(*)(u8)) - Task to call
        byte: pri - Task Priority
        byte: argc - Argument Count
        short * argc: argv - Variadic Arguments for function - copied 
              to ma02_t0_02037F02
        
    04: Countdown (Pause)
        byte: time/frames
        
    05: Wait Animaion
        Void
        
    06: Nop (might break; doesn't advance the cursor)
        Void
        
    07: Nop (might break; doesn't advance the cursor)
        Void
        
    08: End
        Void
        
    09: Play Sound
        short: Sound to play
        
    0A: ???
        byte: ???
        
    0B: Clear bitfield except visiblity
        byte: Target
        
    0C: Set BLDCNT and BLDALPHA
        BLDCNT = 0x3F40
        short: BLDALPHA
        
    0D: Reset blends
        Void
        
    0E: Call (Doesn't have a call stack. Can only call and return once)
        long: pointer to target
        
    0F: Return
        Void
        
    10: Set ma02_t0_02037F02
        byte: Index in ma02_t0_02037F02
        short: Value
        
    11: If byte_2037F16
        long: location to jump to if byte_2037F16 & 1
        
    12: Conditional If
        byte: condition
        long: location to jump to if byte_2037F16 == cond
        
    13: Goto
        long: pointer
        
    14: Load Background
        byte: bg id
        
    15: Load battle screen elements - I guess it resets
        Void
        
    16: Wait for battle screen elements
        wait for is_battle_screen_elements_loader_running == 2
        Void
        
    17: Wait for battle screen elements
        wait for is_battle_screen_elements_loader_running = 0
        
    18: Load background
        byte bg index
        
    19: Audio Play and Stuff
        short: sound
        byte: I don't even know
        
    1A: ???
        byte: ???
        
    1B: ??? - Audio Related. Adds a task
        short: sound
        byte: ???
        byte: ???
        byte: ???
        byte: ???
    
    1C: ??? - Adds a task
        short: ???
        byte: ???
        byte: ???
        byte: ???
    
    1D: ??? - Task sub_8074028
        short: ???
        byte: ???
        byte: ???
    
    1E: Set BLDCNT
        short: BLDCNT
    
    1F: Start a sub task
        long: pointer - task
        byte: argc
        short * argc: Variadic Arguments
    
    20: Wait for something (audio related)
        Void
        
    21: Check ma02_t0_02037F02
        byte: index in ma02_t0_02037F02
        short: value to check
        long: pointer - jumps here if ma02_t0_02037F02[index] == short 
    
    22: Conditional form of cmd0b?
        byte: Target
    
    23: Similar to cmd22
        byte: Target
    
    24: Nop Skip 4
            long: Skip
    
    25: Set background for attacker/defender
        byte: bg if defender
        byte: bg if attacker
        short: nothing
    
    26: Launch task c3_08073CEC (audio related)
        short: Song to play
        byte: priv[0], priv[4] and second arg to audio_play_and_stuff
        byte: priv[1]
        byte: priv[2]
        byte: priv[3]
    
    27: Similar to cmd26 but runs through some functions first
        short: song to play
        byte: ???
        byte: ???
        byte: ???
        byte: ???
    
    28: LCD bg operations for each side something
        byte: Side
    
    29: LCD bg operations above, except unconditional
            Void
    
    2A: Similar to cmd28
            byte: Side
    
    2B: Make side invisible
            byte: side
    
    2C: Make side visible
            byte: side
    
    2D: Visibility something
        byte: side
    
    2E: Something with oam attrs
        byte: side
    
    2F: Stop music
            Void
    Next steps should be thinking of names for each command, and then building a basic decompiler/compiler.
     
    Last edited:
    3,830
    Posts
    14
    Years
    • Age 27
    • OH
    • Seen May 10, 2024
    Very nice work! I have a question about command 0x4. By countdown do you mean it pauses the game for the given time?

    And I've got my own small contribution: the command table is located at 083ADF3C in LeafGreen.
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Very nice work! I have a question about command 0x4. By countdown do you mean it pauses the game for the given time?

    And I've got my own small contribution: the command table is located at 083ADF3C in LeafGreen.

    Yeah, it just pauses execution of the script for the given number of frames. I guess it is like the pause command in OW scripting.
     
    58
    Posts
    8
    Years
    • Seen Jan 7, 2017
    Yeah, it just pauses execution of the script for the given number of frames. I guess it is like the pause command in OW scripting.
    I believe that cmd21's parameters are in this format: byte, short, long.
    This is part of its ASM function in knizz's DB:
    Code:
    ROM:08074164                 PUSH    {R4-R6,LR}
    ROM:08074166                 LDR     R5, =move_anim_cursor
    ROM:08074168                 LDR     R4, [R5]
    [COLOR="Red"]ROM:0807416A                 ADDS    R3, R4, #1[/COLOR]
    ROM:0807416C                 STR     R3, [R5]
    ROM:0807416E                 LDRB    R2, [R4,#1]     @ arg1
    [COLOR="Red"]ROM:08074170                 LDRB    R1, [R3,#1]
    ROM:08074172                 LDRB    R0, [R3,#2]
    ROM:08074174                 LSLS    R0, R0, #8
    ROM:08074176                 ORRS    R1, R0  [/COLOR]        @ arg2

    I hope that I can see your great script editor for this :)
     
    Last edited:

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    I believe that cmd21's parameters are in this format: byte, short, long.
    This is part of its ASM function in knizz's DB:
    Code:
    ROM:08074164                 PUSH    {R4-R6,LR}
    ROM:08074166                 LDR     R5, =move_anim_cursor
    ROM:08074168                 LDR     R4, [R5]
    [COLOR="Red"]ROM:0807416A                 ADDS    R3, R4, #1[/COLOR]
    ROM:0807416C                 STR     R3, [R5]
    ROM:0807416E                 LDRB    R2, [R4,#1]     @ arg1
    [COLOR="Red"]ROM:08074170                 LDRB    R1, [R3,#1]
    ROM:08074172                 LDRB    R0, [R3,#2]
    ROM:08074174                 LSLS    R0, R0, #8
    ROM:08074176                 ORRS    R1, R0  [/COLOR]        @ arg2

    I hope that I can see your great script editor for this :)

    Nice catch, I've updated the main post with this order. Instead of a script editor, I might just release a series of ASM macros. Those are probably easier to make and use.
     
    Back
    Top