• 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

5
Posts
5
Years
    • Seen Oct 11, 2022
    I would like to ask if anyone can do a routine wich maximizes the IV's/EV's stats of my team's first pokemon
     
    Last edited:

    U.Flame

    Maker of Short Games
    1,326
    Posts
    15
    Years
  • Having some issues with Spherical Ice's Dive ASM here in this thread: https://www.pokecommunity.com/showthread.php?t=257723

    This is the ASM as I inserted it:
    Spoiler:


    I had asked about this in Rom Hacking Help with no luck, since this is an ASM specific thread maybe this is a better place to ask. Basically, it functions but has problems with female players. Firstly, the Dive sprite uses the Dive overworld sprites but with the palette of the normal walking overworld sprites. It does this for both genders, but upon entering and exiting a menu or battle, the palette is corrected to the dive sprite palette. This in itself can be a non-issue if both sprites share palettes. For male players, this is the only issue.

    The main problem is with female players upon entering a menu/battle, the dive sprite is reverted to the normal walking sprite. This includes behavior as well, no longer bobbing and is now able to run. There's an additional oddity if the dive and walk sprites are different sizes. The reverted sprite appears glitched, but upon another menu/battle, fully reverts to a normal looking walk state.

    So what's causing female players to undo the dive state like that, and not males? One other thing I noticed is that the underwater fog still appears but the bubbles only appear after entering and exiting a menu. I tried implementing this in both my ongoing project and in vanilla Firered, no change in results. Then I checked diving in Pokemon Gaia, and found that the sprites function perfectly well for both genders, no palette issue, no reversion issue. But that the bubbles not appearing until after a menu thing is there. My main concern is just the female players breaking. The palette and bubbles issue isn't important, I can live with that, but I can't have players walking underwater.
     
    Last edited:
    3
    Posts
    4
    Years
    • Seen Dec 22, 2019

    Getting IVs and EVs


    The routines are very similar so I ended up just combining the two routines into one. Basically given a slot number of a Pokemon in 0x8004, the routines will return the EVs or IVs, respectively, into the vars 0x8005-0x800A with 0x8003 as the IV/EV switch.


    How to insert:

    Compile and insert the following routine into free space:

    Spoiler:



    Usage:
    setvar 0x8003 0x[anything except 0 = IV, 0 = EV]
    setvar 0x8004 0x[slot number 0 to 5]
    callasm 0x[this routine +1]

    The variables will be:
    0x8005: HP IV/EV
    0x8006: Atk IV/EV
    0x8007: Def IV/EV
    0x8008: Spd IV/EV
    0x8009: S.atk IV/EV
    0x800A: S.def IV/EV

    So for about the last 10 hours I've been trying to figure something out with this code.
    It works completely fine, other than the fact that when I run it, it sets all 6 variables to the IV of the pokemon I specified in the scripts HP IV

    Spoiler:


    I've taken the code and put in comments on each line summarizing what I understand each line to do. Am I mistaken? Am I completely wrong?

    Spoiler:


    with the compiled thing ending up as

    Code:
    0x08251C50        3F B5 00 24 05 2C 17 D8 0C 48 00 88 64 21 41 43
    0x08251C60        0B 48 40 18 0B 4B 1B 88 00 2B 01 D0 27 31 00 E0
    0x08251C70        1A 31 09 4A 00 F0 07 F8 01 1C 08 4A 60 00 12 18
    0x08251C80        11 80 01 34 E6 E7 10 47 3F BD C0 46 C0 70 03 02 
    0x08251C90        86 42 02 02 BE 70 03 02 E9 FB 03 08 C4 70 03 02

    Everything I have there follows the implementation instructions to a T, yet the memory still shows

    Code:
    0x020370BD        00 01 00 00 00 19 00 19 00 19 00 19 00 19 00 19
    0x020370CD        00 19 00 01 00 02 00 04 00 00 00 00 00 FF 00 01

    and just to make sure it wasn't a statistical fluke, I ran the same script with 5 or so more randomly encountered pokemon and ran them through an IV calculator. Each time, the HP IV shown by the ASM was correct, but then copied it to every other variable set in the script.
     
    3
    Posts
    4
    Years
    • Seen Dec 22, 2019

    Getting IVs and EVs


    The routines are very similar so I ended up just combining the two routines into one. Basically given a slot number of a Pokemon in 0x8004, the routines will return the EVs or IVs, respectively, into the vars 0x8005-0x800A with 0x8003 as the IV/EV switch.


    How to insert:

    Compile and insert the following routine into free space:

    Spoiler:



    Usage:
    setvar 0x8003 0x[anything except 0 = IV, 0 = EV]
    setvar 0x8004 0x[slot number 0 to 5]
    callasm 0x[this routine +1]

    The variables will be:
    0x8005: HP IV/EV
    0x8006: Atk IV/EV
    0x8007: Def IV/EV
    0x8008: Spd IV/EV
    0x8009: S.atk IV/EV
    0x800A: S.def IV/EV

    So for about the last 10 hours I've been trying to figure something out with this code.
    It works completely fine, other than the fact that when I run it, it sets all 6 variables to the IV of the pokemon I specified in the scripts HP IV

    Spoiler:


    with the compiled thing ending up as

    Code:
    0x08251C50        3F B5 00 24 05 2C 17 D8 0C 48 00 88 64 21 41 43
    0x08251C60        0B 48 40 18 0B 4B 1B 88 00 2B 01 D0 27 31 00 E0
    0x08251C70        1A 31 09 4A 00 F0 07 F8 01 1C 08 4A 60 00 12 18
    0x08251C80        11 80 01 34 E6 E7 10 47 3F BD C0 46 C0 70 03 02 
    0x08251C90        86 42 02 02 BE 70 03 02 E9 FB 03 08 C4 70 03 02

    I've taken the code and put in comments on each line summarizing what I understand each line to do. Am I mistaken? Am I completely wrong?

    Spoiler:


    Everything I have there follows the implementation instructions to a T, yet the memory still shows

    Code:
    0x020370BD        00 01 00 00 00 19 00 19 00 19 00 19 00 19 00 19
    0x020370CD        00 19 00 01 00 02 00 04 00 00 00 00 00 FF 00 01

    and just to make sure it wasn't a statistical fluke, I ran the same script with 5 or so more randomly encountered pokemon and ran them through an IV calculator. Each time, the HP IV shown by the ASM was correct, but then copied it to every other variable set in the script.
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Hi, first of all I'd like to apologize for the mistake. I haven't tested that code, and it's in assembly so a semantic error here and there tend to be around for some of them. A quick skim through it, it does seem like there is a minor error.

    add r1, r1, #0x27 @IV
    This line of code I assume gets the HP IV, however, it will always be 0x27, and therefore not get any subsequent IVs.
    That line should be replaced by:
    add r1, r4, #0x27
    If the assembler says the above line is invalid, try:
    add r1, r1, r4
    add r1, r1, #0x27
    Hopefully that does the trick.
     
    3
    Posts
    4
    Years
    • Seen Dec 22, 2019
    Hi, first of all I'd like to apologize for the mistake. I haven't tested that code, and it's in assembly so a semantic error here and there tend to be around for some of them. A quick skim through it, it does seem like there is a minor error.

    Code:
    add r1, r1, #0x27 @IV

    This line of code I assume gets the HP IV, however, it will always be 0x27, and therefore not get any subsequent IVs.
    That line should be replaced by:

    Code:
    add r1, r4, #0x27

    If the assembler says the above line is invalid, try:

    Code:
    add r1, r1, r4
    add r1, r1, #0x27

    Hopefully that does the trick.

    Hey FBI, thanks for the reply, and I'm happy to say that
    Code:
    add r1, r1, r4
    add r1, r1, #0x27

    did the trick perfectly! It seems to be displaying the correct IVs for each stat now and isn't causing any issues. Again, thank you so much for the help.
     
    Last edited:
    3
    Posts
    4
    Years
    • Seen Jul 30, 2020
    I'm having a problem with shiny odds, compiled all three parts but when I clear the textbox after receiving my starter the game resets, any idea what I did wrong?
     
    Last edited:
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    [FR] Map Music Loader

    This small hack loads map music by a variable rather than the map header (if the variable is set to a non-zero value). just set MUSIC_VAR to some variable value and compile, insert into free space, and overwrite the corresponding bytes at 0x55D70 (found at top of routine).

    In a script, set the variable to a specific song ID, and the game will play that song ID after trainerbattles and warps (perhaps others that I have not thought of or tested).

    Spoiler:

    Enjoy!
     
    Last edited:
    232
    Posts
    5
    Years
    • Seen Apr 16, 2024
    Pokemon LoathingFriendship Evolution:
    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global loathFriendship
    
    main:
    push {r0-r7}
    add r0, r6, r7
    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
    cmp r1, #0x10
    blo max_lowhappy
    b exit
    
    max_lowhappy:
    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, #0x20
    ldr r2, decryptpoke
    bx r2
    
    .align 2
    no_evo: .word 0x08043111
    evolution_loc: .word 0x0804310D
    decryptpoke: .word 0x0803FBE9

    The Pokemons happiness must be between 0-10 to trigger the evolution.
    To insert follow instructions in this thread.

    I hope some find this useful.
    I thought about trade evolution basically being just this.
    A Pokemon so depressed it evolves...

    It took me 50+ pages to find this. But thanks brotato. This is exactly what I need 👍
     

    BluRose

    blu rass
    811
    Posts
    10
    Years
  • headbutt trees (fire red)
    OOQuzFF.png

    so basically i was talking with petuh 2 days ago about how rusty i probably am at strict assembly

    so here i am! i made a thing

    Spoiler:
    this is also downloadable here.

    this implements a modified jpan's behavior byte hack so that it takes up far less space (only affects the behavior byte entries it governs). it then adds a new entry, a pointer to the script that's also dynamically compiled. by default, this new one is behavior byte 0xA4!

    in its purest form, you need to configure the tables and then compile it using your favorite asm compiling software. go to 0x806D1F0 and copy it until the zeros are reached. note that you will need to edit the tables in there as you so desire.
    each new table needs to be referenced in tableoftables so that the code will read it.
    copy that over to 0x6D1F0 in your fire red v1.0 rom. that's it! all you have to do.

    tables are split into entries for each pokemon, each 7 bytes:
    [2 bytes] - species
    [1 byte] - lower level
    [1 byte] - higher level
    [2 bytes] - item
    [1 byte] - chance of appearing (when subtracted from the previous entry's chance entry, it gives the specific entry's chance of appearing

    this will generate a pokemon of the defined species with a random level between lower level and higher level with the item in the table.

    in editing the tables, there's an .equ for table_amount. edit that to accomodate the new tables; it's currently at 3.

    now, i tried to label it as well as i could. ask me any questions you have on the code ahaha

    this system works by loading separate tables based on the second byte in advancemap labeled "behavior byte" when given a certain behavior byte. you know, this one:

    iJTYSBk.png


    in classic amap fashion, this is rather wrong

    what happens in the code is that all 4 of those are considered one 4-byte word and the game retrieves the values it wants in various fields

    everything that wants to retrieve a value from this area eventually references 0x8058F1C, or blockinfo_get_field in knizz's idb.
    it takes the blockinfo and a field value and returns the value of that field.

    blockinfo_get_field uses the words at 352EF0, or's it w the blockinfo (the 4 bytes from the block editor in amap), and returns the result shifted right by the corresponding entry in the byte array at 352F10. this results in a neat return value.

    field 0 is the behavior byte field, like the main one, but is also 1 bit from the second byte (it's 9 bits long)
    the one that is kind of labeled in amap

    field 1 is then part of the second byte labeled as a behavior byte. this is the field i used in this to try not to rewrite anything too extensively
    within the second byte, we split it down into bits:

    [7] [6] [5] [4] [3] [2] [1] [0]

    field 1 is bits 1-5 (NOT zero!). they are bold in the above example. this is why the grass is 2, and the water is 4; the values for field 1 for these respective values are actually 1 and 2!

    what this practically means? the second byte is the table number * 2. so if i wanted to use table 3 (the 4th table because of 0-indexing), then i would put 6 in that second field.
    for ease of editing, a bunch of equ's for various bug pokemon are included in the file. brightpowder is also the only defined item, but that can be changed if you so desire.

    so that tree in the amap screen up there? it's a headbutt tree (behavior byte 0xA4) that accesses table 2.

    ONE NOTE ON THIS

    you have 0x358 bytes to work with here. if you go to 0x806D1F0 in the compiled binary and select all those bytes and the size is over 0x358, then you will be overwriting surfing code.
    you have up to 0x6D548.
    this supports easy repointing, be it the tree tables or the script. either way, just uncomment one of the org's and change it to the place where free space is.

    with all that done, you should have a new headbutt tree system in your game! see you next time~

    COLmkYl.png


    EDIT: also i have half a mind to take thread ownership. i'll start compiling a list of everything here and links to them w descriptions when i have free time tomorrow and then ask if i can take over after everything is compiled
     
    Last edited:
    249
    Posts
    11
    Years
    • Seen Apr 22, 2024
    Colored Stats based on Nature[RUBY]
    sNVysl4.png
    To implement this feature, only one routine is needed:
    Spoiler:

    After compiling the routine in a free offset, go to 0x09FFBC and overwrite the bytes with 00480047xxxxxx08.
    Instead of the XX, will be entered the offset of previous routine + 1 and in Little Endian format (example: 08123456 -> 57 34 12 08).
     
    Last edited:
    51
    Posts
    9
    Years
    • Seen Nov 18, 2023
    Side Quest Menu [FR]

    This hack converts the PC item storage menu into a side quest menu, or task list, etc.

    Here is the repository, the compilation instructions are included in the readme. You will need to define your own parameters/ram in src/headers/defs.asm and create your own tables of string pointers for all of the quest names, descriptions, item images, and quest details. I kept the item image part to allow hackers to include items that might be symbolic of their quest, eg. a scroll or key or pokeball.

    To use in a script (XSE)
    Code:
    writebytetooffset 0x1 <your questflag ram in src/headers/defs.asm>
    fadescreen 0x1
    callasm 0x80EBCD9
    waitstate

    Enjoy! And please let me know of any bugs.

    I have a lot of problem with this Side Quest Menu...I make some screens

    Item Menu doesn't show the item name

    6jrzJI6.png


    Item menu without item show ?????? 0x0 item

    qsOA0SB.png


    Quest Menu doesn't show quest name with activate flag ON

    qwwcQAx.png
     
    75
    Posts
    10
    Years
  • This is the code to show icon on pause menu for Ruby by Andrea.. I need help to insert it on emerlad

    .THUMB
    .ALIGN 2
    @08071174 00490847XXXXXX08
    @080711C8 MOVS R0, #0x16 @coordinata x
    @08071208 lunghezza cursore
    @0807120E posizione X cursore

    PUSH {R0-R7}
    LDR R1, = 0x06008020
    LDR R0, = 0x087200D0
    MOV R2, #0x15
    LSL R2, #4
    SWI 0xC

    LSL R2, #2
    ADD R0, R2

    MOV R3, #1
    LSL R3, #10

    LDR R1, = 0x0202EC48
    MOV R2, #8
    SWI 0xC
    LDR R4, = 0x0202FEB3
    LDRB R4, [R4]
    CMP R4, #0x16
    BNE ICONE
    ADD R1, R1, R3
    SWI 0xC

    ICONE:
    MOV R6, #0

    MOV R0, #1
    LSL R0, #11
    ADD R0, #1
    BL CHECKFLAG
    CMP R0, #0
    BEQ PARTY

    ADD R6, #1
    MOV R0, #0
    MOV R1, #0
    BL SPAWN

    PARTY:
    MOV R0, #1
    LSL R0, #11
    BL CHECKFLAG
    CMP R0, #0
    BEQ ALTRO

    MOV R0, #1
    ADD R6, #1
    CMP R6, #2
    BEQ CONTROLLO
    MOV R0, #0
    CONTROLLO:
    MOV R1, #1
    BL SPAWN

    ALTRO:
    LDR R5, = 0x0202E8FD
    LDRB R5, [R5]

    MOV R7, #2
    LOOP2:
    MOV R0, R6
    MOV R1, R7
    BL SPAWN
    ADD R6, #1
    ADD R7, #1
    CMP R6, R5
    BNE LOOP2

    FINE:
    POP {R0-R7}
    POP {R4-R7,PC}

    SPAWN:
    LSL R0, #7
    LDR R2, = 0x0600F8A8
    ADD R0, R2
    MOV R3, #6
    MUL R1, R3
    ADD R1, #1
    MOV R2, #0xC0
    LSL R2, #8
    ADD R1, R2
    MOV R2, #0
    MOV R3, #0
    LOOP:
    STRH R1, [R0]
    ADD R0, #2
    ADD R1, #1
    ADD R2, #1
    CMP R2, #3
    BNE LOOP
    ADD R0, #0x3A
    MOV R2, #0
    ADD R3, #1
    CMP R3, #2
    BNE LOOP
    BX LR

    CHECKFLAG:
    PUSH {R0}
    LDR R0, = 0x08069341
    MOV R10, R0
    POP {R0}
    BX R10
     
    13
    Posts
    7
    Years
    • Seen Sep 14, 2021
    I want to change the amount of experience given by pokemon in Fire Red. I could go through and manually update the values of each pokemon, but I'm just wondering if anybody knows where to find the offset where the experience formula is.
     
    119
    Posts
    14
    Years
  • Pokemon Storage (outside the PC)


    Basically, in it's current state, this is effectively a storage system. It stores Pokemon and can be interacted with by the player to withdraw or deposit Pokemon. It's standalone from the PC storage system and is also much smaller (I've limited it to 6, but it can go upto 47). Some things that you will be able to do with this routine (and conjunction with some smaller ones) include:
    - Extra Pokemon storage, you can possibly get a little over 1 box worth
    - Flash back battles (complete swap between stored Pokemon and party Pokemon with capabilities to swap back)
    - Carry a party of greater than 6 Pokemon (you can use the 2nd party for HM slaves, or whatever)
    - Trade evolver guy! He will take your Pokemon and then when you come back it can be evolved! (silent evolution ftw!)
    - Separate Daycare holding larger amount of Pokemon at once

    I've tested it thoroughly and there doesn't seem to be any problems. I will be adding more and more features into this because I believe that it has the potential to become a very useful feature.
    Currently planning to add:
    - Party swap completely all in one go (this will actually be in the very near future..maybe today even :P)
    - Partial swapping (believe it or not, this is hard because there's no graphical support)
    - Suggest me more :D

    Spoiler:

    It seems that the memory location for the storage system (0x203C000) has been used already by another ASM routine my ROM base (Leon/UltimaSoul's) has implemented. I cannot find which exact memory locations are free, but I figured the best shot would be 0x203CC00.

    I have tried to amend the routine by simply changing the memory location in the routine under .STORAGE. However, unfortunately the game freezes when the ASM routine is called. What is the best way to relocate the storage system to free memory space? Am I missing something obvious? Thanks in advance for any help!
     
    Last edited:
    788
    Posts
    17
    Years
    • Seen today
    Functional Pokérus [FR]

    This allows Pokérus to be caught randomly, spread between Pokémon, and (optionally) cured. It also includes a special for checking if a Pokémon in the player's party has Pokérus, for use in a Nurse Joy script.

    Curing Pokérus is based on walking around, not on an RTC.

    Several of the Pokérus related functions included here were lifted directly (or with small modifications) from pokeemerald.

    Let me know if you have issues.
     
    Last edited:
    788
    Posts
    17
    Years
    • Seen today
    More Options For In-Game Trades [FR]

    It allows you to have In-Game Trades that come with/at/in:

    • Static levels, like in newer games
    • Pokérus
    • Custom movesets
    • PP bonuses
    • Poké Balls other than the default

    You can also use it as a sort of trade editor, because it extracts the in-game trade data from your ROM in a compilable form you can modify.

    Let me know if you run into issues.

    Spoiler:
     
    Last edited:
    81
    Posts
    7
    Years
    • Seen yesterday
    Colored Stats based on Nature[RUBY]
    sNVysl4.png
    To implement this feature, only one routine is needed:
    Spoiler:

    After compiling the routine in a free offset, go to 0x09FFBC and overwrite the bytes with 00480047xxxxxx08.
    Instead of the XX, will be entered the offset of previous routine + 1 and in Little Endian format (example: 08123456 -> 57 34 12 08).

    How to invert the colors from red to blue?
     
    81
    Posts
    7
    Years
    • Seen yesterday
    Thanks. Though I would like to point out, to use them all you really need to know is how to insert them and what they do. I've documented a guide on how to insert for beginners (it's a link in the FAQ first post). If you don't understand something or don't see how some routine works, feel free to ask!


    :3



    I'm still not understanding the incentive to randomizing the starting Pokemon. I suppose it would be a small bit of "game change" if someone were to play your hack more than once, but the feature seems a little useless to me :/



    Yeah it definitely could, and should read off of a table. I'll have to redo that little bit :x


    Battle Modes addon: Delete fainted Pokemon


    For those hackers who like minigames, this routine will delete Pokemon who have fainted in battle. There's a few things that need to happen for this effect to occur.

    1) Pokemon who die in battle must be deleted
    2) Eggs are spared
    3) Pokemon who die outside of battle must be deleted (Poison or another similar effect)

    However, if you put this in turn basis, you will NEED to make another routine to delete the Player's party if he/she loses the match. This is because the turn counter isn't reached on the last turn the player loses :x

    If you're lazy like me you can just put this routine in as a battle by move addon and cover the whiteout case. Which is actually fine. It's rather fast, because it deletes the Pokemon as they die, so the worse case scenario is unforeseeable. And if a Pokemon dies it will only need to loop 5 times only doing operations on one of the 5 loops. If you're curious looping a maximum of 21 times is the worst case scenario (all 6 of your Pokemon die in 1 turn i.e never, and even if that did happen it'd be done in less .25 seconds). So it's fine to put in the battle by move section without expecting the game to lag.


    How to insert:
    Insert as addon to battle modes battle by move.
    You will notice that near the start of the routine there is some commented out code (denoted by a prefix "@" symbol). That's for a flag check. Change [flag/4] = your flag/4 in hex if you want to toggle by flag. Of course the normal battle mode toggle flag should be used as well.

    Spoiler:



    Usage:
    If you opted to use a flag, set it to allow further battles to delete Pokemon as they faint. If you didn't just sit back and let the unicorns inside the game do the rest.


    I need help for pokemon ruby routine:

    Spoiler:
     
    Back
    Top