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

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
m (Again: don't use these jargony abbreviations, that's not proper on a wiki)
(19 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Pokémon in the {{game|Ruby and Sapphire|s}}, {{2v2|FireRed|LeafGreen}}, and {{v|Emerald}}s are all stored the same way in a 100-byte structure.
Pokémon in the {{game|Ruby and Sapphire|s}}, {{2v2|FireRed|LeafGreen}}, and {{v|Emerald}}s are all stored the same way in a 100-byte structure. All numbers are stored in little-endian order.


==Notes==
==Notes==


{| 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"
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; float: right; margin: 0 0 0.5em 0.5em;" cellpadding="2"
|-  
|-  
! colspan="3" style="text-align: center; background: #{{hoenn color}};" | '''Pokémon'''
! colspan="3" style="text-align: center; background: #{{hoenn color}};" | '''Pokémon'''
Line 9: Line 9:
! || type || offset
! || type || offset
|-
|-
| [[Personality]] || dword || 0
| [[Personality value]] || dword || 0
|-
|-
| OT ID || dword || 4
| [[Original Trainer|OT]] [[Trainer ID number|ID]] || dword || 4
|-
|-
| Nickname || 10 bytes || 8
| [[Nickname]] || 10 bytes || 8
|-
|-
| Language || word || 18
| Language || word || 18
Line 19: Line 19:
| OT name || 7 bytes || 20
| OT name || 7 bytes || 20
|-
|-
| Mark || byte || 27
| {{DL|Pokémon Storage System|Markings}} || byte || 27
|-
|-
| Checksum || word || 28
| Checksum || word || 28
Line 25: Line 25:
| ???? || word  || 30
| ???? || word  || 30
|-
|-
| [[Pokémon data substructures in the GBA|Data]] || 48 bytes || 32
| [[Pokémon data substructures in Generation III|Data]] || 48 bytes || 32
|-
|-
| [[Status ailment]] || dword || 80
| [[Status condition]] || dword || 80
|-
|-
| Level || byte || 84
| [[Level]] || byte || 84
|-
|-
| [[Pokérus]] remaining || byte || 85
| [[Pokérus]] remaining || byte || 85
|-
|-
| Current HP || word || 86
| Current [[stats|HP]] || word || 86
|-
|-
| Total HP || word || 88
| Total [[stats|HP]] || word || 88
|-
|-
| Attack || word || 90
| [[stats|Attack]] || word || 90
|-
|-
| Defense || word || 92
| [[stats|Defense]] || word || 92
|-
|-
| Speed || word || 94
| [[stats|Speed]] || word || 94
|-
|-
| Sp. Attack || word || 96
| [[stats|Sp. Attack]] || word || 96
|-
|-
| Sp. Defense || word || 98
| [[stats|Sp. Defense]] || word || 98
|}
|}


===Personality value===
===Personality value===
The [[personality value]] controls many things, including gender, {{p|Unown}}'s letter, {{p|Spinda}}'s dots, any Pokémon's [[Nature]], and others.
The [[personality value]] controls many things, including [[gender]], {{p|Unown}}'s letter, {{p|Spinda}}'s dots, any Pokémon's [[Nature]], and more.


===OT ID===
===OT ID===
The Original Trainer's ID Number. Part of the XOR encryption key for the data section, also used in Shiny determination and the lottery.
The [[Original Trainer]]'s [[Trainer ID number|ID number]]. This number is part of the XOR encryption key for the [[Pokémon data substructures in Generation III|data]] section, and is also used in [[Shiny Pokémon|Shiny]] determination and the [[Pokémon Lottery Corner|lottery]]. The least significant bytes of this number are the Trainer ID visible on the status screen.


===Nickname===
===Nickname===
The Pokémon's nickname, limited to 10 characters. <!-- Use the [[Pokéscii Table]] to convert to readable characters. -->
The Pokémon's [[nickname]], limited to 10 characters. The characters represented by each byte are determined by the [[Character encoding in Generation III|proprietary character set]].


===Language===
===Language===
Determines the language of the game the Pokémon comes from. Valid values are:
The language of the game the Pokémon comes from. [[Pokémon Egg|Eggs]] have this value set to <code>0x0601</code>. In international versions, the language value determines which character set is used when displaying the Pokémon's name and OT name. Any Pokémon with a language value of <code>0x0601</code> will, in international versions, be named the game's regional variant of "EGG", ignoring the nickname field.
* 0201 = Japanese
* 0202 = English
* 0203 = French
* 0204 = Italian
* 0205 = German
* 0206 = Korean (unused)
* 0207 = Spanish


