Pokémon data structure (Generation I): Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
(Major cleanup)
Line 1: Line 1:
{{cleanup}}{{incomplete}}
{{incomplete}}


== Notes ==
The '''Pokémon data structure''' in the [[Generation I]] games stores most information about the current state of a [[player]]'s [[caught Pokémon]]. It has a length of 44 bytes for Pokémon in the player's [[party]] and 33 bytes for Pokémon in boxes on [[Bill's PC]]. The information lost when depositing a Pokémon in Bill's PC is its [[level]] and its [[HP]], [[Attack]], [[Defense]], [[Special]] and [[Speed]]; this allows the [[box trick]] to work by recalculating the lost information upon withdrawing the Pokémon again.


{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; float: right; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="2"
=== The structure ===
 
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="2"
|-  
|-  
! colspan="2" style="text-align: center; background: #ccf;" | '''Pokémon'''
! style="text-align: center; background: #ccf;" | '''Offset'''
|-
! style="text-align: center; background: #ccf;" | '''Contents'''
| [[List of Pokémon by index number (GB)|Species]] || byte
! style="text-align: center; background: #ccf;" | '''Size'''
|-
| Remaining HP || word
|-
| Level?? (See left) || byte
|-
| [[Status_ailment|Status]] || byte
|-
| ? || 3 bytes
|-
|-
| [[List of moves|Attack]] 1 || byte
| 0x00 || [[List of Pokémon by index number (GB)|Index number of species]] || Byte
|-
|-
| Attack 2 || byte
| 0x01 || Remaining HP || {{tt|Word|2 bytes, with Remaining HP / 256 stored first}}
|-
|-
| Attack 3 || byte
| 0x03 || Level? || Byte
|-
|-
| Attack 4 || byte
| 0x04 || [[Status_ailment|Status ailments]] || Byte
|-
|-
| OT ID || word
| 0x05 || Unknown || 3 bytes
|-
|-
| [[Experience]] || 3 bytes
| 0x08 || [[List of moves#Generation I|Index number of first move]] || Byte
|-
|-
| HP Up || byte
| 0x09 || Index number of second move || Byte
|-
|-
| ? || byte
| 0x0A || Index number of third move || Byte
|-
|-
| Protein || 1 byte
| 0x0B || Index number of fourth move || Byte
|-
|-
| ? || byte
| 0x0C || [[Trainer ID number|Original trainer ID number]] || {{tt|Word|2 bytes, with Trainer ID number / 256 stored first}}
|-
|-
| Iron || 1 byte
| 0x0E || [[Experience]] || {{tt|3 bytes|Experience / 65536, then Experience / 256 mod 256, then Experience mod 256}}
|-
|-
| ? || byte
| 0x11 || [[HP]] [[stat experience]] || {{tt|Word|2 bytes, with HP stat experience / 256 stored first}}
|-
|-
| Carbos || byte
| 0x13 || [[Attack]] stat experience || {{tt|Word|2 bytes, with Attack stat experience / 256 stored first}}
|-
|-
| ? || 1 byte
| 0x15 || [[Defense]] stat experience || {{tt|Word|2 bytes, with Defense stat experience / 256 stored first}}
|-
|-
| Calcium || byte
| 0x17 || [[Speed]] stat experience || {{tt|Word|2 bytes, with Speed stat experience / 256 stored first}}
|-
|-
| ? || 1 byte
| 0x19 || [[Special]] stat experience || {{tt|Word|2 bytes, with Special stat experience / 256 stored first}}
|-
|-
| DVs || word
| 0x1B || [[Individual values]] || {{tt|Word|4 bits for each IV excluding HP}}
|-
|-
| PP1 || byte
| 0x1D || [[PP]] of first move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| PP2 || byte
| 0x1E || [[PP]] of second move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| PP3 || byte
| 0x1F || [[PP]] of third move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| PP4 || byte
| 0x20 || [[PP]] of fourth move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| level || byte
| 0x21 || [[Level]] || Byte
|-
|-
| Total HP || word
| 0x22 || Maximum HP || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
|-
|-
| Attack || word
| 0x24 || Attack || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
|-
|-
| Defense || word
| 0x26 || Defense || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
|-
|-
| Speed || word
| 0x28 || Speed || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
|-
|-
| Special || word
| 0x2A || Special || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
|}
|}


Pokémon in [[Generation I]] games are all stored in the same 44-byte structure.
Notably missing from this structure are the Pokémon's nickname and the original trainer's name, which are stored elsewhere.


The trainer EO is stored in other memory address.
Pokémon stored in Bill's PC use a form of this structure that stops after the PP data for the fourth move, at 0x20.


Pokémon stored in a PC box use a shortened form of this structure that is 33-bytes in length, ending after the PP data.
The Pokémon box data consists only of the currently open Pokémon box, which explains the need for the player to save the game before switching the open box. In [[Pokémon Yellow Version|Pokémon Yellow]] for the US, this data starts at 0xDA95 in volatile RAM and continues for 660 bytes (33 bytes each for 20 Pokémon).
The Pokémon box data in Pokémon Yellow begins at 0xDA95 in memory (WRAM), and consists only of the currently open Pokémon box (this necessitates the need to save when switching open boxes). This box data is 660-bytes long (33-bytes * 20 Pokémon).
 
== Explanation of fields ==


=== Species ===
=== Species ===


This value is 1 byte length, and is the Pokémon Species.
The [[List of Pokémon by index number (GB)|index number]] for the Pokémon's species.
 
The value for each Pokémon is listed in [[List of Pokémon by index number (GB)|this article]].


=== Remaining HP ===
=== Remaining HP ===


This value is 2 bytes length.
The number of HP left on the Pokémon. This value may not be greater than the Maximum HP field's value.
 
Is the current level of HP remaining for this Pokémon. The value must not be greater than the total HP.


=== Level ===
=== Level ===


1-byte in length. Though it appears to be the level of the Pokémon, it seems effectively redundant: Exists as a Pokémon's level when said Pokémon is stored in a PC box, yet is overwritten as part of the recalculation that takes place when the Pokémon is withdrawn. If the Pokémon is re-deposited back into a box, this value is set to the Pokémon's level again. This value's purpose is currently unknown.
Though it appears to be the level of the Pokémon, it seems effectively redundant: it exists as a Pokémon's level when said Pokémon is stored in a PC box, yet is overwritten as part of the recalculation that takes place when the Pokémon is withdrawn. If the Pokémon is deposited back into a box, this value is set to the Pokémon's level again. This value's purpose is currently unknown.


=== Status ===
=== Status ailments ===


This value is 1 byte length, and is the status of the Pokémon:
The [[status ailment|status ailments]] of the Pokémon, as a bit field.


0 = OK
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="2"
|-
! style="text-align: center; background: #ccf;" | '''Bit'''
! style="text-align: center; background: #ccf;" | '''Value'''
! style="text-align: center; background: #ccf;" | '''Status ailment'''
|-
| 3 || 0x04 || Asleep
|-
| 4 || 0x08 || Poisoned
|-
| 5 || 0x10 || Burned
|-
| 6 || 0x20 || Frozen
|-
| 7 || 0x40 || Paralyzed
|}


4 = Sleep
Since [[Toxic (move)|toxic poison]] is a temporary condition in [[Pokémon battle|battles]], it is not stored here. Confusion is also not stored here. 0x00 means that the Pokémon is not affected by any major status ailment.


8 = Poisson
=== Original trainer ID number ===


10 = Burn
The [[Trainer ID number|ID number]] of the [[trainer]] who [[caught Pokémon|caught]] the Pokémon.


20 = Freezed
=== Experience ===
 
40 = Paralysis


=== OT ID ===
The number of [[Experience|EXP. Points]] accumulated by the Pokémon. The [[level]] of the Pokémon should correspond with this value according to the growth formula for the Pokémon species.


Is the ID of the trainer who catched the Pokémon. Is is different than ours, the Pokémon will gain extra experience.
=== Stat experience ===


=== Experience ===
{{main|Effort values}}
The stat experience accumulated by the Pokémon in each of the 5 permanent stats after battling or receiving [[vitamin|vitamins]].


Is the total amount of experience gained. The level of the Pokémon should be concordant with the experience amount. Visit the [[experience]] article for more information about Pokémon grow types, and experience formulas.
=== PP ===


=== HP Up ===
{{main|Power points}}
The PP for each move the Pokémon knows. The lowest 6 bits of each of these values is the current amount of PP for the move, and the highest 2 bits are the number of [[PP Up|PP Ups]] applied to the move.


This value informs about the amount of [[HP Up]] used in the Pokémon. Just because the number of HP Ups we can use with a Pokémon is limited.
This explains the behavior of [[Hyper Beam (move)|Hyper Beam]] and other such multi-turn moves when they [[glitch]]: the game subtracts 1 from the entire byte, and 0x00 rolls over to 0xFF, which applies 3 PP Ups to the move and makes its current PP 63. However, if one or more PP Ups are already applied to the move, the byte does not roll over in this way, so one PP Up is ''removed'' from the move. For example, if the move has 2 PP Ups applied, the byte is 0x80, which becomes 0x7F, which specifies 63 PP and one PP Up.


=== Protein, Carbos, Iron, Calcium ===
=== Maximum HP ===


The same as HP Up.
The HP that the Pokémon has when at full health.


=== Total HP ===
=== Attack, Defense, Speed, Special ===


Is the total HP the Pokémon can have when we visit a Pokémon Center.
The values of the Pokémon's Attack, Defense, Speed and Special stats, as they were last calculated from the [[base stats]] of the species, the Pokémon's individual values and its stat experience. This occurs at level-up and when the Pokémon is withdrawn from Bill's PC.


{{stub}}
{{data structure}}
{{data structure}}

Revision as of 03:56, 24 October 2009

050Diglett.png This article is incomplete.
Please feel free to edit this article to add missing information and complete it.

The Pokémon data structure in the Generation I games stores most information about the current state of a player's caught Pokémon. It has a length of 44 bytes for Pokémon in the player's party and 33 bytes for Pokémon in boxes on Bill's PC. The information lost when depositing a Pokémon in Bill's PC is its level and its HP, Attack, Defense, Special and Speed; this allows the box trick to work by recalculating the lost information upon withdrawing the Pokémon again.

The structure

Offset Contents Size
0x00 Index number of species Byte
0x01 Remaining HP Word
0x03 Level? Byte
0x04 Status ailments Byte
0x05 Unknown 3 bytes
0x08 Index number of first move Byte
0x09 Index number of second move Byte
0x0A Index number of third move Byte
0x0B Index number of fourth move Byte
0x0C Original trainer ID number Word
0x0E Experience 3 bytes
0x11 HP stat experience Word
0x13 Attack stat experience Word
0x15 Defense stat experience Word
0x17 Speed stat experience Word
0x19 Special stat experience Word
0x1B Individual values Word
0x1D PP of first move Byte
0x1E PP of second move Byte
0x1F PP of third move Byte
0x20 PP of fourth move Byte
0x21 Level Byte
0x22 Maximum HP Word
0x24 Attack Word
0x26 Defense Word
0x28 Speed Word
0x2A Special Word

Notably missing from this structure are the Pokémon's nickname and the original trainer's name, which are stored elsewhere.

Pokémon stored in Bill's PC use a form of this structure that stops after the PP data for the fourth move, at 0x20.

The Pokémon box data consists only of the currently open Pokémon box, which explains the need for the player to save the game before switching the open box. In Pokémon Yellow for the US, this data starts at 0xDA95 in volatile RAM and continues for 660 bytes (33 bytes each for 20 Pokémon).

Explanation of fields

Species

The index number for the Pokémon's species.

Remaining HP

The number of HP left on the Pokémon. This value may not be greater than the Maximum HP field's value.

Level

Though it appears to be the level of the Pokémon, it seems effectively redundant: it exists as a Pokémon's level when said Pokémon is stored in a PC box, yet is overwritten as part of the recalculation that takes place when the Pokémon is withdrawn. If the Pokémon is deposited back into a box, this value is set to the Pokémon's level again. This value's purpose is currently unknown.

Status ailments

The status ailments of the Pokémon, as a bit field.

Bit Value Status ailment
3 0x04 Asleep
4 0x08 Poisoned
5 0x10 Burned
6 0x20 Frozen
7 0x40 Paralyzed

Since toxic poison is a temporary condition in battles, it is not stored here. Confusion is also not stored here. 0x00 means that the Pokémon is not affected by any major status ailment.

Original trainer ID number

The ID number of the trainer who caught the Pokémon.

Experience

The number of EXP. Points accumulated by the Pokémon. The level of the Pokémon should correspond with this value according to the growth formula for the Pokémon species.

Stat experience

Main article: Effort values

The stat experience accumulated by the Pokémon in each of the 5 permanent stats after battling or receiving vitamins.

PP

Main article: Power points

The PP for each move the Pokémon knows. The lowest 6 bits of each of these values is the current amount of PP for the move, and the highest 2 bits are the number of PP Ups applied to the move.

This explains the behavior of Hyper Beam and other such multi-turn moves when they glitch: the game subtracts 1 from the entire byte, and 0x00 rolls over to 0xFF, which applies 3 PP Ups to the move and makes its current PP 63. However, if one or more PP Ups are already applied to the move, the byte does not roll over in this way, so one PP Up is removed from the move. For example, if the move has 2 PP Ups applied, the byte is 0x80, which becomes 0x7F, which specifies 63 PP and one PP Up.

Maximum HP

The HP that the Pokémon has when at full health.

Attack, Defense, Speed, Special

The values of the Pokémon's Attack, Defense, Speed and Special stats, as they were last calculated from the base stats of the species, the Pokémon's individual values and its stat experience. This occurs at level-up and when the Pokémon is withdrawn from Bill's PC.


Data structure in the Pokémon games
General Character encoding
Generation I Pokémon speciesPokémonPoké MartCharacter encodingSave
Generation II Pokémon speciesPokémonTrainerCharacter encoding (Korean) • 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