Post subject: Calculating checksum in relation to save files
Mitjitsu
He/Him
Banned User
Joined: 4/24/2006
Posts: 2997
I figured I might as well take a punt on this forum, because it's hard to find an answer to this fairly technical question. I've been playing playing Shining Force 3 on the Sega Saturn and have been trying to alter ingame stats using a hex editor and then transferring the modified file back to my Saturn. It can also be done with emulators as well. However, even the slightest alteration will cause the file to corrupt because it doesn't match up with the checksum. I believe I found the checksum after an hour or so of looking, but have no idea how to calculate a new one. Just wondering how I would go about doing this? There is a save file editor, which calculates it for you. However, it's buggy and incomplete, and has been abandoned years ago. I've tried contacting the original author to ask for help, but there has been no reply. Before anyone asks here's my unmodified .dat file I extracted from my Saturn and here's the save file editor for Shining Force 3 if you wish to see it. I believe it's possible to use .dat file on SSF if you rename it to "InternalBackupRAM.bin"
Joined: 10/18/2011
Posts: 64
It depends on how the checksum is generated. For a very basic test, try increasing one byte by one, then go 4 bytes ahead in the file and reduce that value by one. If it doesn't work, restore the +4 byte value to its original value, then try reducing the +8 byte by 1. I can dig up the code I used to generate a valid checksum for God of War's saves if you think it would help. If you're at all comfortable with assembly and debugging, I was able to decipher God of War's checksum method by setting a breakpoint right before it started reading the save data to generate it. I'd then zero-fill the memory and see what checksum was generated. After doing that a few times and changing a few bytes to see how it affected the checksum, it wasn't too difficult to work it out. For example, if you've found the checksum value, you could make a savestate, set a breakpoint on it reading a specific stat, then save and see how the checksum is altered by altering that stat and its surrounding values. Or you could just chase through the assembly, depending on your comfort level, but I usually find that far more time consuming than just poking things and seeing the results.
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
Most games use very basic checksums which sum up the bytes in 8, 16, or 32 bit units. For games with a basic checksum, to find it, save your game, duplicate the save file, then try to increase or decrease some in-game value by 1 (such as money or health), then save again. Compare your old file with the new one. You'll generally see that up to three things changed between the two (assuming you did not modify anything else). One of these three should match your value (such as money or health), be sure to look at different integer units to determine which of the three changes is your value here. The remaining 2 will generally be a checksum and often a checksum inverse. Once you have this, you can then modify your value to what you want, and offset the checksum and checksum inverse by the same quanity and make up your own save files. In case you cannot find the checksum, then if you add one to a byte, subtract one from some other byte, and a basic checksum will end up seeing the same sum, and it'll work itself out. You may need to adjust this for 16 or 32 bit units as necessary. If the game uses a more complicated sort of checksum, the above strategy for locating where it's stored will generally work, but just simply offsetting will not.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.
Joined: 10/18/2011
Posts: 64
I downloaded the save editor and tried it out. As Nach says, it's a simple sum. Increase a stat by 1, 1 byte of the checksum goes up by 1. Give it a try yourself, compare the differences between the original save and a modified save. If you're going to be doing it all by hand, maybe start taking notes about which stats affect which byte of the checksum. Shouldn't be too hard for you to figure out.
Mitjitsu
He/Him
Banned User
Joined: 4/24/2006
Posts: 2997
Wulf2k wrote:
It depends on how the checksum is generated. For a very basic test, try increasing one byte by one, then go 4 bytes ahead in the file and reduce that value by one. If it doesn't work, restore the +4 byte value to its original value, then try reducing the +8 byte by 1. I can dig up the code I used to generate a valid checksum for God of War's saves if you think it would help.
I tried altering one of the stats by one, then decreasing the next by one, and it corrupted. So there might be more to it than I thought there was. I did find this guide on GameFaqs https://www.gamefaqs.com/saturn/578114-shining-force-iii-premium-disc/faqs/24967 However, since it was written published in 2003. I can't imagine the guy being around anymore.
Joined: 10/18/2011
Posts: 64
The "next" stat is unlikely to be the one that needs lowering. Instead of lowering the next stat, try increasing one byte of the checksum's value by 1. You'll probably guess wrong the first time, so if that reads as corrupt, lower it, then increase the next byte until it works.