===OT name===
In Japanese versions, the language value is entirely disregarded. Names always use the nickname bytes decoded with the Japanese character set.
The name of the original Trainer of the Pokémon. <!-- Use the Pokéscii Table to convert to readable characters. -->
 
For Pokémon not in Eggs, the valid values are:


===Mark===
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
The marks seen in the storage Box. These marks serve only to aid in organizing large collections of Pokémon.
! Hex || Language
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em;" cellspacing="1" cellpadding="2"
|-
|-  
| 0x0201 || [[File:Japan Flag.png|20px]] Japanese
| '''Bit||Mark'''
|-
| 0x0202 || [[File:England Flag.png|20px]] English
|-
|-
|0|| Circle
| 0x0203 || [[File:France Flag.png|20px]] French
|-
|-
|1|| Square
| 0x0204 || [[File:Italy Flag.png|20px]] Italian
|-
|-
|2|| Triangle
| 0x0205 || [[File:Germany Flag.png|20px]] German
|-
|-
|3|| Heart
| 0x0206 || [[File:South Korea Flag.png|20px]] Korean{{tt|*|unused}}
|-
|-
| 0x0207 || [[File:Spain Flag.png|20px]] Spanish
|}
|}


===Checksum===
===OT name===
The checksum is of the 48-byte data section in the structure. It is computed by simply adding all the unencrypted values one word at a time. If this value does not match the real checksum, the Pokémon is interpreted as a [[Bad Egg]].
The name of the Pokémon's Original Trainer. The characters represented by each byte are determined by the [[Character encoding in Generation III|proprietary character set]].


===Padding===
===Markings===
Any entry marked (Padding) is not used and usually set to either 0 or -1 of the respective data type.
The markings seen in the [[Pokémon Storage System|storage Box]]. These markings serve only to aid in organizing large collections of Pokémon.
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
! Bit || Mark
|-
| 0 || ●
|-
| 1 || ■
|-
| 2 || ▲
|-
| 3 || ♥
|}


===Status ailment===
===Checksum===
The Pokémon's [[status ailment]]s are stored as follows:
The checksum for the 48-byte [[Pokémon data substructures in Generation III|data]] section of this structure. It is computed by adding all of the unencrypted values of that section one word at a time. If the computed sum and the stored checksum do not match, the Pokémon is interpreted as a [[Bad Egg]].


* 0-2: Sleep bits. Indicates turns of sleep, so 111b = 7 turns, 101b = 5 turns, etc.
===????===
* 3: Poison
Unknown, possibly simply padding (not used and usually set to either 0 or -1, depending on the data type).
* 4: Burned
* 5: Frozen
* 6: Paralysis
* 7: Bad poison


==Location==
===Data===
Certain [[Pokémon data substructures in Generation III|data]] pertaining to the Pokémon that is stored in a special and encrypted format.


A Trainer's [[party|team]] starts at the following addresses in the GBA's RAM (for US games?):
===Status condition===
The Pokémon's [[status condition]] is stored as follows:


* Ruby: 0x03004360
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
* Sapphire: 0x03004360
! Bit || colspan=2 | Status
* Emerald: 0x02024190, 0x020244EC for US games
|-
* FireRed: 0x02024284
| 0-2 || class="roundy" style="background:#{{status color}}; border:1px solid #f8f8ff; text-align:center" width="32px" | <small>{{color2|FFFFFF|Sleep (status condition)|SLP}}</small> || Sleep
* LeafGreen: 0x020241e4
|-
| 3 || class="roundy" style="background:#{{poison color}}; border:1px solid #f8f8ff; text-align:center" | <small>{{color2|FFFFFF|Poison (status condition)|PSN}}</small> || Poison
|-
| 4 || class="roundy" style="background:#{{fire color}}; border:1px solid #f8f8ff; text-align:center" | <small>{{color2|FFF|Burn (status condition)|BRN}}</small> || Burn
|-
| 5 || class="roundy" style="background:#{{ice color}}; border:1px solid #f8f8ff; text-align:center" | <small>{{color2|FFFFFF|Freeze (status condition)|FRZ}}</small> || Freeze
|-
| 6 || class="roundy" style="background:#{{electric color}}; border:1px solid #f8f8ff; text-align:center" | <small>{{color2|FFFFFF|Paralysis (status condition)|PAR}}</small> || Paralysis
|-
| 7 || class="roundy" style="background:#{{poison color}}; border:1px solid #f8f8ff; border-bottom:1px solid; text-align:center" | <small>{{color2|FFFFFF|Poison (status condition)|PSN}}</small> || Bad Poison
|}
The three sleep bits are used to indicate turns of sleep. So 111<sub>2</sub> = 7 turns of sleep, 101<sub>2</sub> = 5 turns, et cetera.


