FF4 SNES SRM Checksum - Printable Version +- FF6 Hacking (https://www.ff6hacking.com/forums) +-- Forum: Discussion Forums (https://www.ff6hacking.com/forums/forum-5.html) +--- Forum: Magitek Research Facility (https://www.ff6hacking.com/forums/forum-9.html) +---- Forum: Other Rom Hacking (https://www.ff6hacking.com/forums/forum-64.html) +---- Thread: FF4 SNES SRM Checksum (/thread-3411.html) Pages:
1
2
|
FF4 SNES SRM Checksum - stonerbot613 - 02-10-2017 Hello everybody, Long time FF player. First time poster. I'm trying to figure out the algorithm for generating the save game checksum for Final Fantasy II on SNES (or 4 however you look at it). I know the file is 8kB long and is divided into 4 equally spaced 2kB blocks. The checksum from what I gather is at the end of this block. I've tried sums of the words, XORs of the words, and I'm really sort of lost as to how it's computed. I found a tool by Lord J - FF4H version 3B that implements this. That's great, but I'd like to know the calculation behind it. From looking at his freely available source code for FF3H, it does look like it's more or less a simple sum of the words in each slot, XORd with all 1's at the end. Is FF4 the same? Thanks for any help you can provide. RE: FF4 SNES SRM Checksum - madsiur - 02-11-2017 I don't know if FF4 is the same. There is no public disassembly of the code to my knowledge. Aside of Lord J, Zyrtophar also made a SRM editor a while back, so the algorithm is known: http://slickproductions.org/forum/index.php?topic=156.msg2110#msg2110 However, there is no source. You could ask in the FF4 forum on that board. RE: FF4 SNES SRM Checksum - stonerbot613 - 02-12-2017 Thanks Madsiur for the direction. I'll go take a look at Zyrthofar's tool and see if I can contact him on that forum. RE: FF4 SNES SRM Checksum - madsiur - 02-12-2017 (02-12-2017, 12:15 AM)stonerbot613 Wrote: I'll go take a look at Zyrthofar's tool and see if I can contact him on that forum. I'm a 100% sure he's not active anymore. However Slick Forums has a few FF4 experts that could likely help. RE: FF4 SNES SRM Checksum - Vertigo - 02-12-2017 Hmm. This may prove useful for my project Thanks people! Need more references. Cheers! RE: FF4 SNES SRM Checksum - stonerbot613 - 02-12-2017 By changing one value at a time in Zyrthofar's tool (ie: Max HP from 1 to 2), I noticed that both bytes of the checksum independently increment by the same amount. For instance, if I increase Cecil's Max HP field by 1, then both checksum bytes increase by 1. If I increase another field by 2, then both checksum bytes increase by 2. They seem to be somewhat independent of each other. I don't know what the final two bytes (or depending on endianness the 3rd and 4th bytes from the end) are 0xE4 and 0x1B. Interestingly these add up to 0xFF, which I could see factoring into some sort of checksum. They could also just as well be an 'end of slot' marker. The 5th byte from the end also changes - maybe as part of the checksum calculation. I haven't figured that out yet. It'd be great if you could take a look at it. Maybe it's a really easy problem and I've just overlooked the obvious solution? RE: FF4 SNES SRM Checksum - m06 - 02-12-2017 I checked this out since I'm also curious. The two bytes at the end $07FE and $07FF are set to #$1BE4 if the save slot is in use. The checksum is calculated word by word but each word will overlap as the checksum counter is only increased by one byte. This is why both bytes of the checksum increase when one byte is increased. Partial disassembly Code: Transfer A to X through $43 Good luck and happy hacking! RE: FF4 SNES SRM Checksum - stonerbot613 - 02-12-2017 Awesome! Thanks for the source assembly code. It's been a long time since I've dealt with assembly code (~17 years or so), so I'll need to brush up on it to get familiar with what these op codes and instructions do on the 65816. If I understand what you said correctly, and from looking at the main loop (0x1cc7b to 0x1cc80) it treats the data as 16-bit (accumulator set to 16 bits at 0x1cc6d), but only increments the byte address by 1? So if my 16-bit words are as follows, 0x1122 0x3344 0x5566 It would add 0x1122, 0x2233, 0x3344, 0x4455, 0x5566 and then set the accumulator to 8-bit mode (effectively dropping all higher bits) and return that as the 16(?)-bit checksum? Am I kind of on the right track? RE: FF4 SNES SRM Checksum - m06 - 02-12-2017 Yep, you pretty much got it. Nothing is dropped though. When the accumulator is set to 8-bit mode the checksum has already been transferred to X so all 16-bits are stored. I'm not sure about all of this as I have not properly tested anything but I found the routines with breakpoints, disassembled them and commented by hand. The checksum starts with RAM value $41, I have no idea what it contains but I hope it's zero. More breakpoints could figure this out though. I think we're on the right track, you're understanding what I have very well. Let us know if you get something working. RE: FF4 SNES SRM Checksum - assassin - 02-12-2017 glad to see you're making short work of this. so it's essentially two separate 8-bit checksums, with the bottom one having all but the last data value, and the top one having all but the first? |