trash memcard code

This commit is contained in:
dborth 2009-11-29 07:55:21 +00:00
parent 251be42e0b
commit 9e7b2d2463
10 changed files with 93 additions and 663 deletions

View File

@ -41,7 +41,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -ldb -ldi -liso9660 -lpng -lmxml \
-lfat -lwiiuse -lz -lbte -logc -lasnd -lvorbisidec -lfreetype -ltinysmb
-lfat -lwiiuse -lz -lbte -lasnd -logc -lvorbisidec -lfreetype -ltinysmb
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View File

@ -25,7 +25,7 @@
#define SILENT 1
const char pathPrefix[9][8] =
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "mca:/", "mcb:/", "carda:/", "cardb:/" };
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "carda:/", "cardb:/" };
enum {
DEVICE_AUTO,
@ -33,8 +33,6 @@ enum {
DEVICE_USB,
DEVICE_DVD,
DEVICE_SMB,
DEVICE_MC_SLOTA,
DEVICE_MC_SLOTB,
DEVICE_SD_SLOTA,
DEVICE_SD_SLOTB
};
@ -76,7 +74,6 @@ struct SGCSettings{
float zoomHor; // horizontal zoom amount
float zoomVert; // vertical zoom amount
int VerifySaves;
int render; // 0 - original, 1 - filtered, 2 - unfiltered
int videomode; // 0 - automatic, 1 - NTSC (480i), 2 - Progressive (480p), 3 - PAL (50Hz), 4 - PAL (60Hz)
int widescreen;

View File

@ -24,7 +24,6 @@
#include "fceusupport.h"
#include "menu.h"
#include "filebrowser.h"
#include "memcardop.h"
#include "fileop.h"
static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation)
@ -77,16 +76,6 @@ bool SaveRAM (char * filepath, bool silent)
if (datasize)
{
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
{
// Set the comments
char comments[2][32];
memset(comments, 0, 64);
sprintf (comments[0], "%s RAM", APPNAME);
snprintf (comments[1], 32, romFilename);
SetMCSaveComments(comments);
}
offset = SaveFile(filepath, datasize, silent);
if (offset > 0)

View File

@ -24,7 +24,6 @@
#include "fceusupport.h"
#include "menu.h"
#include "filebrowser.h"
#include "memcardop.h"
#include "fileop.h"
#include "gcvideo.h"
@ -40,7 +39,7 @@ bool SaveState (char * filepath, bool silent)
return 0;
// save screenshot - I would prefer to do this from gameScreenTex
if(gameScreenTex2 != NULL && device != DEVICE_MC_SLOTA && device != DEVICE_MC_SLOTB)
if(gameScreenTex2 != NULL)
{
AllocSaveBuffer ();
@ -70,18 +69,7 @@ bool SaveState (char * filepath, bool silent)
datasize = save.tellp();
if (datasize)
{
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
{
// Set the comments
char comments[2][32];
memset(comments, 0, 64);
sprintf (comments[0], "%s State", APPNAME);
snprintf (comments[1], 32, romFilename);
SetMCSaveComments(comments);
}
offset = SaveFile(save.buf(), filepath, datasize, silent);
}
if (offset > 0)
{

View File

@ -25,7 +25,6 @@
#include "filebrowser.h"
#include "networkop.h"
#include "fileop.h"
#include "memcardop.h"
#include "pad.h"
#include "fceuload.h"
#include "gcunzip.h"
@ -85,10 +84,6 @@ int autoSaveMethod(bool silent)
device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB;
else if(ChangeInterface(DEVICE_MC_SLOTA, SILENT))
device = DEVICE_MC_SLOTA;
else if(ChangeInterface(DEVICE_MC_SLOTB, SILENT))
device = DEVICE_MC_SLOTB;
else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB;
else if(!silent)
@ -284,32 +279,12 @@ bool MakeFilePath(char filepath[], int type, char * filename, int filenum)
if(filenum >= -1)
{
if(GCSettings.SaveMethod == DEVICE_MC_SLOTA || GCSettings.SaveMethod == DEVICE_MC_SLOTB)
{
if(filenum > 9)
{
return false;
}
else if(filenum == -1)
{
filename[27] = 0; // truncate filename
sprintf(file, "%s.%s", filename, ext);
}
else
{
filename[26] = 0; // truncate filename
sprintf(file, "%s%i.%s", filename, filenum, ext);
}
}
if(filenum == -1)
sprintf(file, "%s.%s", filename, ext);
else if(filenum == 0)
sprintf(file, "%s Auto.%s", filename, ext);
else
{
if(filenum == -1)
sprintf(file, "%s.%s", filename, ext);
else if(filenum == 0)
sprintf(file, "%s Auto.%s", filename, ext);
else
sprintf(file, "%s %i.%s", filename, filenum, ext);
}
sprintf(file, "%s %i.%s", filename, filenum, ext);
}
else
{
@ -332,17 +307,7 @@ bool MakeFilePath(char filepath[], int type, char * filename, int filenum)
sprintf(file, "%s.cht", romFilename);
break;
}
switch(GCSettings.SaveMethod)
{
case DEVICE_MC_SLOTA:
case DEVICE_MC_SLOTB:
sprintf (temppath, "%s%s", pathPrefix[GCSettings.SaveMethod], file);
temppath[31] = 0; // truncate filename
break;
default:
sprintf (temppath, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], folder, file);
break;
}
sprintf (temppath, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], folder, file);
}
CleanupPath(temppath); // cleanup path
strncpy(filepath, temppath, MAXPATHLEN);

View File

@ -29,7 +29,6 @@
#include "fceugx.h"
#include "fileop.h"
#include "networkop.h"
#include "memcardop.h"
#include "gcunzip.h"
#include "menu.h"
#include "filebrowser.h"
@ -392,16 +391,6 @@ bool FindDevice(char * filepath, int * device)
*device = DEVICE_SD_SLOTB;
return true;
}
else if(strncmp(filepath, "mca:", 4) == 0)
{
*device = DEVICE_MC_SLOTA;
return true;
}
else if(strncmp(filepath, "mcb:", 4) == 0)
{
*device = DEVICE_MC_SLOTB;
return true;
}
return false;
}
@ -441,12 +430,6 @@ bool ChangeInterface(int device, bool silent)
case DEVICE_SMB:
mounted = ConnectShare(silent);
break;
case DEVICE_MC_SLOTA:
mounted = TestMC(CARD_SLOTA, silent);
break;
case DEVICE_MC_SLOTB:
mounted = TestMC(CARD_SLOTB, silent);
break;
}
return mounted;
@ -717,74 +700,63 @@ LoadFile (char * rbuffer, char *filepath, size_t length, bool silent)
// halt parsing
HaltParseThread();
if(device == DEVICE_MC_SLOTA)
// open the file
while(!size && retry)
{
size = LoadMCFile (rbuffer, CARD_SLOTA, StripDevice(filepath), silent);
}
else if(device == DEVICE_MC_SLOTB)
{
size = LoadMCFile (rbuffer, CARD_SLOTB, StripDevice(filepath), silent);
}
else
{
// open the file
while(!size && retry)
if(!ChangeInterface(device, silent))
break;
file = fopen (filepath, "rb");
if(!file)
{
if(!ChangeInterface(device, silent))
if(silent)
break;
file = fopen (filepath, "rb");
retry = ErrorPromptRetry("Error opening file!");
continue;
}
if(!file)
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
{
size = fread (rbuffer, 1, length, file);
}
else // load whole file
{
readsize = fread (zipbuffer, 1, 32, file);
if(!readsize)
{
if(silent)
break;
retry = ErrorPromptRetry("Error opening file!");
unmountRequired[device] = true;
retry = ErrorPromptRetry("Error reading file!");
continue;
}
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
if (IsZipFile (zipbuffer))
{
size = fread (rbuffer, 1, length, file);
size = UnZipBuffer ((unsigned char *)rbuffer); // unzip
}
else // load whole file
else
{
readsize = fread (zipbuffer, 1, 32, file);
fseeko(file,0,SEEK_END);
size = ftello(file);
fseeko(file,0,SEEK_SET);
if(!readsize)
while(!feof(file))
{
unmountRequired[device] = true;
retry = ErrorPromptRetry("Error reading file!");
continue;
}
if (IsZipFile (zipbuffer))
{
size = UnZipBuffer ((unsigned char *)rbuffer); // unzip
}
else
{
fseeko(file,0,SEEK_END);
size = ftello(file);
fseeko(file,0,SEEK_SET);
while(!feof(file))
{
ShowProgress ("Loading...", offset, size);
readsize = fread (rbuffer + offset, 1, 4096, file); // read in next chunk
if(readsize <= 0)
break; // reading finished (or failed)
offset += readsize;
}
size = offset;
CancelAction();
ShowProgress ("Loading...", offset, size);
readsize = fread (rbuffer + offset, 1, 4096, file); // read in next chunk
if(readsize <= 0)
break; // reading finished (or failed)
offset += readsize;
}
size = offset;
CancelAction();
}
fclose (file);
}
fclose (file);
}
// go back to checking if devices were inserted/removed
@ -825,49 +797,38 @@ SaveFile (char * buffer, char *filepath, size_t datasize, bool silent)
ShowAction("Saving...");
if(device == DEVICE_MC_SLOTA)
while(!written && retry == 1)
{
written = SaveMCFile (buffer, CARD_SLOTA, StripDevice(filepath), datasize, silent);
}
else if(device == DEVICE_MC_SLOTB)
{
written = SaveMCFile (buffer, CARD_SLOTB, StripDevice(filepath), datasize, silent);
}
else
{
while(!written && retry == 1)
if(!ChangeInterface(device, silent))
break;
file = fopen (filepath, "wb");
if(!file)
{
if(!ChangeInterface(device, silent))
if(silent)
break;
file = fopen (filepath, "wb");
retry = ErrorPromptRetry("Error creating file!");
continue;
}
if(!file)
{
if(silent)
break;
while(written < datasize)
{
if(datasize - written > 4096) nextwrite=4096;
else nextwrite = datasize-written;
writesize = fwrite (buffer+written, 1, nextwrite, file);
if(writesize != nextwrite) break; // write failure
written += writesize;
}
fclose (file);
retry = ErrorPromptRetry("Error creating file!");
continue;
}
if(written != datasize) written = 0;
while(written < datasize)
{
if(datasize - written > 4096) nextwrite=4096;
else nextwrite = datasize-written;
writesize = fwrite (buffer+written, 1, nextwrite, file);
if(writesize != nextwrite) break; // write failure
written += writesize;
}
fclose (file);
if(written != datasize) written = 0;
if(!written)
{
unmountRequired[device] = true;
retry = ErrorPromptRetry("Error saving file!");
}
if(!written)
{
unmountRequired[device] = true;
retry = ErrorPromptRetry("Error saving file!");
}
}

