• 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

3,830
Posts
14
Years
  • Age 27
  • OH
  • Seen Feb 26, 2024

ASM Resource Thread

This thread is for the development of new assembly routines and hacks based off of the requests of users. Feel free to make requests, fulfil others' requests, and expand upon the work of others to develop and improve the routines and hacks posted. Note that some of these routines are untested and, therefore, may have unexpected side-effects, bugs or oddities. Be sure to report them by quoting the post of the original routine (after checking if the bug has been fixed or reported already) and patiently wait. Always make a back up of your ROM before making any changes!

Thread rules

Do not demand for your requests to be fulfilled!
People do not have to fulfil your requests, they do it because they want to! Not only are those posts annoying, they also are completely pointless! If such a post is found, it will probably be deleted.

Wrap your hacks and routines in [SPOILER]spoiler tags[/SPOILER].
This is here to keep the thread as easy to browse as possible, as most routines tend to take up multiple lines and this can make scrolling through the thread a chore.

Be reasonable with your requests!
This thread is more mostly small routines: don't be greedy! No-one is going to make an entire hack for you.

Give credit when requested!
If and when you use any of the routines posted here, give credit to the original creator if they ask for it. If they don't explicitly ask for credit, assume they do. Theft won't be tolerated and if you're caught the moderators will request you add credits to your hack threads, and if not your thread may be deleted.

State the base game for which your requests / routines are for.
This is mostly to avoid confusion, and to allow for easier organisation of the thread.

Read the thread before making a request!
Again for organisational reasons, it is a waste of space and time to request routines which have already been created.

Routines

Ruby/Sapphire

Graphic Routines

FireRed

Pokémon Routines

Party Routines

Battle Routines

Item Routines

Other Routines

Graphical Routines

LeafGreen

Item Routines

Item Routines

Emerald

Pokémon Routines

Party Routines

Battle Routines

Item Routines

Specials Routines

Graphical Routines

Other Routines

Helpful Links

Assembling and Inserting ASM Routines by FBI
This post explains how to insert ASM routines to your ROM.

HackMew's Knowledge by HackMew
This includes a compiler and explains how to compile routines, as well as the basic construction of a routine and an overview of what ASM is.

GBA ASM Programming by Shiny Quagsire
This is another ASM tutorial that explains how assembly works with step-by-step explanations and useful images.

Yet another ASM tutorial by knizz and Full Metal
This is a tutorial about ASM for the Gameboy Advanced. It features expanding the Town Map for FireRed.
 
Last edited by a moderator:

Blah

Free supporter
1,924
Posts
11
Years
Would like, changing hms into key items so you don't need slaves be good?

Hi, already removed the need for HMs from Pokemon, and still create the field effect. If you want to use items to achieve this effect: http://www.pokecommunity.com/showthread.php?t=258426
When you get to the "addscript" part you will have to just point it to an existing script.

Surf is actually very easy to port to an item. You simply have to run the surf script, lol. That's at 0x1A6AC8. You only need to change that to this:
Spoiler:


Fly is the only one which will require some ASM, and even that is easy, because the research is already done for you. For the item script for fly, just do "callasm 0x80C4EF9 (this info is in my thread btw)

Flash is my last post in the HM thread.
RockSmash, Strength, waterfall are all done exactly the same as surf.
Strength however has a special flag, 0x805 which needs to be set. It allows the "strength effect" to persist.

It requires you have JPAN's hacker engine applied to put scripts on items btw, according to the tutorial I linked you.
 

kearnseyboy6

Aussie's Toughest Mudder
300
Posts
15
Years
  • Seen Jun 22, 2019
I like this idea and I have being playing ORAS and here are some features that could be implemented:

Only open if you want some features spoiled
Spoiler:
 

Blah

Free supporter
1,924
Posts
11
Years
I like this idea and I have being playing ORAS and here are some features that could be implemented:

Only open if you want some features spoiled
Spoiler:

I'm particularly interested in the wild Pokemon with special moves. The "encountered a specific pokemon" one is a little easy and hard at the same time. By that I mean what you have to do is easy, but doing it is a lot of work :P
The item about Pokemon on the route I'll check out after completing wild Pokemon with special moves :)
 

