Last active
August 13, 2019 21:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: