• 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

135
Posts
4
Years
    • Seen Apr 26, 2024
    I know this is an old thread, but I tried porting this to Emerald, and I'm stuck.
    Spoiler:

    I can't find the equivalent of "sub_80A16D0" in Emerald.
     

    RuFF

    Hope you're having a RuFF day!
    365
    Posts
    11
    Years
  • Button detection in scripts


    How to insert:

    First compile and insert into free space, the following routine
    Spoiler:


    Now navigate to 0x6B89A and do the following byte changes:
    Code:
     00 00 00 48 00 47 XX XX XX 08
    Where XX XX XX is the pointer to wherever you inserted this routine +1

    Hello, I trying to convert this to Ruby. How will I find the corresponding offsets mentioned above?

    (0x806B922 +1)
    (0x806B8A6 +1)

    0x6B89A

    I already found the corresponding one for (0x30030F0).
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Hello, I trying to convert this to Ruby. How will I find the corresponding offsets mentioned above?

    (0x806B922 +1)
    (0x806B8A6 +1)

    0x6B89A

    I already found the corresponding one for (0x30030F0).

    Don't follow this method, it's a poor implementation. Instead, create a task which listens to a key press and use callasm to run it.
     

    RuFF

    Hope you're having a RuFF day!
    365
    Posts
    11
    Years
  • Don't follow this method, it's a poor implementation. Instead, create a task which listens to a key press and use callasm to run it.

    How do you integrate wait key in asm? I tried looping until a button is pressed but I think I got stuck in an infinite loop.

    Spoiler:


    I also tried using waitbutton command from PKSV then callasm this routine but It just sets the var to 0. Also waitbutton only accepts "A" and "B"

    Spoiler:
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • How do you integrate wait key in asm? I tried looping until a button is pressed but I think I got stuck in an infinite loop.

    Spoiler:


    I also tried using waitbutton command from PKSV then callasm this routine but It just sets the var to 0. Also waitbutton only accepts "A" and "B"

    Spoiler:

    You need two routines to pull this off. The first routine would pause script execution, and start a key listener task. Then the key listener task would check for a new key press, and destroy the task/resume the script
     
    33
    Posts
    2
    Years
    • Seen yesterday

    Battle Modes!


    In this post, we will be implementing a base skeleton structure to allow the hacker to add in their own battle modes, I'll also be including some example "add-ons" so you know how to do it yourself. The post currently contains possibilities for the hacker to implement routines which run once at the end of each turn (perfect for tournament clauses) and a routine which runs once every move is chosen and used (perfect for trainer sliding *hint hint danillS*).

    I'm calling it a skeleton, but it's actually more like a hook into a routine which runs your routines!
    It works like this:
    1) Hook from original to routine which runs routines
    2) If flag is set, routine runs the routines it's told to run
    3) Returns back to hooking location

    So all you really need to do to add new battle modes, is add to the list of routines we call (Which is simple, I'll explain in detail later). I should also mention that these routines are called in ALL types of battle including wild, trainer, and scripted. Happy hacking!

    Battle Routine By Move:


    This routine will run, on average four times per turn. Once you select your move, once you use your move, once the opponents uses their move and at the end of the aftermath. This makes the routine a perfect branching place for an Oak-tutorial like battle.

    How to insert:
    Look at the routine below. The last line .table has an incomplete pointer. It says 0x[pointer to routine table]. Find enough free space (takes 4 byte per routine) in your ROM and set the pointer for .table to that. You do not add +1 to the pointer, nor is it in reverse hex. Once you've fixed the pointer, compile the routine into free space. The last pointer in the routine NEEDS to be 00 00 00 00.


    Spoiler:


    Now navigate to 0xE2E0 and insert the byte changes:
    Code:
    00 4D 28 47 XX XX XX 08
    Where XX XX XX is the reverse hex pointer to your routine +1.



    Usage:
    The routine is toggled by flag 0x2FC. Activate the flag to toggle routines called by this routine. To add routines into the list of called routines, navigate to the pointer of freespace you made .table point to. Insert into that table pointers in reverse hex +1 to wherever you compiled the addon routines make sure they have the 0x8 prefix. The structure of the table should be: [routine pointer in reverse hex +1 (4 bytes)] for each pointer in the table. I.e if I put the addon at 0x740000, the pointer would read 01 00 74 08.


    Addons for Battle by move:


    Prevent loss (white out):
    Spoiler:



    Battle by turn:


    This routine will run all of it's referenced routines at the end of the turn (right before the turn counter in incremented.

    How to insert:
    Look at the routine below. The last line .table has an incomplete pointer. It says 0x[pointer to routine table]. Find enough free space (takes 4 byte per routine) in your ROM and set the pointer for .table to that. You do not add +1 to the pointer, nor is it in reverse hex. Once you've fixed the pointer, compile the routine into free space.
    Last entry in the table needs to be 00 00 00 00.

    Credits to daniilS for helping with optimization.
    Spoiler:


    Now navigate to 0x13CB0 and insert the following byte changes:
    Code:
    00 48 00 47 XX XX XX 08


    Usage:
    The routine is toggled by flag 0x2F8. Activate the flag to toggle routines called by this routine. To add routines into the list of called routines, navigate to the pointer of freespace you made .table point to. Insert into that table pointers in reverse hex +1 to wherever you compiled the addon routines make sure they have the 0x8 prefix. The structure of the table should be: [routine pointer in reverse hex +1 (4 bytes)] for each pointer in the table. I.e if I put the addon at 0x740000, the pointer would read 01 00 74 08.

    Battle by turn addons:


    Sleeping clause:
    Spoiler:


    Battle end by turn:
    Spoiler:

    Sleep Clause it works?

    I correctly installed Delete Fainted Pokémon and it worked, but Sleep Clause did not :[

    013CB0: 00 48 00 47 01 00 80 08
    800000: BE 20 80 00 0B 4A 00 F0 11 F8 00 28 07 D0 08 4C 22 68 00 2A 03 D0 00 F0 09 F8 04 34 F8 E7 06 49 C8 7C FE 28 01 D8 01 30 C8 74 04 4A 10 47 C0 46 00 00 81 08 D1 E6 06 08 90 4F 00 03 BD 3C 01 08
    810000: 01 00 82 08 00 00 00 00
    820000: 0F B5 00 22 00 23 05 2A 0B D0 09 48 64 21 51 43 40 18 00 78 40 01 40 09 00 28 00 D0 01 33 01 32 F1 E7 01 2B 02 DD 03 48 05 21 01 70 0F BD C0 46 7C 40 02 02 8A 3E 02 02
     
    Last edited:

    sylingga

    Red Everywhere
    86
    Posts
    10
    Years
    • Seen May 6, 2024
    I don't really feel like doing a challenge cup. Also some of your features can be achieved using the already created party checker routine. Species Clause, Evasion Clause, OHKO clause can all be done by it. Maybe if I feel like it in future :P


    Custom nicknames for enemy Pokemon


    So this works for any wild or trainer Pokemon. It basically allows you to nickname a Pokemon on the enemy team prior to battling. For those special trainers or maybe special Pokemon :)

    How to insert:

    There's actually a little bit of work before you can compile and insert routines. First look at the routine below. You'll notice at the last line there is a Pointer to something that I call "TABLE". This table is going to be a table full of nickname with each entry 0xB bytes long. Find some space in your ROM which you will use for this table and correct the offset accordingly.

    Spoiler:

    Once you've made the modification to the pointer, compile and insert the routine into freespace.
    Next navigate to offset 0x406DC and insert the following:
    Code:
    00 48 00 47 XX XX XX 08
    Where XX is the pointer to the above routine in reverse hex +1.

    Usage:
    First navigate to your table which will contain the nicknames (it should be the offset in the routine you changed). You need to keep the table formatted like this [10 bytes (Name in hex)] [1 byte (0xFF)]. Insert as many names as you'd like.

    Next, to activate the routine, you must setflag 0x270 AND you need to setvar 0x8000 0x[table starting index].
    If you're battling a trainer with 6 Pokemon, the nicknames will be determined from the table. It will read six nicknames starting from the starting index given by variable 0x8000. There is no need to callasm. :)

    wZeZnYU.png


    I want to use this on my rom hack,
    Can you help me?

    i'm not really good at scripting
     
    192
    Posts
    5
    Years
  • [FR] EV-reducing Berries

    Find 0x49C bytes of free space at a word-aligned address, and take note of it.
    Set the EV-reducing berries' Type to Type 1 ("Out of battle").
    Set the items' Field script pointers to the address you noted, plus 1.
    Set the items' Battle script pointer to 0xA2239.
    Assemble the following routine, changing 0xXXXXXX to the address you noted (not plus 1).
    Open the generated .bin file, navigate to the location address, and select 0x49C bytes.
    Copy the bytes and paste them in your ROM, at the same address.
    ...
    This will introduce the Pomeg Glitch; see tkim's post here on how to fix it.

    I implemented this routine in my project and it is working "as it should". 😔
    There is a huge problem: If I use a Kelpsy Berry, it will reduce my Pokémon's Attack EVs without error, but if I use a Protein, the item is not consumed. 😡
    If I accidentally use it on a level 100 Pokemon, I can no longer increase the EVs.

    How can this be fixed?
     
    173
    Posts
    4
    Years
    • Seen Feb 4, 2024
    I wonder is there has a code implements BW item use system...
    If selected item (such as Potion) has many, on map use it to a Pokemon (or it won't affect) won't back to bag automaticly unless that item is last one.
     

    sylingga

    Red Everywhere
    86
    Posts
    10
    Years
    • Seen May 6, 2024
    I wonder is there has a code implements BW item use system...
    If selected item (such as Potion) has many, on map use it to a Pokemon (or it won't affect) won't back to bag automaticly unless that item is last one.

    yes there is.
    i think its on HMA discord. try join that and you will see
     
    192
    Posts
    5
    Years
  • Summary Screen Wrap-Around

    First of all, I would like to thank Zeturic for creating the original routine for this. My routine is different from theirs, and I have extended it a bit, which is why I am posting this here.

    Anyway, this patch modifies the summary screens in both the Party Menu and in the PC so that if you are on the first Pokemon and you go upwards, you will loop around to the last Pokemon (and vice versa). Ordinarily, in this circumstance, nothing would happen.

    (Download)

    This folder contains the patch itself, and the two routines that comprise it. There were two functions which were replaced, and both of the new functions were shorter than the originals (hence why this could be turned into a patch).

    This patch will skip over Eggs when scrolling while in the Party or PC, but if you want to see the Egg's summary (to see how long it will take to hatch), you can select their summary individually.

    If you have more than one Egg in the party and move up or down (if the next slot is an egg), the game freezes.
     

    Marinebeast

    violet phantom in disguise
    11
    Posts
    1
    Years
  • Here's a quick question!

    I used the Ability Capsule script by Spherical Ice to create an Ability Capsule item, and it worked great-- but I'm making this for a romhack where almost all of the Pokemon have two abilities, so making an infinite-use key item that runs this script for a Pokemon would be preferable.

    What edits would I need to make to the script (or post-compiled hexadecimal) in order to change this? I would imagine it's similar to the scripts that alter TMs or make other reusable key items, but at the moment I'm not confident with ASM script or trying to find the specific hex bytes that need to be altered.

    Thanks so much in advance. This thread's incredibly helpful and I appreciate all the excellent content being shared here!
     

    AkameTheBulbasaur

    Akame Marukawa of Iyotono
    409
    Posts
    10
    Years
  • If you have more than one Egg in the party and move up or down (if the next slot is an egg), the game freezes.

    Great catch!

    I fixed the problem now. I updated the download. All you need to do is reapply the patch and it should be fixed now.

    Turns out that the Party routine was not updating the counter correctly when there was an Egg, creating an infinite loop which soft-locked the game.

    Not anymore though! I tried it with two Eggs (it should work for more than two as well, hopefully).

    Here's a quick question!

    I used the Ability Capsule script by Spherical Ice to create an Ability Capsule item, and it worked great-- but I'm making this for a romhack where almost all of the Pokemon have two abilities, so making an infinite-use key item that runs this script for a Pokemon would be preferable.

    What edits would I need to make to the script (or post-compiled hexadecimal) in order to change this? I would imagine it's similar to the scripts that alter TMs or make other reusable key items, but at the moment I'm not confident with ASM script or trying to find the specific hex bytes that need to be altered.

    Thanks so much in advance. This thread's incredibly helpful and I appreciate all the excellent content being shared here!

    As it turns out, you are in luck. I did this exact same thing in my game. The way you do it is very simple.

    First, you write out an NPC script which has the Item's effect. You will want to write it in such a way that it does not remove the item after the script is over. Remember where you inserted it.

    Next, you can use this routine by Darthatron to allow an item to run a script when you "use" it. Replace the "08AABBCC" with the address of your NPC Script (do not add one). Also, make sure to put the address where you will insert this routine after the ".equ ROM, 0x08" part (so if you put it at 0xAABBCC you would have ".equ ROM, 0x08AABBCC").

    Spoiler:


    Finally, in the Item Editor, I believe there is an option to allow the item to run a routine when used. You set the address of that routine to the address of Darthatron's routine. Then you only need to set the Item to be a Key Item in the editor, and you should be done.
     
    Last edited:
    192
    Posts
    5
    Years
  • Great catch!

    I fixed the problem now. I updated the download. All you need to do is reapply the patch and it should be fixed now.

    Turns out that the Party routine was not updating the counter correctly when there was an Egg, creating an infinite loop which soft-locked the game.

    Not anymore though! I tried it with two Eggs (it should work for more than two as well, hopefully).

    Thanks!!!
     
    Last edited:

    Marinebeast

    violet phantom in disguise
    11
    Posts
    1
    Years
  • Thank you Akame for the pointers! That pointer script works great and should help a lot in the future when I can't run something directly from an item.

    I did notice, previously in the thread, there was mention of Everstone nature-passing functionality being ported to FireRed, but I'm not sure if it was posted.
    Was this ever done/is there a script for it anywhere? I know there's the CFRU standalone item pack out there that has the Everstone update in it, but it writes to an offset that's unfortunately already very full in the hack I'm shining up.
     
    192
    Posts
    5
    Years
  • Nature Changing
    Before I begin, I should mention that this only works for FireRed at the moment. This is because it uses the Lustre stat, which in FireRed is unused but in Emerald is not. If you can find another stat to use, (or you don't have contests in your Emerald hack), then you can use this.


    I'm having trouble inserting the Synchronize upgrade element.
    The method of how this is inserted is very poorly explained. Could you make a step-by-step video of how to implement the whole context?
    My game freezes if I have the first Pokémon with Synchronize.
     

    AkameTheBulbasaur

    Akame Marukawa of Iyotono
    409
    Posts
    10
    Years
  • I'm having trouble inserting the Synchronize upgrade element.
    The method of how this is inserted is very poorly explained. Could you make a step-by-step video of how to implement the whole context?
    My game freezes if I have the first Pokémon with Synchronize.

    The manual assumes that the reader is familiar with how to insert THUMB Assembly routines, so my apologies if it was unclear for you. It might have also been unclear how to use the ".equ ROM" statement at the top.

    The purpose of it is to be a dynamic address, which is helpful as the Synchronise routine is actually two routines baked into one. So, let's say you put the combined routine at 0xAABBCC. Setting "equ ROM, 0x08AABBCC" creates a keyword named "ROM", which is equal to 0x08AABBCC. So, when the routine calls the GetNature function at "GetNatureFunction+ROM", it will be able to format the pointer correctly.

    Anyway, using it is very simple and saves you time in the long run since you don't have to insert as many routines. I thought it has a comment saying to put the address of the routine you were inserting by it, but I realised that the version that was up here was missing that. I added that in now, but I'll explain what to do here in case you are still confused.

    Here is what you should do:
    1. Find some free space in the ROM where the routine will go and write it down. The routine should have the number of bytes it uses written at the top (I realised the Synchronise one did not, so I updated it to - it uses 0x138 bytes).

    2. Put the offset where the routine will go after the "ROM 0x8" piece at the top. If you are going to put the routine at 0xAABBCC, then you should have ".equ ROM, 0x08AABBCC".

    3. Insert the routine at the offset you used in the ".equ ROM" line. They need to match always (so if you move the routine after inserting it, that will break it).

    4. Put in the byte changes which are indicated at the top of the routine. Remember that XX XX XX 08 is the offset of the routine, plus one, in reverse. So, if you had 0xAABBCC it would become CD BB AA 08.

    PM me if you are still having trouble and I'd be happy to help you.
     
    10
    Posts
    5
    Years
    • he/him
    • Seen Oct 31, 2023
    Sitrus Berry Update:
    Spoiler:


    Berry Activation Update:
    Spoiler:

    For any folks having trouble with the Sitrus Berry use effect, remove these two lines from the routine, and it should work:
    cmp r1, #0x8E
    bne Skip
     
    3
    Posts
    10
    Years
    • Seen Feb 18, 2023
    How about I would like to know if there is currently a routine that use the functions to generate a pokemon with all its specific data, basically to be able to replicate a pokemon for example from another trainer, keeping the data of the other trainer, for FR Y E
     
    Back
    Top