Skip to content
cxd4 edited this page Apr 2, 2016 · 4 revisions

Significance

check_sum is the game code's identifier for the flash data's checksum.

Syntax

  • zs $filepath -- Loads the flash memory data file $filepath, fills in the magic number and new checksum for File 1 and exits.
  • There is no command-line flag or switch specifically for writing to check_sum, as there is no reason for a user to write anything other than the correct checksum to it so that the game will accept the data.

Tested Inputs

Only the up-to-date checksum is the correct value for game file sections in flash memory. Anything else causes the game to dismiss the memory section as an empty, unused file in the File Select screen, unless the corresponding backup copy of the section is found to be valid and copied back into the original, corrupt section.

The editor is designed to make the save file bi-compatible with both Japanese and non-Japanese ROMs.

Notes

The algorithm for computing the checksum is simple addition. Because the final checksum storage is only 16 bits wide in front of over 4096 bytes of data (4096 * 0xFF > 0xFFFF), it is plausible that the correct result will be based on wraparound from unsigned overflow.

The following is a C99 function representing the checksum algorithm for a USA ROM version.

#include <stdint.h>
#include "flash_io.h"

uint16_t check_sum(unsigned int section) {
    uint8_t * file;
    uint16_t sum = 0x0000;
    int is_owl_save;

    file = &flash_RAM[section << 13];
    is_owl_save = (file[0x0023] != 0x00) ? 1 : 0;
    for (unsigned int i = 0x0000; i < 0x2000 << is_owl_save; i++)
        sum += file[i];
    return sum;
}

Note that in the case of non-Japanese ROM versions, the full 16-KiB storage is needed for a single game file. In this case, the checksum is an accumulation of all bytes until &file[0x4000], not &file[0x2000].

Relevant Bits

file[0x100A:0x100B]15..0
file[0x138E:0x138F]15..0 for Japanese ROM versions

Derived Cheat Codes

(Do we care to have a cheat code for this?)

Clone this wiki locally