raphi.xyz

Boktai save file checksums

This content has been moved to the Boktai Hacking Wiki.

Archived version

The save files of Boktai games contain checksums that are verified when the save is loaded. After modifying save files with a hex editor or another tool, these checksums must be updated so the save will load correctly again.

The save file is divided into blocks. Each block size is a multiple of 8 bytes. After the last 8-byte chunk in a block, there is another 8-byte chunk containing the checksum. The checksum are these 4 halfwords:

  1. Constant 0xffff
  2. Byte size of this block, excluding this checksum
  3. Sum of halfwords in this block, excluding this checksum
  4. XOR-sum of halfwords in this block, excluding this checksum

Hex dump of the first block in Boktai 1 saves, with the checksum in bold. Note that each halfword is stored in the save file in big-endian byte order:

00000000: 0000 00e4 0003 cc18 0000 0101 0000 0000 00000010: 0000 0000 0000 0000 ffff 0018 ce00 cdfe

Boktai 1 save files contain the following blocks. Here is a Python script that updates all checksums of a Boktai 1 save.

Byte offset Byte size
0x0000 0x18
0x00c0 0x28
0x0200 0x28
0x0340 0x400
0x0780 0x418
0x0dc0 0x400
0x1200 0x418
0x1840 0x168
0x1a40 0x168

Tags: boktai boktai1 boktai2 boktai3