Pokémon data substructures (Generation III): Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
⧼bulbapediamonobook-jumptonavigation⧽⧼bulbapediamonobook-jumptosearch⧽
Looking at a RAM dump of Pokemon Emerald, species comes before held item. Corrected table accordingly.
m Format: Better code... In the "Order" subsection, the letter explanation should preface the table. Other misc.
Line 2: Line 2:


==Format==
==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:
A Pokémon's data is slightly more complex than the rest of the [[Pokémon data structure in Generation III|encapsulating structure]]. It is stored as four distinct substructures, each 12 bytes in length:


{| cellspacing="3" style="border: 1px solid #88a; padding: 0.5em"
{| cellspacing="3" style="border: 1px solid #88a; padding: 0.5em"
Line 45: Line 45:
| [[Stats#Special Defense|Special Defense]] EV || 1 || 5
| [[Stats#Special Defense|Special Defense]] EV || 1 || 5
|-
|-
| colspan="3" rowspan="2" style="border-bottom: 0;" |  
| colspan="3" rowspan="2" |
| PP 3 || 1 || 10
| PP 3 || 1 || 10
| Coolness || 1 || 6
| Coolness || 1 || 6
Line 52: Line 52:
| Beauty || 1 || 7
| Beauty || 1 || 7
|-
|-
| colspan="6" rowspan="4" style="border-top: 0;" |  
| colspan="6" rowspan="4" |
| Cuteness || 1 || 8
| Cuteness || 1 || 8
|-
|-
Line 62: Line 62:
|}
|}


===Order===
===Substructure 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:
The order of the structures is determined by the [[personality value]] of the Pokémon modulo 24, as shown below, where G, A, E, and M stand for the substructures growth, moves, EVs and condition, and miscellaneous, respectively.


{| style="margin:auto; border: 1px solid #88a; background: white; padding: 1px; text-align: center;" cellspacing="1" cellpadding="2"
{| style="margin:auto; border: 1px solid #88a; background: #f8f8ff; padding: 1px; text-align: center;" cellspacing="1" cellpadding="2"
|- style="background: #f8f8ff;"
| width="25%" | 00. GAEM
| width="25%" | 00. GAEM
| width="25%" | 06. AGEM
| width="25%" | 06. AGEM
| width="25%" | 12. EGAM
| width="25%" | 12. EGAM
| width="25%" | 18. MGAE
| width="25%" | 18. MGAE
|- style="background: #f8f8ff;"
|-
| 01. GAME
| 01. GAME
| 07. AGME
| 07. AGME
| 13. EGMA
| 13. EGMA
| 19. MGEA
| 19. MGEA
|- style="background: #f8f8ff;"
|-
| 02. GEAM
| 02. GEAM
| 08. AEGM
| 08. AEGM
| 14. EAGM
| 14. EAGM
| 20. MAGE
| 20. MAGE
|- style="background: #f8f8ff;"
|-
| 03. GEMA
| 03. GEMA
| 09. AEMG
| 09. AEMG
| 15. EAMG
| 15. EAMG
| 21. MAEG
| 21. MAEG
|- style="background: #f8f8ff;"
|-
| 04. GMAE
| 04. GMAE
| 10. AMGE
| 10. AMGE
| 16. EMGA
| 16. EMGA
| 22. MEGA
| 22. MEGA
|- style="background: #f8f8ff;"
|-
| 05. GMEA
| 05. GMEA
| 11. AMEG
| 11. AMEG
Line 97: Line 96:
| 23. MEAG
| 23. MEAG
|}
|}
Where G, A, E, and M stand for the substructures: growth, moves, EVs and condition, and miscellaneous respectively.


===Encryption===
===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 [[Trainer ID number|original Trainer ID]] must be {{wp|XOR}}ed 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 structure in Generation III|Pokémon data structures]], the entirety of the four unencrypted data substructures must be summed into a 16-bit value.
The four data substructures are stored in an encrypted form. Decrypting the data involves two steps: actually decrypting the data, and validating the decrypted data. To obtain the 32-bit decryption key, the entire [[Original Trainer]] [[Trainer ID number|ID number]] must be {{wp|XOR}}ed 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 given in the encapsulating [[Pokémon data structure in Generation III|Pokémon data structure]], the entirety of the four unencrypted data substructures must be summed into a 16-bit value.


==Notes==
==Notes==

Revision as of 12:24, 22 March 2014

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 encapsulating structure. It is stored as four distinct 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)
Species 2 0 Move 1 2 0 HP EV 1 0 Pokérus status 1 0
Item held 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

Substructure order

The order of the structures is determined by the personality value of the Pokémon modulo 24, as shown below, where G, A, E, and M stand for the substructures growth, moves, EVs and condition, and miscellaneous, respectively.

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

Encryption

The four data substructures are stored in an encrypted form. Decrypting the data involves two steps: actually decrypting the data, and validating the decrypted data. To obtain the 32-bit decryption key, the entire Original Trainer ID number 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 given in the encapsulating Pokémon data structure, 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.