ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Thu Oct 29, 2020 7:13 am

All times are UTC




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Sep 23, 2020 10:57 pm 

Joined: Wed Aug 13, 2014 6:43 pm
Posts: 27
This is a first draft to convert a save file from Rune Factory 4 for the 3DS to a working save file for Rune Factory 4 Special for the Nintendo Switch.
The save format seems to have stayed mostly the same, but the Special save files are 128 bytes larger. I've tried to identify where this additional space is and adjust the data.

It's a bit wonky, and i haven't dissected the thousands of bitflags in the save file (the RF4 devs LOOOVE their tightly packed bitfields, nothing like seeing an array of 1000+ unpadded 30-bit numbers), so i just kludge the memory a bit and hope that it works. The nature of constructing and comparing a 100kb+ save file for a 100 hour game across three different hardwares makes it a bit, uh...

Anyways, this script takes a 3DS RF4 save file (rf4a.sav, rf4b.sav, rf4c.sav) and converts it to an afaik mostly functional Switch RF4S save file (named rf4_sXX.sav, substitute your own slot number from 01-20).

I might expand the script to do the reverse eventually, but tbh, i highly doubt there's any practical demand for that. :lol:

https://pastebin.com/uNNGqtpv


Top
   
PostPosted: Wed Sep 23, 2020 10:59 pm 

Joined: Wed Aug 13, 2014 6:43 pm
Posts: 27
Here's version 1 of the script in full:

edit: small 0-day patch because i messed up the CRC calculation for the finished save file, of all things. It's fixed now.

Code:
# Rune Factory 4 (Special)
# Script to convert save files from RF4 to RF4S
# Version 1
#
# Written by HenryEx
#
# script for QuickBMS http://quickbms.aluigi.org
# See also: http://aluigi.altervista.org/bms/quickbms_crc_engine.txt

set PAD long 0xE0
set JANK long 0
get NAME filename
get FILESIZE asize

if FILESIZE != 0x22400  # RF4 file
  print "Filesize incorrect! Is: %FILESIZE|h%! Should be: 0x22400. Exiting..."
  CleanExit
endif

get FILECRC long
SavePos OFFSET
xmath SIZE "FILESIZE - OFFSET - PAD"

# check if the save is valid
encryption CRC 0xEDB88320 "32 -1 -1 0 0 1"
log MEMORY_FILE OFFSET SIZE
set NEWCRC long QUICKBMS_CRC

if FILECRC != NEWCRC
  print "CRC check failed! Script will only work on a valid save file! Exiting..."
  CleanExit
endif

encryption "" ""
log MEMORY_FILE 0 0
math SIZE + 0x80

################################
# Assemble save file

append  # Append ON
log MEMORY_FILE 0 0x1E5D9
log MEMORY_FILE 0x1E55C 0x7D
log MEMORY_FILE 0x1E5D9 0x50  # we lose a byte here, i hope it wasn't important
log MEMORY_FILE 0x1E62A 0x20B6
goto 0x2075C MEMORY_FILE
put JANK long MEMORY_FILE # maybe this won't even horribly break eventually? let's just pray
log MEMORY_FILE 0x206E0 0x1D20
append  # Append OFF

encryption CRC 0xEDB88320 "32 -1 -1 0 0 1"
log MEMORY_FILE2 OFFSET SIZE MEMORY_FILE
encryption "" ""
set NEWCRC long QUICKBMS_CRC

goto 0 MEMORY_FILE
put NEWCRC long MEMORY_FILE

log "rf4_sXX.sav" 0 0x22480 MEMORY_FILE
CleanExit


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited