Save data structure in Generation II

The save data structure for Generation II is stored in the cartridge's battery-backed RAM chip (SRAM), or as a ".sav" file from most emulators. The structure consists of 32 KB of data, though not every byte is used. Emulators may append additional data for the purposes of maintaining real-time clock operations.

Two regions of the save data have their integrity validated via checksums. These region contain all of the information that directly pertains to the player and his or her Pokémon. Additional information pertinent to the save file is also present in the other regions of the data.

Data types
Unless otherwise noted, integer values occupy the specified number of bytes, and are and either unsigned or.

Text data is stored in a proprietary encoding.

Item lists
Lists of items in the save data follow a particular format.

Lists have entries of 2 bytes each, and a capacity. The total size of the list data, in bytes, is.

For example, the player's pocket inventory can hold 20 item entries, so the size of that list is 20 * 2 + 2 = 42 bytes.

Count
The number of item entries actually being represented in the list. Note that count and capacity are not the same thing.

Entries
The exact data for each item entry in the list. For more information, see below.

Terminator
The byte following the last item entry, according to Count, must always be a terminator, which is byte value.

This spare byte is present at the end of the list data for the event when the list is filled to capacity.

Entry format
The Entry record has the following format:

Count
The amount of that particular item. Must be between 1 and 99, inclusive.

Index
The item's index.

Pokémon lists
Lists of Pokémon in the save data follow a particular format.

Lists have entries of varying sizes, and a capacity. The total size of the list data in bytes is  in a save file from an English game, and   in a save file from a Japanese game.

For example, the player's Pokémon team contains 6 entries and each entry is 48 bytes in size, so the size of that list is 6 * (48 + 23) + 2 = 428 bytes in an English save file, and 6 * (48 + 13) + 2 = 368 bytes in a Japanese one.

Count
The number of Pokémon entries actually being represented in the list. Note that the count and the count and the capacity are not the same thing - a Pokémon list may have a capacity of, say, 30 Pokémon but only use a few of those slots. The count tells how many are actually used.

Species
A list of species indexes, one for each Pokémon in the list. This is used by the team menu as well as the PC management interface.

The byte following the last species entry, according to Count, must always be a terminator, which is the byte. This means the species section is one byte longer than just the index numbers would make it.

If an entry in this field is set to, then the corresponding Pokémon is still in its egg.

Pokémon
The exact data for each Pokémon entry in the list. For the format, please refer to: Pokémon data structure in Generation II


 * For team Pokémon, the entry size is the full 48 bytes as documented in that article.
 * For PC Pokémon, only the first 32 bytes are used, meaning everything after Level is not included. Instead, those values are regenerated upon withdrawing a Pokémon from the PC. This is the basis of the Box trick.

OT names
Text strings representing the names of the original Trainers for each Pokémon entry. Each name can contain up to 10 characters in a save file from an English game, and up to 5 characters in a save file from Japanese one. Following the 10 or 5 bytes, there is always one  byte, for a total of 11 or 6 bytes per name.

Names
Text strings representing the names for each Pokémon entry. Each name can contain up to 10 characters in a save file from an English game, and up to 5 characters in a save file from Japanese one. Following the 10 or 5 bytes, there is always one  byte, for a total of 11 or 6 bytes per name.

A name is considered a "nickname" if it does not perfectly match the default name for a Pokémon. The default name follows these rules:


 * The first however many characters must match the species name exactly. This is typically all-uppercase.
 * The remainder of the string must be all terminator characters, aka.

Therefore, if a Pokémon with a 9- or 10-letter species name, such as, is given a nickname that matches the species name, the nickname will not be retained should that Pokémon evolve.

File structure
Known data within the save file can be found at the following offsets within the data, such that offset 0 is the first byte of an emulator ".sav" file.

Although all data appears twice in the save file, only the primary copy is documented below. For more information, see the Checksums section.

English and Japanese save files are quite a bit different, mostly due to Japanese Generation II games having 9 boxes in the PC of 30 Pokémon each, while the English games have 14 boxes of 20 each. The save format also differs between game versions, as Crystal has more features than Gold and Silver.

Player name
Represents text strings that can be from 1 to 7 characters in length, although the save structure allocates 11 bytes for the name.

The first 8 bytes contain the name with any leftover equal to.

Since the name can be 7 bytes at most, the eighth byte will always be.

The remaining 3 bytes are all.

Rival name
Represents text strings that can be from 1 to 7 characters in length, although the save structure allocates 11 bytes for the name.

The first 8 bytes contain the name with any leftover equal to.

Since the name can be 7 bytes at most, the eighth byte will always be.

The remaining 9th, 10th, and 11th bytes are equal to,  ,   respectively.

Daylight savings
Specifies whether daylight savings time (DST) is in effect.

The highest bit of this field is set to indicate DST is in effect.

The lower 7 bits of this field have unknown significance.

Time played
Specifies how much time has elapsed during gameplay.

This value is actually 4 1-byte values representing, in this order: the hours, minutes, seconds and "frames" that have elapsed. A frame is 1/60th of a second.

This timer is not halted when the game is paused, and also counts up on the main menu before selecting to continue a saved game.

Player palette
Specifies the colors of the player character.

