Advertisement
Guest User

FFVI SRM checksum fix

a guest
Apr 24th, 2013
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. """
  2.        Fix hacked FFVIj/FFIIIus SRM files
  3.        2013, by m06
  4.  
  5.        Usage: python FF6_SRM_fix.py /path/to/save_file.srm
  6.  
  7. """
  8.  
  9. print "\n\tFinal Fantasy VI SRM checksum fix\n"
  10.  
  11. from struct import *
  12. import sys
  13.  
  14. filename = ''
  15.  
  16. if len(sys.argv) > 1:
  17.         filename = sys.argv[1]
  18.  
  19. if filename == '':
  20.         print "!!! Please provide an SRM file to fix !!!\nUsage: python FF6_SRM_fix.py /PATH/TO/FILE.SRM\n"
  21.         quit()
  22.  
  23. print "Fixing file: " + filename
  24.  
  25. with open(filename, "r+b") as f:
  26.     for i in range(3):
  27.         checksum = 0
  28.         for b in f.read(2558):
  29.             checksum += unpack('i', b + '\x00\x00\x00')[0]
  30.         f.seek(2558 + (i*2560))
  31.         f.write( pack('B', checksum % 256) )
  32.         f.write( pack('B', (checksum/256) % 256) )
  33.  
  34.         print "Checksum for save slot " + str(i+1) + ": " + str(checksum)
  35.  
  36. print"Done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement