Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

EarthBound/SRAM map: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
(Basic map. Needs some explanation.)
 
(Bunch of format/integrity documentation)
Line 1: Line 1:
{{srammap|game=EarthBound}}
{{srammap|game=EarthBound}}


* <tt>0000-001b (001c)</tt>: Save 1A Signature
* <tt>0000-0013 (0014)</tt>: Save 1A Signature
* <tt>0014-001b (0008)</tt>: '''Unused'''
* <tt>001c-001d (0002)</tt>: Save 1A Checksum 1
* <tt>001c-001d (0002)</tt>: Save 1A Checksum 1
* <tt>001e-001f (0002)</tt>: Save 1A Checksum 2
* <tt>001e-001f (0002)</tt>: Save 1A Checksum 2
* <tt>0020-04ff (04df)</tt>: Save 1A Data
* <tt>0020-04ff (04df)</tt>: Save 1A Data
* <tt>0500-051b (001c)</tt>: Save 1B Signature
* <tt>0500-0513 (0014)</tt>: Save 1B Signature
* <tt>0514-051b (0008)</tt>: '''Unused'''
* <tt>051c-051d (0002)</tt>: Save 1B Checksum 1
* <tt>051c-051d (0002)</tt>: Save 1B Checksum 1
* <tt>051e-051f (0002)</tt>: Save 1B Checksum 2
* <tt>051e-051f (0002)</tt>: Save 1B Checksum 2
* <tt>0520-09ff (04df)</tt>: Save 1B Data
* <tt>0520-09ff (04df)</tt>: Save 1B Data
* <tt>0a00-0a1b (001c)</tt>: Save 2A Signature
* <tt>0a00-0a13 (0014)</tt>: Save 2A Signature
* <tt>0a14-0a1b (0008)</tt>: '''Unused'''
* <tt>0a1c-0a1d (0002)</tt>: Save 2A Checksum 1
* <tt>0a1c-0a1d (0002)</tt>: Save 2A Checksum 1
* <tt>0a1e-0a1f (0002)</tt>: Save 2A Checksum 2
* <tt>0a1e-0a1f (0002)</tt>: Save 2A Checksum 2
* <tt>0a20-0eff (04df)</tt>: Save 2A Data
* <tt>0a20-0eff (04df)</tt>: Save 2A Data
* <tt>0f00-0f1b (001c)</tt>: Save 2B Signature
* <tt>0f00-0f13 (0014)</tt>: Save 2B Signature
* <tt>0f14-0f1b (0008)</tt>: '''Unused'''
* <tt>0f1c-0f1d (0002)</tt>: Save 2B Checksum 1
* <tt>0f1c-0f1d (0002)</tt>: Save 2B Checksum 1
* <tt>0f1e-0f1f (0002)</tt>: Save 2B Checksum 2
* <tt>0f1e-0f1f (0002)</tt>: Save 2B Checksum 2
* <tt>0f20-12ff (04df)</tt>: Save 2B Data
* <tt>0f20-12ff (04df)</tt>: Save 2B Data
* <tt>1300-131b (001c)</tt>: Save 3A Signature
* <tt>1300-1313 (0014)</tt>: Save 3A Signature
* <tt>1314-131b (0008)</tt>: '''Unused'''
* <tt>131c-131d (0002)</tt>: Save 3A Checksum 1
* <tt>131c-131d (0002)</tt>: Save 3A Checksum 1
* <tt>131e-131f (0002)</tt>: Save 3A Checksum 2
* <tt>131e-131f (0002)</tt>: Save 3A Checksum 2
* <tt>1320-17ff (04df)</tt>: Save 3A Data
* <tt>1320-17ff (04df)</tt>: Save 3A Data
* <tt>1800-181b (001c)</tt>: Save 3B Signature
* <tt>1800-1813 (0014)</tt>: Save 3B Signature
* <tt>1814-181b (0008)</tt>: '''Unused'''
* <tt>181c-181d (0002)</tt>: Save 3B Checksum 1
* <tt>181c-181d (0002)</tt>: Save 3B Checksum 1
* <tt>181e-181f (0002)</tt>: Save 3B Checksum 2
* <tt>181e-181f (0002)</tt>: Save 3B Checksum 2
* <tt>1820-1cff (04df)</tt>: Save 3B Data
* <tt>1820-1cff (04df)</tt>: Save 3B Data
* <tt>1d00-1fef (02f0)</tt>: '''Unused'''
* <tt>1d00-1fef (02f0)</tt>: '''Unused'''
* <tt>1ff0-1ff0 (0001)</tt>: Anti-Piracy Check Byte
* <tt>1ff0-1ff0 (0001)</tt>: [[#AntiPiracyCheckByte|Anti-Piracy Check Byte]]
* <tt>1ff1-1ffd (000d)</tt>: '''Unused'''
* <tt>1ff1-1ffd (000d)</tt>: '''Unused'''
* <tt>1ffe-1fff (0002)</tt>: Version
* <tt>1ffe-1fff (0002)</tt>: Version
==Save Format==
EarthBound SRAM contains 3 save files or slots, corresponding with the 3 save games from the main menu. The data of a save file is a copy of the [[EarthBound/RAM_map#PersistentData|WRAM Persistent Data]] in the same order and format. For redundancy, each save file is repeated in two separate exact-mirror copies.
==Data Integrity==
EarthBound employs multiple mechanisms to validate and fix save files against data corruption:
* A version number (<code>0x0493</code> for US-release ROMs) is stored at <tt>1ffe-1fff</tt>, and on game startup, all 8KB of SRAM is erased/reset if the version number does not match the expectation hard coded in the ROM. This is assumed to primarily be a development compatibility mechanism to ensure incompatible saves with different formats from earlier builds of the game cannot be accidentally loaded, but the mechanism has a secondary role in detecting corruption if the version number somehow changes in SRAM.
* The first 20 bytes of each <tt>0x500</tt> block of SRAM is set to a known signature ("HAL Laboratory, inc." in ascii). On game startup, all 6 signatures are validated against the expectation hard coded in the ROM. If any signature does not match the expectation, the respective <tt>0x500</tt> block of SRAM is erased and the signature is rewritten.
* Each <tt>0x500</tt> block of SRAM contains 2 checksum values of the block's respective data section, one derived from adding together all data bytes, and the other from XORing all the data.<p>On game startup, checksums are recalculated for all 6 SRAM blocks, and if the newly calculated checksums do not match the saved checksums for any SRAM block, the respective <tt>0x500</tt> block of SRAM is erased and the signature is rewritten. For every 2 blocks redundantly storing the same save file, if only 1 block is reset, the entire <tt>0x500</tt> good block (including signature and checksums) is copied over the bad block. If both blocks are invalid and reset, an error message is displayed to the user in the main save-selection menu.</p><p>On game save, when data is redundantly saved to 2 <tt>0x500</tt> block of SRAM, checksums for each block are calculated and written to that block. Then the checksum is calculated again for each block, and if that checksum does not match the value saved in the block, the entire save file process (for both blocks) starts over.</p>
==Anti Piracy Check Byte<span class="anchor" id="AntiPiracyCheckByte"></span>==


{{stub}}
{{stub}}

Revision as of 20:23, 8 June 2024

Chip tiny.png The following article is an SRAM map for EarthBound.

  • 0000-0013 (0014): Save 1A Signature
  • 0014-001b (0008): Unused
  • 001c-001d (0002): Save 1A Checksum 1
  • 001e-001f (0002): Save 1A Checksum 2
  • 0020-04ff (04df): Save 1A Data
  • 0500-0513 (0014): Save 1B Signature
  • 0514-051b (0008): Unused
  • 051c-051d (0002): Save 1B Checksum 1
  • 051e-051f (0002): Save 1B Checksum 2
  • 0520-09ff (04df): Save 1B Data
  • 0a00-0a13 (0014): Save 2A Signature
  • 0a14-0a1b (0008): Unused
  • 0a1c-0a1d (0002): Save 2A Checksum 1
  • 0a1e-0a1f (0002): Save 2A Checksum 2
  • 0a20-0eff (04df): Save 2A Data
  • 0f00-0f13 (0014): Save 2B Signature
  • 0f14-0f1b (0008): Unused
  • 0f1c-0f1d (0002): Save 2B Checksum 1
  • 0f1e-0f1f (0002): Save 2B Checksum 2
  • 0f20-12ff (04df): Save 2B Data
  • 1300-1313 (0014): Save 3A Signature
  • 1314-131b (0008): Unused
  • 131c-131d (0002): Save 3A Checksum 1
  • 131e-131f (0002): Save 3A Checksum 2
  • 1320-17ff (04df): Save 3A Data
  • 1800-1813 (0014): Save 3B Signature
  • 1814-181b (0008): Unused
  • 181c-181d (0002): Save 3B Checksum 1
  • 181e-181f (0002): Save 3B Checksum 2
  • 1820-1cff (04df): Save 3B Data
  • 1d00-1fef (02f0): Unused
  • 1ff0-1ff0 (0001): Anti-Piracy Check Byte
  • 1ff1-1ffd (000d): Unused
  • 1ffe-1fff (0002): Version

Save Format

EarthBound SRAM contains 3 save files or slots, corresponding with the 3 save games from the main menu. The data of a save file is a copy of the WRAM Persistent Data in the same order and format. For redundancy, each save file is repeated in two separate exact-mirror copies.

Data Integrity

EarthBound employs multiple mechanisms to validate and fix save files against data corruption:

  • A version number (0x0493 for US-release ROMs) is stored at 1ffe-1fff, and on game startup, all 8KB of SRAM is erased/reset if the version number does not match the expectation hard coded in the ROM. This is assumed to primarily be a development compatibility mechanism to ensure incompatible saves with different formats from earlier builds of the game cannot be accidentally loaded, but the mechanism has a secondary role in detecting corruption if the version number somehow changes in SRAM.
  • The first 20 bytes of each 0x500 block of SRAM is set to a known signature ("HAL Laboratory, inc." in ascii). On game startup, all 6 signatures are validated against the expectation hard coded in the ROM. If any signature does not match the expectation, the respective 0x500 block of SRAM is erased and the signature is rewritten.
  • Each 0x500 block of SRAM contains 2 checksum values of the block's respective data section, one derived from adding together all data bytes, and the other from XORing all the data.

    On game startup, checksums are recalculated for all 6 SRAM blocks, and if the newly calculated checksums do not match the saved checksums for any SRAM block, the respective 0x500 block of SRAM is erased and the signature is rewritten. For every 2 blocks redundantly storing the same save file, if only 1 block is reset, the entire 0x500 good block (including signature and checksums) is copied over the bad block. If both blocks are invalid and reset, an error message is displayed to the user in the main save-selection menu.

    On game save, when data is redundantly saved to 2 0x500 block of SRAM, checksums for each block are calculated and written to that block. Then the checksum is calculated again for each block, and if that checksum does not match the value saved in the block, the entire save file process (for both blocks) starts over.

Anti Piracy Check Byte

So very stubbly.
This page is rather stubbly and could use some expansion.
Are you a bad enough dude to rescue this article?