• 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!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • 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.

[ASM & Hex] Encryption of IVs

  • 37
    Posts
    7
    Years
    • Seen May 20, 2021
    Hi guys, I'm trying to make a routine to decrypt pokemon data but I can't figure out how the IVs are encrypted. I read the explanation of the data structure in bulbapedia but I'm confused about IVs.
    The IVs are supposed to be given by a xor operation between the personnality value and the trainer ID, right? or correct me if I'm wrong.
    However, it never gives me the good value! I made a test with a pidgey, I went to the start address of the pokemon data (0x02024284), its personnality value is ffab1a6f and its original trainer id is 4f9d9ed5. When I make a xor between those 2 values, it gives me b03684ba. This word should be the 32 bits for IV values (5 bits for each stat and the 2 last bits for other info).

    I wanted to make sure that it's correct with an IV calculator online, the pidgey is level 100(caught in the wild by hacking wild encounters with advance map), then it can gives me the exact IVs of pidgey for each stat: it's 10, 20, 12, 17, 28 and 8. So, technically the 30 bits are 010101010001100100011110001000, which gives a word like 0x15464788 approximately(without counting the 2 last bits).
    The IVs given by the calculator don't match the IVs given by the xor operation, then why? Where did I do something wrong?

    I also tried to take the encrypted word of IVs and xor it with the xor PersonnalityValue-trainerID, but still nothing. the encrypted IVs are 3a049083 (and I'm sure that the sections are in the good order, I checked it).

    SO WHY??!! I tried everything, honestly, I'm comfortable with ASM but this IV thing is driving me crazy. I can't make any decrypt routine since I don't know how IVs are encrypted.
    My question is just: how are IVs encrypted in the pokemon data? I would really appreciate your help!
     
    Last edited:
    Hey man, did you know gamefreak has their own decryption functions for Pokemon data?
    0803FBE8 in FR, it's better to use one of these than write your own!
     
    I'm not looking for a routine/function to decrypt the pokemon data, that's not the point of this post, I want to know how the IVs are encrypted.
    How could I use a function while I don't understand what I'm doing? ASM is already confusing, then it's impossible to make a routine if I don't know what happens. It's a programming language that is very very close to the machine, then you cannot just call a function if you don't know what it does exactly. Hacking is always about understanding and THEN programming.

    By the way I already used the function of game freak (at 0803fbe8) with the routine of JPAN and other people, it doesn't give the good IVs. The online calculators give different values.

    Anyway, I just want to know what is the operation or method to encrypt this data.
    If I knew it, I could be sure that the routine works correctly or not at least.
     
    How can you reverse engineer game code without learning the language? It doesn't make any sense. It's like trying to read in English without knowing the alphabet.

    I would first reverse engineer the decryption function, so I understand how the creators decrypt it. If you don't know enough ASM to do that, then this would be a good opportunity.

    The decryptor function does give the correct IVs, so you must've been calling it incorrectly.
     
    Back
    Top