Additionally, a wild Pokémon or an opponent's Pokémon will begin at:
===Pokérus===
{{incomplete|section|What happens when this value ticks down to 0? What determines when it ticks down?}}
{{main|Pokérus}}
Not the same as the value found in [[Pokémon data substructures in Generation III#Pokérus status|the miscellaneous data substructure]], which is a [[Pokérus#Technical_information|standard Pokérus byte]]. Instead, this value starts at 0xFF (and is in fact set to 0xFF initially even for Pokémon who haven't contracted Pokérus) and slowly ticks down. Cured Pokémon have this value set to 0.


* Emerald: 0x02024744
==Data location==
* FireRed: 0x0202402C
{{incomplete|section|Are the addresses below only for US games? Also, is the mentioned "general region" of box data correct?}}
 
A Trainer's [[party]] starts at the following addresses in the GBA's RAM.
 
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
There are 6 Pokémon per team, so the whole team continues for 600 bytes afterward.
! Game || Address
 
|-
This structure is used to save data on Pokémon stored in the player's team.
| '''{{color2|{{ruby color}}|Pokémon Ruby and Sapphire Versions|Ruby}}''' || rowspan=2 | 0x03004360
The structure for Pokémon saved in the PC stops after the data field, making it only 80 bytes long.
|-
| '''{{color2|{{sapphire color}}|Pokémon Ruby and Sapphire Versions|Sapphire}}'''
|-
| '''{{color2|{{emerald color}}|Pokémon Emerald Version|Emerald}}''' || 0x02024190<br>0x020244EC<sup>{{tt|US|for US games}}</sup>
|-
| '''{{color2|{{firered color}}|Pokémon FireRed and LeafGreen Versions|FireRed}}''' || 0x02024284
|-
| '''{{color2|{{leafgreen color}}|Pokémon FireRed and LeafGreen Versions|LeafGreen}}''' || 0x020241E4<br>0x02024284<sup>{{tt|US|for US games}}</sup>
|}
An opponent's party, or a wild Pokémon, starts at the following addresses.
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
! Game || Address
|-
| '''{{color2|{{emerald color}}|Pokémon Emerald Version|Emerald}}''' || 0x02024744
|-
| '''{{color2|{{firered color}}|Pokémon FireRed and LeafGreen Versions|FireRed}}''' || 0x0202402C
|}


This explains why Pokémon injured by status ailment will cure themselves when put in the PC. It also applies to stats and level, which are recalculated based on Experience.
The 600 bytes following these addresses describe a whole team of 6 Pokémon.


Thus, there are also 33600 (14*30*80) bytes stored somewhere else in the GBA's RAM to save data on Pokémon in the PC.
The full 100-byte structure for a Pokémon is only used to describe Pokémon being held in the player's party. When Pokémon are stored in the PC, their data is recorded using only the first 80 bytes of this structure, stopping after the [[Pokémon data substructures in Generation III|data]] field. The last 20 bytes (excepting status condition) can all be recalculated from data in the data substructure when a Pokémon is withdrawn (level being derived from experience). This also explains why Pokémon suffering a status condition are "cured" when put in the PC.


When the GBA's saved state (including memory contents) are unzipped into a 740,000+ byte file and viewed, the 14 Boxes of 420 Pokémon are stored in the general region of $038000 $040000.
This means there are also 33,600 bytes (80 bytes * 30 per Box * 14 Boxes) elsewhere in the GBA's RAM describing Pokémon in the PC. When the GBA's saved state (including memory contents) is unzipped into a 740,000+ byte file and viewed, the 14 Boxes of 420 Pokémon are stored in the general region of $038000 and $040000. In the US version of Pokémon Emerald, box data is between 0x02FE9888 and 0x02FF1BC8, non-inclusive. The first 6 80-byte structures make up, from left to right, the first row of Pokémon in box 1. The next Pokémon gets placed on the next row. After 5 rows (30 80-byte structures), the next Pokémon is placed in box 2, and so on.


==See also==
==See also==

Revision as of 18:18, 8 May 2017

Pokémon in the Pokémon Ruby and Sapphire, FireRed and LeafGreen, and Emerald Versions are all stored the same way in a 100-byte structure. All numbers are stored in little-endian order.

Notes

Pokémon
type offset
Personality value dword 0
OT ID dword 4
Nickname 10 bytes 8
Language word 18
OT name 7 bytes 20
Markings byte 27
Checksum word 28
???? word 30
Data 48 bytes 32
Status condition dword 80
Level byte 84
Pokérus remaining byte 85
Current HP word 86
Total HP word 88
Attack word 90
Defense word 92
Speed word 94
Sp. Attack word 96
Sp. Defense word 98

