mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-25 20:16:53 +01:00
trash memcard code
This commit is contained in:
parent
ecb132c10c
commit
03a41bf40a
@ -42,7 +42,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
|
|||||||
# any extra libraries we wish to link with
|
# any extra libraries we wish to link with
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -ldb -ldi -liso9660 -lpng -lmxml -lwiikeyboard \
|
LIBS := -ldb -ldi -liso9660 -lpng -lmxml -lwiikeyboard \
|
||||||
-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
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "memcardop.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "wiiusbsupport.h"
|
#include "wiiusbsupport.h"
|
||||||
@ -86,10 +85,6 @@ int autoSaveMethod(bool silent)
|
|||||||
device = DEVICE_SD;
|
device = DEVICE_SD;
|
||||||
else if(ChangeInterface(DEVICE_USB, SILENT))
|
else if(ChangeInterface(DEVICE_USB, SILENT))
|
||||||
device = DEVICE_USB;
|
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))
|
else if(ChangeInterface(DEVICE_SMB, SILENT))
|
||||||
device = DEVICE_SMB;
|
device = DEVICE_SMB;
|
||||||
else if(!silent)
|
else if(!silent)
|
||||||
@ -285,32 +280,12 @@ bool MakeFilePath(char filepath[], int type, char * filename, int filenum)
|
|||||||
|
|
||||||
if(filenum >= -1)
|
if(filenum >= -1)
|
||||||
{
|
{
|
||||||
if(GCSettings.SaveMethod == DEVICE_MC_SLOTA || GCSettings.SaveMethod == DEVICE_MC_SLOTB)
|
if(filenum == -1)
|
||||||
{
|
sprintf(file, "%s.%s", filename, ext);
|
||||||
if(filenum > 9)
|
else if(filenum == 0)
|
||||||
{
|
sprintf(file, "%s Auto.%s", filename, ext);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
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
|
|
||||||
sprintf(file, "%s %i.%s", filename, filenum, ext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -318,17 +293,7 @@ bool MakeFilePath(char filepath[], int type, char * filename, int filenum)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch(GCSettings.SaveMethod)
|
sprintf (temppath, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], folder, file);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CleanupPath(temppath); // cleanup path
|
CleanupPath(temppath); // cleanup path
|
||||||
strncpy(filepath, temppath, MAXPATHLEN);
|
strncpy(filepath, temppath, MAXPATHLEN);
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "vbasupport.h"
|
#include "vbasupport.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "memcardop.h"
|
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
@ -391,16 +390,6 @@ bool FindDevice(char * filepath, int * device)
|
|||||||
*device = DEVICE_SD_SLOTB;
|
*device = DEVICE_SD_SLOTB;
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,12 +429,6 @@ bool ChangeInterface(int device, bool silent)
|
|||||||
case DEVICE_SMB:
|
case DEVICE_SMB:
|
||||||
mounted = ConnectShare(silent);
|
mounted = ConnectShare(silent);
|
||||||
break;
|
break;
|
||||||
case DEVICE_MC_SLOTA:
|
|
||||||
mounted = TestMC(CARD_SLOTA, silent);
|
|
||||||
break;
|
|
||||||
case DEVICE_MC_SLOTB:
|
|
||||||
mounted = TestMC(CARD_SLOTB, silent);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mounted;
|
return mounted;
|
||||||
@ -716,74 +699,63 @@ LoadFile (char * rbuffer, char *filepath, size_t length, bool silent)
|
|||||||
// halt parsing
|
// halt parsing
|
||||||
HaltParseThread();
|
HaltParseThread();
|
||||||
|
|
||||||
if(device == DEVICE_MC_SLOTA)
|
// open the file
|
||||||
|
while(!size && retry)
|
||||||
{
|
{
|
||||||
size = LoadMCFile (rbuffer, CARD_SLOTA, StripDevice(filepath), silent);
|
if(!ChangeInterface(device, silent))
|
||||||
}
|
break;
|
||||||
else if(device == DEVICE_MC_SLOTB)
|
|
||||||
{
|
file = fopen (filepath, "rb");
|
||||||
size = LoadMCFile (rbuffer, CARD_SLOTB, StripDevice(filepath), silent);
|
|
||||||
}
|
if(!file)
|
||||||
else
|
|
||||||
{
|
|
||||||
// open the file
|
|
||||||
while(!size && retry)
|
|
||||||
{
|
{
|
||||||
if(!ChangeInterface(device, silent))
|
if(silent)
|
||||||
break;
|
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)
|
unmountRequired[device] = true;
|
||||||
break;
|
retry = ErrorPromptRetry("Error reading file!");
|
||||||
|
|
||||||
retry = ErrorPromptRetry("Error opening file!");
|
|
||||||
continue;
|
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;
|
ShowProgress ("Loading...", offset, size);
|
||||||
retry = ErrorPromptRetry("Error reading file!");
|
readsize = fread (rbuffer + offset, 1, 4096, file); // read in next chunk
|
||||||
continue;
|
|
||||||
}
|
if(readsize <= 0)
|
||||||
|
break; // reading finished (or failed)
|
||||||
if (IsZipFile (zipbuffer))
|
|
||||||
{
|
offset += readsize;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
size = offset;
|
||||||
|
CancelAction();
|
||||||
}
|
}
|
||||||
fclose (file);
|
|
||||||
}
|
}
|
||||||
|
fclose (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
@ -824,49 +796,48 @@ SaveFile (char * buffer, char *filepath, size_t datasize, bool silent)
|
|||||||
|
|
||||||
ShowAction("Saving...");
|
ShowAction("Saving...");
|
||||||
|
|
||||||
if(device == DEVICE_MC_SLOTA)
|
while(!written && retry == 1)
|
||||||
{
|
{
|
||||||
written = SaveMCFile (buffer, CARD_SLOTA, StripDevice(filepath), datasize, silent);
|
if(!ChangeInterface(device, silent))
|
||||||
}
|
break;
|
||||||
else if(device == DEVICE_MC_SLOTB)
|
|
||||||
{
|
file = fopen (filepath, "wb");
|
||||||
written = SaveMCFile (buffer, CARD_SLOTB, StripDevice(filepath), datasize, silent);
|
|
||||||
}
|
if(!file)
|
||||||
else
|
|
||||||
{
|
|
||||||
while(!written && retry == 1)
|
|
||||||
{
|
{
|
||||||
if(!ChangeInterface(device, silent))
|
if(silent)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
file = fopen (filepath, "wb");
|
retry = ErrorPromptRetry("Error creating file!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("datasize: %d\n", datasize);
|
||||||
|
|
||||||
if(!file)
|
while(written < datasize)
|
||||||
{
|
{
|
||||||
if(silent)
|
if(datasize - written > 4096) nextwrite=4096;
|
||||||
break;
|
else nextwrite = datasize-written;
|
||||||
|
writesize = fwrite (buffer+written, 1, nextwrite, file);
|
||||||
|
if(writesize != nextwrite)
|
||||||
|
{
|
||||||
|
printf("writesize (%d) != nextwrite (%d)!\n", writesize, nextwrite);
|
||||||
|
break; // write failure
|
||||||
|
}
|
||||||
|
written += writesize;
|
||||||
|
}
|
||||||
|
fclose (file);
|
||||||
|
|
||||||
retry = ErrorPromptRetry("Error creating file!");
|
if(written != datasize)
|
||||||
continue;
|
{
|
||||||
}
|
printf("wrote 0!\n");
|
||||||
|
written = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while(written < datasize)
|
if(!written)
|
||||||
{
|
{
|
||||||
if(datasize - written > 4096) nextwrite=4096;
|
unmountRequired[device] = true;
|
||||||
else nextwrite = datasize-written;
|
retry = ErrorPromptRetry("Error saving file!");
|
||||||
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!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,384 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* Visual Boy Advance GX
|
|
||||||
*
|
|
||||||
* Tantric September 2008
|
|
||||||
*
|
|
||||||
* memcardop.cpp
|
|
||||||
*
|
|
||||||
* Memory Card routines
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#include <gccore.h>
|
|
||||||
#include <ogcsys.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "vba.h"
|
|
||||||
#include "video.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 ("VBA0", "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);
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* Visual Boy Advance GX
|
|
||||||
*
|
|
||||||
* Tantric September 2008
|
|
||||||
*
|
|
||||||
* memcardop.cpp
|
|
||||||
*
|
|
||||||
* 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
|
|
@ -26,7 +26,6 @@
|
|||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "memcardop.h"
|
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "vbaconfig.h"
|
#include "vbaconfig.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
@ -1433,22 +1432,12 @@ static int FindGameSaveNum(char * savefile, int method)
|
|||||||
int romlen = strlen(ROMFilename);
|
int romlen = strlen(ROMFilename);
|
||||||
int savelen = strlen(savefile);
|
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;
|
int diff = savelen-romlen;
|
||||||
|
|
||||||
if(strncmp(savefile, ROMFilename, romlen) != 0)
|
if(strncmp(savefile, ROMFilename, romlen) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(method == DEVICE_MC_SLOTA || method == DEVICE_MC_SLOTB)
|
if(savefile[romlen] == ' ')
|
||||||
{
|
|
||||||
if(diff == 2)
|
|
||||||
n = atoi(&savefile[savelen-2]);
|
|
||||||
else if(diff == 1)
|
|
||||||
n = atoi(&savefile[savelen-1]);
|
|
||||||
}
|
|
||||||
else if(savefile[romlen] == ' ')
|
|
||||||
{
|
{
|
||||||
if(diff == 5 && strncmp(&savefile[romlen+1], "Auto", 4) == 0)
|
if(diff == 5 && strncmp(&savefile[romlen+1], "Auto", 4) == 0)
|
||||||
n = 0; // found Auto save
|
n = 0; // found Auto save
|
||||||
@ -1551,19 +1540,8 @@ static int MenuGameSaves(int action)
|
|||||||
|
|
||||||
memset(&saves, 0, sizeof(saves));
|
memset(&saves, 0, sizeof(saves));
|
||||||
|
|
||||||
if(method == DEVICE_MC_SLOTA)
|
sprintf(browser.dir, "%s%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder);
|
||||||
{
|
ParseDirectory(true);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
len = strlen(ROMFilename);
|
len = strlen(ROMFilename);
|
||||||
|
|
||||||
@ -1594,23 +1572,20 @@ static int MenuGameSaves(int action)
|
|||||||
saves.files[saves.type[j]][n] = 1;
|
saves.files[saves.type[j]][n] = 1;
|
||||||
strncpy(saves.filename[j], browserList[i].filename, MAXJOLIET);
|
strncpy(saves.filename[j], browserList[i].filename, MAXJOLIET);
|
||||||
|
|
||||||
if(method != DEVICE_MC_SLOTA && method != DEVICE_MC_SLOTB)
|
if(saves.type[j] == FILE_SNAPSHOT)
|
||||||
{
|
{
|
||||||
if(saves.type[j] == FILE_SNAPSHOT)
|
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);
|
memset(savebuffer, 0, SAVEBUFFERSIZE);
|
||||||
if(LoadFile(scrfile, SILENT))
|
if(LoadFile(scrfile, SILENT))
|
||||||
saves.previewImg[j] = new GuiImageData(savebuffer);
|
saves.previewImg[j] = new GuiImageData(savebuffer);
|
||||||
}
|
}
|
||||||
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
|
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
|
||||||
if (stat(filepath, &filestat) == 0)
|
if (stat(filepath, &filestat) == 0)
|
||||||
{
|
{
|
||||||
timeinfo = localtime(&filestat.st_mtime);
|
timeinfo = localtime(&filestat.st_mtime);
|
||||||
strftime(saves.date[j], 20, "%a %b %d", timeinfo);
|
strftime(saves.date[j], 20, "%a %b %d", timeinfo);
|
||||||
strftime(saves.time[j], 10, "%I:%M %p", timeinfo);
|
strftime(saves.time[j], 10, "%I:%M %p", timeinfo);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@ -3121,7 +3096,6 @@ static int MenuSettingsFile()
|
|||||||
sprintf(options.name[i++], "Cheats Folder");
|
sprintf(options.name[i++], "Cheats Folder");
|
||||||
sprintf(options.name[i++], "Auto Load");
|
sprintf(options.name[i++], "Auto Load");
|
||||||
sprintf(options.name[i++], "Auto Save");
|
sprintf(options.name[i++], "Auto Save");
|
||||||
sprintf(options.name[i++], "Verify MC Saves");
|
|
||||||
options.length = i;
|
options.length = i;
|
||||||
options.name[4][0] = 0; // hide cheats folder (not implemented)
|
options.name[4][0] = 0; // hide cheats folder (not implemented)
|
||||||
|
|
||||||
@ -3209,10 +3183,6 @@ static int MenuSettingsFile()
|
|||||||
if (GCSettings.AutoSave > 3)
|
if (GCSettings.AutoSave > 3)
|
||||||
GCSettings.AutoSave = 0;
|
GCSettings.AutoSave = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
|
||||||
GCSettings.VerifySaves ^= 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret >= 0 || firstRun)
|
if(ret >= 0 || firstRun)
|
||||||
@ -3242,19 +3212,10 @@ static int MenuSettingsFile()
|
|||||||
GCSettings.SaveMethod++;
|
GCSettings.SaveMethod++;
|
||||||
#endif
|
#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
|
// correct load/save methods out of bounds
|
||||||
if(GCSettings.LoadMethod > 4)
|
if(GCSettings.LoadMethod > 4)
|
||||||
GCSettings.LoadMethod = 0;
|
GCSettings.LoadMethod = 0;
|
||||||
if(GCSettings.SaveMethod > 6)
|
if(GCSettings.SaveMethod > 5)
|
||||||
GCSettings.SaveMethod = 0;
|
GCSettings.SaveMethod = 0;
|
||||||
|
|
||||||
if (GCSettings.LoadMethod == DEVICE_AUTO) sprintf (options.value[0],"Auto Detect");
|
if (GCSettings.LoadMethod == DEVICE_AUTO) sprintf (options.value[0],"Auto Detect");
|
||||||
@ -3267,8 +3228,6 @@ static int MenuSettingsFile()
|
|||||||
else if (GCSettings.SaveMethod == DEVICE_SD) sprintf (options.value[1],"SD");
|
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_USB) sprintf (options.value[1],"USB");
|
||||||
else if (GCSettings.SaveMethod == DEVICE_SMB) sprintf (options.value[1],"Network");
|
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[2], 30, "%s", GCSettings.LoadFolder);
|
||||||
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
|
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
|
||||||
@ -3283,8 +3242,6 @@ static int MenuSettingsFile()
|
|||||||
else if (GCSettings.AutoSave == 2) sprintf (options.value[6],"Snapshot");
|
else if (GCSettings.AutoSave == 2) sprintf (options.value[6],"Snapshot");
|
||||||
else if (GCSettings.AutoSave == 3) sprintf (options.value[6],"Both");
|
else if (GCSettings.AutoSave == 3) sprintf (options.value[6],"Both");
|
||||||
|
|
||||||
sprintf (options.value[7], "%s", GCSettings.VerifySaves == true ? "On" : "Off");
|
|
||||||
|
|
||||||
optionBrowser.TriggerUpdate();
|
optionBrowser.TriggerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "vbaconfig.h"
|
#include "vbaconfig.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "memcardop.h"
|
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
@ -168,7 +167,6 @@ preparePrefsData ()
|
|||||||
createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
|
createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
|
||||||
createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
|
createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
|
||||||
//createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
|
//createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
|
||||||
createXMLSetting("VerifySaves", "Verify Memory Card Saves", toStr(GCSettings.VerifySaves));
|
|
||||||
|
|
||||||
createXMLSection("Network", "Network Settings");
|
createXMLSection("Network", "Network Settings");
|
||||||
|
|
||||||
@ -468,7 +466,6 @@ decodePrefsData ()
|
|||||||
loadXMLSetting(GCSettings.LoadFolder, "LoadFolder", sizeof(GCSettings.LoadFolder));
|
loadXMLSetting(GCSettings.LoadFolder, "LoadFolder", sizeof(GCSettings.LoadFolder));
|
||||||
loadXMLSetting(GCSettings.SaveFolder, "SaveFolder", sizeof(GCSettings.SaveFolder));
|
loadXMLSetting(GCSettings.SaveFolder, "SaveFolder", sizeof(GCSettings.SaveFolder));
|
||||||
//loadXMLSetting(GCSettings.CheatFolder, "CheatFolder", sizeof(GCSettings.CheatFolder));
|
//loadXMLSetting(GCSettings.CheatFolder, "CheatFolder", sizeof(GCSettings.CheatFolder));
|
||||||
loadXMLSetting(&GCSettings.VerifySaves, "VerifySaves");
|
|
||||||
|
|
||||||
// Network Settings
|
// Network Settings
|
||||||
|
|
||||||
@ -581,10 +578,7 @@ SavePrefs (bool silent)
|
|||||||
if(device == 0)
|
if(device == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PREF_FILE_NAME);
|
||||||
sprintf(filepath, "%s%s", pathPrefix[device], PREF_FILE_NAME);
|
|
||||||
else
|
|
||||||
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PREF_FILE_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(device == 0)
|
if(device == 0)
|
||||||
@ -598,16 +592,6 @@ SavePrefs (bool silent)
|
|||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
datasize = preparePrefsData ();
|
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);
|
offset = SaveFile(filepath, datasize, silent);
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
@ -668,11 +652,9 @@ bool LoadPrefs()
|
|||||||
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
||||||
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
||||||
#else
|
#else
|
||||||
numDevices = 4;
|
numDevices = 2;
|
||||||
sprintf(filepath[0], "carda:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
sprintf(filepath[0], "carda:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
||||||
sprintf(filepath[1], "cardb:/%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
|
#endif
|
||||||
|
|
||||||
for(int i=0; i<numDevices; i++)
|
for(int i=0; i<numDevices; i++)
|
||||||
@ -715,10 +697,7 @@ bool SavePalettes(bool silent)
|
|||||||
if(device == 0)
|
if(device == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PAL_FILE_NAME);
|
||||||
sprintf(filepath, "%s%s", pathPrefix[device], PAL_FILE_NAME);
|
|
||||||
else
|
|
||||||
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PAL_FILE_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(device == 0)
|
if(device == 0)
|
||||||
@ -732,16 +711,6 @@ bool SavePalettes(bool silent)
|
|||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
datasize = preparePalData(palettes, loadedPalettes);
|
datasize = preparePalData(palettes, loadedPalettes);
|
||||||
|
|
||||||
if (device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
|
||||||
{
|
|
||||||
// Set the comments
|
|
||||||
char prefscomment[2][32];
|
|
||||||
memset(prefscomment, 0, 64);
|
|
||||||
sprintf(prefscomment[0], "%s Pal", APPNAME);
|
|
||||||
sprintf(prefscomment[1], "Palette");
|
|
||||||
SetMCSaveComments(prefscomment);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, silent);
|
offset = SaveFile(filepath, datasize, silent);
|
||||||
|
|
||||||
FreeSaveBuffer();
|
FreeSaveBuffer();
|
||||||
@ -805,11 +774,9 @@ bool LoadPalettes()
|
|||||||
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
||||||
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
||||||
#else
|
#else
|
||||||
numDevices = 4;
|
numDevices = 2;
|
||||||
sprintf(filepath[0], "carda:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
sprintf(filepath[0], "carda:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
||||||
sprintf(filepath[1], "cardb:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
sprintf(filepath[1], "cardb:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
||||||
sprintf(filepath[2], "mca:/%s", PAL_FILE_NAME);
|
|
||||||
sprintf(filepath[3], "mcb:/%s", PAL_FILE_NAME);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(i=0; i<numDevices; i++)
|
for(i=0; i<numDevices; i++)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#define SILENT 1
|
#define SILENT 1
|
||||||
|
|
||||||
const char pathPrefix[9][8] =
|
const char pathPrefix[9][8] =
|
||||||
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "mca:/", "mcb:/", "carda:/", "cardb:/" };
|
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "carda:/", "cardb:/" };
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DEVICE_AUTO,
|
DEVICE_AUTO,
|
||||||
@ -33,8 +33,6 @@ enum {
|
|||||||
DEVICE_USB,
|
DEVICE_USB,
|
||||||
DEVICE_DVD,
|
DEVICE_DVD,
|
||||||
DEVICE_SMB,
|
DEVICE_SMB,
|
||||||
DEVICE_MC_SLOTA,
|
|
||||||
DEVICE_MC_SLOTB,
|
|
||||||
DEVICE_SD_SLOTA,
|
DEVICE_SD_SLOTA,
|
||||||
DEVICE_SD_SLOTB
|
DEVICE_SD_SLOTB
|
||||||
};
|
};
|
||||||
@ -53,7 +51,6 @@ struct SGCSettings{
|
|||||||
char LoadFolder[MAXPATHLEN]; // Path to game files
|
char LoadFolder[MAXPATHLEN]; // Path to game files
|
||||||
char SaveFolder[MAXPATHLEN]; // Path to save files
|
char SaveFolder[MAXPATHLEN]; // Path to save files
|
||||||
char CheatFolder[MAXPATHLEN]; // Path to cheat files
|
char CheatFolder[MAXPATHLEN]; // Path to cheat files
|
||||||
int VerifySaves;
|
|
||||||
|
|
||||||
char smbip[16];
|
char smbip[16];
|
||||||
char smbuser[20];
|
char smbuser[20];
|
||||||
|
@ -78,7 +78,6 @@ DefaultSettings ()
|
|||||||
|
|
||||||
GCSettings.WiimoteOrientation = 0;
|
GCSettings.WiimoteOrientation = 0;
|
||||||
|
|
||||||
GCSettings.VerifySaves = 0;
|
|
||||||
GCSettings.gbaZoomHor = 1.0; // GBA horizontal zoom level
|
GCSettings.gbaZoomHor = 1.0; // GBA horizontal zoom level
|
||||||
GCSettings.gbaZoomVert = 1.0; // GBA vertical zoom level
|
GCSettings.gbaZoomVert = 1.0; // GBA vertical zoom level
|
||||||
GCSettings.gbZoomHor = 1.0; // GBA horizontal zoom level
|
GCSettings.gbZoomHor = 1.0; // GBA horizontal zoom level
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "vba.h"
|
#include "vba.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "memcardop.h"
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "vmmem.h"
|
#include "vmmem.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
@ -359,7 +358,7 @@ bool SaveBatteryOrState(char * filepath, int action, bool silent)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// save screenshot - I would prefer to do this from gameScreenTex
|
// save screenshot - I would prefer to do this from gameScreenTex
|
||||||
if(action == FILE_SNAPSHOT && gameScreenTex2 != NULL && device != DEVICE_MC_SLOTA && device != DEVICE_MC_SLOTB)
|
if(action == FILE_SNAPSHOT && gameScreenTex2 != NULL)
|
||||||
{
|
{
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
@ -385,23 +384,6 @@ bool SaveBatteryOrState(char * filepath, int action, bool silent)
|
|||||||
|
|
||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
|
|
||||||
// set comments for Memory Card saves
|
|
||||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
|
||||||
{
|
|
||||||
char savecomments[2][32];
|
|
||||||
char savetype[10];
|
|
||||||
memset(savecomments, 0, 64);
|
|
||||||
|
|
||||||
if(action == FILE_SRAM)
|
|
||||||
sprintf(savetype, "SRAM");
|
|
||||||
else
|
|
||||||
sprintf(savetype, "Snapshot");
|
|
||||||
|
|
||||||
sprintf (savecomments[0], "%s %s", APPNAME, savetype);
|
|
||||||
snprintf (savecomments[1], 32, ROMFilename);
|
|
||||||
SetMCSaveComments(savecomments);
|
|
||||||
}
|
|
||||||
|
|
||||||
// put VBA memory into savebuffer, sets datasize to size of memory written
|
// put VBA memory into savebuffer, sets datasize to size of memory written
|
||||||
if(action == FILE_SRAM)
|
if(action == FILE_SRAM)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user