From a technical standpoint, the lowest 3 bits of this field are transferred to OAM to select the colors when drawing the player character. This means that there are a total of 8 possible palettes:


 * Red,
 * Blue,
 * Green,
 * Brown,
 * Orange,
 * Gray,
 * Dark Green,
 * Dark Red,

From a practical standpoint, this value is set by the game depending on whether the player character is a boy or a girl:


 * For boy characters, this is set to  (red)
 * For girl characters, this is set to  (blue)

Despite only being able to make boy characters in Gold and Silver, this field is still present and functional.

Johto Badges
The eight badges are stored on eight bits, one bit for each badge; '1' means the badge is acquired, '0' otherwise.

From MSB to LSB, badges are in this order: Zephyr, Insect, Plain, Fog, Storm, Mineral, Glacier, Rising.

TM pocket
The items that the player has in his or her TM Pocket inventory.

TMs list
Each byte specifies the quantity of the corresponding TM that the player is holding. Should be 0 to 99.

Indexes match item numbers, meaning 0 corresponds with TM01 and 49 corresponds with TM50.

HMs list
Each byte specifies the quantity of the corresponding HM that the player is holding. Should be 0 to 1.

Indexes match item numbers, meaning 0 corresponds with HM01 and 6 corresponds with HM07.

Item pocket item list
The items that the player has in his or her item pocket inventory.

Stored as an Item list with a capacity of 20.

Key item pocket item list
The items that the player has in his or her Key Item Pocket inventory.

Stored as an Item list with a capacity of 26.

Ball pocket item list
The items that the player has in his or her Ball Pocket inventory.

Stored as an Item list with a capacity of 12.

PC item list
The items that the player has stored in the PC.

Stored as an Item list with a capacity of 50.

Current PC Box
Indicates which PC box is currently selected, minus 1. That is to say, box 1 is represented as 0, and box 14 is represented as 13.

The lowest 4 bits of this value are the box index.

PC Box names
The 9 (Japanese game) or 14 (English game) box names. Each name is a string between 1 and 8 characters plus a terminator byte, for a total of 9 bytes each.

Team Pokémon list
The Pokémon that the player has in his or her team.

Stored as a Pokémon list with a capacity of 6 and an entry size of 48 bytes.

Pokédex owned, Pokédex seen
Represents the specific Pokédex entries that have been either seen or owned during gameplay.

Pokémon are indexed by their usual Pokédex order, meaning the order is the same as in the National Pokédex. However, indexes begin counting at 0, rather than 1.

1 bit is used to represent whether a given Pokémon has been seen/owned. Bits are ordered within bytes from lowest to highest, starting with the first byte. Therefore, the exact bit can be extracted from the list using the following formula:

Bit = ( Data[ RoundDown(PokeNum / 8) ] / 2 ^ (PokeNum Mod 8) ) AND 1

Or in C-style code (shift occurs before other bitwise operations):

Bit = Data[PokeNum >> 3] >> (PokeNum & 7) & 1;

Example
Let us say that we want to know whether #120 has been seen/owned:


 * PokeNum becomes 119, since it is 0-based.
 * The byte of the list in which bit 119 is located is = 119 / 8 = 14
 * The bit within that byte is = 119 Mod 8 = 7
 * Dividing the byte value by 2 ^ Bit, or shifting right by Bit, moves the bit to the least-significant position
 * Performing a bitwise AND with 1 will remove all but the least-significant bit

PC Box Pokémon lists
The Pokémon that the player has stored in PC boxes.

Stored as Pokémon lists with a capacity of 20 Pokémon in English save files and 30 in Japanese ones, and an entry size of 32 bytes. After every list is the two bytes.

Normally, Pokémon are deposited and withdrawn from the Current Box list, which is within the checksum-validated region of the save data. When switching boxes, the data from the Current Box is copied to the corresponding PC Box data, then the data from the switched-to PC Box is transferred into the Current Box data.

Player gender
Specifies the gender of the player character:


 * For boy characters, this is set to
 * For girl characters, this is set to

This field is not within the checksum-validated region.

Checksums
Used to validate the integrity of saved data.

Player data in Generation II is stored in the save file twice. The primary copy is located at, and a secondary copy is stored elsewhere in the file. Checksums are performed on both copies and stored in the data.


 * If only one checksum is correct, then the information from that copy of the data will be used.
 * If both values are incorrect, the player will be forced to start a new game.

The checksums are simply the 16-bit sum of all byte values of the corresponding byte regions. Checksums are stored as little-endian.

Gold and Silver
The secondary data copy in Gold and Silver is not contiguous like the primary copy is. Instead, it is split across 5 sections and stored at different locations in the save file. The following table shows which sections of the primary copy are relocated for the secondary copy:

Calculating the checksums, therefore, can be done as follows:


 * Sum the bytes from  to   and store the result at
 * Sum the bytes from  to ,   to   and   to 7E6C, and store the result at

Crystal
The secondary data copy in Crystal is a byte-for-byte match of the primary copy. The following table shows which regions of the save file are occupied by each copy:

Calculating the checksums, therefore, can be done as follows:


 * Sum the bytes from  to   and store the result at
 * Sum the bytes from  to   and store the result at

For Japanese games, the secondary partition is from  to   the checksums can be calculated as follows:


 * Sum the bytes from  to   and store the result at
 * Sum the bytes from  to   and store the result at