Personality value

The personality value controls many things, including gender, Unown's letter, Spinda's dots, any Pokémon's Nature, and more.

OT ID

The Original Trainer's ID number. This number is part of the XOR encryption key for the data section, and is also used in Shiny determination and the lottery. The least significant bytes of this number are the Trainer ID visible on the status screen.

Nickname

The Pokémon's nickname, limited to 10 characters. The characters represented by each byte are determined by the proprietary character set.

Language

The language of the game the Pokémon comes from. Eggs have this value set to 0x0601. In international versions, the language value determines which character set is used when displaying the Pokémon's name and OT name. Any Pokémon with a language value of 0x0601 will, in international versions, be named the game's regional variant of "EGG", ignoring the nickname field.

In Japanese versions, the language value is entirely disregarded. Names always use the nickname bytes decoded with the Japanese character set.

For Pokémon not in Eggs, the valid values are:

Hex Language
0x0201 Japan Flag.png Japanese
0x0202 England Flag.png English
0x0203 France Flag.png French
0x0204 Italy Flag.png Italian
0x0205 Germany Flag.png German
0x0206 South Korea Flag.png Korean*
0x0207 Spain Flag.png Spanish

OT name

The name of the Pokémon's Original Trainer. The characters represented by each byte are determined by the proprietary character set.

Markings

The markings seen in the storage Box. These markings serve only to aid in organizing large collections of Pokémon.

Bit Mark
0
1
2
3

Checksum

The checksum for the 48-byte data section of this structure. It is computed by adding all of the unencrypted values of that section one word at a time. If the computed sum and the stored checksum do not match, the Pokémon is interpreted as a Bad Egg.

????

Unknown, possibly simply padding (not used and usually set to either 0 or -1, depending on the data type).

Data

Certain data pertaining to the Pokémon that is stored in a special and encrypted format.

Status condition

The Pokémon's status condition is stored as follows:

Bit Status
0-2 SLP Sleep
3 PSN Poison
4 BRN Burn
5 FRZ Freeze
6 PAR Paralysis
7 PSN Bad Poison

The three sleep bits are used to indicate turns of sleep. So 1112 = 7 turns of sleep, 1012 = 5 turns, et cetera.

Pokérus

050Diglett.png This section is incomplete.
Please feel free to edit this section to add missing information and complete it.
Reason: What happens when this value ticks down to 0? What determines when it ticks down?
Main article: Pokérus

Not the same as the value found in the miscellaneous data substructure, which is a standard Pokérus byte. Instead, this value starts at 0xFF (and is in fact set to 0xFF initially even for Pokémon who haven't contracted Pokérus) and slowly ticks down. Cured Pokémon have this value set to 0.

Data location

050Diglett.png This section is incomplete.
Please feel free to edit this section to add missing information and complete it.
Reason: Are the addresses below only for US games? Also, is the mentioned "general region" of box data correct?

A Trainer's party starts at the following addresses in the GBA's RAM.

Game Address
Ruby 0x03004360
Sapphire
Emerald 0x02024190
0x020244ECUS
FireRed 0x02024284
LeafGreen 0x020241E4
0x02024284US

An opponent's party, or a wild Pokémon, starts at the following addresses.

Game Address
Emerald 0x02024744
FireRed 0x0202402C

The 600 bytes following these addresses describe a whole team of 6 Pokémon.

The full 100-byte structure for a Pokémon is only used to describe Pokémon being held in the player's party. When Pokémon are stored in the PC, their data is recorded using only the first 80 bytes of this structure, stopping after the data field. The last 20 bytes (excepting status condition) can all be recalculated from data in the data substructure when a Pokémon is withdrawn (level being derived from experience). This also explains why Pokémon suffering a status condition are "cured" when put in the PC.

This means there are also 33,600 bytes (80 bytes * 30 per Box * 14 Boxes) elsewhere in the GBA's RAM describing Pokémon in the PC. When the GBA's saved state (including memory contents) is unzipped into a 740,000+ byte file and viewed, the 14 Boxes of 420 Pokémon are stored in the general region of $038000 and $040000. In the US version of Pokémon Emerald, box data is between 0x02FE9888 and 0x02FF1BC8, non-inclusive. The first 6 80-byte structures make up, from left to right, the first row of Pokémon in box 1. The next Pokémon gets placed on the next row. After 5 rows (30 80-byte structures), the next Pokémon is placed in box 2, and so on.

See also

Links


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.