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

Code: ASM Resource Thread

7
Posts
3
Years
  • Display move power on press select [Fire Red]

    when you select some move in battle to change the position will show the power of it.

    here images for show what i mean.
    Spoiler:

    or replacing the text completely(read the code for see how you can make this).
    Spoiler:


    here the routine.
    Spoiler:
     
    Last edited:
    7
    Posts
    2
    Years
    • Seen Jan 31, 2022
    I couldn't find an Emerald equivalent of FBI's PID Generator (used for forced wild shiny encounters), so I decided to port it myself. This post also includes a port for the Random number generating routine that's necessary for the shiny encounter one. For the sake of clarity, the majority of the formatting is the same as FBI's original post.

    Random Natural Number Generator

    Simply compile into free space the following routine:
    Spoiler:


    Shiny Pokémon

    Before you can insert this routine you need to have inserted the Random number generating routine from before. Remember the offset which you inserted it because you're going to need to remember in a short while.

    Look at the orange text in spoiled code below. Insert inside the brackets the location of where you compiled the random number generator code. Make sure to add an 0x8 prefix. So if I compiled the random number generator at 0x743210, I'd write:
    Code:
    ldr r4, =(0x8743210 +1)

    After you've fixed that line, compile the code and insert into free space.
    Spoiler:


    Now navigate to 0x067BF8 and insert the following byte changes:
    Code:
    00 48 00 47 [COLOR="Yellow"]XX XX XX[/COLOR] 08
    Where XX XX XX is the reverse hex pointer of where you compiled the PID generating routine +1.

    Finally, go to 0x067BEE and insert the following byte changes:
    Code:
    00 00 02 E0
    Usage:
    Code:
    setvar 0x8002 0xFF
    This line makes it so the next Pokemon you encounter, or are given is a shiny Pokemon with a properly generated PID. The code sets 0xFF back to 0x0, so you don't have to disable it after.

    Here are two Sharpedo generated with the same hack (no EVs).
    fZ922T5.png


    All credits go to FBI! I merely ported these routines to Emerald.
     
    Last edited:
    4
    Posts
    4
    Years
    • Seen Oct 25, 2023
    What offset are you referring to? If you are talking about the 5 digit offset in the post 460F8. Just add a zero in front so it now becomes 0460F8. Try searching that offset in your hex editor. If you are still having trouble I'll make a quick video for you. I'll try my best to help you anyway I can

    still dont work
     
    7
    Posts
    2
    Years
    • They/Them
    • Seen Apr 14, 2022
    Ok so I have an .asm for a custom level/experience range system sent by a friend of mine but I am struggling to install it and he forgot to do so he can't help.

    Spoiler:

    I turned it into a bin, put the code in an empty space and wrote on the place was supposed to be, replacing the XX XX XX with my address of choice for the code as usual. However, every time I try I have 2 results, either it
    Doesn't work at all
    Every battle soft-resets the game

    Does anyone know what am I doing wrong, I'm doing it on Ruby and this code is for RSE btw

    and if I recall correctly, is based on this one https://www.pokecommunity.com/showpost.php?p=9727834&postcount=1251
     
    81
    Posts
    7
    Years
    • Seen yesterday
    Ok so I have an .asm for a custom level/experience range system sent by a friend of mine but I am struggling to install it and he forgot to do so he can't help.

    Spoiler:

    I turned it into a bin, put the code in an empty space and wrote on the place was supposed to be, replacing the XX XX XX with my address of choice for the code as usual. However, every time I try I have 2 results, either it
    Doesn't work at all
    Every battle soft-resets the game

    Does anyone know what am I doing wrong, I'm doing it on Ruby and this code is for RSE btw

    and if I recall correctly, is based on this one https://www.pokecommunity.com/showpost.php?p=9727834&postcount=1251


    This code is not for ruby, it is for FR and Em, besides that I see that the one you are using is for FR due to the address of the table 0x254784, if you need it for ruby you should look for the corresponding compensations but the routines do not always work since at least in ruby there are many different things compared to FR and Em that are more similar.
     
    7
    Posts
    2
    Years
    • They/Them
    • Seen Apr 14, 2022
    This code is not for ruby, it is for FR and Em, besides that I see that the one you are using is for FR due to the address of the table 0x254784, if you need it for ruby you should look for the corresponding compensations but the routines do not always work since at least in ruby there are many different things compared to FR and Em that are more similar.

    Is there any way I can find the corresponding compensation for ruby?

    Furthermore when I applied to Emerald, the game would soft reset every time I received the experience
     
    81
    Posts
    7
    Years
    • Seen yesterday
    Is there any way I can find the corresponding compensation for ruby?

    Furthermore when I applied to Emerald, the game would soft reset every time I received the experience

    Well, the creator left a link with both routines, obviously you must apply depending on the rom you use, surely you are putting FR in Em and that's why that happens, and I don't know if there is a way to find all that data for ruby, as you do. I say it is more complicated to find those data for ruby, I would have to review them but I do not assure you that they are all found.
     
    31
    Posts
    3
    Years
  • Stats on the Pokédex screen replacing the weight comparison


    QMVkkkn.png
    LpH11UN.png
    8pyCTYQ.png

    Code:
    .thumb
    
    @ credits to DoesntKnowHowToPlay and Squeetz
    
    .equ rom, 0x08000000
    .equ offset, 0x
    
    .org 0x10611E, 0xFF
    	.byte 0x43, 0xE0
    	
    .org 0x106370, 0xFF
    	.byte 0x0, 0x48, 0x0, 0x47
    	.word main + rom + 1
    
    .org 0x106530, 0xFF
    	.byte 0xCE, 0xE0
    	
    .org 0x452200, 0xFF
    	.byte 0xA
    
    .org offset, 0xFF
    main:
        mov r5, #4
        str r5, [sp]
        str r6, [sp, #4]
        mov r0, r10
        cmp r0, #0
        beq unknown_base_stats
    
    hp:
        mov r0, #0
        bl print_stat
        mov r3, #4 @ y co-ord
        str r3, [sp]
        mov r3, #0 @ x co-ord
        ldr r5, write_method
        bl call_via_r5
        
    atk:
        mov r0, #1
        bl print_stat
        mov r3, #4 @ y co-ord
        str r3, [sp]
        mov r3, #0x2C @ x co-ord
        ldr r5, write_method
        bl call_via_r5
         
    def:
        mov r0, #2
        bl print_stat
        mov r3, #18 @ y co-ord
        str r3, [sp]
        mov r3, #0 @ x co-ord
        ldr r5, write_method
        bl call_via_r5
         
    spa:
        mov r0, #4
        bl print_stat
        mov r3, #18 @ y co-ord
        str r3, [sp]
        mov r3, #0x2C @ x co-ord
        ldr r5, write_method
        bl call_via_r5
         
    spd:
        mov r0, #5
        bl print_stat
        mov r3, #32 @ y co-ord
        str r3, [sp]
        mov r3, #0 @ x co-ord
        ldr r5, write_method
        bl call_via_r5
         
    spe:
        mov r0, #3
        bl print_stat
        mov r3, #32 @ y co-ord
        str r3, [sp]
        mov r3, #0x2C @ x co-ord
        ldr r5, write_method
        bl call_via_r5
        
    print_ability_one:
        ldr r0, [sp, #0x1C]
        mov r3, #0x1C
        mul r0, r3
        ldr r1, base_stats
    	ldr r1, [r1]
        mov r3, #0x16
        add r1, r1, r3
        add r1, r0, r1
        ldr r3, abilities
    	ldr r3, [r3]
        ldrb r2, [r1]
        mov r1, #0xD
        mul r1, r2
        add r2, r1, r3    
        ldr r1, [r7]
        add r1, #0x53
        ldrb r1, [r1]
        mov r0, r1
        mov r1, #0
        mov r3, #46
        str r3, [sp]
        mov r3, #0
        ldr r5, write_method
        bl call_via_r5
        
    print_ability_two:
        ldr r0, [sp, #0x1C]
        mov r3, #0x1C
        mul r0, r3
        ldr r1, base_stats
    	ldr r1, [r1]
        mov r3, #0x16
        add r1, r1, r3
        add r1, r0, r1
        ldrb r2, [r1, #1]
        ldrb r5, [r1, #0]
        ldr r3, abilities
    	ldr r3, [r3]
        cmp r2, r5
        beq return
        cmp r2, #0
        beq return
        mov r1, #0xD
        mul r1, r2
        add r2, r1, r3
        
        ldr r1, [r7]
        add r1, #0x53
        ldrb r1, [r1]
        mov r0, r1
        mov r1, #0
        mov r3, #60
        str r3, [sp]
        mov r3, #0
        ldr r5, write_method
        bl call_via_r5
        b return
        
    unknown_base_stats:
        mov r0, r1
        mov r1, #0
        ldr r2, str_unknown
        mov r3, #4 @ y co-ord
        str r3, [sp]
        mov r3, #0 @ x co-ord
        ldr r5, write_method
        bl call_via_r5
        
    return:
        mov r5, #0
        ldr r0, return_loc
        bx r0
        
    print_stat:
        push {lr}
        ldr r3, [sp, #0x20]
        mov r1, #0x1C
        mul r3, r1
        ldr r2, base_stats
    	ldr r2, [r2]
        add r2, r3
        add r2, r0
        ldrb r1, [r2]
        mov r4, r0
        ldr r0, fcode_buffer2
        mov r3, #0
        cmp r1, #99
        bhi no_leading_zeroes
        cmp r1, #9
        bhi one_leading_zero
    
    two_leading_zeroes:
        str r3, [r0]
        add r0, #1
    
    one_leading_zero:
        str r3, [r0]
        add r0, #1
    
    no_leading_zeroes:
        mov r3, #3
        ldr r5, int_to_str
        bl call_via_r5
        
        mov r2, r4
        ldr r0, displayed_string
        ldr r1, str_table
        lsl r2, r2, #2
        add r1, r2
        ldr r1, [r1]
        ldr r5, fdecoder
        bl call_via_r5
        ldr r1, [r7]
        add r1, #0x53
        ldrb r1, [r1]
        mov r0, r1
        mov r1, #0
        ldr r2, displayed_string
        pop {r5}
        
    call_via_r5:
        bx r5
    
    .align 2
        base_stats:             .word 0x1BC + rom
        abilities:              .word 0x1C0 + rom
        str_table:              .word table + rom
        str_unknown:            .word capture + rom
        fcode_buffer2:          .word 0x02021CD0
        displayed_string:       .word 0x02021D18
        int_to_str:             .word 0x08008E78|1
        fdecoder:               .word 0x08008FCC|1
        write_method:           .word 0x081047C8|1
        return_loc:             .word 0x08106380|1
    table:
    	.word stat_hp + rom
    	.word stat_atk + rom
    	.word stat_def + rom
    	.word stat_spe + rom
    	.word stat_spa + rom
    	.word stat_spd + rom
    	
    stat_hp:
    	.byte 0xC2, 0xCA, 0x0, 0x0, 0xFD, 0x2, 0xFF
    	
    stat_atk:
    	.byte 0xBB, 0xE8, 0xDF, 0x0, 0xFD, 0x2, 0xFF 
    	
    stat_def:
    	.byte 0xBE, 0xD9, 0xDA, 0x0, 0xFD, 0x2, 0xFF
    	
    stat_spe:
    	.byte 0xCD, 0xE4, 0xD9, 0x0, 0xFD, 0x2, 0xFF
    	
    stat_spa:
    	.byte 0xCD, 0xE4, 0xBB, 0x0, 0xFD, 0x2, 0xFF
    	
    stat_spd:
    	.byte 0xCD, 0xE4, 0xBE, 0x0, 0xFD, 0x2, 0xFF
    	
    capture:
    	.byte 0xBD, 0xD5, 0xE4, 0xE8, 0xE9, 0xE6, 0xD9, 0x0, 0xDA, 0xE3, 0xE6, 0xFE, 0xE1, 0xE3, 0xE6, 0xD9, 0x0, 0xDD, 0xE2, 0xDA, 0xE3, 0xE6, 0xE1, 0xD5, 0xE8, 0xDD, 0xE3, 0xE2, 0xAB, 0xFF

    Thanks to DoesntKnowHowToPlay for the base routine which I slightly edited / optimised, and to Squeetz for making the routine into a form that can be applied as a patch.

    HI SIR!!!!!!!!... Do you also have this kind of patch to Pokemon Emerald?....thanks in advance sir!!!
     
    173
    Posts
    4
    Years
    • Seen Feb 4, 2024
    Scaled Experience Formula

    In Generation V, a new way of determining the Experience Points gained after Battle was introduced. Previously, the Experience Formula was a flat one, which did not change based on Level Differences between your Pokemon and the other one.

    In Black & White, they used a Scaled Experience Formula, which would cause your Pokemon to gain more experience if their opponent was a higher Level, and less if their opponent was a lower one.

    Today, I am sharing a way to have this sort of Scaled Experience Points in Fire Red or Emerald. I have included the download link to a folder which contains four items.

    Spoiler:
    Amazing stuff, but I never get success :(
    I try the script for EM, first I modified 0x0804A67B to 0x0804A66B at line 10 because I don't use that Exp. All patch, then I compiled it and insert them into 0x32A5F0 since there has a lot of 00, modified 0x4A5AC to 00 48 00 47 F0 A5 32 08 as your tutorial said, seems it all OK, but...
    I tried to find a wild Pokemon to battle, after I win, the game crashed and mGBA gives an error message said somehow "Jumped to invalid address 0x09670880".
    Could you help me how to implement it so it works well? Thanks.
     

    AkameTheBulbasaur

    Akame Marukawa of Iyotono
    409
    Posts
    10
    Years
  • Amazing stuff, but I never get success :(
    I try the script for EM, first I modified 0x0804A67B to 0x0804A66B at line 10 because I don't use that Exp. All patch, then I compiled it and insert them into 0x32A5F0 since there has a lot of 00, modified 0x4A5AC to 00 48 00 47 F0 A5 32 08 as your tutorial said, seems it all OK, but...
    I tried to find a wild Pokemon to battle, after I win, the game crashed and mGBA gives an error message said somehow "Jumped to invalid address 0x09670880".
    Could you help me how to implement it so it works well? Thanks.

    Well, I can see the first thing you did is that you forgot to add one to the address. You should have 00 48 00 47 F1 A5 32 08. The reason for this is because the "00 48 00 47 F1 A5 32 08" translates to:

    ldr r0, #=0x0832A5F1
    bx r0

    The first thing loads the location of the routine, and the second tells the game to jump there.

    However, when you use bx in particular, you need to add one to the location of the routine. The game has two modes, ARM and THUMB. When we do ASM, we use THUMB. The "bx r0" part jumps to the location you put in r0, but it also switches modes. If r0 has an even number, it goes to ARM mode (which we don't want). The solution is to add +1 to the routine so that r0 will be odd so it will stay in THUMB.

    So, any time you call a routine this way (which will be 99.99999% of the time), you need to add one. I thought I would explain it since maybe some people don't know exactly why you have to do that.

    Try doing that, and if it still doesn't work then we'll move from there!
     
    173
    Posts
    4
    Years
    • Seen Feb 4, 2024
    Well, I can see the first thing you did is that you forgot to add one to the address. You should have 00 48 00 47 F1 A5 32 08. The reason for this is because the "00 48 00 47 F1 A5 32 08" translates to:
    Spoiler:
    Thanks for your advice, but still doesn't work :(
    This time emulator won't pop up an error, but game stucks on "Wild <Name> fainted!" and producing garbage audio.
    Oh wait, I need to try battle with trainer!
    However no luck, when my Pokemon defeat an enemy, game encounters an error, mGBA said jumped to invalid address 0xFDFFB954.
    I have no idea how to implement this correctly :(
     

    AkameTheBulbasaur

    Akame Marukawa of Iyotono
    409
    Posts
    10
    Years
  • Thanks for your advice, but still doesn't work :(
    This time emulator won't pop up an error, but game stucks on "Wild <Name> fainted!" and producing garbage audio.
    Oh wait, I need to try battle with trainer!
    However no luck, when my Pokemon defeat an enemy, game encounters an error, mGBA said jumped to invalid address 0xFDFFB954.
    I have no idea how to implement this correctly :(

    I figured out the problem. Turns out, I am an idiot and I forgot to change the address of the Flag Check routine from FireRed to Emerald. :P I am updating the download to have the correct routine.

    You can change the routine you have now by replacing "D1 E6 06 08" with "91 D7 09 08". This should allow it to work, as this made it work on a clean ROM.
     
    Last edited:
    7
    Posts
    3
    Years
  • Automatic swap page on naming screen [Fire Red]

    when you write the first character in the naming screen of a pokemon(or the player/rival) the page automatic swap to lower case.

    here the routine.
    Spoiler:


    credits: Jaizu for the EM one made in C, i just port it to FR binary.
     
    3
    Posts
    2
    Years
    • He / Him
    • CA
    • Seen Oct 31, 2022
    Hiya! I have a hack request for FireRed or RSE: Universal Pokemon Randomizer (UPR) + In-Battle Type Display
    I'd like to use UPR combined with a, to my knowledge, non-existent hack that shows a pokemon's typing(s) in battle so I can react to its randomized typing.
    I've attempted to mix UPR with Complete FireRed Upgrade (CFRU), as it has the type showing functionality, even following its documentation to remove functionalities I didn't want, but CFRU overall adds too many things past gen 3 that UPR doesn't handle.
    I should also mention that I have Radical Red (which has the in-battle type showing functionality), but its randomizer is very limited and it doesn't even randomize types.
    Something I could preferably patch before patching with UPR would be awesome. Patching after UPR would be fine too
    In the meantime I'll hopefully be researching ASM to attempt this myself
    Also please withhold fan game recommendations (rather than romhack recs), because I prefer playing roms on my 3ds
     

    jacobhue

    Banned
    2
    Posts
    2
    Years
    • Seen Oct 27, 2022
    Extremely decent instructional exercise!
    The main thing I didn't comprehend is the motivation behind why we want midfix4agb.exe, as it appears to be not to be remembered for the instructional exercise. :(
     

    GalarianZatcunoltres

    Digamos 25% de sabedoria sobre hacking
    1
    Posts
    2
    Years
    • Seen Oct 4, 2022
    Here ya go ^_^
    Faint/Low Hp Evolution:
    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global faintEvolution
    
    main:
    push {r0-r7}
    [COLOR="Lime"]add r0, r6, r7[/COLOR]   @line to change if expanded evos
    lsl r0, r0, #0x3
    add r0, r2, r0
    add r3, r0, r3
    ldrb r2, [r3, #0x2]
    mov r0, r8
    bl decrypt
    mov r11, r0
    pop {r0-r7}
    mov r1, r11
    [COLOR="Lime"]cmp r1, #0x2[/COLOR]    @Compare Amount of Current Hp
    blo low_hp
    b exit
    
    low_hp:
    mov r10, r3
    pop {r0-r7}
    mov r1, r10
    ldr r0, evolution_loc
    bx r0
    
    exit:
    pop {r0-r7}
    ldr r0, no_evo
    bx r0
    
    decrypt: 
    push {r0-r7}
    mov r1, #0x39
    ldr r2, decryptpoke
    bx r2
    
    .align 2
    no_evo: .word 0x08043111
    evolution_loc: .word 0x0804310D
    decryptpoke: .word 0x0803FBE9


    Note for the first highlighted in green:
    If you have expaned your evolutions for your pokemon you must change this line:
    "add r0, r6, r7"
    to:
    8 evos or less = lsl r0, r6, #0x1
    16 evos or less = lsl r0, r6, #0x2
    32 evos or less = lsl r0, r6, #0x3

    or
    just change the bytes in the compiled file from F0 19 to:
    8 evos or less = 70 00
    16 evos or less = B0 00
    32 evos or less = F0 00


    Note for second highlighted in green:
    As it is the Pokemon must be leveled up with a Rare Candy to get it to revive and have 1-Hp.
    You can change the value of 0x2 to something higher but anything lower than 0x2 will not work with this routine.
    After the compare it the vaule must be lower than the "0x2" or what ever value you decide to change it to.


    Hope this helps!
    o

    Eu queria ver como era essa rotina em ação. ^_^ achei a temática legal.

    O pequeno problema é que mesmo seguindo tutoriais que nos mesmos, funcionam a expansão de métedos evolutivos, eu não consigo fazer os métodos novos funcionarem enquanto eu jogo =_=

    Queria saber ASM para fazer um metódo evolutivo igual ou semelhante ao de Basculegion, Ursaluna ou Wyrdeer e Overqwill T-T
     
    51
    Posts
    9
    Years
    • Seen Nov 18, 2023
    I dont know if it already exists but is there any routine to show Pokemon icon at desired X Y position.
    A simple "showpokepic" command...

    #dynamic 0x800000
    #org @start
    showpokepic 0x[n° pokémon species to display] 0x[X coordinate] 0x[Y coordinate]
    pause 0x80
    hidepokepic
    end
     
    Back
    Top