PDA

View Full Version : Development: Checking POKEMON LEVELS without ASM


pokemonforever27
February 4th, 2010, 02:10 PM
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:
'---------------
#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

Luster
February 15th, 2010, 01:52 PM
can I do this with stats, nature etc and write them to another pokemon?

NarutoActor
February 15th, 2010, 03:05 PM
will if your trying to find a way without asm try some wrightbytetooffset command

HackMew
February 15th, 2010, 03:28 PM
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
February 15th, 2010, 05:47 PM
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
February 16th, 2010, 10:46 AM
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 (http://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_data_substructures_in_the_GBA) article should help explain what I'm talking about.

Luster
February 23rd, 2010, 07:32 AM
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 (http://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_data_substructures_in_the_GBA) article should help explain what I'm talking about.

thanks a lot, i thik i understand now.

HackMew
February 25th, 2010, 09:08 AM
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.