• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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
    16
    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
     
    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.
     
    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.
     
    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