• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

Development: Take/Return Pokemon

1,104
Posts
16
Years
ASM Take and Return Pokémon

NOTE:This is currently only for Fire Red. I'll add support for other ROM's when I find time.

To do this all you'll need is a little knowledge about command #23 (callasm) and the ability to use a hex editor very basically. You don't need to be an expert, because I'll even give you an example script.

Okay here's the code for those who know what to do with it. Its also is partly commented for those you have trouble understanding. Don't ask what to do with this if you don't already know. For those who don't know what to do with this, I'll give the other way to get the ASM code into the ROM. The code may not be the best but it works.
Spoiler:


Here's the ASM code for those who don't know how to compile it. This isn't an ASM tutorial so I won't cover anything other than what's needed to get this working.
Input this data into your ROM through a hex editor at an address of your choice. Write the address down, because you'll need them for the script.
Take Pokemon
Code:
1FB5 1A48 0088 1A49 0988 8842 00DC 03E0 
0120 1849 0880 1FBD 134B 0028 04D0 0022 
6433 0132 8242 FBD1 181C 1349 1922 0CDF 
0020 0021 1960 0433 0130 1928 FADB 6421 
5A1A 0949 511A 0D4C A142 08D0 0029 06D0 
081C 0421 06DF 111C 021C 181C 0CDF 0020 
0449 0880 1FBD 0000 8442 0202 B870 0302 
BA70 0302 B870 0302 00F0 0202 F401 0000

Then you'll also need to input this code into your Hex editor as well.
Return Pokemon
Code:
07B5 1048 0088 0528 00D0 03E0 0120 0E49 
0860 07BD 0A49 0028 04D0 0022 6431 0132 
8242 FBD1 0948 1922 0CDF 0022 0021 0160 
0430 0132 1928 FADB 0020 0349 0880 07BD 
8442 0202 B870 0302 BC70 0302 00F0 0202

Now that you have the ASM part done. This part should be easy. All we need to do now is script it. Most people are most comfortable with XSE nowadays so I'll put my example script to use the code in XSE.
But now we're still not ready to code. We need to know some things about your ASM code.
The first code uses 3 variables 0x8000, 0x8001, and 0x8002. The second code uses only two variables 0x8000 and 0x8002.
In the first code, 0x8000 is used to store the number of the Pokemon in your party. For example, if it's the first Pokemon, you would store zero, if it were the sixth Pokemon, you would store 5 into the variable.
0x8001 is used to store the total amount of Pokemon in your party. This can be obtained by just using countpokemon and then a copyvar from 0x800D to 0x8001.
0x8002 is used as an error check. For example if the Pokemon's number in your party that you wanted to take, was less than the total Pokemon in your party designated by the above two variables. This is just originating from a normal C/C++ and the fact that a returned 0 means no problems, and a return of anything else means an error occurred.

In the second script, 0x8000 is used for the total Pokemon you have.
0x8002 is used in the same way as in the first code and is an error check.

So here's an example script using the ASM code. I'll comment any important areas out so you should know what's going on even if you don't script very well.
Code:
#alias @ $

#dynamic 0x800000

#org $start	'Code to take a Pokemon
lock
faceplayer
checkflag 0x200 
if 0x1 goto $return
setvar 0x8000 0x0	'Pokemon to take is first in Party.
countpokemon		'Total Pokemon in party.
copyvar 0x8001 0x800D
callasm 0x800001	'callasm 0x(address + 1) Of course then I inserted this code at 0x800001
compare 0x800D 0x1	'If error occurred.
if 0x1 goto $error
msgbox $1 0x6
setflag 0x200
release
end

#org $error
msgbox $2 0x6
release 
end

#org $return
countpokemon
compare 0x800D 0x5
if 0x1 goto $error	'If there's no room for the return.
copyvar 0x8000 0x800D
callasm 0x800101	'Callasm 0x(address +1) Mine was 0x800100
compare 0x8002 0x1	'Error Check
if 0x1 goto $error
msgbox $3 0x6
clearflag 0x200
release
end

#org $1
= Pokemon taken. 

#org $2
= Error occurred.

#org $3
= Pokemon returned

Note this will only allow you to take one Pokemon at a time. If you try to take a second it will overwrite the first Pokemon and you'll lose the first Pokemon.
Please let me know if there are any bugs. I haven't extensively tested it out, I only checked whether it worked with the first Pokemon being taken and returned or not. The quicker people let me know, the quicker I can fix it.

