• 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

2
Posts
3
Years
    • Seen Apr 1, 2022
    You would use the party checker routine to check if Mewtwo is holding the item. Then, depending on the return you would call silent evolution. It's just simply combining two routines I've already done.


    Thanks.

    Get Pokemon Type


    Recently, someone commented on the limitations of my special 0x12b edit. Honestly speaking it is very limited, and only really has a use for checking if you have a certain type of Pokemon. If you had multiple pokemon of the same type it would only return the first one..ect.ect. Well I decided to customize it a little more. It's less powerful now, but more useful (hopefully). All it does is return the type of a Pokemon in a certain slot.

    How to insert:

    Compile and insert into free space the following routine:
    Spoiler:


    Usage:
    setvar 0x8000 0x[pokemon slot from 0 to 5]
    callasm 0x[routine +1]

    It will store the Pokemon's type in variable 0x8000 in the form of an integer. The values in decimal follow this table (it will be stored in hex of course):
    Code:
    0x0 - Normal
    0x1 - Fighting	
    0x2 - Flying
    0x3 - Poison
    0x4 - Ground
    0x5 - Rock
    0x6 - Bug
    0x7 - Ghost
    0x8 - Steel
    0x9 - ???
    0xA - Fire
    0xB - Water
    0xC - Grass
    0xD - Electric
    0xE - Psychic
    0xF - Ice
    0x10 - Dragon
    0x11 - Dark
     
    65
    Posts
    8
    Years
  • Hello,

    I'd like to request an ASM to determine an NPC's location on a map. So if an NPC is moved (by the Copy-Player Movement f.ex.) and lands on a certain location, a script should trigger, like breaking a rock in order for the Player to pass.

    Thank you :)

    Best regards,
    Xero3C
     
    75
    Posts
    10
    Years
  • FKayVct.png

    9QvzU7S.png

    How to apply this at emerald?
     

    Dreamaker

    Banned
    97
    Posts
    14
    Years
  • Thick Club [ Fire Red ]

    Spoiler:
     
    Last edited:

    Dreamaker

    Banned
    97
    Posts
    14
    Years
  • Stick [ Fire Red ]

    Spoiler:
     

    Dreamaker

    Banned
    97
    Posts
    14
    Years
  • Exp Block via Badge [ Fire Red ]

    Spoiler:


    Edit the level table to your liking. (AAAAAA)
     

    JK0JK

    JK is JK
    25
    Posts
    3
    Years
  • Actually the whole overworld loading thing is weird..it's done in like 9 places lol.
    If you experience bugs, use it in conjunction with the backsprite hack I made. If you still have bugs, report them here!

    I've been experimenting with your routine and I noticed that, though it changes every time a warp is made, hiding the OW sprite with a menu (such as the backpack's or the trainer card's) will return the sprite to the "hero [gender]" sprite, with the colour palette of the most recently used sprite. Hiding the player a second time will return the colour palette to the one associated with the default sprite, only changing back to the one the routine wants once a warp is made.

    How would I solve this?
     
    5
    Posts
    9
    Years
    • Seen Oct 1, 2023
    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.

    Offsets listed here are for FireRed, though, so keep that in mind if you decide to port it.

    Anyway, without further ado, I present Nature Changing!

    How Does It Work?
    Skip this if you don't care about the behind the scenes stuff.

    Basically, this hijacks the GetNature function. It first checks the Lustre stat of the Pokemon in question. If it's equal to zero, then it gets the Nature form the PID as usual. If it's not zero, then it uses the Lustre value as the Nature, effectively changing the Pokemon's Nature without messing with the PID (and potentially messing up other stuff like the Pokemon's gender, Shininess, etc.).

    This does mean you can't set the Nature to Hardy, but this is not that big of a deal since there are other neutral Natures you can use.

    The Main Event
    I have written an instruction manual that explains how to use the hack in detail. It also contains links to download everything.

    The link presented below is the link to download the folder with the Instruction Manual and all the routines. Not every routine in the folder is one you need to insert, as there are a couple of optional add-ons to make changed Natures compatible with other hacks.

    Download: Here!

    Hey I just wanted to say great work with everything you have done!

    But I'm sitting here going crazy at the moment because every time I'm testing my rom to see if I have implemented everything correctly, I run into an issue. When I select a starter Pokémon my game freezes after choosing the Pokémon. It only does this after I rewrite 0x42E9C.

    I have chosen the offset 0x750040 for the routine. So it should be just replacing "00 B5 00 21 00 22 FC F7" with "00 49 08 47 40 00 75 08" right?

    Not sure if you have had this issue in the past or may have an idea of what I might be doing wrong. Any help is much appreciated!
     
    116
    Posts
    16
    Years
  • Hey I just wanted to say great work with everything you have done!

    But I'm sitting here going crazy at the moment because every time I'm testing my rom to see if I have implemented everything correctly, I run into an issue. When I select a starter Pokémon my game freezes after choosing the Pokémon. It only does this after I rewrite 0x42E9C.

    I have chosen the offset 0x750040 for the routine. So it should be just replacing "00 B5 00 21 00 22 FC F7" with "00 49 08 47 40 00 75 08" right?

    Not sure if you have had this issue in the past or may have an idea of what I might be doing wrong. Any help is much appreciated!

    Try replace it as 00 49 08 47 41 00 75 08.
     
    990
    Posts
    4
    Years
  • Change Titlescreen Cry For CFRU/DPE based hacks
    Simple ASM which changes the TS cry for the ROM's that utilize the CFRU/DPE (since manually changing them doesn't work).

    Code:
    Code:
    .thumb
    .global TitlescreenCryFix
    
    .org 0x791EE
    ldr r0, .Pointer
    bx r0
    
    .align 2
    .Pointer: .word Main + 0x8000001
    
    .org 0x[Offset where you want to insert the code]
    Main:
    ldrh r0, .[Your PKMN Name; check names in DPE (include/species.h)]
    mov r1, #0x0
    bl CryRelated
    ldrb r0, [r4, #0xC]
    ldr r2, =0x80791F9
    bx r2
    
    CryRelated:
    ldr r2, =0x8071DF1
    bx r2
    
    .align 2
    .[Your PKMN Name; check names in DPE (include/species.h)]: .word 0x[Your PKMN Cry (same number); check names in DPE (include/species.h)]


    Making it work:
    Put 01 48 00 47 C0 46 XX XX XX XX 00 at x791EE where XX XX XX XX is your pointer + 1.


    That's about it.
     

    Dreamaker

    Banned
    97
    Posts
    14
    Years
  • Hidden Power + Held Item = 2nd Type [ Fire Red ]

    Spoiler:


    Same Hidden Power + Equivalent Held Item = 2nd Type (Only Works in Single Type Pokémon)

    Example:
    Alakazam + Hidden Power Dark + Black Glasses = Psychic / Dark
    Tauros + Hidden Power Fighting + Black Belt = Normal / Fighting
    Miltank + Hidden Power Rock + Hard Rock = Normal / Rock
    Stantler + Hidden Power Psychic + Twisted Spoon = Normal / Psychic
     
    42
    Posts
    2
    Years
  • I would like to request a routine that allows for more region maps in emerald.
    I would also like to request a routine that allows for more map names in emerald
    I'm not sure how hard this would be and I appreciate anybody who writes ASM Routines
     
    4
    Posts
    4
    Years
    • Seen Oct 25, 2023

    Inheriting IVs from parents (via Destiny Knot, in the daycare)


    How to insert:

    Before doing anything, look at the code. There are two comments that say:
    @masterball lol. Change to item you want :D
    @Parent2 has masterball :D
    At those lines, change the line to "cmp r0, #0xDestinyKnotItemID" and
    "cmp r3, #0xDestinyKnotItemID" respectively.

    Once you're done that, compile and insert into free space.
    Spoiler:


    Here's a compiled version:
    Code:
    48 B4 76 46 28 1C 0C 21 26 4A 00 F0 49 F8 03 1C 28 1C 8C 30 0C 21 23 4A 00 F0 42 F8 01 28 0A D0 01 2B 08 D0 B6 46 48 BC 68 46 29 1C 1E 4B 00 F0 38 F8 1E 48 00 47 05 23 00 F0 26 F8 1B 88 90 B4 27 24 E4 18 00 27 06 2F 18 D0 A7 42 14 D0 01 23 00 F0 1A F8 18 1C 00 88 8C 21 48 43 40 19 27 21 C9 19 13 4A 00 F0 1C F8 12 4A 10 80 27 21 C9 19 68 46 11 4B 00 F0 15 F8 01 37 E4 E7 68 46 0F 4B 00 F0 0E F8 90 BC CD E7 0D 4A 00 F0 09 F8 00 04 00 0C 19 1C 0B 4B 00 F0 04 F8 06 4B 18 80 70 47 10 47 18 47 45 FD 03 08 C1 5A 04 08 01 61 04 08 E9 FB 03 08 D0 70 03 02 7D 03 04 08 7D E4 03 08 C9 4E 04 08 85 46 1E 08
    Now go to 0x460F8 and insert the following:
    Code:
     00 48 00 47 XX XX XX 08
    Where XX XX XX is the pointer in reverse hex +1 of the routine you just compiled.


    How it works:
    When the egg is generated, we check both parents to see if their holding an item matching the item we're looking for. If they are, the egg inherits 5/6 IVs from their parents. Each parent has a 50% chance to pass down one of their IVs.

    There is no usage section, because the rest is done automagically when you have two compatible Pokemon in the daycare and they make an egg :)

    Also, sorry for the double post, I wanted a fresh post for the first page :P
    so what program did you use to compile all of this? and can you provide a link?
     
    4
    Posts
    4
    Years
    • Seen Oct 25, 2023
    seemed to work but i cant find the offset mentioned in the post, i hate to sound like a noob, but can you post a video or something. im fairly new to this and i dont get all the lingo.
     
    55
    Posts
    3
    Years
    • Seen Feb 27, 2022
    I would like a request an ASM that stores the current map bank and map ID that the player is currently in, in variable let's say in vars 0x8003 and 0x8004

    For future dynamic usage :3 (Think of how you drop down to the underground mines and pop out to the surface at the recent route you were in.)
     
    42
    Posts
    2
    Years
  • seemed to work but i cant find the offset mentioned in the post, i hate to sound like a noob, but can you post a video or something. im fairly new to this and i dont get all the lingo.

    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
     
    55
    Posts
    3
    Years
    • Seen Feb 27, 2022

    OAM routines


    The first hackathon was probably the worst thing that could have happened for this thread. It completely killed my motivation for hacking and made me quit for a few months. There are some good things that came out of it, I was able to do a lot of research on things I hadn't before including field moves, OAM, trainer generation and such. I was looking around my older routines for OAM manipulation, and I had trouble understanding and ripping my own code! I had lost the source code, so I decided to rip as much as I can and redo the jibberish including some clean up.

    Similar routines to these ones I'm presenting were used for the custom intro in team 4's hackoff ROM :)


    Generating OAMs


    This routine is only to generate OAMs which are trainer or Pokemon sprites. I've modified it to be usable with a script, but honestly, setting the values yourself via ASM would've been faster (not that this is noticeably slow, just comparatively). I will have to do more research on making it portray an arbitrary image, but with the expansion work on the Pokedex and such, I don't see it as very necessary anymore.

    How to insert:
    Compile and insert the following routine into a free word aligned offset.

    Spoiler:


    Usage:
    The usage is quite simple, but it takes up a lot of temporary variables :P

    Code:
    @var 0x8000 - Slot #. Set 0x6 for shiny.
    @var 0x8001 - X-pos
    @var 0x8002 - Y-pos
    @var 0x8003 - Unoccupied Pal ID number. See OAM viewer.
    @var 0x8004 - Occupacity silluette set 1
    @var 0x8005 - species/trainer sprite ID
    @var 0x8006 - Front (1) or Back (0)
    @var 0x8007 - Toggle trainer or Pokemon

    Some quick notes about these variables.

    Variable 0x8000 is to determine the Pokemon's shinyness. If you're showing a Pokemon in your party just use that Pokemon's party slot. If you're showing a shiny Pokemon go ahead and use 0x6. Basically 0x6 = shiny, anything else (must be lower) depends on party slot.

    Variable 0x8003 plays a key role. Make sure in the OAM viewer the sprite ID is free.
    rwUxxWe.png

    Here sprite number 0 is taken by Oak's OAM. Click the Arrow until you find something not occupied, and set this variable to that value!

    Variable 0x8007 is a switch of sorts. It determines whether to show a trainer sprite or a Pokemon sprite.

    I think the rest of the variables are self explanatory. Mess around with them a little :)


    OAM tracking


    So I'm sure you can imagine, that at some point in time you want your OAM to disappear. You can't have it on the screen forever, maybe even make it disappear temporarily and reshow it without having to do the painfully expensive creation call again. I made a routine which will take into account the last OAM ID which you created and stores it in var 0x8008. Note that this is an ID assigned by the game code, not the same ID as the one we assigned on creation. Therefore it's important to track this.

    How to insert

    Compile and insert the following routine into free space.
    Spoiler:


    Navigate to 080070B0 and insert the following byte changes:
    Code:
    00 49 08 47 XX XX XX 08
    Where XX XX XX is the location your inserted your routine in reverse hex +1. The trailing "08" may change to 09 or something depending on where you inserted it. Remember to stay word aligned!

    Usage:
    This routine doesn't really do anything by itself. It's more of a routine which works in the background. It just writes to variable 0x8008 the last displayed OAM's ID. Basically, just insert it and do nothing :3


    A quick explanation of how OAMs are shown/hidden in FireRed.


    There's a neat RAM structure in FireRed which controls whether or not to show or unshow an OAM on the screen. This OAM's ID needs to be present in said structure. The structure, for some unknown reason, is 40 bytes in size. It looks like this:

    [OAM ID (1 byte)] [OAM ID (1 byte)] [OAM ID (1 byte)] ... [Byte 0x3F] [Filler bytes] ...[40th filler byte]

    In case you don't understand by now, it's basically a table of X entries where each entry is an OAM's ID to display. Every entry after the byte 0x3F is not read by game code, and is therefore nothing more than filler bytes!

    The reason as to why I'm confused the structure is 40 bytes is because the routines which use this structure restrict themselves by using another structure. This second structure only holds 13 OAMs at a time, which is why we can only have 13 OAMs present in FR on screen at once WITHOUT fully customized code. For the most part you'll never go over 13 anyways. I used 9 in total for the custom intro and the screen was cluttered :X

    My guess as to why it's 40 bytes is because it's used for animation frames as well. I'm not sure, I haven't researched that.
    This structure is located at 0x2021800.

    Hiding OAMs created


    Now that you understood the data structure, you need to remove your OAM's byte ID from the table. But how do you know which byte is your OAM's byte? That was what the previous tracker routine was for. Right after you create your OAM the corresponding table ID will be in var 0x8008. Copy this value into somewhere you won't lose it (i,e a non-temporary variable), from there you can callasm this routine with the appropriate parameters :)

    How to insert:

    Compile and insert the following routine to free space:
    Spoiler:



    Usage:

    In a script, set variable 0x8000 to the OAM ID you want to vanish, then simply callasm this routine. This data structure is updated every frame from what I was able to see, so the results should be immediate.


    Show OAM


    Sometimes you want to hide an OAM but only temporary. This routine will show an OAM which has already been loaded, but flagged as hidden or similar.

    How to insert:

    Compile and insert into free space the following routine:
    Spoiler:


    Usage:

    In a script, set variable 0x8000 to the OAM ID you want to reappear, then simply callasm this routine. This data structure is updated every frame from what I was able to see, so the results should be immediate.

    Closing notes:


    I may or may not update these with animations as well. One I'm particularly interested in doing is a slow fade. The biggest thing I want to address is how to use these in a script. I think it's fairly intuitive, but a quick example may help :)

    Spoiler:


    Play around with it. It can be fun, and hopefully this will open more doors for hackers. I've made it as friendly as possible even opening up the potential to use it in scripts, but if you have any questions you can direct them to me at the ASM help thread or something :D



    Hi, the OAM sprite show works wonders. Although, is there a way to delete the OAM sprites rather than hide them? The hide OAM causes glitchy bugs. And after the battle or even talking to an NPC with a yes or no decision/buying at the show, it causes the OAM not to show up using Show OAM.
     
    Last edited:
    Back
    Top