HenryEx

RF4 save checksum correction QuickBMS

Sep 21st, 2020
49
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Rune Factory 4 (Special)
  2. # Script to fix save checksum after modification
  3. #
  4. # Works on save files and "system saves" / save select file
  5. #
  6. # Written by HenryEx
  7. #
  8. # script for QuickBMS http://quickbms.aluigi.org
  9. # See also: http://aluigi.altervista.org/bms/quickbms_crc_engine.txt
  10.  
  11. get NAME filename
  12. get FILESIZE asize
  13. get MAGIC long
  14. set PAD long 0xE0
  15.  
  16. if MAGIC == 1144276562 # string 'RF4D'
  17. get FILECRC long
  18. set PAD long 0
  19. else
  20. set FILECRC long MAGIC
  21. set PAD long 0xE0
  22. endif
  23.  
  24. SavePos OFFSET
  25. xmath SIZE "FILESIZE - OFFSET - PAD"
  26.  
  27. # print "File CRC: %FILECRC|x%, data pos: %OFFSET%, pad by %PAD%, data size: %SIZE%"
  28.  
  29. encryption CRC 0xEDB88320 "32 -1 -1 0 0 1"
  30. log MEMORY_FILE OFFSET SIZE
  31. set NEWCRC long QUICKBMS_CRC
  32.  
  33. if FILECRC == NEWCRC
  34. print "Save CRC seems to be intact! No modification necessary."
  35. CleanExit
  36. endif
  37.  
  38. encryption "" ""
  39. log MEMORY_FILE 0 FILESIZE
  40.  
  41. math OFFSET - 4
  42. goto OFFSET MEMORY_FILE
  43. put NEWCRC long MEMORY_FILE
  44. print "Checksum fixed! New CRC: %NEWCRC|x%"
  45.  
  46. log NAME 0 FILESIZE MEMORY_FILE
  47. CleanExit
RAW Paste Data