mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-25 18:51:50 +01:00
This commit is contained in:
parent
14c80e74e2
commit
bf1e7f19c5
@ -190,7 +190,7 @@ int UpdateDirName(int method)
|
||||
}
|
||||
}
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, int method)
|
||||
bool MakeFilePath(char filepath[], int type, int method, char * filename, int filenum)
|
||||
{
|
||||
char file[512];
|
||||
char folder[1024];
|
||||
@ -216,11 +216,49 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
{
|
||||
case FILE_SRAM:
|
||||
sprintf(folder, GCSettings.SaveFolder);
|
||||
sprintf(file, "%s.srm", Memory.ROMFilename);
|
||||
|
||||
if(filenum >= 0)
|
||||
{
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
{
|
||||
filename[26] = 0; // truncate filename
|
||||
sprintf(file, "%s%i.srm", filename, filenum);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(filenum == 0)
|
||||
sprintf(file, "%s Auto.srm", filename);
|
||||
else
|
||||
sprintf(file, "%s %i.srm", filename, filenum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(file, "%s.srm", filename);
|
||||
}
|
||||
break;
|
||||
case FILE_SNAPSHOT:
|
||||
sprintf(folder, GCSettings.SaveFolder);
|
||||
sprintf(file, "%s.frz", Memory.ROMFilename);
|
||||
|
||||
if(filenum >= 0)
|
||||
{
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
{
|
||||
filename[26] = 0; // truncate filename
|
||||
sprintf(file, "%s%i.frz", filename, filenum);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(filenum == 0)
|
||||
sprintf(file, "%s Auto.frz", filename);
|
||||
else
|
||||
sprintf(file, "%s %i.frz", filename, filenum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(file, "%s.frz", filename);
|
||||
}
|
||||
break;
|
||||
case FILE_CHEAT:
|
||||
sprintf(folder, GCSettings.CheatFolder);
|
||||
@ -247,7 +285,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcpy(filepath, temppath);
|
||||
strncpy(filepath, temppath, MAXPATHLEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ extern char rootdir[10];
|
||||
|
||||
extern unsigned long SNESROMSize;
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, int method);
|
||||
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1);
|
||||
int UpdateDirName(int method);
|
||||
int OpenGameList();
|
||||
int autoLoadMethod();
|
||||
|
@ -559,6 +559,9 @@ u32 LoadFile(char * filepath, int method, bool silent)
|
||||
u32
|
||||
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
{
|
||||
if(datasize == 0)
|
||||
return 0;
|
||||
|
||||
u32 written = 0;
|
||||
|
||||
if(!ChangeInterface(method, silent))
|
||||
@ -566,17 +569,14 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
|
||||
ShowAction("Saving...");
|
||||
|
||||
switch(method)
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
{
|
||||
case METHOD_MC_SLOTA:
|
||||
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
||||
break;
|
||||
case METHOD_MC_SLOTB:
|
||||
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||
break;
|
||||
if(method == METHOD_MC_SLOTA)
|
||||
written = SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
||||
else
|
||||
written = SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||
}
|
||||
|
||||
if (datasize)
|
||||
else
|
||||
{
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
@ -595,15 +595,16 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
if(!written && !silent)
|
||||
{
|
||||
if(!written)
|
||||
unmountRequired[method] = true;
|
||||
ErrorPrompt("Error saving file!");
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
}
|
||||
|
||||
if(!written && !silent)
|
||||
ErrorPrompt("Error saving file!");
|
||||
|
||||
CancelAction();
|
||||
return written;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ NGCFreezeGame (char * filepath, int method, bool silent)
|
||||
|
||||
if(err!=Z_OK)
|
||||
{
|
||||
sprintf (msg, "zip error %s ",zError(err));
|
||||
sprintf (msg, "Zip error %s",zError(err));
|
||||
ErrorPrompt(msg);
|
||||
goto done;
|
||||
}
|
||||
@ -224,6 +224,12 @@ done:
|
||||
int
|
||||
NGCFreezeGameAuto (int method, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
char filepath[1024];
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
@ -351,12 +357,16 @@ NGCUnfreezeGame (char * filepath, int method, bool silent)
|
||||
int
|
||||
NGCUnfreezeGameAuto (int method, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
char filepath[1024];
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
sprintf(filepath, "%s Auto.frz", Memory.ROMFilename);
|
||||
else
|
||||
sprintf(filepath, "%s/%s Auto.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
if(!MakeFilePath(filepath, FILE_SNAPSHOT, method, Memory.ROMFilename, 0))
|
||||
return false;
|
||||
|
||||
return NGCUnfreezeGame(filepath, method, silent);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
|
||||
saveBtn[i]->SetImageOver(saveBgOverImg[i]);
|
||||
saveBtn[i]->SetIcon(savePreviewImg[i]);
|
||||
saveBtn[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
saveBtn[i]->SetPosition(247*(i % 2),87*(i/2));
|
||||
saveBtn[i]->SetPosition(257*(i % 2),87*(i/2));
|
||||
saveBtn[i]->SetTrigger(trigA);
|
||||
saveBtn[i]->SetState(STATE_DISABLED);
|
||||
saveBtn[i]->SetEffectGrow();
|
||||
@ -347,10 +347,11 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
|
||||
|
||||
len = strlen(saves->filename[listOffset+i]);
|
||||
if(len > 10 &&
|
||||
saves->filename[listOffset+i][len-8] == 'A' &&
|
||||
((saves->filename[listOffset+i][len-8] == 'A' &&
|
||||
saves->filename[listOffset+i][len-7] == 'u' &&
|
||||
saves->filename[listOffset+i][len-6] == 't' &&
|
||||
saves->filename[listOffset+i][len-5] == 'o'
|
||||
saves->filename[listOffset+i][len-5] == 'o') ||
|
||||
saves->filename[listOffset+i][len-5] == '0')
|
||||
)
|
||||
{
|
||||
strcat(savetext, " (Auto)");
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 546 B After Width: | Height: | Size: 549 B |
Binary file not shown.
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 546 B |
@ -335,8 +335,7 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CardError =
|
||||
CARD_Write (&CardFile, buf + byteswritten,
|
||||
SectorSize, byteswritten);
|
||||
CARD_Write (&CardFile, buf + byteswritten, SectorSize, byteswritten);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
|
@ -484,14 +484,14 @@ void AutoSave()
|
||||
else if (GCSettings.AutoSave == 2)
|
||||
{
|
||||
if (WindowPrompt("Save", "Save Snapshot?", "Save", "Don't Save") )
|
||||
NGCFreezeGameAuto(GCSettings.SaveMethod, SILENT);
|
||||
NGCFreezeGameAuto(GCSettings.SaveMethod, NOTSILENT);
|
||||
}
|
||||
else if (GCSettings.AutoSave == 3)
|
||||
{
|
||||
if (WindowPrompt("Save", "Save SRAM and Snapshot?", "Save", "Don't Save") )
|
||||
{
|
||||
SaveSRAMAuto(GCSettings.SaveMethod, SILENT);
|
||||
NGCFreezeGameAuto(GCSettings.SaveMethod, SILENT);
|
||||
SaveSRAMAuto(GCSettings.SaveMethod, NOTSILENT);
|
||||
NGCFreezeGameAuto(GCSettings.SaveMethod, NOTSILENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1212,10 +1212,11 @@ static int MenuGame()
|
||||
resetBtn.SetEffect(EFFECT_FADE, 15);
|
||||
controllerBtn.SetEffect(EFFECT_FADE, 15);
|
||||
cheatsBtn.SetEffect(EFFECT_FADE, 15);
|
||||
|
||||
AutoSave();
|
||||
}
|
||||
|
||||
ResumeGui();
|
||||
AutoSave();
|
||||
|
||||
while(menu == MENU_NONE)
|
||||
{
|
||||
@ -1229,7 +1230,6 @@ static int MenuGame()
|
||||
{
|
||||
level = (userInput[i].wpad.battery_level / 100.0) * 4;
|
||||
batteryBarImg[i]->SetTile(level);
|
||||
batteryBtn[i]->SetAlpha(255);
|
||||
|
||||
if(level == 0)
|
||||
batteryImg[i]->SetImage(&batteryRed);
|
||||
@ -1241,6 +1241,7 @@ static int MenuGame()
|
||||
else // controller not connected
|
||||
{
|
||||
batteryBarImg[i]->SetTile(0);
|
||||
batteryImg[i]->SetImage(&battery);
|
||||
batteryBtn[i]->SetAlpha(150);
|
||||
}
|
||||
}
|
||||
@ -1296,12 +1297,12 @@ static int MenuGame()
|
||||
titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 35);
|
||||
mainmenuBtn.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
bgBottomImg->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
btnLogo->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
#ifdef HW_RVL
|
||||
batteryBtn[0]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
batteryBtn[1]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
batteryBtn[2]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
batteryBtn[3]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
btnLogo->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
#endif
|
||||
|
||||
saveBtn.SetEffect(EFFECT_FADE, -15);
|
||||
@ -1430,6 +1431,9 @@ static int MenuGameSaves(int action)
|
||||
len = strlen(Memory.ROMFilename);
|
||||
len2 = strlen(browserList[i].filename);
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
len = 26; // memory card filenames are a maximum of 32 chars
|
||||
|
||||
// find matching files
|
||||
if(len2 > 5 && strncmp(browserList[i].filename, Memory.ROMFilename, len) == 0)
|
||||
{
|
||||
@ -1508,8 +1512,7 @@ static int MenuGameSaves(int action)
|
||||
|
||||
if(action == 0) // load
|
||||
{
|
||||
sprintf(filepath, "%s/%s", GCSettings.SaveFolder, saves.filename[ret]);
|
||||
|
||||
MakeFilePath(filepath, saves.type[ret], method, saves.filename[ret]);
|
||||
switch(saves.type[ret])
|
||||
{
|
||||
case FILE_SRAM:
|
||||
@ -1532,7 +1535,7 @@ static int MenuGameSaves(int action)
|
||||
|
||||
if(i < 100)
|
||||
{
|
||||
sprintf(filepath, "%s/%s %i.srm", GCSettings.SaveFolder, Memory.ROMFilename, i);
|
||||
MakeFilePath(filepath, FILE_SRAM, method, Memory.ROMFilename, i);
|
||||
SaveSRAM(filepath, GCSettings.SaveMethod, NOTSILENT);
|
||||
menu = MENU_GAME_SAVE;
|
||||
}
|
||||
@ -1545,15 +1548,14 @@ static int MenuGameSaves(int action)
|
||||
|
||||
if(i < 100)
|
||||
{
|
||||
sprintf(filepath, "%s/%s %i.frz", GCSettings.SaveFolder, Memory.ROMFilename, i);
|
||||
MakeFilePath(filepath, FILE_SNAPSHOT, method, Memory.ROMFilename, i);
|
||||
NGCFreezeGame (filepath, GCSettings.SaveMethod, NOTSILENT);
|
||||
menu = MENU_GAME_SAVE;
|
||||
}
|
||||
}
|
||||
else // overwrite SRAM/Snapshot
|
||||
{
|
||||
sprintf(filepath, "%s/%s", GCSettings.SaveFolder, saves.filename[ret-2]);
|
||||
|
||||
MakeFilePath(filepath, saves.type[ret-2], method, saves.filename[ret-2]);
|
||||
switch(saves.type[ret-2])
|
||||
{
|
||||
case FILE_SRAM:
|
||||
@ -1581,6 +1583,7 @@ static int MenuGameSaves(int action)
|
||||
titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 35);
|
||||
backBtn.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
bgBottomImg->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
btnLogo->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
|
||||
w.SetEffect(EFFECT_FADE, -15);
|
||||
|
||||
@ -1700,6 +1703,7 @@ static int MenuGameCheats()
|
||||
titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 35);
|
||||
backBtn.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
bgBottomImg->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
btnLogo->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 35);
|
||||
|
||||
w.SetEffect(EFFECT_FADE, -15);
|
||||
|
||||
|
@ -174,6 +174,12 @@ LoadSRAM (char * filepath, int method, bool silent)
|
||||
bool
|
||||
LoadSRAMAuto (int method, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
char filepath[1024];
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
@ -227,11 +233,16 @@ SaveSRAM (char * filepath, int method, bool silent)
|
||||
bool
|
||||
SaveSRAMAuto (int method, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
char filepath[1024];
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
sprintf(filepath, "%s Auto.srm", Memory.ROMFilename);
|
||||
else
|
||||
sprintf(filepath, "%s/%s Auto.srm", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
if(!MakeFilePath(filepath, FILE_SRAM, method, Memory.ROMFilename, 0))
|
||||
return false;
|
||||
|
||||
return SaveSRAM(filepath, method, silent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user