Skip to content

Instantly share code, notes, and snippets.

@sinfante
Last active August 13, 2019 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinfante/70256ffcbf7f3af010e3 to your computer and use it in GitHub Desktop.
Save sinfante/70256ffcbf7f3af010e3 to your computer and use it in GitHub Desktop.
N64 Emulators: C++ code to move an *.sra in-game save to the sixtyforce format *.n64save
#include <stdio.h>
#define SRAM_SIZE (32 * 1024)
static unsigned char SRAM[SRAM_SIZE];
int main(void)
{
FILE * stream;
register int i;
stream = fopen("input.sra", "rb");
if (stream == NULL)
{
printf("Could not open \"%s\" for reading.\n", "input.sra");
return 1;
}
for (i = 0; i < SRAM_SIZE; i++)
SRAM[i ^ 3] = fgetc(stream);
fclose(stream);
stream = fopen("output.n64save", "wb");
for (i = 0; i < SRAM_SIZE; i++)
fputc(SRAM[i], stream);
fclose(stream);
return 0;
}
@sinfante
Copy link
Author

I didn't write this code, it was written by HatCat and found in http://forum.pj64-emu.com/showthread.php?t=4376&page=2

One important step is to have the *.sra (in-game save of Mupen64Plus) in the folder of the executable, renamed to "input.sra". If you are using OpenEmu it can be found in ~/Library/Application Support/OpenEmu/Mupen64Plus/Battery Saves/[game_name].sra

This is does not work out of the box. You need to prepend the "header" that sixtyforce creates, to the file "output.n64save". Unfortunately it is different for every game and I haven't analyzed it much, so if someone wants to include that header in the code it would be great.

To prepend the header:

  1. Open an in-game save of sixtyforce with a Hex editor (I'm using Hex Fiend). The save files are usually located in ~/Library/Application Support/sixtyforce/Autosave/*.n64save. If there is no save game for your game (the game name is easily seen in the Hex editor in the first few lines), you have to go "play" the game in sixtyforce and save in-game.
  2. Open the result of this "program", output.n64save with the Hex editor and prepend all the parts that are not included. In the game I tested this, the header that needed to be included was 136 bits.
  3. Change the name of output.n64save to the name of the original sixtyforce *.n64save
  4. Copy this new file to the ~/Library/Application Support/sixtyforce/Autosave folder.
  5. Play the game

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment