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

m
cases, link templates, etc.
m (cases, link templates, etc.)
Line 3: Line 3:
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 {{stat|HP}}, {{stat|Attack}}, {{stat|Defense}}, {{stat|Special}} and {{stat|Speed}}; this allows the [[box trick]] to work by recalculating the lost information upon withdrawing the Pokémon again.
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 {{stat|HP}}, {{stat|Attack}}, {{stat|Defense}}, {{stat|Special}} and {{stat|Speed}}; this allows the [[box trick]] to work by recalculating the lost information upon withdrawing the Pokémon again.


=== The structure ===
===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"
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="2"
|-  
|-  
Line 17: Line 16:
| 0x03 || Level? || Byte
| 0x03 || Level? || Byte
|-
|-
| 0x04 || [[Status_ailment|Status ailments]] || Byte
| 0x04 || [[Status ailment]]s || Byte
|-
|-
| 0x05 || [[Elemental type|Type 1]] || Byte
| 0x05 || [[Elemental type|Type 1]] || Byte
Line 33: Line 32:
| 0x0B || Index number of fourth move || Byte
| 0x0B || Index number of fourth move || Byte
|-
|-
| 0x0C || [[Trainer ID number|Original trainer ID number]] || {{tt|Word|2 bytes, with Trainer ID number / 256 stored first}}
| 0x0C || [[Trainer ID number|Original Trainer ID number]] || {{tt|Word|2 bytes, with Trainer ID number / 256 stored first}}
|-
|-
| 0x0E || [[Experience]] || {{tt|3 bytes|Experience / 65536, then Experience / 256 mod 256, then Experience mod 256}}
| 0x0E || [[Experience]] || {{tt|3 bytes|Experience / 65536, then Experience / 256 mod 256, then Experience mod 256}}
Line 49: Line 48:
| 0x1B || [[Individual values]] || {{tt|Word|4 bits for each IV excluding HP}}
| 0x1B || [[Individual values]] || {{tt|Word|4 bits for each IV excluding HP}}
|-
|-
| 0x1D || [[Power points|PP]] of first move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| 0x1D || {{PP}} of first move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| 0x1E || [[Power points|PP]] of second move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| 0x1E || {{PP}} of second move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| 0x1F || [[Power points|PP]] of third move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| 0x1F || {{PP}} of third move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| 0x20 || [[Power points|PP]] of fourth move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| 0x20 || {{PP}} of fourth move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
|-
|-
| 0x21 || [[Level]] || Byte
| 0x21 || [[Level]] || Byte
Line 70: Line 69:
|}
|}


Notably missing from this structure are the Pokémon's nickname and the original trainer's name, which are stored elsewhere. In Pokemon Blue (US), this structure appears to  
Notably missing from this structure are the Pokémon's nickname and the original Trainer's name, which are stored elsewhere. In Pokemon Blue (US), this structure appears to  


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 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 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 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 {{game|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 ===


==Explanation of fields==
===Species===
The [[List of Pokémon by index number (GB)|index number]] for the Pokémon's species.
The [[List of Pokémon by index number (GB)|index number]] for the Pokémon's species.


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


=== Level ===
===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.
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 ===
===Status ailments===
 
The [[status ailment]]s of the Pokémon, as a bit field.
The [[status ailment|status ailments]] of the Pokémon, as a bit field.


{| 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="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="2"
Line 113: Line 107:
Since being [[Status ailment#Badly poisoned|badly poisoned]] 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.
Since being [[Status ailment#Badly poisoned|badly poisoned]] 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.


=== Type ===
===Type===
 
The [[elemental type]] of the Pokémon. If the Pokémon has only one type, both values are the same. It seems redundant, as there is no way a Pokémon can change type in Generation I besides [[Evolution|evolving]], and through the use of Conversion.
The [[elemental type]] of the Pokémon. If the Pokémon has only one type, both values are the same. It seems redundant, as there is no way a Pokémon can change type in Generation I besides [[Evolution|evolving]], and through the use of Conversion.


Line 156: Line 149:
|}
|}


=== Catch rate/Held item ===
===Catch rate/Held item===
 
The [[catch rate]] for the species. This does not change when the Pokémon evolves, even if its evolution has a different catch rate.
The [[catch rate]] for the species. This does not change when the Pokémon evolves, even if its evolution has a different catch rate.


When trading with {{gameabbrev3|GSC}}, this field is co-opted for storing the Pokémon's [[held item]].
When trading with {{3v2|Gold|Silver|Crystal}}, this field is co-opted for storing the Pokémon's [[held item]].
 
=== Original trainer ID number ===


===Original Trainer ID number===
The [[Trainer ID number|ID number]] of the {{pkmn|Trainer}} who [[caught Pokémon|caught]] the Pokémon.
The [[Trainer ID number|ID number]] of the {{pkmn|Trainer}} who [[caught Pokémon|caught]] the Pokémon.


=== Experience ===
===Experience===
 
The number of [[Experience]] 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.
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.
 
=== Stat experience ===


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


===PP===
{{main|Power points}}
{{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.
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]]s applied to the move.
 
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.


=== Maximum HP ===
This explains the behavior of {{m|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.
The HP that the Pokémon has when at full health.


=== Attack, Defense, Speed, Special ===
===Attack, Defense, Speed, and 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.
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.


==Storage==
==Storage==
The following are ROM offsets for the beginning of the party structure while playing:
The following are ROM offsets for the beginning of the party structure while playing:


Line 198: Line 183:
* Yellow (en): Unknown
* Yellow (en): Unknown


====6-Pokemon Party Structure====
====6-Pokemon party structure====
 
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 1.0em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="3"
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 1.0em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="3"
|-  
|-  
Line 223: Line 207:
|}
|}


NOTE: This structure only applies when the party is FULL.
Note that this structure only applies when the party is full.


The list of party index values ends with FF, which is followed by 00s through the rest of the section. The set of Pokemon structures themselves, on the other hand, are followed by a set of values whose significance are not yet clear.
The list of party index values ends with FF, which is followed by 00s through the rest of the section. The set of Pokemon structures themselves, on the other hand, are followed by a set of values whose significance are not yet clear.