Don't take without Permission.
Tutorial and code by thethethethe.​
 

Gamer2020

Accept no Imitations!
1,062
Posts
15
Years
This looks good. I will try it when i get a chance. I wish there was something like this for ruby. lol

Yay! first post!
 
Last edited:

Vrai

can you feel my heart?
2,896
Posts
15
Years
  • Age 29
  • Seen Oct 24, 2022
This is ftw, thethethethe. Nice job. ^^

You really should write an ASM tutorial.
 

ZodiacDaGreat

Working on a Mobile System
429
Posts
17
Years
I see, so its posted :) Great job

Edit: I'll do another one where both routines are combined and works with special 0x9F.
 
Last edited:
1,104
Posts
16
Years
Sorry, I made a little mistake. I need to fix it up. At the moment this will only be good for taking the first Pokemon when only having one Pokemon. I know where the mistake is. I'll fix it up and test it properly by about tomorrow or possibly the day after.

Ahah, very nice. Very nice indeed.

Hm, DevKitPro?
If you'd like. devkitARM, HAM, goldroad, MIDI2GBA, it's all good.
 

Juan

Brazilian with a bad English
92
Posts
16
Years
mov r2, #25 @or 50, I can't remember off the top of my head.
It is even 50, or 0x32(I used with 0x32 and worked)

En(Google):
I liked their routines had not seen before making mine.
You used three variables, but I think not need the number of Pokémon on the team, because a loop from 0 to 5 did not consume much space and not much memory.
I like to check the error occurred, and the "debugger" used with the variable 0x8002.
Never would have thought of something. :D
One more thing, I think you can simplify these routines, especially the label "fix" that though complex, can (I think) to be optimized.
Thank you for sharing your knowledge with us, are with examples such as I learn new things. ^^

PT_BR:
Gostei das suas rotinas, não tinha visto antes de fazer a minha.
Você usou três variáveis, mas acho que não precisaria o número de pokémon na equipe, pois um loop de 0 à 5 não consome tanto espaço, e nem tanta memória.
Gostei da parte de verificar se deu erro, e o "debugger" usado com a variável 0x8002.
Nunca teria pensado em algo parecido :D
Mais uma coisa, acho que dá para simplificar essas rotinas, principalmente o label "fix", que apesar de complexo, pode(eu acho) ser otimizado.
Obrigado por compartilhar seu conhecimento conosco, são com exemplos desse tipo que eu aprendo coisas novas. ^^
 
1,104
Posts
16
Years
It is even 50, or 0x32(I used with 0x32 and worked)

En(Google):
I liked their routines had not seen before making mine.
You used three variables, but I think not need the number of Pokémon on the team, because a loop from 0 to 5 did not consume much space and not much memory.
I like to check the error occurred, and the "debugger" used with the variable 0x8002.
Never would have thought of something. :D
One more thing, I think you can simplify these routines, especially the label "fix" that though complex, can (I think) to be optimized.
Thank you for sharing your knowledge with us, are with examples such as I learn new things. ^^
No. It's 25 for what I used. I checked that. That comment was there for me so I could check it later. You used swi 0xB, which the r2 amount is half of the full length because it uses two byte writes or half-word writes. 0xC uses double that and the r2 holds a quarter of the full amount because it uses word long writes.

You're right, the code still needs to be fixed up a bit.
 

Juan

Brazilian with a bad English
92
Posts
16
Years
No. It's 25 for what I used. I checked that. That comment was there for me so I could check it later. You used swi 0xB, which the r2 amount is half of the full length because it uses two byte writes or half-word writes. 0xC uses double that and the r2 holds a quarter of the full amount because it uses word long writes.

You're right, the code still needs to be fixed up a bit.

now that I saw you used the 0xC and I 0xB ^^

EDIT:
.pokedata:
.word 0x02024284
.var1:
.word 0x020370b8
.var2:
.word 0x020370ba
.var3:
.word 0x020370b8

0x8002(var2) offset is $020370BC, not $020370b8 ^^

Spoiler:
 
Last edited:

0m3GA ARS3NAL

Im comin' home...
1,816
Posts
16
Years
This is great! But I gotta say, the ASM is a bit confusing, not many people will understand this at all...
Also, how do you compile all of this information? I certainly dont know how, and how do you know these functions and such, where can I learn all of this, because I really want to get into ASM!
A tutorial would be a great idea though, even if you were to release it in stages, like HackMew's XSE guide. (It does not have to be a .chm file though, lol. )
This is a breakthrough though, +Rep for you!
 

