Pokémon data substructures (Generation III)

From Bulbapedia, the community-driven Pokémon encyclopedia.
Revision as of 02:23, 28 August 2013 by Patriot (talk | contribs) (→‎IVs: Clarified the ability-bit, and the egg-bit)
Jump to navigationJump to search

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 Attacks Effort & Condition Miscellaneous
size in bytes offset in bytes size in bytes offset in bytes size in bytes offset in bytes size in bytes offset in bytes
Species 2 0 Attack 1 2 0 HP EV 1 0 Pokérus status 1 0
Item held 2 0 Attack 2 2 2 Attack EV 1 1 Location caught 1 1
Experience 4 4 Attack 3 2 4 Defense EV 1 2 Origins info 2 2
PP bonuses 1 8 Attack 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, attacks, effort, and miscellaneous respectively.

Encryption

The entire data structure is encrypted by XORing the entire Trainer ID with the personality value, after that the player will get a 4 bytes value, then XORing the resulting value with the data (one long value at a time, p/s: one long value here refer to 4 bytes). The same process is used to decrypt the encrypted data, for detail check on use of xor. The correct checksum is found by summing the original values, not the encrypted values.

Notes

PP bonuses

The PP bonuses byte stores the number of PP Ups used for each attack. Two bits per attack, starting with the first attack from the least significant bits upward to the last attack.

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

Some tools divide this into two bytes:

GLLLLLLL (Level) FBBBBGGG (Ball/Game)

Level caught

Level caught 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 range does not include zero because setting this value to zero causes the game to produce the "Level 5 (egg)" message 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

When regarding the Origins-word as two separate bytes (Level and Poké Ball/Trainer, this value is confusing as it spans into both (taking bit 0-2 of the the Poké Ball/Trainer gender plus the MSB of Pokémon) so it is recommended to tread the Origins-word as an LSB two-byte value. Then, Bits 7-10 report the game which the Pokémon came from:

Poké Ball

When examining offset 3 as a single byte, this information is stored in Bits 3-6. When treating Origins as two-byte word, Bits 11-14 store the Poké Ball type that the Pokémon was caught in.

Trainer gender

The most significant bit stores whether the original Trainer is female. This can be 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
Generation I Pokémon speciesPokémonPoké MartCharacter encodingSave
Generation II Pokémon speciesPokémonTrainerCharacter encoding (Korean) • Save
Generation III Pokémon species (Pokémon evolutionPokédexType chart)
Pokémon (substructures) • MoveContestContest moveItem
Trainer TowerBattle FrontierCharacter encodingSave
Generation IV Pokémon species (Pokémon evolutionLearnsets)
PokémonSaveCharacter encoding
Generation V-present Character encoding
TCG GB and GB2 Character encoding


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