From Bulbapedia, the community-driven Pokémon encyclopedia.
This is the list of Pokémon data substructures in the Generation III Game Boy Advance games, Pokémon Ruby, Sapphire, FireRed, LeafGreen, and Emerald.
A Pokémon's data is slightly more complex than the rest of the structure. It is stored as four substructures, each 12 bytes in length:
The order of the structures is determined by the personality value of the Pokémon. The order is determined by the value modulo 24:
| 00. GAEM
|| 06. AGEM
|| 12. EGAM
|| 18. MGAE
| 01. GAME
|| 07. AGME
|| 13. EGMA
|| 19. MGEA
| 02. GEAM
|| 08. AEGM
|| 14. EAGM
|| 20. MAGE
| 03. GEMA
|| 09. AEMG
|| 15. EAMG
|| 21. MAEG
| 04. GMAE
|| 10. AMGE
|| 16. EMGA
|| 22. MEGA
| 05. GMEA
|| 11. AMEG
|| 17. EMAG
|| 23. MEAG
Where G, A, E, and M stand for the substructures: growth, moves, EVs and condition, and miscellaneous respectively.
The four data substructures are stored in an encrypted form, decrypting the data is a two-step process. To obtain the 32-bit decryption key, the entire original Trainer ID must be XORed with the personality value of the entry. This key can then be used to decrypt the data by XORing it, 32 bits (or 4 bytes) at a time. To validate the checksum as described in the Pokémon data structures, the entirety of the four unencrypted data substructures must be summed into a 16-bit value.
The PP bonuses byte stores the number of PP Ups used for each move. Two bits per move, starting with the first move from the least significant bits upward to the last move.
Pokérus status is stored in a single byte. The lower 4 bits represents the number of units of time left until the virus wears away. If any bit in the upper 4 bits is set, the Pokémon is immune to Pokérus, indicated a small black dot appears on the Pokémon's status screen. Both values are completely random when caught, leading to the fact that not all Pokémon contract the virus for the same amount of time and some are able to catch it again.
This byte is sometimes divided into two bytes:
FBBBBGGG (Trainer gender/Ball/Game)
Level met (represented by L above) is a 7-bit value stored in the lowest seven bits of the origins-word. It is limited to the range of 1-127. This value being zero represents being hatched from an Egg, so will display "Level 5 (egg)" instead of the regular "Level # (met)" message.
When examining the Level-byte on its own, the highest bit has to be cleared.
Game of origin
Game of origin (represented by G above) is contained in bits 7-10, when considering the origins-word as a whole word rather than two separate bytes.
The type of Poké Ball obtained in (represented by B above) is stored in bits 3-6 when considering offset 3 a single byte, and in bits 11-14 when considered a two-byte word.
The most significant bit (represented by F above) stores whether the original Trainer is female. This is used to color the name in the status screen.
IVs are stored pretty logically. Starting from the least significant bit, each stat from HP to Special Defense takes up 5 bits.
The uppermost bit of this value stores which of its abilities the Pokémon has. If the bit is set to 0, the first ability is used. If it is set to 1, the second ability is used. If the Pokémon can only have one ability, this bit can still be one.
The second-most significant bit of this value is a 1 if this entry is still an egg, 0 if not.