mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-29 05:54:17 +01:00
corrections to SRAM/snapshot saving and loading
This commit is contained in:
parent
52179a367c
commit
9ed52afbb7
@ -1441,9 +1441,9 @@ static int MenuGameSaves(int action)
|
|||||||
// find matching files
|
// find matching files
|
||||||
if(len2 > 5 && strncmp(browserList[i].filename, ROMFilename, len) == 0)
|
if(len2 > 5 && strncmp(browserList[i].filename, ROMFilename, len) == 0)
|
||||||
{
|
{
|
||||||
if(strncmp(&browserList[i].filename[len2-4], ".srm", 4) == 0)
|
if(strncmp(&browserList[i].filename[len2-4], ".sav", 4) == 0)
|
||||||
saves.type[j] = FILE_SRAM;
|
saves.type[j] = FILE_SRAM;
|
||||||
else if(strncmp(&browserList[i].filename[len2-4], ".frz", 4) == 0)
|
else if(strncmp(&browserList[i].filename[len2-4], ".sgm", 4) == 0)
|
||||||
saves.type[j] = FILE_SNAPSHOT;
|
saves.type[j] = FILE_SNAPSHOT;
|
||||||
else
|
else
|
||||||
saves.type[j] = -1;
|
saves.type[j] = -1;
|
||||||
@ -1522,10 +1522,12 @@ static int MenuGameSaves(int action)
|
|||||||
switch(saves.type[ret])
|
switch(saves.type[ret])
|
||||||
{
|
{
|
||||||
case FILE_SRAM:
|
case FILE_SRAM:
|
||||||
case FILE_SNAPSHOT:
|
|
||||||
result = LoadBatteryOrState(filepath, GCSettings.SaveMethod, saves.type[ret], NOTSILENT);
|
result = LoadBatteryOrState(filepath, GCSettings.SaveMethod, saves.type[ret], NOTSILENT);
|
||||||
emulator.emuReset();
|
emulator.emuReset();
|
||||||
break;
|
break;
|
||||||
|
case FILE_SNAPSHOT:
|
||||||
|
result = LoadBatteryOrState(filepath, GCSettings.SaveMethod, saves.type[ret], NOTSILENT);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(result)
|
if(result)
|
||||||
menu = MENU_EXIT;
|
menu = MENU_EXIT;
|
||||||
|
@ -261,11 +261,9 @@ bool LoadBatteryOrState(char * filepath, int method, int action, bool silent)
|
|||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, action, method))
|
if(method == METHOD_AUTO)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ShowAction ("Loading...");
|
|
||||||
|
|
||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
|
|
||||||
// load the file into savebuffer
|
// load the file into savebuffer
|
||||||
@ -319,7 +317,7 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent)
|
|||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method, ROMFilename, 0))
|
if(!MakeFilePath(filepath, action, method, ROMFilename, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return LoadBatteryOrState(filepath, method, action, silent);
|
return LoadBatteryOrState(filepath, method, action, silent);
|
||||||
@ -332,9 +330,8 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent)
|
|||||||
* action = 1 - Save state
|
* action = 1 - Save state
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool SaveBatteryOrState(char * filename, int method, int action, bool silent)
|
bool SaveBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||||
{
|
{
|
||||||
char filepath[1024];
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int datasize = 0; // we need the actual size of the data written
|
int datasize = 0; // we need the actual size of the data written
|
||||||
@ -343,6 +340,9 @@ bool SaveBatteryOrState(char * filename, int method, int action, bool silent)
|
|||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent);
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
|
|
||||||
// set comments for Memory Card saves
|
// set comments for Memory Card saves
|
||||||
@ -355,7 +355,7 @@ bool SaveBatteryOrState(char * filename, int method, int action, bool silent)
|
|||||||
if(action == FILE_SRAM)
|
if(action == FILE_SRAM)
|
||||||
sprintf(savetype, "SRAM");
|
sprintf(savetype, "SRAM");
|
||||||
else
|
else
|
||||||
sprintf(savetype, "Freeze");
|
sprintf(savetype, "Snapshot");
|
||||||
|
|
||||||
sprintf (savecomments[0], "%s %s", APPNAME, savetype);
|
sprintf (savecomments[0], "%s %s", APPNAME, savetype);
|
||||||
snprintf (savecomments[1], 32, ROMFilename);
|
snprintf (savecomments[1], 32, ROMFilename);
|
||||||
@ -366,13 +366,13 @@ bool SaveBatteryOrState(char * filename, int method, int action, bool silent)
|
|||||||
if(action == FILE_SRAM)
|
if(action == FILE_SRAM)
|
||||||
{
|
{
|
||||||
if(cartridgeType == 1)
|
if(cartridgeType == 1)
|
||||||
datasize = MemgbWriteBatteryFile((char *)savebuffer+offset);
|
datasize = MemgbWriteBatteryFile((char *)savebuffer);
|
||||||
else
|
else
|
||||||
datasize = MemCPUWriteBatteryFile((char *)savebuffer+offset);
|
datasize = MemCPUWriteBatteryFile((char *)savebuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool written = emulator.emuWriteMemState((char *)savebuffer+offset, SAVEBUFFERSIZE-offset);
|
bool written = emulator.emuWriteMemState((char *)savebuffer, SAVEBUFFERSIZE);
|
||||||
// we need to set datasize to the exact memory size written
|
// we need to set datasize to the exact memory size written
|
||||||
// but emuWriteMemState doesn't return that for us
|
// but emuWriteMemState doesn't return that for us
|
||||||
// so instead we'll find the end of the save the old fashioned way
|
// so instead we'll find the end of the save the old fashioned way
|
||||||
@ -467,7 +467,7 @@ bool SaveBatteryOrStateAuto(int method, int action, bool silent)
|
|||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method, ROMFilename, 0))
|
if(!MakeFilePath(filepath, action, method, ROMFilename, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return SaveBatteryOrState(filepath, method, action, silent);
|
return SaveBatteryOrState(filepath, method, action, silent);
|
||||||
|
Loading…
Reference in New Issue
Block a user