News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Possible to patch a save file to a rom?  (Read 1023 times)

vozycozyx

  • Newbie
  • *
  • Posts: 1
    • View Profile
Possible to patch a save file to a rom?
« on: May 08, 2018, 03:34:50 pm »
I want to patch Earthbound with a .srm file so that the game starts off at a certain part of the game without needing the .srm file to take me there. Sorry if this is the wrong board. Hope I'm being clear about what I need.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6892
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Possible to patch a save file to a rom?
« Reply #1 on: May 08, 2018, 06:21:38 pm »
You could write an ASM hack to replace the code that initializes SRAM. But it's probably not going to be a copy-paste insertion.
That's probably the only way.
"My watch says 30 chickens" Google, 2018

VicVergil

  • Hero Member
  • *****
  • Posts: 713
    • View Profile
Re: Possible to patch a save file to a rom?
« Reply #2 on: May 09, 2018, 12:22:04 pm »
The .srm file is a representation of the game's SRAM memory the emulator keeps for when it's no longer running, just like real SNES cartridges are battery powered to preserve the save.

I guess one way to do it is to follow the tutorial for adding an intro, but instead of all the graphical programming to display an intro screen, it instead just:
  • Checks if the game's SRAM is empty or not, in other terms if you played the game for the first time or not. If it's not empty it skips the rest of the programming. This is in fact needed unless you want the game to erase any progress made on future playthroughs whenever it's booted and returning it to that initial state.
  • Copy 64kb (or whatever size the game's SRAM is) from the ROM, from an address where you hex edited in the contents of your *.srm file with the mid-game save, to the SRAM.
  • Continues to the original entry point of the ROM that launches the game as normal.

And yes, you'll need to know ASM to write that program. It's fortunately simple enough, in fact the method could be repurposed for other games, providing there is space for the .srm file in the ROM.

nesrocks

  • Hero Member
  • *****
  • Posts: 588
    • View Profile
    • nesrocks.com
Re: Possible to patch a save file to a rom?
« Reply #3 on: May 09, 2018, 03:06:11 pm »
Having the entire sram save file on the ROM is a waste of space, certainly. The game doesn't need all that data, just a few specific bytes. It would be "correct" to just add assembly code to initialize those specific values.

Jorpho

  • Hero Member
  • *****
  • Posts: 4136
  • The cat screams with the voice of a man.
    • View Profile
Re: Possible to patch a save file to a rom?
« Reply #4 on: May 10, 2018, 12:43:16 am »
I want to patch Earthbound with a .srm file so that the game starts off at a certain part of the game without needing the .srm file to take me there. Sorry if this is the wrong board. Hope I'm being clear about what I need.
I'm not completely sure what you're going for, but you are aware there's a well-documented debug mode that can warp you all around the game, right?  In theory, you can even access it shortly after starting the game, without even using a Game Genie.
http://tasvideos.org/3406S.html
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!