HenryEx

RF4 save conversion QuickBMS script

Sep 23rd, 2020 (edited)
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Rune Factory 4 (Special)
  2. # Script to convert save files from RF4 to RF4S
  3. # Version 1
  4. #
  5. # Written by HenryEx
  6. #
  7. # script for QuickBMS http://quickbms.aluigi.org
  8. # See also: http://aluigi.altervista.org/bms/quickbms_crc_engine.txt
  9.  
  10. set PAD long 0xE0
  11. set JANK long 0
  12. get NAME filename
  13. get FILESIZE asize
  14.  
  15. if FILESIZE != 0x22400 # RF4 file
  16. print "Filesize incorrect! Is: %FILESIZE|h%! Should be: 0x22400. Exiting..."
  17. CleanExit
  18. endif
  19.  
  20. get FILECRC long
  21. SavePos OFFSET
  22. xmath SIZE "FILESIZE - OFFSET - PAD"
  23.  
  24. # check if the save is valid
  25. encryption CRC 0xEDB88320 "32 -1 -1 0 0 1"
  26. log MEMORY_FILE OFFSET SIZE
  27. set NEWCRC long QUICKBMS_CRC
  28.  
  29. if FILECRC != NEWCRC
  30. print "CRC check failed! Script will only work on a valid save file! Exiting..."
  31. CleanExit
  32. endif
  33.  
  34. encryption "" ""
  35. log MEMORY_FILE 0 0
  36. math SIZE + 0x80
  37.  
  38. ################################
  39. # Assemble save file
  40.  
  41. append # Append ON
  42. log MEMORY_FILE 0 0x1E5D9
  43. log MEMORY_FILE 0x1E55C 0x7D
  44. log MEMORY_FILE 0x1E5D9 0x50 # we lose a byte here, i hope it wasn't important
  45. log MEMORY_FILE 0x1E62A 0x20B6
  46. goto 0x2075C MEMORY_FILE
  47. put JANK long MEMORY_FILE # maybe this won't even horribly break eventually? let's just pray
  48. log MEMORY_FILE 0x206E0 0x1D20
  49. append # Append OFF
  50.  
  51. encryption CRC 0xEDB88320 "32 -1 -1 0 0 1"
  52. log MEMORY_FILE2 OFFSET SIZE MEMORY_FILE
  53. encryption "" ""
  54. set NEWCRC long QUICKBMS_CRC
  55.  
  56. goto 0 MEMORY_FILE
  57. put NEWCRC long MEMORY_FILE
  58.  
  59. log "rf4_sXX.sav" 0 0x22480 MEMORY_FILE
  60. CleanExit
RAW Paste Data