View File

@ -1,387 +0,0 @@
/****************************************************************************
* FCE Ultra
* Nintendo Wii/Gamecube Port
*
* Tantric September 2008
*
* memcardop.c
*
* Memory Card routines
****************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <malloc.h>
#include "fceugx.h"
#include "fceusupport.h"
#include "gcvideo.h"
#include "menu.h"
#include "preferences.h"
#include "filebrowser.h"
#include "fileop.h"
#include "images/saveicon.h"
static u8 * SysArea = NULL;
static char savecomments[2][32];
static u8 * verifybuffer = NULL;
/****************************************************************************
* MountMC
*
* Mounts the memory card in the given slot.
* Returns the result of the last attempted CARD_Mount command.
***************************************************************************/
static int MountMC(int slot, bool silent)
{
int ret = -1;
int tries = 0;
// Initialize Card System
SysArea = (u8 *)memalign(32, CARD_WORKAREA);
memset (SysArea, 0, CARD_WORKAREA);
CARD_Init ("FCEU", "00");
// Mount the card
while(tries < 10 && ret != 0)
{
EXI_ProbeReset();
ret = CARD_Mount (slot, SysArea, NULL);
VIDEO_WaitVSync();
tries++;
}
if(ret != 0 && !silent)
{
if (slot == CARD_SLOTA)
ErrorPrompt("Unable to mount Slot A Memory Card!");
else
ErrorPrompt("Unable to mount Slot B Memory Card!");
}
return ret;
}
/****************************************************************************
* TestMC
*
* Checks to see if a card is in the card slot specified
***************************************************************************/
bool TestMC(int slot, bool silent)
{
// Memory Cards do not work in Wii mode - disable
#ifdef HW_RVL
return false;
#endif
bool ret = false;
// Try to mount the card
if (MountMC(slot, silent) == 0)
{
// Mount successful!
CARD_Unmount (slot);
ret = true;
}
free(SysArea);
return ret;
}
/****************************************************************************
* ParseMCDirectory
*
* Parses a list of all files on the specified memory card
***************************************************************************/
int
ParseMCDirectory (int slot)
{
card_dir CardDir;
int CardError;
int entryNum = 0;
HaltDeviceThread();
// Try to mount the card
CardError = MountMC(slot, NOTSILENT);
if (CardError == 0)
{
CardError = CARD_FindFirst (slot, &CardDir, TRUE);
while (CardError != CARD_ERROR_NOFILE)
{
if(!AddBrowserEntry())
{
entryNum = 0;
break;
}
strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET);
StripExt(browserList[entryNum].displayname, browserList[entryNum].filename); // hide file extension
browserList[entryNum].length = CardDir.filelen;
entryNum++;
CardError = CARD_FindNext (&CardDir);
}
CARD_Unmount(slot);
}
ResumeDeviceThread();
// Sort the file list
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
CancelAction();
browser.numEntries = entryNum;
return entryNum;
}
/****************************************************************************
* Verify Memory Card file against buffer
***************************************************************************/
static int
VerifyMCFile (char *buf, int slot, char *filename, int datasize)
{
card_file CardFile;
int CardError;
unsigned int blocks;
unsigned int SectorSize;
int bytesleft = 0;
int bytesread = 0;
verifybuffer = (u8 *)memalign(32, 262144);
memset (verifybuffer, 0, 262144);
// Get Sector Size
CARD_GetSectorSize (slot, &SectorSize);
memset (&CardFile, 0, sizeof (CardFile));
CardError = CARD_Open (slot, filename, &CardFile);
if(CardError)
{
ErrorPrompt("Unable to open file!");
}
else
{
blocks = CardFile.len;
if (blocks < SectorSize)
blocks = SectorSize;
if (blocks % SectorSize)
blocks += SectorSize;
if (blocks > (unsigned int)datasize)
blocks = datasize;
bytesleft = blocks;
bytesread = 0;
while (bytesleft > 0)
{
CardError = CARD_Read (&CardFile, verifybuffer, SectorSize, bytesread);
if (CardError || memcmp (buf + bytesread, verifybuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
{
bytesread = 0;
ErrorPrompt("File integrity could not be verified!");
break;
}
bytesleft -= SectorSize;
bytesread += SectorSize;
ShowProgress ("Verifying...", bytesread, blocks);
}
CARD_Close (&CardFile);
CancelAction();
}
free(verifybuffer);
return bytesread;
}
/****************************************************************************
* LoadMCFile
* Load savebuffer from Memory Card file
***************************************************************************/
int
LoadMCFile (char *buf, int slot, char *filename, bool silent)
{
card_file CardFile;
int CardError;
unsigned int blocks;
unsigned int SectorSize;
int bytesleft = 0;
int bytesread = 0;
// Try to mount the card
CardError = MountMC(slot, NOTSILENT);
if (CardError == 0)
{
// Get Sector Size
CARD_GetSectorSize (slot, &SectorSize);
memset (&CardFile, 0, sizeof (CardFile));
CardError = CARD_Open (slot, filename, &CardFile);
if(CardError)
{
if(!silent)
ErrorPrompt("Unable to open file!");
}
else
{
blocks = CardFile.len;
if (blocks < SectorSize)
blocks = SectorSize;
if (blocks % SectorSize)
blocks += SectorSize;
bytesleft = blocks;
bytesread = 0;
while (bytesleft > 0)
{
CardError = CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
if(CardError)
{
ErrorPrompt("Error loading file!");
bytesread = 0;
break;
}
bytesleft -= SectorSize;
bytesread += SectorSize;
ShowProgress ("Loading...", bytesread, blocks);
}
CARD_Close (&CardFile);
CancelAction();
}
CARD_Unmount(slot);
}
// discard save icon and comments
memmove(buf, buf+sizeof(saveicon)+64, bytesread);
bytesread -= (sizeof(saveicon)+64);
free(SysArea);
return bytesread;
}
/****************************************************************************
* SaveMCFile
* Write savebuffer to Memory Card file
***************************************************************************/
int
SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
{
card_file CardFile;
card_stat CardStatus;
int CardError;
unsigned int blocks;
unsigned int SectorSize;
int byteswritten = 0;
int bytesleft = 0;
if(datasize <= 0)
return 0;
// add save icon and comments
memmove(buf+sizeof(saveicon)+64, buf, datasize);
memcpy(buf, saveicon, sizeof(saveicon));
memcpy(buf+sizeof(saveicon), savecomments, 64);
datasize += (sizeof(saveicon)+64);
// Try to mount the card
CardError = MountMC(slot, NOTSILENT);
if (CardError == 0)
{
// Get Sector Size
CARD_GetSectorSize (slot, &SectorSize);
// Calculate number of blocks required
blocks = (datasize / SectorSize) * SectorSize;
if (datasize % SectorSize)
blocks += SectorSize;
// Delete existing file (if present)
memset(&CardStatus, 0, sizeof(card_stat));
CardError = CARD_Open (slot, filename, &CardFile);
if(CardError == 0)
{
CARD_Close (&CardFile);
CardError = CARD_Delete(slot, filename);
if (CardError)
{
ErrorPrompt("Unable to delete existing file!");
goto done;
}
}
// Create new file
memset(&CardStatus, 0, sizeof(card_stat));
CardError = CARD_Create (slot, filename, blocks, &CardFile);
if (CardError)
{
if (CardError == CARD_ERROR_INSSPACE)
ErrorPrompt("Insufficient space to create file!");
else
ErrorPrompt("Unable to create card file!");
goto done;
}
// Now, have an open file handle, ready to send out the data
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
CardStatus.icon_addr = 0x0;
CardStatus.icon_fmt = 2;
CardStatus.icon_speed = 1;
CardStatus.comment_addr = 2048;
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
bytesleft = blocks;
while (bytesleft > 0)
{
CardError =
CARD_Write (&CardFile, buf + byteswritten, SectorSize, byteswritten);
if(CardError)
{
ErrorPrompt("Error writing file!");
byteswritten = 0;
break;
}
bytesleft -= SectorSize;
byteswritten += SectorSize;
ShowProgress ("Saving...", byteswritten, blocks);
}
CARD_Close (&CardFile);
CancelAction();
if (byteswritten > 0 && GCSettings.VerifySaves)
{
// Verify the written file
if (!VerifyMCFile (buf, slot, filename, byteswritten) )
byteswritten = 0;
}
done:
CARD_Unmount (slot);
}
free(SysArea);
return byteswritten;
}
void SetMCSaveComments(char comments[2][32])
{
memcpy(savecomments, comments, 64);
}

View File

@ -1,21 +0,0 @@
/****************************************************************************
* FCE Ultra
* Nintendo Wii/Gamecube Port
*
* Tantric 2008-2009
*
* memcardop.h
*
* Memory Card routines
****************************************************************************/
#ifndef _MEMCARDOP_
#define _MEMCARDOP_
int ParseMCDirectory (int slot);
int LoadMCFile (char *buf, int slot, char *filename, bool silent);
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
bool TestMC(int slot, bool silent);
void SetMCSaveComments(char comments[2][32]);
#endif

View File

@ -30,7 +30,6 @@
#include "filebrowser.h"
#include "gcunzip.h"
#include "networkop.h"
#include "memcardop.h"
#include "fileop.h"
#include "fceuram.h"
#include "fceustate.h"
@ -1490,22 +1489,12 @@ static int FindGameSaveNum(char * savefile, int method)
int romlen = strlen(romFilename);
int savelen = strlen(savefile);
if(romlen > 26 && (method == DEVICE_MC_SLOTA || method == DEVICE_MC_SLOTB))
romlen = 26; // memory card filenames are a maximum of 32 chars
int diff = savelen-romlen;
if(strncmp(savefile, romFilename, romlen) != 0)
return -1;
if(method == DEVICE_MC_SLOTA || method == DEVICE_MC_SLOTB)
{
if(diff == 2)
n = atoi(&savefile[savelen-2]);
else if(diff == 1)
n = atoi(&savefile[savelen-1]);
}
else if(savefile[romlen] == ' ')
if(savefile[romlen] == ' ')
{
if(diff == 5 && strncmp(&savefile[romlen+1], "Auto", 4) == 0)
n = 0; // found Auto save
@ -1608,19 +1597,8 @@ static int MenuGameSaves(int action)
memset(&saves, 0, sizeof(saves));
if(method == DEVICE_MC_SLOTA)
{
ParseMCDirectory(CARD_SLOTA);
}
else if(method == DEVICE_MC_SLOTB)
{
ParseMCDirectory(CARD_SLOTB);
}
else
{
sprintf(browser.dir, "%s%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder);
ParseDirectory(true);
}
sprintf(browser.dir, "%s%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder);
ParseDirectory(true);
len = strlen(romFilename);
@ -1651,24 +1629,21 @@ static int MenuGameSaves(int action)
saves.files[saves.type[j]][n] = 1;
strncpy(saves.filename[j], browserList[i].filename, MAXJOLIET);
if(method != DEVICE_MC_SLOTA && method != DEVICE_MC_SLOTB)
if(saves.type[j] == FILE_STATE)
{
if(saves.type[j] == FILE_STATE)
{
sprintf(scrfile, "%s%s/%s.png", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, tmp);
sprintf(scrfile, "%s%s/%s.png", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, tmp);
memset(savebuffer, 0, SAVEBUFFERSIZE);
if(LoadFile(scrfile, SILENT))
saves.previewImg[j] = new GuiImageData(savebuffer);
FreeSaveBuffer();
}
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
if (stat(filepath, &filestat) == 0)
{
timeinfo = localtime(&filestat.st_mtime);
strftime(saves.date[j], 20, "%a %b %d", timeinfo);
strftime(saves.time[j], 10, "%I:%M %p", timeinfo);
}
memset(savebuffer, 0, SAVEBUFFERSIZE);
if(LoadFile(scrfile, SILENT))
saves.previewImg[j] = new GuiImageData(savebuffer);
FreeSaveBuffer();
}
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
if (stat(filepath, &filestat) == 0)
{
timeinfo = localtime(&filestat.st_mtime);
strftime(saves.date[j], 20, "%a %b %d", timeinfo);
strftime(saves.time[j], 10, "%I:%M %p", timeinfo);
}
j++;
}
@ -3360,7 +3335,6 @@ static int MenuSettingsFile()
sprintf(options.name[i++], "Cheats Folder");
sprintf(options.name[i++], "Auto Load");
sprintf(options.name[i++], "Auto Save");
sprintf(options.name[i++], "Verify MC Saves");
options.length = i;
for(i=0; i < options.length; i++)
@ -3447,10 +3421,6 @@ static int MenuSettingsFile()
if (GCSettings.AutoSave > 3)
GCSettings.AutoSave = 0;
break;
case 7:
GCSettings.VerifySaves ^= 1;
break;
}
if(ret >= 0 || firstRun)
@ -3480,19 +3450,10 @@ static int MenuSettingsFile()
GCSettings.SaveMethod++;
#endif
// disable MC saving in Wii mode - does not work for some reason!
#ifdef HW_RVL
if(GCSettings.SaveMethod == DEVICE_MC_SLOTA)
GCSettings.SaveMethod++;
if(GCSettings.SaveMethod == DEVICE_MC_SLOTB)
GCSettings.SaveMethod++;
options.name[7][0] = 0;
#endif
// correct load/save methods out of bounds
if(GCSettings.LoadMethod > 4)
GCSettings.LoadMethod = 0;
if(GCSettings.SaveMethod > 6)
if(GCSettings.SaveMethod > 5)
GCSettings.SaveMethod = 0;
if (GCSettings.LoadMethod == DEVICE_AUTO) sprintf (options.value[0],"Auto Detect");
@ -3505,8 +3466,6 @@ static int MenuSettingsFile()
else if (GCSettings.SaveMethod == DEVICE_SD) sprintf (options.value[1],"SD");
else if (GCSettings.SaveMethod == DEVICE_USB) sprintf (options.value[1],"USB");
else if (GCSettings.SaveMethod == DEVICE_SMB) sprintf (options.value[1],"Network");
else if (GCSettings.SaveMethod == DEVICE_MC_SLOTA) sprintf (options.value[1],"MC Slot A");
else if (GCSettings.SaveMethod == DEVICE_MC_SLOTB) sprintf (options.value[1],"MC Slot B");
snprintf (options.value[2], 30, "%s", GCSettings.LoadFolder);
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
@ -3521,8 +3480,6 @@ static int MenuSettingsFile()
else if (GCSettings.AutoSave == 2) sprintf (options.value[6],"State");
else if (GCSettings.AutoSave == 3) sprintf (options.value[6],"Both");
sprintf (options.value[7], "%s", GCSettings.VerifySaves == true ? "On" : "Off");
optionBrowser.TriggerUpdate();
}

View File

@ -19,7 +19,6 @@
#include "button_mapping.h"
#include "filebrowser.h"
#include "menu.h"
#include "memcardop.h"
#include "fileop.h"
#include "fceugx.h"
#include "pad.h"
@ -125,7 +124,6 @@ preparePrefsData ()
createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
createXMLSetting("VerifySaves", "Verify Memory Card Saves", toStr(GCSettings.VerifySaves));
createXMLSetting("gamegenie", "Game Genie", toStr(GCSettings.gamegenie));
createXMLSection("Network", "Network Settings");
@ -298,7 +296,6 @@ decodePrefsData ()
loadXMLSetting(GCSettings.LoadFolder, "LoadFolder", sizeof(GCSettings.LoadFolder));
loadXMLSetting(GCSettings.SaveFolder, "SaveFolder", sizeof(GCSettings.SaveFolder));
loadXMLSetting(GCSettings.CheatFolder, "CheatFolder", sizeof(GCSettings.CheatFolder));
loadXMLSetting(&GCSettings.VerifySaves, "VerifySaves");
loadXMLSetting(&GCSettings.gamegenie, "gamegenie");
// Network Settings
@ -378,10 +375,7 @@ SavePrefs (bool silent)
if(device == 0)
return false;
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
sprintf(filepath, "%s%s", pathPrefix[device], PREF_FILE_NAME);
else
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PREF_FILE_NAME);
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PREF_FILE_NAME);
}
if(device == 0)
@ -394,17 +388,6 @@ SavePrefs (bool silent)
AllocSaveBuffer ();
datasize = preparePrefsData ();
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
{
// Set the comments
char prefscomment[2][32];
memset(prefscomment, 0, 64);
sprintf (prefscomment[0], "%s Prefs", APPNAME);
sprintf (prefscomment[1], "Preferences");
SetMCSaveComments(prefscomment);
}
offset = SaveFile(filepath, datasize, silent);
FreeSaveBuffer ();
@ -467,11 +450,9 @@ bool LoadPrefs()
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PREF_FILE_NAME);
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PREF_FILE_NAME);
#else
numDevices = 4;
numDevices = 2;
sprintf(filepath[0], "carda:/%s/%s", APPFOLDER, PREF_FILE_NAME);
sprintf(filepath[1], "cardb:/%s/%s", APPFOLDER, PREF_FILE_NAME);
sprintf(filepath[2], "mca:/%s", PREF_FILE_NAME);
sprintf(filepath[3], "mcb:/%s", PREF_FILE_NAME);
#endif
for(int i=0; i<numDevices; i++)