Pikmin 2 save file

From Pikmin Technical Knowledge Base
Revision as of 09:13, 15 October 2020 by Espyo (talk | contribs)
Jump to navigation Jump to search

Data about the Pikmin 2 save file format. The following info was taken from the US version of Pikmin 2 based on a .gci save taken from Dolphin. This data applies to all GameCube versions of the game, the only difference being the region code on the 4th byte of the file


To do: Figure out how to decrypt save files for the NPC version

The save file contains save data for each of the 3 save slot used in-game. The data of such a save slot starts with the 8 byte magic word string PlVa0003 and is 0xC000 bytes (49152 bytes in decimal) long. Directly after the string follows a byte which has the slot number of the save (0x00 for first slot, 0x01 for second, 0x02 for third). The last 4 bytes of the slot data contain the checksum calculated for the preceding slot data. The checksum is detailed in this section.

Addresses

Addresses of interest relative to the start of the save slot (i.e. the start of the magic word string):

Address Size Description
0x13 1 byte When this byte is set to 0 the save file is considered new
0x14 4 bytes Integer representing the day count as shown on the file select screen (might not be permanent, i.e. overwritten when you end a day normally.)
0x2C 4 bytes Integer representing the Poko count as shown on the file select screen.
0x30 4 bytes Integer representing the treasure count as shown on the file select screen. Usually the same as the amount of treasures as accessed on the Area Select Screen.
0x3C 4 bytes Integer representing the time (in minutes) played on the save file as shown on the file select screen.
0x53 array of 2, 4 byte integers followed by a 1 byte bitmask 4 byte integer of Pikmin lost to the said enemy, followed by a 4 byte integer representing the amount of enemies killed, followed by a 1 byte bitmask 0b1 represents that the enemy has been unlocked in the Piklopedia and 0b10 represents that the enemy has been viewed in the Piklopedia.
0x3E9 4 bytes Actual day count the game registers, differing from what is displayed on the file select screen if only one of the two addresses is edited.
0x3ED 2 bytes Bitmask for Exploration Kit items and their activity. The least significant bit represents the EK item with an internal ID of 0 When the bit is set to 1, the item is active. This activity does not reflect the treasure being collected.
0x3F1 21 length 4 byte array Pikmin types that fall from the sky during entering and exiting a cave. Editing this value on a save file that is on the area select screen will result in the Pikmin falling from the sky upon entering an area. The Pikmin types are organized into groups of three, with the first integer representing a leaf Pikmin, the second a bud Pikmin, and the third a flower Pikmin. The Pikmin types in the array are ordered Blue, Red, Yellow, Purple, White, Bulbmin, and an unused Pikpik carrot.
0x479 21 length 4 byte array Same as above but for Pikmin in the Onions and Ship. When either Bulbmin or Pikpik carrots are added the total number of Pikmin is increased however as they have no Onions there is no way to access them.
0x4CF 188 length 1 byte array 1 byte each represents the treasure as accessed on the area select screen. Treasures appear to follow their internal IDs for order. These are all the treasures not part of the Exploration Kit (nor The Key). Non-zero values mean collected. 02 means that the treasure will appear with "New" in the Piklopedia, while 06 means its old.
0x58D 13 length 1 byte array Same as above, only for Exploration Kit treasures including The Key.
0x7E7 1 byte Bitstream representing progress in Valley of Repose. If the least significant bit is set to 1 it plays the unlock fanfare next time the save is loaded. If the next bit is set to 1 then the fanfare won't play.

To do: Figure out what the other bits control

0x7E8 1 byte Used for the above ground treasure counter for the Valley of Repose on the map screen.
0x7E9 1 byte Same as 0x7E7 but for the Awakening Wood.
0x7EA 1 byte Used for the above ground treasure counter for the Awakening Wood on the map screen.
0x7EB 1 byte Same as 0x7E7 but for the Perplexing Pool.
0x7EC 1 byte Used for the above ground treasure counter for the Perplexing Pool on the map screen.
0x7ED 1 byte Same as 0x7E7 but for the Wistful Wild.
0x7EE 1 byte Used for the above ground treasure counter for the Wistful Wild on the map screen.
0x834 4 bytes Actual Poko count the game registers, differing from what is displayed on the file select screen if only one of the two addresses is edited.

Checksum

The checksum of a save slot is calculated according to this method.

This Python script (requires Python >3.4) assists with calculating the checksum for the data in a save slot. Not recalculating and fixing the checksum results in the game detecting the modified save slot as being corrupted (but if you have any unmodified save slots, those will still work fine).

Very careful editing might allow you to fool the corruption detection without having to recalculate the value: Due to the checksum being an additive one, if you increase one value by 1 and decrease a different value by 1, the checksum should still remain valid.[unsure]