FIX94: I have a proposed (but untested) change to /loader/source/main.c (r279) that would automatically back up the memory card file before starting a game. Please keep in mind that I wrote it in Notepad and rarely (i.e. almost never) write C code, so this might not work correctly as is.
Replace lines 556 and 557 with the following:
Replace lines 556 and 557 with the following:
Code:
else {
char backupPath[30];
backupPath = sprintf(MemCardBackup, "%s/%s%s.raw", BasePath, MemCardName, "backup"); //"backup" should probably be a timestamp
FILE *backup = fopen(backupPath, "wb");
if (backup == NULL) {
ClearScreen();
PrintFormat(DEFAULT_SIZE, MAROON, MENU_POS_X, 232, "Failed to create Memory Card Backup!");
ExitToLoader(1);
}
else {
size_t bytesRead, bytesWritten;
unsigned char backupBuffer[8192];
do {
bytesRead = fread(backupBuffer, 1, sizeof backupBuffer, f);
if (bytesRead) bytesWritten = fwrite(backupBuffer, 1, bytesRead, backup);
else bytesWritten = 0;
} while ((bytesRead > 0) && (bytesRead == bytesWritten ));
if (bytesWritten) {
ClearScreen();
PrintFormat(DEFAULT_SIZE, MAROON, MENU_POS_X, 232, "Failed to write Memory Card Backup!");
ExitToLoader(1);
}
}
fclose(backup);
fclose(f);
}