Pokémon data substructures (Generation III)

From Bulbapedia, the community-driven Pokémon encyclopedia.
Revision as of 05:00, 17 March 2014 by Im420blaziken (talk | contribs)
⧼bulbapediamonobook-jumptonavigation⧽⧼bulbapediamonobook-jumptosearch⧽

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.

Format

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:

Growth Moves EVs & Condition Miscellaneous
size
(bytes)
offset
(bytes)
size
(bytes)
offset
(bytes)
size
(bytes)
offset
(bytes)
size
(bytes)
offset
(bytes)
Item held 2 0 Move 1 2 0 HP EV 1 0 Pokérus status 1 0
Species 2 2 Move 2 2 2 Attack EV 1 1 Met location 1 1
Experience 4 4 Move 3 2 4 Defense EV 1 2 Origins info 2 2
PP bonuses 1 8 Move 4 2 6 Speed EV 1 3 IVs 4 4
Friendship 1 9 PP 1 1 8 Special Attack EV 1 4 Ribbons 4 8
Unknown 2 10 PP 2 1 9 Special Defense EV 1 5
PP 3 1 10 Coolness 1 6
PP 4 1 11 Beauty 1 7
Cuteness 1 8
Smartness 1 9
Toughness 1 10
Feel 1 11

Order

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.

Encryption

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.

Notes

PP bonuses

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

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.

Origins

FBBBBGGGGLLLLLLL

This byte is sometimes divided into two bytes:

GLLLLLLL (Game/Level)
FBBBBGGG (Trainer gender/Ball/Game)

Level met

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.

Poké Ball

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.

Trainer gender

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

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.

See also

Data structure in the Pokémon games
General Character encoding
Generation I Pokémon speciesPokémonPoké MartCharacter encoding (Stadium) • Save
Generation II Pokémon speciesPokémonTrainerCharacter encoding (StadiumKorean) • Save
Generation III Pokémon species (EvolutionPokédexType chart)
Pokémon (substructures) • MoveContestContest moveItem
Trainer TowerBattle FrontierCharacter encoding (GameCube) • Save
Generation IV Pokémon species (EvolutionLearnsets)
PokémonSaveCharacter encoding (Wii)
Generation V–present Character encoding
Generation VIII Save
TCG GB and GB2 Character encoding


This data structure article is part of Project Games, a Bulbapedia project that aims to write comprehensive articles on the Pokémon games.