Turtl3Skulll

Blue Turtl3
76
Posts
10
Years
Dood, this sounds awesome, I hope you get some cool ideas from this.

Here's what came to my mind (For Fire Red U):
Spoiler:


If you can achieve any of the ideas let me know thanks.
 
Last edited:
204
Posts
9
Years
  • Age 37
  • Seen Jul 26, 2021
A nuzlocke feature, where fainted pokemon cant be healed would be great.
 

Blah

Free supporter
1,924
Posts
11
Years

Wild Pokemon With custom attacks


Well, this took me longer than it should have lol. I initially just edited the wild Pokemon in RAM to have the moves I wanted, and used masterballs to capture it (i.e I didn't battle it).
Then I got a PP problem where the PP didn't match, so I wrote a routine to try and fix the PP problem. Then I talked to a friend on IRC, and he pointed out that I should make sure the Pokemon has the same moves in battle. Yeah, needless to say it didn't lol. So I ended up hacking the wild pokemon generator.

How to insert:

First compile this ASM routine.
ASM Routine:
Spoiler:


compiled version:
Code:
0F 4D 00 24 29 1C 09 78 00 29 13 D0 02 21 61 43 49 19 09 88 40 46 0B 4B 00 F0 10 F8 01 34 04 2C F0 D1 00 04 49 46 0D 0C 00 9B 07 49 48 45 06 D1 06 49 08 47 03 4B 00 F0 01 F8 F2 E7 18 47 08 47 B8 70 03 02 B1 E8 03 08 61 EA 03 08 57 EA 03 08

Now go to 0x3EA46 and insert:
Code:
01 48 00 47 00 00 XX XX XX 08

Where XX XX XX is the reverse hex pointer to where you inserted the previously compiled routine.

How to use:
Set var 0x8000 to 0x0 to disable.
Variables 0x8000 to 0x8003 are the 4 custom attacks you want inserted.
So to set the first attack of the wild Pokemon to firepunch, I would setvar 0x8000 0x7.

Here's a present :3
LjzUa9a.png


EDIT: Attacks must be between 0x0-0xFFFF
 
Last edited:

Blah

Free supporter
1,924
Posts
11
Years
Adding new abilities will be good
Will be too hard for me because I don't have any experience with battle scripts. You're better off making a thread in R/D for it, sorry :(

Dood, this sounds awesome, I hope you get some cool ideas from this.

Here's what came to my mind (For Fire Red U):
Spoiler:



If you can achieve any of the ideas let me know thanks.

Rival naming, capturing trainer pokemon and items in wild battles I'll look into. Btw, Pokemon already use their berries in wild battles.

I am a total newb. Something I want is hacking the text box loadingroutine so that it would use a variableto load a certain text box.

Sign post vs normal text box? Kinda graphically, but I'll look into it.

A nuzlocke feature, where fainted pokemon cant be healed would be great.
Already been done by JPAN! It's also very simple, just set max HP to 0 when it's fainted.

Can you port for me and finish Double Wild Pokemon Battle code for Emerald.
Sorry I forgot to mention I only hack Fire Red. Not interested in other ROMs

EDIT:

Wild Pokemon Seen Count:


Check how many pokemon of a particular species you've seen. Requires JPAN's save block hack (here: http://www.pokecommunity.com/showpost.php?p=6993092&postcount=206)

How to Insert:

First compile the below ASM Code and insert into free space:
Spoiler:


Here's a compiled version
Code:
09 48 0B 21 09 4A 00 F0 0C F8 06 49 09 18 01 78 41 70 07 48 00 68 00 28 01 D1 06 49 08 47 01 BC 00 47 10 47 00 C0 03 02 2C 40 02 02 E9 FB 03 08 C8 3B 02 02 1D 35 01 08

Then navigate to 0x13516 and insert:
Code:
01 48 00 47 00 00 XX XX XX 08
Where XX XX XX is the reverse hex pointer to the routine you compiled above (plus 1).

To get the amount you've seen simply compile and insert:
Spoiler:


Here's a compiled version
Code:
03 B5 05 48 03 49 09 78 40 18 02 49 00 68 08 70 03 BD C0 46 B4 70 03 02 00 C0 03 02

How to use:
There is no use for the storing part, it's done automagically. For the getting part, setvar 0x8000 0xSpeciesYouWant
and then callasm 0xWhereYouCompiledGetterCode +1.

That's it. The limitations are it only counts up to 255 natural encounters. It supports up to 3576 inserted Pokemon Species.
 
Last edited:

MrDollSteak

Formerly known as 11bayerf1
858
Posts
15
Years

Wild Pokemon With custom attacks


Well, this took me longer than it should have lol. I initially just edited the wild Pokemon in RAM to have the moves I wanted, and used masterballs to capture it (i.e I didn't battle it).
Then I got a PP problem where the PP didn't match, so I wrote a routine to try and fix the PP problem. Then I talked to a friend on IRC, and he pointed out that I should make sure the Pokemon has the same moves in battle. Yeah, needless to say it didn't lol. So I ended up hacking the wild pokemon generator.

How to insert:

First compile this ASM routine.
ASM Routine:
Spoiler:


compiled version:
Code:
0D 4D 00 24 29 1C 09 78 FF 29 0A D0 02 21 61 43 49 19 09 78 40 46 09 4B 00 F0 0C F8 01 34 04 2C F0 D1 00 04 49 46 0D 0C 00 9C 05 49 48 45 02 D1 04 49 08 47 18 47 08 47 B8 70 03 02 B1 E8 03 08 61 EA 03 08 55 EA 03 08

Now go to 0x3EA46 and insert:
Code:
01 48 00 47 00 00 XX XX XX 08

Where XX XX XX is the reverse hex pointer to where you inserted the previously compiled routine.

How to use:
Set var 0x8000 to 0xFF to disable.
Variables 0x8000 to 0x8003 are the 4 custom attacks you want inserted.
So to set the first attack of the wild Pokemon to firepunch, I would setvar 0x8000 0x7.

Here's a present :3
LjzUa9a.png


EDIT: Attacks must be between 0x0-0xFF. You can only have 255 attacks in Pokemon :/

This is great FBI!

But there's actually room for 1FF attacks in Vanilla Pokemon, and expanded roms can get to FFFF now. So ideally this should be accounted for. I was under the impression that variables could be set to FFFF, because they're 2 bytes long. If this is untrue I have some suggestions.

One thing that could fix this is if you alter the routine a little, rather than making the variables account for a move, they should account for the position of the move in the egg move table. The reason I suggest this, is because ORAS specifically allows pokemon to be generated with an egg move. Now what I'd suggest is that when you load the var, you also load the egg move table, at which point you check for the pokemon or its pre-evolved form, and at that point add the variable number to this offset to get the egg move.

If you want to keep the freedom of having any move however, what you could do is, rather than allowing all four moves to be custom, you could make it more like ORAS in that its only the first slot that is changed. And then the second variable could be the second part of the move index, ie. if the halfword index of the move is 108, you'd set 8000 to 08, and then 8001 to 01. Then you'd shift it two places to the left and add them together to get your move.

This is just a suggestion because your current implementation is impressive, but is sadly not at its full potential, because being limited to the first 255 moves is just a pity.
 

Blah

Free supporter
1,924
Posts
11
Years
This is great FBI!

But there's actually room for 1FF attacks in Vanilla Pokemon, and expanded roms can get to FFFF now. So ideally this should be accounted for. I was under the impression that variables could be set to FFFF, because they're 2 bytes long. If this is untrue I have some suggestions.

One thing that could fix this is if you alter the routine a little, rather than making the variables account for a move, they should account for the position of the move in the egg move table. The reason I suggest this, is because ORAS specifically allows pokemon to be generated with an egg move. Now what I'd suggest is that when you load the var, you also load the egg move table, at which point you check for the pokemon or its pre-evolved form, and at that point add the variable number to this offset to get the egg move.

If you want to keep the freedom of having any move however, what you could do is, rather than allowing all four moves to be custom, you could make it more like ORAS in that its only the first slot that is changed. And then the second variable could be the second part of the move index, ie. if the halfword index of the move is 108, you'd set 8000 to 08, and then 8001 to 01. Then you'd shift it two places to the left and add them together to get your move.

This is just a suggestion because your current implementation is impressive, but is sadly not at its full potential, because being limited to the first 255 moves is just a pity.

Hello, does the Pokemon Egg moves get looked up for wild Pokemon?
Also, it's 255 limited by choice, if I loaded a half-word instead of a byte it would read 0xFFFF moves (simple fix for that is to replace all the ldrb with ldrh) You would also just subtract "1" from the .VAR offset.

Also if you don't want a full custom move set, and only the first move custom, then you can do:
setvar 0x8000 0xmove
setvar 0x8001 0xFF (or FFFF with halfword instead, though I'm not sure you can setvar that high, pls check for me :P)

And the routine will stop generating custom moves at that point and look into default moves.

Edit: Though if the Pokemon you are battling has only 1 move, it will not generate a second. Extra moves are only generated if the variable is set. For example level 1 bulbasaur has only tackle. If found in the wild, and given razor leaf, then even if 0x8001 is 0xFF it won't learn tackle.


Mini-progress which I quit halfway:
Skipping rival naming, go to 0x130690 and insert D1 0B. It will skip the rival naming and then do the turn small animation. But it won't unfade the screen and frankly freezes. Probably a very easy fix somewhere, but I'm lazy to look at all the code there.
 
Last edited:

Blah

Free supporter
1,924
Posts
11
Years
Nah! Its okay...
Ahhmmm how about Expanded PC boxes? in FireRed?

About that, I feel very bad shutting down all of your suggestions, but that seems like a lot of work for a feature that's not even that great. There's already a large amount of space in the PC, and I'm sure to expand it will take hours and hours of work :/

Capturing Opponent's Pokemon:

So I was working on making trainer's Pokemon capture-able, and it does this check to see if the Pokemon is capturable, and if it was it'd check to see if it's a trainer's Pokemon. Well, I disabled the check and was successful in capturing a Pokemon that didn't belong to me :P

Sadly, the Pokemon turned into a bad egg the moment I caught it. The only solution to this was to edit the checksum so it'd make sense again, however that would be a lot of work, and honestly the checksum is calculated relatively frequently. So upon investigation (mostly by Shinyquagsire, thanks for the deduction detective!) we were able to determine the egg was turning bad because the checksum was no longer valid with the player's trainer ID. So, after diving through the code a bit I found the part of the code that overwrote the trainer ID with the player ID. Then it was a matter of disabling it!

To insert:
insert the following bytes at the following offsets:
0x2D496: E0 E0
0x40B36: 00 00 00 00 00

To fix the Pokedex bug
Follow the instructions in this link: http://www.pokecommunity.com/showpost.php?p=8536920&postcount=333

Here's Brock's Onix :3

9Q92xd9.png
 
Last edited:

Turtl3Skulll

Blue Turtl3
76
Posts
10
Years
About that, I feel very bad shutting down all of your suggestions, but that seems like a lot of work for a feature that's not even that great. There's already a large amount of space in the PC, and I'm sure to expand it will take hours and hours of work :/

Capturing Opponent's Pokemon:

So I was working on making trainer's Pokemon capture-able, and it does this check to see if the Pokemon is capturable, and if it was it'd check to see if it's a trainer's Pokemon. Well, I disabled the check and was successful in capturing a Pokemon that didn't belong to me :P

Sadly, the Pokemon turned into a bad egg the moment I caught it. The only solution to this was to edit the checksum so it'd make sense again, however that would be a lot of work, and honestly the checksum is calculated relatively frequently. So upon investigation (mostly by Shinyquagsire, thanks for the deduction detective!) we were able to determine the egg was turning bad because the checksum was no longer valid with the player's trainer ID. So, after diving through the code a bit I found the part of the code that overwrote the trainer ID with the player ID. Then it was a matter of disabling it!

To insert:
insert the following bytes at the following offsets:
0x2D496: E0 E0
0x40B36: 00 00 00 00 00

Here's Brock's Onix :3

9Q92xd9.png

Thanks for researching so quickly, I'll try it later, hopefully it works along with JPAN's engine
 
3,044
Posts
9
Years
About that, I feel very bad shutting down all of your suggestions, but that seems like a lot of work for a feature that's not even that great. There's already a large amount of space in the PC, and I'm sure to expand it will take hours and hours of work :/

Capturing Opponent's Pokemon:

So I was working on making trainer's Pokemon capture-able, and it does this check to see if the Pokemon is capturable, and if it was it'd check to see if it's a trainer's Pokemon. Well, I disabled the check and was successful in capturing a Pokemon that didn't belong to me :P

Sadly, the Pokemon turned into a bad egg the moment I caught it. The only solution to this was to edit the checksum so it'd make sense again, however that would be a lot of work, and honestly the checksum is calculated relatively frequently. So upon investigation (mostly by Shinyquagsire, thanks for the deduction detective!) we were able to determine the egg was turning bad because the checksum was no longer valid with the player's trainer ID. So, after diving through the code a bit I found the part of the code that overwrote the trainer ID with the player ID. Then it was a matter of disabling it!

To insert:
insert the following bytes at the following offsets:
0x2D496: E0 E0
0x40B36: 00 00 00 00 00

Here's Brock's Onix :3

9Q92xd9.png

This seems awesome enough and very easy to insert. I know that there's a Gameshark code about that xD

Good job! ^^
 

Blah

Free supporter
1,924
Posts
11
Years
Thanks for researching so quickly, I'll try it later, hopefully it works along with JPAN's engine

It should have no problems with any other hacks; this check is quite standalone. I should also mention the Pokemon you captured from another trainer will act like a Pokemon who has been traded. If you don't have the badges to train it, it will disobey you.

Please don't waste time on rival naming skip; there's a routine for it published in this post: www.pokemonhackersonline.com/showthread.php?t=14448-Jambo51-s-ASM-Resource-Center

Thanks for that.

This seems awesome enough and very easy to insert. I know that there's a Gameshark code about that xD

Good job! ^^

Thanks. To my knowledge, the gameshark code still turns your Pokemon to a bad egg. This fixes the bad egg too!

Anyways, I've finished all the requests which I'm willing to do. Keep shooting them at me guys :P

EDIT:


Toggling Capturability of Pokemon


So it's quite likely that maybe you want a Pokemon to be uncapturable, and at the same time you don't want to diminish it's catch rate to 0 in your Pokemon editor. Or perhaps you used the "capture trainer Pokemon" hack and you don't want it to work for all trainers. No problem, this is the hack for you :P

Basically it checks if variable 0x8000 is 0x1 or not. If it's 0x1, then any Pokemon you encounter (trainer or wild, via script or natural encounter) will become uncapturable even with the master ball. Simply set 0x8000 back to normal for the original game mechanics.
Note: If you use this hack, to say make it so the player can only capture a certain trainer's Pokemon, you will need to set 0x8000 right before the encounter, and unset it after (which is quite simple)
Note2: This hack won't let you capture trainer Pokemon, you need to have the capture trainer Pokemon hack from last time to create that effect.

How to insert:

First compile the following ASM code and insert into free space:
Spoiler:


Here is a compiled version:
Code:
05 48 01 68 03 4A 12 78 01 2A 01 D0 03 48 00 47 03 48 00 47 B8 70 03 02 4C 2B 02 02 91 D4 02 08 61 D4 02 08

Now navigate to 0x2D452 and insert the following:
Code:
01 48 00 47 00 00 XX XX XX 08
Where XX XX XX is the reverse hex pointer to where you inserted the above routine. That's it :)
EDIT: Add one to the pointer.

Here's a pesky Rattata:
JpL4im1.png

(Yes, the Pokeball animation is still there, this was taken after it.)
 
Last edited:
Back
Top