• 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.

Development: Checking POKEMON LEVELS without ASM

pokemonforever27

IS RIDING LUGIA...
55
Posts
15
Years
Something that is becoming more popular to do in a hack is TRAINER BATTLEs whose POKEMON are at the same level of the players highest. JPAN, Hackmew, and myself have done some extensive research into the ASM aspect, but I only recently figured out that it was in fact possible without ASM. This tutorial will show you how to check which POKEMON is at the highest level without having to insert or deal with ASM. It stores the level of the highest POKEMON in LASTRESULT.

First, the code:
Code:
'---------------
#org 0xpointer1
lockall
copybyte 0x20370D0 0x20242D8
comparefarbytes 0x20370D0 0x202433C
if 0x0 goto 0xpointer2
comparefarbytes 0x20370D0 0x20243A0
if 0x0 goto 0xpointer3
comparefarbytes 0x20370D0 0x2024404
if 0x0 goto 0xpointer4
comparefarbytes 0x20370D0 0x2024468
if 0x0 goto 0xpointer5
comparefarbytes 0x20370D0 0x20244CC
if 0x0 goto 0xpointer6
releaseall
end
 
'---------------
#org 0xpointer2
copybyte 0x20370D0 0x202433C
comparefarbytes 0x20370D0 0x20243A0
if 0x0 goto 0xpointer3
comparefarbytes 0x20370D0 0x2024404
if 0x0 goto 0xpointer4
comparefarbytes 0x20370D0 0x2024468
if 0x0 goto 0xpointer5
comparefarbytes 0x20370D0 0x20244CC
if 0x0 goto 0xpointer6
releaseall
end
 
'---------------
#org 0xpointer3
copybyte 0x20370D0 0x20243A0
comparefarbytes 0x20370D0 0x2024404
if 0x0 goto 0xpointer4
comparefarbytes 0x20370D0 0x2024468
if 0x0 goto 0xpointer5
comparefarbytes 0x20370D0 0x20244CC
if 0x0 goto 0xpointer6
releaseall
end
 
'---------------
#org 0xpointer4
copybyte 0x20370D0 0x2024404
comparefarbytes 0x20370D0 0x2024468
if 0x0 goto 0xpointer5
comparefarbytes 0x20370D0 0x20244CC
if 0x0 goto 0xpointer6
releaseall
end
 
'---------------
#org 0xpointer5
copybyte 0x20370D0 0x2024468
comparefarbytes 0x20370D0 0x20244CC
if 0x0 goto 0xpointer6
releaseall
end
 
'---------------
#org 0xpointer6
copybyte 0x20370D0 0x20244CC
releaseall
end

Second, the walk through:
"copybyte 0x20370D0 0x20242D8" this line copies the byte at the memory address of the level of the first POKEMON into the memory address of LASTRESULT. For this routine to work, we'll assume that the first POKEMON is highest, and we'll always copy the highest level POKEMON into LASTRESULT.

"comparefarbytes 0x20370D0 0x202433C
if 0x0 goto 0xpointer2
comparefarbytes 0x20370D0 0x20243A0
if 0x0 goto 0xpointer3
comparefarbytes 0x20370D0 0x2024404
if 0x0 goto 0xpointer4
comparefarbytes 0x20370D0 0x2024468
if 0x0 goto 0xpointer5
comparefarbytes 0x20370D0 0x20244CC
if 0x0 goto 0xpointer6"
These commands compare the bytes at the memory locations of the other POKEMON to LASTRESULT. If any of them are higher, we skip to an offset (0xpointer1, 0xpointer2, etc)

The copybyte command at the beginning of each offset copies the new highest level into LASTRESULT. The rest of their code then checks the remaining levels.

This routine checks all possible combinations. It doesn't matter what order the POKEMON are in.

Before you use the code, you'll need to put offsets in where I've written pointer1, pointer2, etc. I removed the pointers since it will be different for each hack.

This is a FIRERED VERSION. To use it in EMERALD, RUBY, SAPPHIRE, or LEAFGREEN, change the memory address values (the values after comparefarbytes and copybyte) to the memory addresses for your game.

Special Thanks:
JPAN for helping me on the ASM side
Hackmew for helping me on the ASM side
 

HackMew

Mewtwo Strikes Back
1,314
Posts
17
Years
  • Seen Oct 26, 2011
Well, I got asked already, and it is indeed possible with plain scripting. The question is: is it worth it, though?
Think about it. Instead of a simple callasm, you have to a lot of compares, and you even use more bytes.
 

NarutoActor

The rocks cry out to me
1,974
Posts
15
Years
I agree If someone already made the asm routine then that's what I go with, but if there is none then I would take the scripting method, due to my lack of asm knowledge.
 

pokemonforever27

IS RIDING LUGIA...
55
Posts
15
Years
The question is: is it worth it, though?
Think about it. Instead of a simple callasm, you have to a lot of compares, and you even use more bytes.

It is true that this code uses more space than the ASM, but not everyone knows ASM, wants to learn it, and wants to deal with inserting it and compiling it. Thus, I made this so that you don't have to know ASM. And let's face it, GAME FREAK coded it this way (although their's was more complex because it needed to set up a custom battle as well).

can I do this with stats, nature etc and write them to another pokemon?

The stats yes, nature, no. The nature, attacks, pp, etc is encoded in a way that requires ASM to decode. This article should help explain what I'm talking about.
 

Luster

Form changing script (HINT)
29
Posts
14
Years
It is true that this code uses more space than the ASM, but not everyone knows ASM, wants to learn it, and wants to deal with inserting it and compiling it. Thus, I made this so that you don't have to know ASM. And let's face it, GAME FREAK coded it this way (although their's was more complex because it needed to set up a custom battle as well).



The stats yes, nature, no. The nature, attacks, pp, etc is encoded in a way that requires ASM to decode. This article should help explain what I'm talking about.

thanks a lot, i thik i understand now.
 

HackMew

Mewtwo Strikes Back
1,314
Posts
17
Years
  • Seen Oct 26, 2011
It is true that this code uses more space than the ASM, but not everyone knows ASM, wants to learn it, and wants to deal with inserting it and compiling it. Thus, I made this so that you don't have to know ASM. And let's face it, GAME FREAK coded it this way (although their's was more complex because it needed to set up a custom battle as well).

Learning ASM in first place is not a bad idea at all. Not to talk about the fact some things cannot be done through plain scripting. Also, the script is actually more complex that the respective ASM version. Consider all those addresses: making errors is quite easy. BTW, you assemble ASM routines (ASM means Assembly).

The fact Game Freak coded it that way doesn't mean anything. It's not like their code is perfect. Either way, your script code is meant to retrieve the highest level only, while I've got a mimum level routine too in the R&D section.
 
Back
Top