Juan

Brazilian with a bad English
92
Posts
16
Years
If you'd like. devkitARM, HAM, goldroad, MIDI2GBA, it's all good.
I could not use with goldroad.
I modified his routine, and changed some things.
Take:
Spoiler:

Return:
Spoiler:

Take:
Code:
00B5 C046 154B 1B88 154C 2488 FFE7 C046
1448 6425 5D43 4019 1349 1922 0CDF 013C
124E 0025 A342 01D0 0E49 05E0 0670 0130
0135 642D FADB 0CE0 0A4F 6425 5D43 7919
5B1C 6425 5D43 7819 0CDF A342 F4DB 0025
ECE7 0020 0649 0880 00BD 0000 B870 0302
BA70 0302 8442 0202 9039 1202 0000 0000
BC70 0302
Where:
84420202 = pokedata
B8700302 = var1(0x8000)
BA700302 = var2(0x8001)
BC700302 = var3(0x8002)
9039 1202 = RAM_offset

Return:
Code:
00B5 C046 0D4D 2D78 052D 12D0 6424 6C43
FBFF FAFF 211C F9FF 0CDF C046 0849 0024
0160 0430 0134 192A FADB 0020 0549 0880
00BD 0120 0349 0880 00BD 0000 B870 0302
0000 0000 BC70 0302
Where:
84420202 = pokedata
B8700302 = var1(0x8000)
BC700302 = var3(0x8002)
9039 1202 = RAM_offset

Script:
Spoiler:



If want to use other variables, or in other versions:
BPRE:
Spoiler:

AXVE:
Spoiler:

AXPE:
Spoiler:

PBEE:
Spoiler:

Also, how do you compile all of this information?
Download the program "goldroad", save the routine in a text file.
Drag the file from the routine to the Goldroad, and a file .GBA will be generated, which is routinely compilled.
 

0m3GA ARS3NAL

Im comin' home...
1,816
Posts
16
Years
Yes, the .GBA is the ASM routine in hexadecimal.

Ok, now, where can I learn all of the definitions and stuff, knowledge basically, I would need in order to ASM hack?
To put it simple, are tehre any reference sheets and/or tutorials I can get ahold of?
 
Last edited:

ZodiacDaGreat

Working on a Mobile System
429
Posts
17
Years
Relax pal, You'll see a set soon ;) Anyway, I must insist that to asm hack you'll need to know the GBA's hardware as well :p
 

0m3GA ARS3NAL

Im comin' home...
1,816
Posts
16
Years
Relax pal, You'll see a set soon ;) Anyway, I must insist that to asm hack you'll need to know the GBA's hardware as well :p

>_> I get this answer / response to me trying to learn ASM from alot of people. Quite frankly, I am tired of it, I am ready to at least TRY, all I ask is a bit of knowlege, and I am actually ecstatic to hear an ASM tutorial might be on it's way, it is about time! ^-^
In any case, I have gold road, and looked at the stuff shown in the little intro .GBA file that came with it, I have been looking at the ASM for it, and don't understand much, since I dont know definitions, or the functions of many of the things in the code.

But all of that is off topic.

All I can say it, that I am glad some people finally cracked give/take pokemon, congrats you guys!
 

Juan

Brazilian with a bad English
92
Posts
16
Years
>_> I get this answer / response to me trying to learn ASM from alot of people. Quite frankly, I am tired of it, I am ready to at least TRY, all I ask is a bit of knowlege, and I am actually ecstatic to hear an ASM tutorial might be on it's way, it is about time! ^-^
In any case, I have gold road, and looked at the stuff shown in the little intro .GBA file that came with it, I have been looking at the ASM for it, and don't understand much, since I dont know definitions, or the functions of many of the things in the code.

But all of that is off topic.

All I can say it, that I am glad some people finally cracked give/take pokemon, congrats you guys!

see GBA Tek: http://nocash.emubase.de/gbatek.htm
 

Vrai

can you feel my heart?
2,896
Posts
15
Years
  • Age 29
  • Seen Oct 24, 2022
AWESOME.

Thanks very much, you two. Maybe you'll help the community by teaching us to do ASM.. ^_^

Probably not, but meh. Thanks again.
 
Back
Top