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

m
direct link
mNo edit summary
m (direct link)
(28 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{incomplete}}
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 [[Pokémon Storage System|Bill's PC]]. The information lost when depositing a Pokémon in Bill's PC is its [[level]], {{stat|HP}}, {{stat|Attack}}, {{stat|Defense}}, {{stat|Speed}} and {{stat|Special}}; 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===
Line 10: Line 8:
! style="text-align: center; background: #ccf;" | '''Size'''
! style="text-align: center; background: #ccf;" | '''Size'''
|-
|-
| 0x00 || [[List of Pokémon by index number (GB)|Index number of species]] || Byte
| [[#Species|0x00]] || [[List of Pokémon by index number (Generation I)|Index number of the Species]] || 1 byte
|-
|-
| 0x01 || Remaining HP || {{tt|Word|2 bytes, with Remaining HP / 256 stored first}}
| [[#Remaining HP|0x01]] || Current {{stat|HP}} || 2 bytes
|-
|-
| 0x03 || Level? || Byte
| [[#Level|0x03]] || {{tt|Level|as represented while viewed from inside the PC}} || 1 byte
|-
|-
| 0x04 || [[Status ailment]]s || Byte
| [[#Status conditions|0x04]] || [[Status condition]] || 1 byte
|-
|-
| 0x05 || [[Elemental type|Type 1]] || Byte
| [[#Type|0x05]] || [[Type|Type 1]] || 1 byte
|-
|-
| 0x06 || Type 2 || Byte
| [[#Type|0x06]] || Type 2 || 1 byte
|-
|-
| 0x07 || [[Catch rate]]/[[Held item]] || Byte
| [[#Catch rate/Held item|0x07]] || [[Catch rate]]/[[Held item]] || 1 byte
|-
|-
| 0x08 || [[List of moves#Generation I|Index number of first move]] || Byte
| 0x08 || [[List of moves#Generation I|Index number of move 1]] || 1 byte
|-
|-
| 0x09 || Index number of second move || Byte
| 0x09 || Index number of move 2 || 1 byte
|-
|-
| 0x0A || Index number of third move || Byte
| 0x0A || Index number of move 3 || 1 byte
|-
|-
| 0x0B || Index number of fourth move || Byte
| 0x0B || Index number of move 4 || 1 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]] || 2 bytes
|-
|-
| 0x0E || [[Experience]] || {{tt|3 bytes|Experience / 65536, then Experience / 256 mod 256, then Experience mod 256}}
| [[#Experience|0x0E]] || [[Experience|Experience points]] || 3 bytes
|-
|-
| 0x11 || {{stat|HP}} [[stat experience]] || {{tt|Word|2 bytes, with HP stat experience / 256 stored first}}
| [[#Stat experience|0x11]] || {{stat|HP}} [[effort values|EV data]] || 2 bytes
|-
|-
| 0x13 || {{stat|Attack}} stat experience || {{tt|Word|2 bytes, with Attack stat experience / 256 stored first}}
| [[#Stat experience|0x13]] || {{stat|Attack}} EV data || 2 bytes
|-
|-
| 0x15 || {{stat|Defense}} stat experience || {{tt|Word|2 bytes, with Defense stat experience / 256 stored first}}
| [[#Stat experience|0x15]] || {{stat|Defense}} EV data || 2 bytes
|-
|-
| 0x17 || {{stat|Speed}} stat experience || {{tt|Word|2 bytes, with Speed stat experience / 256 stored first}}
| [[#Stat experience|0x17]] || {{stat|Speed}} EV data || 2 bytes
|-
|-
| 0x19 || {{stat|Special statistic|Special}} stat experience || {{tt|Word|2 bytes, with Special stat experience / 256 stored first}}
| [[#Stat experience|0x19]] || {{stat|Special}} EV data || 2 bytes
|-
|-
| 0x1B || [[Individual values]] || {{tt|Word|4 bits for each IV excluding HP}}
| 0x1B || [[Individual values|IV data]] || {{tt|2 bytes|4 bits for each IV excluding HP}}
|-
|-
| 0x1D || {{PP}} of first move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| [[#PP|0x1D]] || Move 1's {{PP}} values || {{tt|1 byte|2 bits for applied PP Ups, 6 bits for current PP}}
|-
|-
| 0x1E || {{PP}} of second move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| [[#PP|0x1E]] || Move 2's PP values || {{tt|1 byte|2 bits for applied PP Ups, 6 bits for current PP}}
|-
|-
| 0x1F || {{PP}} of third move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| [[#PP|0x1F]] || Move 3's PP values || {{tt|1 byte|2 bits for applied PP Ups, 6 bits for current PP}}
|-
|-
| 0x20 || {{PP}} of fourth move || {{tt|Byte|6 bits for current PP, 2 bits for applied PP Ups}}
| [[#PP|0x20]] || Move 4's PP values || {{tt|1 byte|2 bits for applied PP Ups, 6 bits for current PP}}
|-
|-
| 0x21 || [[Level]] || Byte
| 0x21 || [[Level]] || 1 byte
|-
|-
| 0x22 || Maximum HP || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
| [[#Maximum HP|0x22]] || Maximum HP || 2 bytes
|-
|-
| 0x24 || Attack || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
| [[#Attack, Defense, Speed, and Special|0x24]] || {{stat|Attack}} || 2 bytes
|-
|-
| 0x26 || Defense || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
| [[#Attack, Defense, Speed, and Special|0x26]] || {{stat|Defense}} || 2 bytes
|-
|-
| 0x28 || Speed || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
| [[#Attack, Defense, Speed, and Special|0x28]] || {{stat|Speed}} || 2 bytes
|-
|-
| 0x2A || Special || {{tt|Word|2 bytes, with Maximum HP / 256 stored first}}
| [[#Attack, Defense, Speed, and Special|0x2A]] || {{stat|Special}} || 2 bytes
|}
|}


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.


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.
Line 77: Line 75:
==Explanation of fields==
==Explanation of fields==
===Species===
===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 (Generation I)|index number]] for the Pokémon's species.


===Remaining HP===
===Remaining HP===
Line 85: Line 83:
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 conditions===
The [[status ailment]]s of the Pokémon, as a bit field.
The [[status condition]]s 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 92: Line 90:
! style="text-align: center; background: #ccf;" | '''Bit'''
! style="text-align: center; background: #ccf;" | '''Bit'''
! style="text-align: center; background: #ccf;" | '''Value'''
! style="text-align: center; background: #ccf;" | '''Value'''
! style="text-align: center; background: #ccf;" | '''Status ailment'''
! style="text-align: center; background: #ccf;" | '''Status condition'''
|-
|-
| 3 || 0x04 || Asleep
| 3 || 0x04 || Asleep
Line 105: Line 103:
|}
|}


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|poison|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 condition.


===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 [[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.
 
If a Pokémon has only one type, the byte for the second type will match that of the first one.


{| 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 152: Line 148:
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 {{3v2|Gold|Silver|Crystal}}, 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]]. Items are preserved when traded from Generation II to Generation I and back, but some catch rates from Generation I do not have corresponding items in Generation II. In these cases, the value in this field is translated to a different value the first time it is traded to Generation II.
 
The following catch rates correspond with bad items in Generation II (usually [[Teru-sama]]), and are converted into other items upon trading, as follows:
 
{| style="margin:auto; background: #{{crystal color dark}}; {{roundy}}; border: 5px solid #{{silver color}};"
|-
|
{| border="1" style="background: #fff; border: 1px solid #{{crystal color dark}}; border-collapse:collapse;"
|- style="background:#{{crystal color dark}};"
! style="background:#{{gold color}}; {{roundytl|5px}};" | {{color|{{gold color dark}}|Old #}}
! style="background:#{{gold color}};" | {{color|{{gold color dark}}|Old Hex}}
! style="background:#{{gold color}};" | {{color|{{gold color dark}}|Old Item}}
! style="background:#{{gold color}};" | {{color|{{gold color dark}}|New #}}
! style="background:#{{gold color}};" | {{color|{{gold color dark}}|New Hex}}
! style="background:#{{gold color}};" | {{color|{{gold color dark}}|New Item}}
|- style="text-align: center;"
|025||0x19||[[Teru-sama]]||146||0x92||[[Leftovers]]
|- style="text-align: center;"
|045||0x2D||Teru-sama||083||0x53||{{DL|Berry (Generation II)|Bitter Berry}}
|- style="text-align: center;"
|050||0x32||Teru-sama||174||0xAE||{{DL|Berry (Generation II)|Gold Berry}}
|- style="text-align: center;"
|090||0x5A||Teru-sama||173||0xAD||[[Berry]]
|- style="text-align: center;"
|100||0x64||Teru-sama||173||0xAD||Berry
|- style="text-align: center;"
|120||0x78||Teru-sama||173||0xAD||Berry
|- style="text-align: center;"
|127||0x7F||[[Card Key]]||173||0xAD||Berry
|- style="text-align: center;"
|190||0xBE||Teru-sama||173||0xAD||Berry
|- style="text-align: center;"
|255||0xFF||[[Cancel]]||173||0xAD||Berry
|}
|}
 
For example, a wild [[Snorlax (Pokémon)|Snorlax]] caught in Generation I has a catch rate of 25. However, this is a [[Teru-sama]] in Generation II, so the value is automatically converted into 146, [[Leftovers]].
 
A value of <code>0x00</code> in this field represents no held item.


===Original Trainer ID number===
===Original Trainer ID number===
Line 178: Line 212:
==Storage==
==Storage==


The following are ROM offsets for the beginning of the party structure while walking around:
The following are RAM offsets for the beginning of the party structure while walking around:


* Red (en): Unknown
* Red (en): 0xD163
* Blue (en): 0xAF2C
* Blue (en): 0xAF2C
* Yellow (en): Unknown
* Yellow (en): 0x2F2C


During battle, on the other hand, the party structure is moved to the following offsets:
During battle, on the other hand, the party structure is moved to the following offsets:


* Green (jp): 0xD123
* Red (en): Unknown
* Red (en): Unknown
* Blue (en): 0xD163
* Blue (en): 0xD163
Line 191: Line 226:




====6-Pokemon Party Structure====
====6-Pokémon 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 199: Line 234:
! style="text-align: center; background: #ccf;" | '''Size'''
! style="text-align: center; background: #ccf;" | '''Size'''
|-
|-
| 0x00 || Number of Pokemon in party || 1 Byte
| 0x00 || Number of Pokémon in party || 1 Byte
|-
|-
| 0x01 || List Party Pokemon Index values || 7 Bytes
| 0x01 || List Party Pokémon Index values || 7 Bytes
|-
|-
| 0x08 || 1st Pokemon structure || 44 Bytes
| 0x08 || 1st Pokémon structure || 44 Bytes
|-
|-
| 0x34 || 2nd Pokemon structure || 44 Bytes
| 0x34 || 2nd Pokémon structure || 44 Bytes
|-
|-
| 0x60 || 3rd Pokemon structure || 44 Bytes
| 0x60 || 3rd Pokémon structure || 44 Bytes
|-
|-
| 0x8C || 4th Pokemon structure || 44 Bytes
| 0x8C || 4th Pokémon structure || 44 Bytes
|-
|-
| 0xB8 || 5th Pokemon structure || 44 Bytes
| 0xB8 || 5th Pokémon structure || 44 Bytes
|-
|-
| 0xE4 || 6th Pokemon structure || 44 Bytes
| 0xE4 || 6th Pokémon structure || 44 Bytes
|-
|-
| 0X110 || 4 0x000B's to terminate || 4 Words
| 0X110 || x 0x000B's to terminate || x Words
|}
|}




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; however, if the party contains only 1 Pokémon, the FF may or may not be there. Finally, the terminating 0x000B's vary in number, and other information appears to follow, but its significance is not yet clear.


Also of note is that the storage of the current Pokemon's information during battle. The internal index of the current is stored at 0xCF91, and the full Pokemon data structure begins at 0xCF98.
Also of note is that the storage of the current Pokémon's information during battle. The internal index of the current is stored at 0xCF91, and the full Pokémon data structure begins at 0xCF98.




{{data structure}}
{{Data structure}}<br>
{{Project Games notice|data structure}}
{{Project Games notice|data structure}}