mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 00:15:10 +01:00
code restructure, revamp filebrowser
This commit is contained in:
parent
ba036c8420
commit
28718ab082
@ -468,6 +468,9 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
|
||||
browserList[entrycount].offset <<= 11;
|
||||
browserList[entrycount].isdir = browserList[entrycount].isdir & 2;
|
||||
|
||||
if(browserList[entrycount].isdir)
|
||||
browserList[entrycount].icon = ICON_FOLDER;
|
||||
|
||||
/*** Prepare for next entry ***/
|
||||
|
||||
@ -585,7 +588,7 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||
|
||||
if(browserList[dirindex].isdir) // only parse directories
|
||||
{
|
||||
UpdateDirName(METHOD_DVD);
|
||||
UpdateDirName();
|
||||
ParseDVDdirectory();
|
||||
}
|
||||
else
|
||||
@ -664,7 +667,7 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
|
||||
if (IsZipFile (readbuffer))
|
||||
{
|
||||
result = UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||
result = UnZipBuffer (buffer, DEVICE_DVD); // unzip from dvd
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -37,7 +37,6 @@
|
||||
BROWSERINFO browser;
|
||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||
|
||||
char rootdir[10];
|
||||
char szpath[MAXPATHLEN];
|
||||
bool inSz = false;
|
||||
|
||||
@ -46,65 +45,62 @@ bool ROMLoaded = false;
|
||||
|
||||
/****************************************************************************
|
||||
* autoLoadMethod()
|
||||
* Auto-determines and sets the load method
|
||||
* Returns method set
|
||||
* Auto-determines and sets the load device
|
||||
* Returns device set
|
||||
****************************************************************************/
|
||||
int autoLoadMethod()
|
||||
{
|
||||
ShowAction ("Attempting to determine load method...");
|
||||
ShowAction ("Attempting to determine load device...");
|
||||
|
||||
int method = METHOD_AUTO;
|
||||
int device = DEVICE_AUTO;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
method = METHOD_SD;
|
||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||
method = METHOD_USB;
|
||||
#ifdef HW_RVL
|
||||
// DVD support not implemented for GameCube
|
||||
else if(ChangeInterface(METHOD_DVD, SILENT))
|
||||
method = METHOD_DVD;
|
||||
#endif
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
method = METHOD_SMB;
|
||||
if(ChangeInterface(DEVICE_SD, SILENT))
|
||||
device = DEVICE_SD;
|
||||
else if(ChangeInterface(DEVICE_USB, SILENT))
|
||||
device = DEVICE_USB;
|
||||
else if(ChangeInterface(DEVICE_DVD, SILENT))
|
||||
device = DEVICE_DVD;
|
||||
else if(ChangeInterface(DEVICE_SMB, SILENT))
|
||||
device = DEVICE_SMB;
|
||||
else
|
||||
ErrorPrompt("Unable to auto-determine load method!");
|
||||
ErrorPrompt("Unable to locate a load device!");
|
||||
|
||||
if(GCSettings.LoadMethod == METHOD_AUTO)
|
||||
GCSettings.LoadMethod = method; // save method found for later use
|
||||
if(GCSettings.LoadMethod == DEVICE_AUTO)
|
||||
GCSettings.LoadMethod = device; // save device found for later use
|
||||
CancelAction();
|
||||
return method;
|
||||
return device;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* autoSaveMethod()
|
||||
* Auto-determines and sets the save method
|
||||
* Returns method set
|
||||
* Auto-determines and sets the save device
|
||||
* Returns device set
|
||||
****************************************************************************/
|
||||
int autoSaveMethod(bool silent)
|
||||
{
|
||||
if(!silent)
|
||||
ShowAction ("Attempting to determine save method...");
|
||||
ShowAction ("Attempting to determine save device...");
|
||||
|
||||
int method = METHOD_AUTO;
|
||||
int device = DEVICE_AUTO;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
method = METHOD_SD;
|
||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||
method = METHOD_USB;
|
||||
else if(ChangeInterface(METHOD_MC_SLOTA, SILENT))
|
||||
method = METHOD_MC_SLOTA;
|
||||
else if(ChangeInterface(METHOD_MC_SLOTB, SILENT))
|
||||
method = METHOD_MC_SLOTB;
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
method = METHOD_SMB;
|
||||
if(ChangeInterface(DEVICE_SD, 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)
|
||||
ErrorPrompt("Unable to auto-determine save method!");
|
||||
ErrorPrompt("Unable to locate a save device!");
|
||||
|
||||
if(GCSettings.SaveMethod == METHOD_AUTO)
|
||||
GCSettings.SaveMethod = method; // save method found for later use
|
||||
if(GCSettings.SaveMethod == DEVICE_AUTO)
|
||||
GCSettings.SaveMethod = device; // save device found for later use
|
||||
|
||||
CancelAction();
|
||||
return method;
|
||||
return device;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -126,6 +122,26 @@ void ResetBrowser()
|
||||
// set aside space for 1 entry
|
||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
||||
memset(browserList, 0, sizeof(BROWSERENTRY));
|
||||
browser.size = 1;
|
||||
}
|
||||
|
||||
bool AddBrowserEntry()
|
||||
{
|
||||
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (browser.size+1) * sizeof(BROWSERENTRY));
|
||||
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
browserList = newBrowserList;
|
||||
}
|
||||
memset(&(browserList[browser.size]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
browser.size++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -134,6 +150,9 @@ void ResetBrowser()
|
||||
***************************************************************************/
|
||||
static void CleanupPath(char * path)
|
||||
{
|
||||
if(!path || path[0] == 0)
|
||||
return;
|
||||
|
||||
int pathlen = strlen(path);
|
||||
int j = 0;
|
||||
for(int i=0; i < pathlen && i < MAXPATHLEN; i++)
|
||||
@ -145,23 +164,41 @@ static void CleanupPath(char * path)
|
||||
path[j++] = path[i];
|
||||
}
|
||||
path[j] = 0;
|
||||
}
|
||||
|
||||
if(strlen(path) == 0)
|
||||
sprintf(path, "/");
|
||||
bool IsDeviceRoot(char * path)
|
||||
{
|
||||
if(path == NULL || path[0] == 0)
|
||||
return false;
|
||||
|
||||
if(strcmp(path, "sd:/") == 0 ||
|
||||
strcmp(path, "usb:/") == 0 ||
|
||||
strcmp(path, "dvd:/") == 0 ||
|
||||
strcmp(path, "smb:/") == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* UpdateDirName()
|
||||
* Update curent directory name for file browser
|
||||
***************************************************************************/
|
||||
int UpdateDirName(int method)
|
||||
int UpdateDirName()
|
||||
{
|
||||
int size=0;
|
||||
char * test;
|
||||
char temp[1024];
|
||||
int device = 0;
|
||||
|
||||
if(browser.numEntries == 0)
|
||||
return 1;
|
||||
|
||||
FindDevice(browser.dir, &device);
|
||||
|
||||
// update DVD directory
|
||||
if(method == METHOD_DVD)
|
||||
if(device == DEVICE_DVD)
|
||||
SetDVDdirectory(browserList[browser.selIndex].offset, browserList[browser.selIndex].length);
|
||||
|
||||
/* current directory doesn't change */
|
||||
@ -172,18 +209,26 @@ int UpdateDirName(int method)
|
||||
/* go up to parent directory */
|
||||
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
|
||||
{
|
||||
/* determine last subdirectory namelength */
|
||||
sprintf(temp,"%s",browser.dir);
|
||||
test = strtok(temp,"/");
|
||||
while (test != NULL)
|
||||
// already at the top level
|
||||
if(IsDeviceRoot(browser.dir))
|
||||
{
|
||||
size = strlen(test);
|
||||
test = strtok(NULL,"/");
|
||||
browser.dir[0] = 0; // remove device - we are going to the device listing screen
|
||||
}
|
||||
else
|
||||
{
|
||||
/* determine last subdirectory namelength */
|
||||
sprintf(temp,"%s",browser.dir);
|
||||
test = strtok(temp,"/");
|
||||
while (test != NULL)
|
||||
{
|
||||
size = strlen(test);
|
||||
test = strtok(NULL,"/");
|
||||
}
|
||||
|
||||
/* remove last subdirectory name */
|
||||
size = strlen(browser.dir) - size - 1;
|
||||
browser.dir[size] = 0;
|
||||
}
|
||||
|
||||
/* remove last subdirectory name */
|
||||
size = strlen(browser.dir) - size - 1;
|
||||
browser.dir[size] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -205,7 +250,7 @@ int UpdateDirName(int method)
|
||||
}
|
||||
}
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, int method, char * filename, int filenum)
|
||||
bool MakeFilePath(char filepath[], int type, char * filename, int filenum)
|
||||
{
|
||||
char file[512];
|
||||
char folder[1024];
|
||||
@ -239,7 +284,7 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
|
||||
|
||||
if(filenum >= -1)
|
||||
{
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
if(GCSettings.SaveMethod == DEVICE_MC_SLOTA || GCSettings.SaveMethod == DEVICE_MC_SLOTB)
|
||||
{
|
||||
if(filenum > 9)
|
||||
{
|
||||
@ -271,28 +316,16 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
|
||||
sprintf(file, "%s", filename);
|
||||
}
|
||||
break;
|
||||
case FILE_CHEAT:
|
||||
sprintf(folder, GCSettings.CheatFolder);
|
||||
sprintf(file, "%s.cht", ROMFilename);
|
||||
break;
|
||||
case FILE_PREF:
|
||||
sprintf(folder, appPath);
|
||||
sprintf(file, "%s", PREF_FILE_NAME);
|
||||
break;
|
||||
case FILE_PAL:
|
||||
sprintf(folder, appPath);
|
||||
sprintf(file, "%s", PAL_FILE_NAME);
|
||||
break;
|
||||
}
|
||||
switch(method)
|
||||
switch(GCSettings.SaveMethod)
|
||||
{
|
||||
case METHOD_MC_SLOTA:
|
||||
case METHOD_MC_SLOTB:
|
||||
sprintf (temppath, "%s", 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", folder, file);
|
||||
sprintf (temppath, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], folder, file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -441,23 +474,16 @@ void ShortenFilename(char * returnstring, char * inputstring)
|
||||
*
|
||||
* Opens the selected 7z file, and parses a listing of the files within
|
||||
***************************************************************************/
|
||||
int BrowserLoadSz(int method)
|
||||
int BrowserLoadSz()
|
||||
{
|
||||
char filepath[MAXPATHLEN];
|
||||
memset(filepath, 0, MAXPATHLEN);
|
||||
|
||||
// we'll store the 7z filepath for extraction later
|
||||
if(!MakeFilePath(szpath, FILE_ROM, method))
|
||||
if(!MakeFilePath(szpath, FILE_ROM))
|
||||
return 0;
|
||||
|
||||
// add device to filepath
|
||||
if(method != METHOD_DVD)
|
||||
{
|
||||
sprintf(filepath, "%s%s", rootdir, szpath);
|
||||
memcpy(szpath, filepath, MAXPATHLEN);
|
||||
}
|
||||
|
||||
int szfiles = SzParse(szpath, method);
|
||||
int szfiles = SzParse(szpath);
|
||||
if(szfiles)
|
||||
{
|
||||
browser.numEntries = szfiles;
|
||||
@ -474,19 +500,24 @@ int BrowserLoadSz(int method)
|
||||
*
|
||||
* Loads the selected ROM
|
||||
***************************************************************************/
|
||||
int BrowserLoadFile(int method)
|
||||
int BrowserLoadFile()
|
||||
{
|
||||
int device;
|
||||
|
||||
if(!FindDevice(browser.dir, &device))
|
||||
return 0;
|
||||
|
||||
// store the filename (w/o ext) - used for sram/freeze naming
|
||||
StripExt(ROMFilename, browserList[browser.selIndex].filename);
|
||||
|
||||
ROMLoaded = LoadVBAROM(method);
|
||||
ROMLoaded = LoadVBAROM();
|
||||
|
||||
if (!ROMLoaded)
|
||||
{
|
||||
if(inSz)
|
||||
{
|
||||
browser.selIndex = 0;
|
||||
BrowserChangeFolder(method);
|
||||
BrowserChangeFolder();
|
||||
}
|
||||
|
||||
ErrorPrompt("Error loading ROM!");
|
||||
@ -494,9 +525,9 @@ int BrowserLoadFile(int method)
|
||||
else
|
||||
{
|
||||
if (GCSettings.AutoLoad == 1)
|
||||
LoadBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SRAM, SILENT);
|
||||
LoadBatteryOrStateAuto(FILE_SRAM, SILENT);
|
||||
else if (GCSettings.AutoLoad == 2)
|
||||
LoadBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SNAPSHOT, SILENT);
|
||||
LoadBatteryOrStateAuto(FILE_SNAPSHOT, SILENT);
|
||||
ResetBrowser();
|
||||
}
|
||||
CancelAction();
|
||||
@ -508,37 +539,98 @@ int BrowserLoadFile(int method)
|
||||
*
|
||||
* Update current directory and set new entry list if directory has changed
|
||||
***************************************************************************/
|
||||
int BrowserChangeFolder(int method)
|
||||
int BrowserChangeFolder()
|
||||
{
|
||||
int device = 0;
|
||||
FindDevice(browser.dir, &device);
|
||||
|
||||
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
|
||||
{
|
||||
if(method == METHOD_DVD)
|
||||
if(device == DEVICE_DVD)
|
||||
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||
|
||||
inSz = false;
|
||||
SzClose();
|
||||
}
|
||||
|
||||
if(!UpdateDirName(method))
|
||||
if(!UpdateDirName())
|
||||
return -1;
|
||||
|
||||
CleanupPath(browser.dir);
|
||||
strcpy(GCSettings.LoadFolder, browser.dir);
|
||||
HaltParseThread(); // halt parsing
|
||||
ResetBrowser(); // reset browser
|
||||
|
||||
switch (method)
|
||||
if(browser.dir[0] != 0)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
ParseDVDdirectory();
|
||||
break;
|
||||
|
||||
default:
|
||||
ParseDirectory(method);
|
||||
break;
|
||||
switch (device)
|
||||
{
|
||||
case DEVICE_DVD:
|
||||
ParseDVDdirectory();
|
||||
break;
|
||||
|
||||
default:
|
||||
ParseDirectory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!browser.numEntries)
|
||||
if(browser.numEntries == 0)
|
||||
{
|
||||
ErrorPrompt("Error reading directory!");
|
||||
browser.dir[0] = 0;
|
||||
int i=0;
|
||||
|
||||
AddBrowserEntry();
|
||||
sprintf(browserList[i].filename, "sd:/");
|
||||
sprintf(browserList[i].displayname, "SD Card");
|
||||
browserList[i].length = 0;
|
||||
browserList[i].mtime = 0;
|
||||
browserList[i].isdir = 1;
|
||||
browserList[i].icon = ICON_SD;
|
||||
i++;
|
||||
|
||||
AddBrowserEntry();
|
||||
sprintf(browserList[i].filename, "usb:/");
|
||||
sprintf(browserList[i].displayname, "USB Mass Storage");
|
||||
browserList[i].length = 0;
|
||||
browserList[i].mtime = 0;
|
||||
browserList[i].isdir = 1;
|
||||
browserList[i].icon = ICON_USB;
|
||||
i++;
|
||||
|
||||
#ifdef HW_RVL
|
||||
AddBrowserEntry();
|
||||
sprintf(browserList[i].filename, "smb:/");
|
||||
sprintf(browserList[i].displayname, "Network Share");
|
||||
browserList[i].length = 0;
|
||||
browserList[i].mtime = 0;
|
||||
browserList[i].isdir = 1;
|
||||
browserList[i].icon = ICON_SMB;
|
||||
i++;
|
||||
#endif
|
||||
|
||||
AddBrowserEntry();
|
||||
sprintf(browserList[i].filename, "dvd:/");
|
||||
sprintf(browserList[i].displayname, "Data DVD");
|
||||
browserList[i].length = 0;
|
||||
browserList[i].mtime = 0;
|
||||
browserList[i].isdir = 1;
|
||||
browserList[i].icon = ICON_DVD;
|
||||
i++;
|
||||
|
||||
browser.numEntries += i;
|
||||
}
|
||||
|
||||
if(browser.dir[0] == 0)
|
||||
{
|
||||
GCSettings.LoadFolder[0] = 0;
|
||||
GCSettings.LoadMethod = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
char * path = StripDevice(browser.dir);
|
||||
if(path != NULL)
|
||||
strcpy(GCSettings.LoadFolder, path);
|
||||
FindDevice(browser.dir, &GCSettings.LoadMethod);
|
||||
}
|
||||
|
||||
return browser.numEntries;
|
||||
@ -551,25 +643,17 @@ int BrowserChangeFolder(int method)
|
||||
int
|
||||
OpenGameList ()
|
||||
{
|
||||
int method = GCSettings.LoadMethod;
|
||||
int device = GCSettings.LoadMethod;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
if(device == DEVICE_AUTO)
|
||||
device = autoLoadMethod();
|
||||
|
||||
// change current dir to roms directory
|
||||
switch(method)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
browser.dir[0] = 0;
|
||||
if(MountDVD(NOTSILENT))
|
||||
if(ParseDVDdirectory()) // Parse root directory
|
||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
||||
break;
|
||||
default:
|
||||
sprintf(browser.dir, "/%s/", GCSettings.LoadFolder);
|
||||
CleanupPath(browser.dir);
|
||||
ParseDirectory(method); // Parse root directory
|
||||
break;
|
||||
}
|
||||
if(device > 0)
|
||||
sprintf(browser.dir, "%s%s", pathPrefix[device], GCSettings.LoadFolder);
|
||||
else
|
||||
browser.dir[0] = 0;
|
||||
|
||||
BrowserChangeFolder();
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ typedef struct
|
||||
int numEntries; // # of entries in browserList
|
||||
int selIndex; // currently selected index of browserList
|
||||
int pageIndex; // starting index of browserList page display
|
||||
int size; // # of entries browerList has space allocated to store
|
||||
} BROWSERINFO;
|
||||
|
||||
typedef struct
|
||||
@ -32,28 +33,39 @@ typedef struct
|
||||
char isdir; // 0 - file, 1 - directory
|
||||
char filename[MAXJOLIET + 1]; // full filename
|
||||
char displayname[MAXJOLIET + 1]; // name for browser display
|
||||
int icon; // icon to display
|
||||
} BROWSERENTRY;
|
||||
|
||||
extern BROWSERINFO browser;
|
||||
extern BROWSERENTRY * browserList;
|
||||
extern char rootdir[10];
|
||||
extern char ROMFilename[512];
|
||||
extern bool ROMLoaded;
|
||||
extern char szpath[MAXPATHLEN];
|
||||
extern bool inSz;
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -2);
|
||||
int UpdateDirName(int method);
|
||||
enum
|
||||
{
|
||||
ICON_NONE,
|
||||
ICON_FOLDER,
|
||||
ICON_SD,
|
||||
ICON_USB,
|
||||
ICON_DVD,
|
||||
ICON_SMB
|
||||
};
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, char * filename = NULL, int filenum = -2);
|
||||
int UpdateDirName();
|
||||
int OpenGameList();
|
||||
int autoLoadMethod();
|
||||
int autoSaveMethod(bool silent);
|
||||
int FileSortCallback(const void *f1, const void *f2);
|
||||
void StripExt(char* returnstring, char * inputstring);
|
||||
void ShortenFilename(char* returnstring, char * inputstring);
|
||||
bool IsSz();
|
||||
void ResetBrowser();
|
||||
int BrowserLoadSz(int method);
|
||||
int BrowserChangeFolder(int method);
|
||||
int BrowserLoadFile(int method);
|
||||
bool AddBrowserEntry();
|
||||
bool IsDeviceRoot(char * path);
|
||||
int BrowserLoadSz();
|
||||
int BrowserChangeFolder();
|
||||
int BrowserLoadFile();
|
||||
|
||||
#endif
|
||||
|
@ -161,8 +161,20 @@ extern const u32 progressbar_outline_png_size;
|
||||
extern const u8 throbber_png[];
|
||||
extern const u32 throbber_png_size;
|
||||
|
||||
extern const u8 folder_png[];
|
||||
extern const u32 folder_png_size;
|
||||
extern const u8 icon_folder_png[];
|
||||
extern const u32 icon_folder_png_size;
|
||||
|
||||
extern const u8 icon_sd_png[];
|
||||
extern const u32 icon_sd_png_size;
|
||||
|
||||
extern const u8 icon_usb_png[];
|
||||
extern const u32 icon_usb_png_size;
|
||||
|
||||
extern const u8 icon_dvd_png[];
|
||||
extern const u32 icon_dvd_png_size;
|
||||
|
||||
extern const u8 icon_smb_png[];
|
||||
extern const u32 icon_smb_png_size;
|
||||
|
||||
extern const u8 battery_png[];
|
||||
extern const u32 battery_png_size;
|
||||
|
@ -91,6 +91,20 @@ HaltDeviceThread()
|
||||
usleep(THREAD_SLEEP);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* HaltParseThread
|
||||
*
|
||||
* Signals the parse thread to stop.
|
||||
***************************************************************************/
|
||||
void
|
||||
HaltParseThread()
|
||||
{
|
||||
parseHalt = true;
|
||||
|
||||
while(!LWP_ThreadIsSuspended(parsethread))
|
||||
usleep(THREAD_SLEEP);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* devicecallback
|
||||
*
|
||||
@ -113,41 +127,41 @@ devicecallback (void *arg)
|
||||
while (1)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if(isMounted[METHOD_SD])
|
||||
if(isMounted[DEVICE_SD])
|
||||
{
|
||||
if(!sd->isInserted()) // check if the device was removed
|
||||
{
|
||||
unmountRequired[METHOD_SD] = true;
|
||||
isMounted[METHOD_SD] = false;
|
||||
unmountRequired[DEVICE_SD] = true;
|
||||
isMounted[DEVICE_SD] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isMounted[METHOD_USB])
|
||||
if(isMounted[DEVICE_USB])
|
||||
{
|
||||
if(!usb->isInserted()) // check if the device was removed
|
||||
{
|
||||
unmountRequired[METHOD_USB] = true;
|
||||
isMounted[METHOD_USB] = false;
|
||||
unmountRequired[DEVICE_USB] = true;
|
||||
isMounted[DEVICE_USB] = false;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateCheck();
|
||||
InitializeNetwork(SILENT);
|
||||
#else
|
||||
if(isMounted[METHOD_SD_SLOTA])
|
||||
if(isMounted[DEVICE_SD_SLOTA])
|
||||
{
|
||||
if(!carda->isInserted()) // check if the device was removed
|
||||
{
|
||||
unmountRequired[METHOD_SD_SLOTA] = true;
|
||||
isMounted[METHOD_SD_SLOTA] = false;
|
||||
unmountRequired[DEVICE_SD_SLOTA] = true;
|
||||
isMounted[DEVICE_SD_SLOTA] = false;
|
||||
}
|
||||
}
|
||||
if(isMounted[METHOD_SD_SLOTB])
|
||||
if(isMounted[DEVICE_SD_SLOTB])
|
||||
{
|
||||
if(!cardb->isInserted()) // check if the device was removed
|
||||
{
|
||||
unmountRequired[METHOD_SD_SLOTB] = true;
|
||||
isMounted[METHOD_SD_SLOTB] = false;
|
||||
unmountRequired[DEVICE_SD_SLOTB] = true;
|
||||
isMounted[DEVICE_SD_SLOTB] = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -212,31 +226,35 @@ void UnmountAllFAT()
|
||||
* Sets libfat to use the device by default
|
||||
***************************************************************************/
|
||||
|
||||
bool MountFAT(int method)
|
||||
static bool MountFAT(int device, int silent)
|
||||
{
|
||||
bool mounted = true; // assume our disc is already mounted
|
||||
char name[10];
|
||||
char name[10], name2[10];
|
||||
const DISC_INTERFACE* disc = NULL;
|
||||
|
||||
switch(method)
|
||||
switch(device)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
case METHOD_SD:
|
||||
case DEVICE_SD:
|
||||
sprintf(name, "sd");
|
||||
sprintf(name2, "sd:");
|
||||
disc = sd;
|
||||
break;
|
||||
case METHOD_USB:
|
||||
case DEVICE_USB:
|
||||
sprintf(name, "usb");
|
||||
sprintf(name2, "usb:");
|
||||
disc = usb;
|
||||
break;
|
||||
#else
|
||||
case METHOD_SD_SLOTA:
|
||||
case DEVICE_SD_SLOTA:
|
||||
sprintf(name, "carda");
|
||||
sprintf(name2, "carda:");
|
||||
disc = carda;
|
||||
break;
|
||||
|
||||
case METHOD_SD_SLOTB:
|
||||
case DEVICE_SD_SLOTB:
|
||||
sprintf(name, "cardb");
|
||||
sprintf(name2, "cardb:");
|
||||
disc = cardb;
|
||||
break;
|
||||
#endif
|
||||
@ -244,95 +262,173 @@ bool MountFAT(int method)
|
||||
return false; // unknown device
|
||||
}
|
||||
|
||||
sprintf(rootdir, "%s:", name);
|
||||
|
||||
if(unmountRequired[method])
|
||||
if(unmountRequired[device])
|
||||
{
|
||||
unmountRequired[method] = false;
|
||||
fatUnmount(rootdir);
|
||||
unmountRequired[device] = false;
|
||||
fatUnmount(name2);
|
||||
disc->shutdown();
|
||||
isMounted[method] = false;
|
||||
isMounted[device] = false;
|
||||
}
|
||||
if(!isMounted[method])
|
||||
if(!isMounted[device])
|
||||
{
|
||||
if(!disc->startup())
|
||||
mounted = false;
|
||||
else if(!fatMountSimple(name, disc))
|
||||
mounted = false;
|
||||
}
|
||||
|
||||
if(!mounted && !silent)
|
||||
{
|
||||
if(device == DEVICE_SD)
|
||||
ErrorPrompt("SD card not found!");
|
||||
else
|
||||
ErrorPrompt("USB drive not found!");
|
||||
}
|
||||
|
||||
isMounted[method] = mounted;
|
||||
isMounted[device] = mounted;
|
||||
return mounted;
|
||||
}
|
||||
|
||||
void MountAllFAT()
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
MountFAT(METHOD_SD);
|
||||
MountFAT(METHOD_USB);
|
||||
MountFAT(DEVICE_SD, SILENT);
|
||||
MountFAT(DEVICE_USB, SILENT);
|
||||
#else
|
||||
MountFAT(METHOD_SD_SLOTA);
|
||||
MountFAT(METHOD_SD_SLOTB);
|
||||
MountFAT(DEVICE_SD_SLOTA, SILENT);
|
||||
MountFAT(DEVICE_SD_SLOTB, SILENT);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool FindDevice(char * filepath, int * device)
|
||||
{
|
||||
if(!filepath || filepath[0] == 0)
|
||||
return false;
|
||||
|
||||
if(strncmp(filepath, "sd:", 3) == 0)
|
||||
{
|
||||
*device = DEVICE_SD;
|
||||
return true;
|
||||
}
|
||||
else if(strncmp(filepath, "usb:", 4) == 0)
|
||||
{
|
||||
*device = DEVICE_USB;
|
||||
return true;
|
||||
}
|
||||
else if(strncmp(filepath, "dvd:", 4) == 0)
|
||||
{
|
||||
*device = DEVICE_DVD;
|
||||
return true;
|
||||
}
|
||||
else if(strncmp(filepath, "smb:", 4) == 0)
|
||||
{
|
||||
*device = DEVICE_SMB;
|
||||
return true;
|
||||
}
|
||||
else if(strncmp(filepath, "carda:", 5) == 0)
|
||||
{
|
||||
*device = DEVICE_SD_SLOTA;
|
||||
return true;
|
||||
}
|
||||
else if(strncmp(filepath, "cardb:", 5) == 0)
|
||||
{
|
||||
*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;
|
||||
}
|
||||
|
||||
char * StripDevice(char * path)
|
||||
{
|
||||
if(path == NULL)
|
||||
return NULL;
|
||||
|
||||
char * newpath = strchr(path,'/');
|
||||
|
||||
if(newpath != NULL)
|
||||
newpath++;
|
||||
|
||||
return newpath;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ChangeInterface
|
||||
* Attempts to mount/configure the device specified
|
||||
***************************************************************************/
|
||||
bool ChangeInterface(int method, bool silent)
|
||||
bool ChangeInterface(int device, bool silent)
|
||||
{
|
||||
bool mounted = false;
|
||||
|
||||
if(method == METHOD_SD)
|
||||
|
||||
switch(device)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
mounted = MountFAT(METHOD_SD); // try Wii internal SD
|
||||
#else
|
||||
mounted = MountFAT(METHOD_SD_SLOTA); // try SD Gecko on slot A
|
||||
if(!mounted) // internal SD and SD Gecko (on slot A) not found
|
||||
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
||||
#endif
|
||||
if(!mounted && !silent) // no SD device found
|
||||
ErrorPrompt("SD card not found!");
|
||||
}
|
||||
else if(method == METHOD_USB)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
mounted = MountFAT(method);
|
||||
|
||||
if(!mounted && !silent)
|
||||
ErrorPrompt("USB drive not found!");
|
||||
#endif
|
||||
}
|
||||
else if(method == METHOD_DVD)
|
||||
{
|
||||
mounted = MountDVD(silent);
|
||||
}
|
||||
case DEVICE_SD:
|
||||
case DEVICE_USB:
|
||||
mounted = MountFAT(device, silent);
|
||||
break;
|
||||
case DEVICE_DVD:
|
||||
mounted = MountDVD(silent);
|
||||
break;
|
||||
#ifdef HW_RVL
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
mounted = ConnectShare(silent);
|
||||
}
|
||||
case DEVICE_SMB:
|
||||
mounted = ConnectShare(silent);
|
||||
break;
|
||||
#endif
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
{
|
||||
mounted = TestMC(CARD_SLOTA, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTB)
|
||||
{
|
||||
mounted = TestMC(CARD_SLOTB, silent);
|
||||
}
|
||||
|
||||
if(!mounted)
|
||||
{
|
||||
sprintf(browser.dir,"/");
|
||||
rootdir[0] = 0;
|
||||
case DEVICE_MC_SLOTA:
|
||||
mounted = TestMC(CARD_SLOTA, silent);
|
||||
break;
|
||||
case DEVICE_MC_SLOTB:
|
||||
mounted = TestMC(CARD_SLOTB, silent);
|
||||
break;
|
||||
}
|
||||
|
||||
return mounted;
|
||||
}
|
||||
|
||||
bool ChangeInterface(char * filepath, bool silent)
|
||||
{
|
||||
int device = -1;
|
||||
|
||||
if(!FindDevice(filepath, &device))
|
||||
return false;
|
||||
|
||||
return ChangeInterface(device, silent);
|
||||
}
|
||||
|
||||
void CreateAppPath(char * origpath)
|
||||
{
|
||||
char * path = strdup(origpath); // make a copy so we don't mess up original
|
||||
|
||||
if(!path)
|
||||
return;
|
||||
|
||||
char * loc = strrchr(path,'/');
|
||||
if (loc != NULL)
|
||||
*loc = 0; // strip file name
|
||||
|
||||
int pos = 0;
|
||||
|
||||
// replace fat:/ with sd:/
|
||||
if(strncmp(path, "fat:/", 5) == 0)
|
||||
{
|
||||
pos++;
|
||||
path[1] = 's';
|
||||
path[2] = 'd';
|
||||
}
|
||||
if(ChangeInterface(&path[pos], SILENT))
|
||||
strncpy(appPath, &path[pos], MAXPATHLEN);
|
||||
appPath[MAXPATHLEN-1] = 0;
|
||||
free(path);
|
||||
}
|
||||
|
||||
bool ParseDirEntries()
|
||||
{
|
||||
@ -356,37 +452,26 @@ bool ParseDirEntries()
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (browser.numEntries+i+1) * sizeof(BROWSERENTRY));
|
||||
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
|
||||
if(AddBrowserEntry())
|
||||
{
|
||||
ResetBrowser();
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
browserList = newBrowserList;
|
||||
}
|
||||
|
||||
memset(&(browserList[browser.numEntries+i]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[browser.numEntries+i].filename, filename, MAXJOLIET);
|
||||
browserList[browser.numEntries+i].length = filestat.st_size;
|
||||
browserList[browser.numEntries+i].mtime = filestat.st_mtime;
|
||||
browserList[browser.numEntries+i].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
|
||||
if(browserList[browser.numEntries+i].isdir)
|
||||
{
|
||||
if(strcmp(filename, "..") == 0)
|
||||
sprintf(browserList[browser.numEntries+i].displayname, "Up One Level");
|
||||
strncpy(browserList[browser.numEntries+i].filename, filename, MAXJOLIET);
|
||||
browserList[browser.numEntries+i].length = filestat.st_size;
|
||||
browserList[browser.numEntries+i].mtime = filestat.st_mtime;
|
||||
browserList[browser.numEntries+i].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
|
||||
if(browserList[browser.numEntries+i].isdir)
|
||||
{
|
||||
if(strcmp(filename, "..") == 0)
|
||||
sprintf(browserList[browser.numEntries+i].displayname, "Up One Level");
|
||||
else
|
||||
strncpy(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename, MAXJOLIET);
|
||||
browserList[browser.numEntries+i].icon = ICON_FOLDER;
|
||||
}
|
||||
else
|
||||
strncpy(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename, MAXJOLIET);
|
||||
}
|
||||
else
|
||||
{
|
||||
StripExt(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename); // hide file extension
|
||||
{
|
||||
StripExt(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename); // hide file extension
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,53 +495,55 @@ bool ParseDirEntries()
|
||||
* Browse subdirectories
|
||||
**************************************************************************/
|
||||
int
|
||||
ParseDirectory(int method, bool waitParse)
|
||||
ParseDirectory(bool waitParse)
|
||||
{
|
||||
char fulldir[MAXPATHLEN];
|
||||
char msg[128];
|
||||
int retry = 1;
|
||||
bool mounted = false;
|
||||
|
||||
// halt parsing
|
||||
parseHalt = true;
|
||||
|
||||
while(!LWP_ThreadIsSuspended(parsethread))
|
||||
usleep(THREAD_SLEEP);
|
||||
|
||||
// reset browser
|
||||
dirIter = NULL;
|
||||
ResetBrowser();
|
||||
|
||||
|
||||
ResetBrowser(); // reset browser
|
||||
|
||||
// open the directory
|
||||
while(dirIter == NULL && retry == 1)
|
||||
{
|
||||
mounted = ChangeInterface(method, NOTSILENT);
|
||||
sprintf(fulldir, "%s%s", rootdir, browser.dir); // add device to path
|
||||
if(mounted) dirIter = diropen(fulldir);
|
||||
mounted = ChangeInterface(browser.dir, NOTSILENT);
|
||||
if(mounted)
|
||||
dirIter = diropen(browser.dir);
|
||||
else
|
||||
return -1;
|
||||
|
||||
if(dirIter == NULL)
|
||||
{
|
||||
unmountRequired[method] = true;
|
||||
sprintf(msg, "Error opening %s", fulldir);
|
||||
sprintf(msg, "Error opening %s", browser.dir);
|
||||
retry = ErrorPromptRetry(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// if we can't open the dir, try opening the root dir
|
||||
// if we can't open the dir, try higher levels
|
||||
if (dirIter == NULL)
|
||||
{
|
||||
if(ChangeInterface(method, SILENT))
|
||||
while(!IsDeviceRoot(browser.dir))
|
||||
{
|
||||
sprintf(browser.dir,"/");
|
||||
sprintf(fulldir, "%s%s", rootdir, browser.dir);
|
||||
dirIter = diropen(fulldir);
|
||||
if (dirIter == NULL)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", rootdir);
|
||||
ErrorPrompt(msg);
|
||||
return -1;
|
||||
}
|
||||
char * devEnd = strrchr(browser.dir, '/');
|
||||
devEnd[0] = 0; // strip remaining file listing
|
||||
dirIter = diropen(browser.dir);
|
||||
if (dirIter)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dirIter == NULL)
|
||||
return -1;
|
||||
|
||||
if(IsDeviceRoot(browser.dir))
|
||||
{
|
||||
browser.numEntries = 1;
|
||||
sprintf(browserList[0].filename, "..");
|
||||
sprintf(browserList[0].displayname, "Up One Level");
|
||||
browserList[0].length = 0;
|
||||
browserList[0].mtime = 0;
|
||||
browserList[0].isdir = 1; // flag this as a dir
|
||||
}
|
||||
|
||||
parseHalt = false;
|
||||
ParseDirEntries(); // index first 20 entries
|
||||
@ -539,24 +626,27 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
* LoadFile
|
||||
***************************************************************************/
|
||||
u32
|
||||
LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
LoadFile (char * rbuffer, char *filepath, u32 length, bool silent)
|
||||
{
|
||||
char zipbuffer[2048];
|
||||
u32 size = 0;
|
||||
u32 readsize = 0;
|
||||
char fullpath[MAXPATHLEN];
|
||||
int retry = 1;
|
||||
int device;
|
||||
|
||||
if(!FindDevice(filepath, &device))
|
||||
return 0;
|
||||
|
||||
switch(method)
|
||||
switch(device)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
return LoadDVDFile (rbuffer, filepath, length, silent);
|
||||
case DEVICE_DVD:
|
||||
return LoadDVDFile (rbuffer, StripDevice(filepath), length, silent);
|
||||
break;
|
||||
case METHOD_MC_SLOTA:
|
||||
return LoadMCFile (rbuffer, CARD_SLOTA, filepath, silent);
|
||||
case DEVICE_MC_SLOTA:
|
||||
return LoadMCFile (rbuffer, CARD_SLOTA, StripDevice(filepath), silent);
|
||||
break;
|
||||
case METHOD_MC_SLOTB:
|
||||
return LoadMCFile (rbuffer, CARD_SLOTB, filepath, silent);
|
||||
case DEVICE_MC_SLOTB:
|
||||
return LoadMCFile (rbuffer, CARD_SLOTB, StripDevice(filepath), silent);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -570,10 +660,9 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
// open the file
|
||||
while(!size && retry == 1)
|
||||
{
|
||||
if(ChangeInterface(method, silent))
|
||||
if(ChangeInterface(device, silent))
|
||||
{
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||
file = fopen (fullpath, "rb");
|
||||
file = fopen (filepath, "rb");
|
||||
|
||||
if(file > 0)
|
||||
{
|
||||
@ -589,7 +678,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
{
|
||||
if (IsZipFile (zipbuffer))
|
||||
{
|
||||
size = UnZipBuffer ((unsigned char *)rbuffer, method); // unzip
|
||||
size = UnZipBuffer ((unsigned char *)rbuffer, device); // unzip
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -630,7 +719,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
{
|
||||
if(!silent)
|
||||
{
|
||||
unmountRequired[method] = true;
|
||||
unmountRequired[device] = true;
|
||||
retry = ErrorPromptRetry("Error loading file!");
|
||||
}
|
||||
else
|
||||
@ -646,9 +735,9 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
return size;
|
||||
}
|
||||
|
||||
u32 LoadFile(char * filepath, int method, bool silent)
|
||||
u32 LoadFile(char * filepath, bool silent)
|
||||
{
|
||||
return LoadFile((char *)savebuffer, filepath, 0, method, silent);
|
||||
return LoadFile((char *)savebuffer, filepath, 0, silent);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -656,23 +745,26 @@ u32 LoadFile(char * filepath, int method, bool silent)
|
||||
* Write buffer to file
|
||||
***************************************************************************/
|
||||
u32
|
||||
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
SaveFile (char * buffer, char *filepath, u32 datasize, bool silent)
|
||||
{
|
||||
char fullpath[MAXPATHLEN];
|
||||
u32 written = 0;
|
||||
int retry = 1;
|
||||
int device;
|
||||
|
||||
if(!FindDevice(filepath, &device))
|
||||
return 0;
|
||||
|
||||
if(datasize == 0)
|
||||
return 0;
|
||||
|
||||
ShowAction("Saving...");
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||
{
|
||||
if(method == METHOD_MC_SLOTA)
|
||||
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
||||
if(device == DEVICE_MC_SLOTA)
|
||||
return SaveMCFile (buffer, CARD_SLOTA, StripDevice(filepath), datasize, silent);
|
||||
else
|
||||
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||
return SaveMCFile (buffer, CARD_SLOTB, StripDevice(filepath), datasize, silent);
|
||||
}
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
@ -681,10 +773,9 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
|
||||
while(!written && retry == 1)
|
||||
{
|
||||
if(ChangeInterface(method, silent))
|
||||
if(ChangeInterface(device, silent))
|
||||
{
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||
file = fopen (fullpath, "wb");
|
||||
file = fopen (filepath, "wb");
|
||||
|
||||
if (file > 0)
|
||||
{
|
||||
@ -704,7 +795,7 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
}
|
||||
if(!written)
|
||||
{
|
||||
unmountRequired[method] = true;
|
||||
unmountRequired[device] = true;
|
||||
if(!silent)
|
||||
retry = ErrorPromptRetry("Error saving file!");
|
||||
else
|
||||
@ -719,7 +810,7 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
return written;
|
||||
}
|
||||
|
||||
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent)
|
||||
u32 SaveFile(char * filepath, u32 datasize, bool silent)
|
||||
{
|
||||
return SaveFile((char *)savebuffer, filepath, datasize, method, silent);
|
||||
return SaveFile((char *)savebuffer, filepath, datasize, silent);
|
||||
}
|
||||
|
@ -23,17 +23,22 @@
|
||||
void InitDeviceThread();
|
||||
void ResumeDeviceThread();
|
||||
void HaltDeviceThread();
|
||||
void HaltParseThread();
|
||||
void MountAllFAT();
|
||||
void UnmountAllFAT();
|
||||
bool ChangeInterface(int method, bool silent);
|
||||
int ParseDirectory(int method, bool waitParse = false);
|
||||
bool FindDevice(char * filepath, int * device);
|
||||
char * StripDevice(char * path);
|
||||
bool ChangeInterface(int device, bool silent);
|
||||
bool ChangeInterface(char * filepath, bool silent);
|
||||
void CreateAppPath(char * origpath);
|
||||
int ParseDirectory(bool waitParse = false);
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
||||
u32 LoadFile(char * filepath, int method, bool silent);
|
||||
u32 LoadFile(char * rbuffer, char *filepath, u32 length, bool silent);
|
||||
u32 LoadFile(char * filepath, bool silent);
|
||||
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
||||
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent);
|
||||
u32 SaveFile(char * buffer, char *filepath, u32 datasize, bool silent);
|
||||
u32 SaveFile(char * filepath, u32 datasize, bool silent);
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern FILE * file;
|
||||
|
@ -101,7 +101,7 @@ IsZipFile (char *buffer)
|
||||
******************************************************************************/
|
||||
|
||||
int
|
||||
UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
UnZipBuffer (unsigned char *outbuffer, int device)
|
||||
{
|
||||
PKZIPHEADER pkzip;
|
||||
int zipoffset = 0;
|
||||
@ -116,9 +116,9 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
int sizeread = 0;
|
||||
|
||||
// Read Zip Header
|
||||
switch (method)
|
||||
switch (device)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
case DEVICE_DVD:
|
||||
sizeread = dvd_safe_read (readbuffer, ZIPCHUNK, 0);
|
||||
break;
|
||||
default:
|
||||
@ -188,9 +188,9 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
zipoffset = 0;
|
||||
zipchunk = ZIPCHUNK;
|
||||
|
||||
switch (method)
|
||||
switch (device)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
case DEVICE_DVD:
|
||||
readoffset += ZIPCHUNK;
|
||||
sizeread = dvd_safe_read (readbuffer, ZIPCHUNK, readoffset);
|
||||
break;
|
||||
@ -223,17 +223,17 @@ done:
|
||||
***************************************************************************/
|
||||
|
||||
char *
|
||||
GetFirstZipFilename (int method)
|
||||
GetFirstZipFilename ()
|
||||
{
|
||||
char * firstFilename = NULL;
|
||||
char tempbuffer[ZIPCHUNK];
|
||||
char filepath[1024];
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
||||
if(!MakeFilePath(filepath, FILE_ROM))
|
||||
return NULL;
|
||||
|
||||
// read start of ZIP
|
||||
if(LoadFile (tempbuffer, filepath, ZIPCHUNK, method, NOTSILENT))
|
||||
if(LoadFile (tempbuffer, filepath, ZIPCHUNK, NOTSILENT))
|
||||
{
|
||||
tempbuffer[28] = 0; // truncate - filename length is 2 bytes long (bytes 26-27)
|
||||
int namelength = tempbuffer[26]; // filename length starts 26 bytes in
|
||||
@ -338,7 +338,7 @@ static SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSi
|
||||
// read data
|
||||
switch (szMethod)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
case DEVICE_DVD:
|
||||
sizeread = dvd_safe_read(sz_buffer, maxRequiredSize, offset);
|
||||
break;
|
||||
default:
|
||||
@ -383,10 +383,15 @@ static SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
||||
* It parses the entire 7z for full browsing capability
|
||||
***************************************************************************/
|
||||
|
||||
int SzParse(char * filepath, int method)
|
||||
int SzParse(char * filepath)
|
||||
{
|
||||
if(!filepath)
|
||||
return 0;
|
||||
|
||||
int device;
|
||||
|
||||
if(!FindDevice(browser.dir, &device))
|
||||
return 0;
|
||||
|
||||
int nbfiles = 0;
|
||||
|
||||
@ -400,22 +405,22 @@ int SzParse(char * filepath, int method)
|
||||
SzArchiveStream.pos = 0;
|
||||
|
||||
// open file
|
||||
switch (method)
|
||||
switch (device)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
case METHOD_SMB:
|
||||
case DEVICE_SD:
|
||||
case DEVICE_USB:
|
||||
case DEVICE_SMB:
|
||||
file = fopen (filepath, "rb");
|
||||
if(!file)
|
||||
return 0;
|
||||
break;
|
||||
case METHOD_DVD:
|
||||
case DEVICE_DVD:
|
||||
SwitchDVDFolder(filepath);
|
||||
break;
|
||||
}
|
||||
|
||||
// set szMethod to current chosen load method
|
||||
szMethod = method;
|
||||
// set szMethod to current chosen load device
|
||||
szMethod = device;
|
||||
|
||||
// set handler functions for reading data from SD/USB/SMB/DVD
|
||||
SzArchiveStream.InStream.Read = SzFileReadImp;
|
||||
@ -502,11 +507,11 @@ int SzParse(char * filepath, int method)
|
||||
CancelAction();
|
||||
|
||||
// close file
|
||||
switch (method)
|
||||
switch (device)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
case METHOD_SMB:
|
||||
case DEVICE_SD:
|
||||
case DEVICE_USB:
|
||||
case DEVICE_SMB:
|
||||
fclose(file);
|
||||
break;
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
#define _GCUNZIP_H_
|
||||
|
||||
int IsZipFile (char *buffer);
|
||||
char * GetFirstZipFilename(int method);
|
||||
int UnZipBuffer (unsigned char *outbuffer, int method);
|
||||
int SzParse(char * filepath, int method);
|
||||
char * GetFirstZipFilename();
|
||||
int UnZipBuffer (unsigned char *outbuffer, int device);
|
||||
int SzParse(char * filepath);
|
||||
int SzExtractFile(int i, unsigned char *buffer);
|
||||
void SzClose();
|
||||
|
||||
|
@ -920,7 +920,7 @@ class GuiFileBrowser : public GuiElement
|
||||
|
||||
GuiText * fileListText[FILE_PAGESIZE];
|
||||
GuiImage * fileListBg[FILE_PAGESIZE];
|
||||
GuiImage * fileListFolder[FILE_PAGESIZE];
|
||||
GuiImage * fileListIcon[FILE_PAGESIZE];
|
||||
|
||||
GuiButton * arrowUpBtn;
|
||||
GuiButton * arrowDownBtn;
|
||||
@ -937,7 +937,11 @@ class GuiFileBrowser : public GuiElement
|
||||
|
||||
GuiImageData * bgFileSelection;
|
||||
GuiImageData * bgFileSelectionEntry;
|
||||
GuiImageData * fileFolder;
|
||||
GuiImageData * iconFolder;
|
||||
GuiImageData * iconSD;
|
||||
GuiImageData * iconUSB;
|
||||
GuiImageData * iconDVD;
|
||||
GuiImageData * iconSMB;
|
||||
GuiImageData * scrollbar;
|
||||
GuiImageData * arrowDown;
|
||||
GuiImageData * arrowDownOver;
|
||||
|
@ -42,7 +42,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
bgFileSelectionImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
|
||||
bgFileSelectionEntry = new GuiImageData(bg_game_selection_entry_png);
|
||||
fileFolder = new GuiImageData(folder_png);
|
||||
|
||||
iconFolder = new GuiImageData(icon_folder_png);
|
||||
iconSD = new GuiImageData(icon_sd_png);
|
||||
iconUSB = new GuiImageData(icon_usb_png);
|
||||
iconDVD = new GuiImageData(icon_dvd_png);
|
||||
iconSMB = new GuiImageData(icon_smb_png);
|
||||
|
||||
scrollbar = new GuiImageData(scrollbar_png);
|
||||
scrollbarImg = new GuiImage(scrollbar);
|
||||
@ -107,7 +112,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
fileListText[i]->SetMaxWidth(380);
|
||||
|
||||
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
|
||||
fileListFolder[i] = new GuiImage(fileFolder);
|
||||
fileListIcon[i] = NULL;
|
||||
|
||||
fileList[i] = new GuiButton(380, 26);
|
||||
fileList[i]->SetParent(this);
|
||||
@ -139,7 +144,11 @@ GuiFileBrowser::~GuiFileBrowser()
|
||||
|
||||
delete bgFileSelection;
|
||||
delete bgFileSelectionEntry;
|
||||
delete fileFolder;
|
||||
delete iconFolder;
|
||||
delete iconSD;
|
||||
delete iconUSB;
|
||||
delete iconDVD;
|
||||
delete iconSMB;
|
||||
delete scrollbar;
|
||||
delete arrowDown;
|
||||
delete arrowDownOver;
|
||||
@ -158,7 +167,9 @@ GuiFileBrowser::~GuiFileBrowser()
|
||||
delete fileListText[i];
|
||||
delete fileList[i];
|
||||
delete fileListBg[i];
|
||||
delete fileListFolder[i];
|
||||
|
||||
if(fileListIcon[i])
|
||||
delete fileListIcon[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,16 +352,34 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
|
||||
fileListText[i]->SetText(browserList[browser.pageIndex+i].displayname);
|
||||
|
||||
if(browserList[browser.pageIndex+i].isdir) // directory
|
||||
if(fileListIcon[i])
|
||||
{
|
||||
fileList[i]->SetIcon(fileListFolder[i]);
|
||||
fileListText[i]->SetPosition(30,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileList[i]->SetIcon(NULL);
|
||||
delete fileListIcon[i];
|
||||
fileListIcon[i] = NULL;
|
||||
fileListText[i]->SetPosition(10,0);
|
||||
}
|
||||
|
||||
switch(browserList[browser.pageIndex+i].icon)
|
||||
{
|
||||
case ICON_FOLDER:
|
||||
fileListIcon[i] = new GuiImage(iconFolder);
|
||||
break;
|
||||
case ICON_SD:
|
||||
fileListIcon[i] = new GuiImage(iconSD);
|
||||
break;
|
||||
case ICON_USB:
|
||||
fileListIcon[i] = new GuiImage(iconUSB);
|
||||
break;
|
||||
case ICON_DVD:
|
||||
fileListIcon[i] = new GuiImage(iconDVD);
|
||||
break;
|
||||
case ICON_SMB:
|
||||
fileListIcon[i] = new GuiImage(iconSMB);
|
||||
break;
|
||||
}
|
||||
fileList[i]->SetIcon(fileListIcon[i]);
|
||||
if(fileListIcon[i] != NULL)
|
||||
fileListText[i]->SetPosition(30,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
BIN
source/ngc/images/icon_dvd.png
Normal file
BIN
source/ngc/images/icon_dvd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
source/ngc/images/icon_sd.png
Normal file
BIN
source/ngc/images/icon_sd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 644 B |
BIN
source/ngc/images/icon_smb.png
Normal file
BIN
source/ngc/images/icon_smb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
source/ngc/images/icon_usb.png
Normal file
BIN
source/ngc/images/icon_usb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 888 B |
@ -931,76 +931,63 @@ static int MenuGameSelection()
|
||||
#endif
|
||||
|
||||
// populate initial directory listing
|
||||
if(OpenGameList() <= 0)
|
||||
{
|
||||
int choice = WindowPrompt(
|
||||
"Error",
|
||||
"Games directory is inaccessible on selected load device.",
|
||||
"Retry",
|
||||
"Check Settings");
|
||||
OpenGameList();
|
||||
|
||||
if(choice)
|
||||
menu = MENU_GAMESELECTION;
|
||||
else
|
||||
menu = MENU_SETTINGS_FILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gameBrowser.ResetState();
|
||||
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||
gameBrowser.TriggerUpdate();
|
||||
gameBrowser.ResetState();
|
||||
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||
gameBrowser.TriggerUpdate();
|
||||
|
||||
while(menu == MENU_NONE)
|
||||
while(menu == MENU_NONE)
|
||||
{
|
||||
usleep(THREAD_SLEEP);
|
||||
|
||||
// update gameWindow based on arrow buttons
|
||||
// set MENU_EXIT if A button pressed on a game
|
||||
for(i=0; i < FILE_PAGESIZE; i++)
|
||||
{
|
||||
usleep(THREAD_SLEEP);
|
||||
|
||||
// update gameWindow based on arrow buttons
|
||||
// set MENU_EXIT if A button pressed on a game
|
||||
for(i=0; i < FILE_PAGESIZE; i++)
|
||||
if(gameBrowser.fileList[i]->GetState() == STATE_CLICKED)
|
||||
{
|
||||
if(gameBrowser.fileList[i]->GetState() == STATE_CLICKED)
|
||||
gameBrowser.fileList[i]->ResetState();
|
||||
// check corresponding browser entry
|
||||
if(browserList[browser.selIndex].isdir || IsSz())
|
||||
{
|
||||
gameBrowser.fileList[i]->ResetState();
|
||||
// check corresponding browser entry
|
||||
if(browserList[browser.selIndex].isdir || IsSz())
|
||||
{
|
||||
if(IsSz())
|
||||
res = BrowserLoadSz(GCSettings.LoadMethod);
|
||||
else
|
||||
res = BrowserChangeFolder(GCSettings.LoadMethod);
|
||||
if(IsSz())
|
||||
res = BrowserLoadSz();
|
||||
else
|
||||
res = BrowserChangeFolder();
|
||||
|
||||
if(res)
|
||||
{
|
||||
gameBrowser.ResetState();
|
||||
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||
gameBrowser.TriggerUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = MENU_GAMESELECTION;
|
||||
break;
|
||||
}
|
||||
if(res)
|
||||
{
|
||||
gameBrowser.ResetState();
|
||||
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||
gameBrowser.TriggerUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
ShutoffRumble();
|
||||
#endif
|
||||
mainWindow->SetState(STATE_DISABLED);
|
||||
if(BrowserLoadFile(GCSettings.LoadMethod))
|
||||
menu = MENU_EXIT;
|
||||
else
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
menu = MENU_GAMESELECTION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
ShutoffRumble();
|
||||
#endif
|
||||
mainWindow->SetState(STATE_DISABLED);
|
||||
if(BrowserLoadFile())
|
||||
menu = MENU_EXIT;
|
||||
else
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
if(settingsBtn.GetState() == STATE_CLICKED)
|
||||
menu = MENU_SETTINGS;
|
||||
else if(exitBtn.GetState() == STATE_CLICKED)
|
||||
ExitRequested = 1;
|
||||
}
|
||||
|
||||
if(settingsBtn.GetState() == STATE_CLICKED)
|
||||
menu = MENU_SETTINGS;
|
||||
else if(exitBtn.GetState() == STATE_CLICKED)
|
||||
ExitRequested = 1;
|
||||
}
|
||||
|
||||
HaltGui();
|
||||
mainWindow->Remove(&titleTxt);
|
||||
mainWindow->Remove(&buttonWindow);
|
||||
@ -1274,19 +1261,19 @@ static int MenuGame()
|
||||
|
||||
if (GCSettings.AutoSave == 1)
|
||||
{
|
||||
SaveBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SRAM, SILENT); // save battery
|
||||
SaveBatteryOrStateAuto(FILE_SRAM, SILENT); // save battery
|
||||
}
|
||||
else if (GCSettings.AutoSave == 2)
|
||||
{
|
||||
if (WindowPrompt("Save", "Save Snapshot?", "Save", "Don't Save") )
|
||||
SaveBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SNAPSHOT, NOTSILENT); // save state
|
||||
SaveBatteryOrStateAuto(FILE_SNAPSHOT, NOTSILENT); // save state
|
||||
}
|
||||
else if (GCSettings.AutoSave == 3)
|
||||
{
|
||||
if (WindowPrompt("Save", "Save SRAM and Snapshot?", "Save", "Don't Save") )
|
||||
{
|
||||
SaveBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SRAM, NOTSILENT); // save battery
|
||||
SaveBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SNAPSHOT, NOTSILENT); // save state
|
||||
SaveBatteryOrStateAuto(FILE_SRAM, NOTSILENT); // save battery
|
||||
SaveBatteryOrStateAuto(FILE_SNAPSHOT, NOTSILENT); // save state
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1445,7 +1432,7 @@ static int FindGameSaveNum(char * savefile, int method)
|
||||
int romlen = strlen(ROMFilename);
|
||||
int savelen = strlen(savefile);
|
||||
|
||||
if(romlen > 26 && (method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB))
|
||||
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;
|
||||
@ -1453,7 +1440,7 @@ static int FindGameSaveNum(char * savefile, int method)
|
||||
if(strncmp(savefile, ROMFilename, romlen) != 0)
|
||||
return -1;
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
if(method == DEVICE_MC_SLOTA || method == DEVICE_MC_SLOTB)
|
||||
{
|
||||
if(diff == 2)
|
||||
n = atoi(&savefile[savelen-2]);
|
||||
@ -1493,7 +1480,7 @@ static int MenuGameSaves(int action)
|
||||
struct tm * timeinfo;
|
||||
int method = GCSettings.SaveMethod;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
if(method == DEVICE_AUTO)
|
||||
autoSaveMethod(NOTSILENT);
|
||||
|
||||
if(!ChangeInterface(method, NOTSILENT))
|
||||
@ -1563,18 +1550,18 @@ static int MenuGameSaves(int action)
|
||||
|
||||
memset(&saves, 0, sizeof(saves));
|
||||
|
||||
if(method == METHOD_MC_SLOTA)
|
||||
if(method == DEVICE_MC_SLOTA)
|
||||
{
|
||||
ParseMCDirectory(CARD_SLOTA);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTB)
|
||||
else if(method == DEVICE_MC_SLOTB)
|
||||
{
|
||||
ParseMCDirectory(CARD_SLOTB);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(browser.dir, GCSettings.SaveFolder, 200);
|
||||
ParseDirectory(GCSettings.SaveMethod, true);
|
||||
sprintf(browser.dir, "%s%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder);
|
||||
ParseDirectory(true);
|
||||
}
|
||||
|
||||
len = strlen(ROMFilename);
|
||||
@ -1604,18 +1591,18 @@ static int MenuGameSaves(int action)
|
||||
saves.files[saves.type[j]][n] = 1;
|
||||
strncpy(saves.filename[j], browserList[i].filename, MAXJOLIET);
|
||||
|
||||
if(method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
||||
if(method != DEVICE_MC_SLOTA && method != DEVICE_MC_SLOTB)
|
||||
{
|
||||
if(saves.type[j] == FILE_SNAPSHOT)
|
||||
{
|
||||
sprintf(scrfile, "%s/%s.png", GCSettings.SaveFolder, tmp);
|
||||
sprintf(scrfile, "%s%s/%s.png", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, tmp);
|
||||
|
||||
AllocSaveBuffer();
|
||||
if(LoadFile(scrfile, GCSettings.SaveMethod, SILENT))
|
||||
if(LoadFile(scrfile, SILENT))
|
||||
saves.previewImg[j] = new GuiImageData(savebuffer);
|
||||
FreeSaveBuffer();
|
||||
}
|
||||
snprintf(filepath, 1024, "%s%s/%s", rootdir, GCSettings.SaveFolder, saves.filename[j]);
|
||||
snprintf(filepath, 1024, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, saves.filename[j]);
|
||||
if (stat(filepath, &filestat) == 0)
|
||||
{
|
||||
timeinfo = localtime(&filestat.st_mtime);
|
||||
@ -1657,15 +1644,15 @@ static int MenuGameSaves(int action)
|
||||
|
||||
if(action == 0) // load
|
||||
{
|
||||
MakeFilePath(filepath, saves.type[ret], method, saves.filename[ret]);
|
||||
MakeFilePath(filepath, saves.type[ret], saves.filename[ret]);
|
||||
switch(saves.type[ret])
|
||||
{
|
||||
case FILE_SRAM:
|
||||
result = LoadBatteryOrState(filepath, GCSettings.SaveMethod, saves.type[ret], NOTSILENT);
|
||||
result = LoadBatteryOrState(filepath, saves.type[ret], NOTSILENT);
|
||||
emulator.emuReset();
|
||||
break;
|
||||
case FILE_SNAPSHOT:
|
||||
result = LoadBatteryOrState(filepath, GCSettings.SaveMethod, saves.type[ret], NOTSILENT);
|
||||
result = LoadBatteryOrState(filepath, saves.type[ret], NOTSILENT);
|
||||
break;
|
||||
}
|
||||
if(result)
|
||||
@ -1681,8 +1668,8 @@ static int MenuGameSaves(int action)
|
||||
|
||||
if(i < 100)
|
||||
{
|
||||
MakeFilePath(filepath, FILE_SRAM, method, ROMFilename, i);
|
||||
SaveBatteryOrState(filepath, GCSettings.SaveMethod, FILE_SRAM, NOTSILENT);
|
||||
MakeFilePath(filepath, FILE_SRAM, ROMFilename, i);
|
||||
SaveBatteryOrState(filepath, FILE_SRAM, NOTSILENT);
|
||||
menu = MENU_GAME_SAVE;
|
||||
}
|
||||
}
|
||||
@ -1694,21 +1681,21 @@ static int MenuGameSaves(int action)
|
||||
|
||||
if(i < 100)
|
||||
{
|
||||
MakeFilePath(filepath, FILE_SNAPSHOT, method, ROMFilename, i);
|
||||
SaveBatteryOrState(filepath, GCSettings.SaveMethod, FILE_SNAPSHOT, NOTSILENT);
|
||||
MakeFilePath(filepath, FILE_SNAPSHOT, ROMFilename, i);
|
||||
SaveBatteryOrState(filepath, FILE_SNAPSHOT, NOTSILENT);
|
||||
menu = MENU_GAME_SAVE;
|
||||
}
|
||||
}
|
||||
else // overwrite SRAM/Snapshot
|
||||
{
|
||||
MakeFilePath(filepath, saves.type[ret], method, saves.filename[ret]);
|
||||
MakeFilePath(filepath, saves.type[ret], saves.filename[ret]);
|
||||
switch(saves.type[ret])
|
||||
{
|
||||
case FILE_SRAM:
|
||||
SaveBatteryOrState(filepath, GCSettings.SaveMethod, FILE_SRAM, NOTSILENT);
|
||||
SaveBatteryOrState(filepath, FILE_SRAM, NOTSILENT);
|
||||
break;
|
||||
case FILE_SNAPSHOT:
|
||||
SaveBatteryOrState(filepath, GCSettings.SaveMethod, FILE_SNAPSHOT, NOTSILENT);
|
||||
SaveBatteryOrState(filepath, FILE_SNAPSHOT, NOTSILENT);
|
||||
break;
|
||||
}
|
||||
menu = MENU_GAME_SAVE;
|
||||
@ -3126,35 +3113,35 @@ static int MenuSettingsFile()
|
||||
|
||||
// no USB ports on GameCube
|
||||
#ifdef HW_DOL
|
||||
if(GCSettings.LoadMethod == METHOD_USB)
|
||||
if(GCSettings.LoadMethod == DEVICE_USB)
|
||||
GCSettings.LoadMethod++;
|
||||
if(GCSettings.SaveMethod == METHOD_USB)
|
||||
if(GCSettings.SaveMethod == DEVICE_USB)
|
||||
GCSettings.SaveMethod++;
|
||||
#endif
|
||||
|
||||
// saving to DVD is impossible
|
||||
if(GCSettings.SaveMethod == METHOD_DVD)
|
||||
if(GCSettings.SaveMethod == DEVICE_DVD)
|
||||
GCSettings.SaveMethod++;
|
||||
|
||||
// disable DVD in GC mode (not implemented)
|
||||
#ifdef HW_DOL
|
||||
if(GCSettings.LoadMethod == METHOD_DVD)
|
||||
if(GCSettings.LoadMethod == DEVICE_DVD)
|
||||
GCSettings.LoadMethod++;
|
||||
#endif
|
||||
|
||||
// disable SMB in GC mode (stalls out)
|
||||
#ifdef HW_DOL
|
||||
if(GCSettings.LoadMethod == METHOD_SMB)
|
||||
if(GCSettings.LoadMethod == DEVICE_SMB)
|
||||
GCSettings.LoadMethod++;
|
||||
if(GCSettings.SaveMethod == METHOD_SMB)
|
||||
if(GCSettings.SaveMethod == DEVICE_SMB)
|
||||
GCSettings.SaveMethod++;
|
||||
#endif
|
||||
|
||||
// disable MC saving in Wii mode - does not work for some reason!
|
||||
#ifdef HW_RVL
|
||||
if(GCSettings.SaveMethod == METHOD_MC_SLOTA)
|
||||
if(GCSettings.SaveMethod == DEVICE_MC_SLOTA)
|
||||
GCSettings.SaveMethod++;
|
||||
if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
|
||||
if(GCSettings.SaveMethod == DEVICE_MC_SLOTB)
|
||||
GCSettings.SaveMethod++;
|
||||
options.name[7][0] = 0;
|
||||
#endif
|
||||
@ -3165,18 +3152,18 @@ static int MenuSettingsFile()
|
||||
if(GCSettings.SaveMethod > 6)
|
||||
GCSettings.SaveMethod = 0;
|
||||
|
||||
if (GCSettings.LoadMethod == METHOD_AUTO) sprintf (options.value[0],"Auto Detect");
|
||||
else if (GCSettings.LoadMethod == METHOD_SD) sprintf (options.value[0],"SD");
|
||||
else if (GCSettings.LoadMethod == METHOD_USB) sprintf (options.value[0],"USB");
|
||||
else if (GCSettings.LoadMethod == METHOD_DVD) sprintf (options.value[0],"DVD");
|
||||
else if (GCSettings.LoadMethod == METHOD_SMB) sprintf (options.value[0],"Network");
|
||||
if (GCSettings.LoadMethod == DEVICE_AUTO) sprintf (options.value[0],"Auto Detect");
|
||||
else if (GCSettings.LoadMethod == DEVICE_SD) sprintf (options.value[0],"SD");
|
||||
else if (GCSettings.LoadMethod == DEVICE_USB) sprintf (options.value[0],"USB");
|
||||
else if (GCSettings.LoadMethod == DEVICE_DVD) sprintf (options.value[0],"DVD");
|
||||
else if (GCSettings.LoadMethod == DEVICE_SMB) sprintf (options.value[0],"Network");
|
||||
|
||||
if (GCSettings.SaveMethod == METHOD_AUTO) sprintf (options.value[1],"Auto Detect");
|
||||
else if (GCSettings.SaveMethod == METHOD_SD) sprintf (options.value[1],"SD");
|
||||
else if (GCSettings.SaveMethod == METHOD_USB) sprintf (options.value[1],"USB");
|
||||
else if (GCSettings.SaveMethod == METHOD_SMB) sprintf (options.value[1],"Network");
|
||||
else if (GCSettings.SaveMethod == METHOD_MC_SLOTA) sprintf (options.value[1],"MC Slot A");
|
||||
else if (GCSettings.SaveMethod == METHOD_MC_SLOTB) sprintf (options.value[1],"MC Slot B");
|
||||
if (GCSettings.SaveMethod == DEVICE_AUTO) sprintf (options.value[1],"Auto Detect");
|
||||
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);
|
||||
|
@ -38,7 +38,7 @@ bool updateFound = false; // true if an app update was found
|
||||
void UpdateCheck()
|
||||
{
|
||||
// we can only check for the update if we have internet + SD
|
||||
if(!updateChecked && networkInit && isMounted[METHOD_SD])
|
||||
if(!updateChecked && networkInit && isMounted[DEVICE_SD])
|
||||
{
|
||||
static char url[128];
|
||||
int retval;
|
||||
@ -262,7 +262,7 @@ ConnectShare (bool silent)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(unmountRequired[METHOD_SMB])
|
||||
if(unmountRequired[DEVICE_SMB])
|
||||
CloseShare();
|
||||
|
||||
if(!networkInit)
|
||||
@ -289,9 +289,6 @@ ConnectShare (bool silent)
|
||||
ErrorPrompt("Failed to connect to network share.");
|
||||
}
|
||||
|
||||
if(networkShareInit)
|
||||
sprintf(rootdir, "smb:");
|
||||
|
||||
return networkShareInit;
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,17 @@ static mxml_node_t *section = NULL;
|
||||
static mxml_node_t *item = NULL;
|
||||
static mxml_node_t *elem = NULL;
|
||||
|
||||
static mxml_node_t *mxmlFindNewElement(mxml_node_t *parent, const char *nodename, const char *attr=NULL, const char *value=NULL) {
|
||||
static mxml_node_t *mxmlFindNewElement(mxml_node_t *parent, const char *nodename, const char *attr=NULL, const char *value=NULL)
|
||||
{
|
||||
mxml_node_t *node = mxmlFindElement(parent, xml, nodename, attr, value, MXML_DESCEND);
|
||||
if (!node) {
|
||||
if (!node)
|
||||
{
|
||||
node = mxmlNewElement(parent, nodename);
|
||||
if (attr && value) mxmlElementSetAttr(node, attr, value);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
static char temp[20];
|
||||
|
||||
static const char * toStr(int i)
|
||||
@ -148,9 +149,8 @@ static const char * XMLSavePalCallback(mxml_node_t *node, int where)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
preparePrefsData (int method)
|
||||
preparePrefsData ()
|
||||
{
|
||||
xml = mxmlNewXML("1.0");
|
||||
mxmlSetWrapMargin(0); // disable line wrapping
|
||||
@ -213,11 +213,15 @@ preparePrefsData (int method)
|
||||
|
||||
static void createXMLPalette(gamePalette *p, bool overwrite, const char *newname = NULL)
|
||||
{
|
||||
if (!newname) newname = p->gameName;
|
||||
if (!newname)
|
||||
newname = p->gameName;
|
||||
section = mxmlFindElement(xml, xml, "game", "name", newname, MXML_DESCEND);
|
||||
if (section && !overwrite) {
|
||||
if (section && !overwrite)
|
||||
{
|
||||
return;
|
||||
} else if (!section) {
|
||||
}
|
||||
else if (!section)
|
||||
{
|
||||
section = mxmlNewElement(data, "game");
|
||||
}
|
||||
mxmlElementSetAttr(section, "name", newname);
|
||||
@ -243,7 +247,7 @@ static void createXMLPalette(gamePalette *p, bool overwrite, const char *newname
|
||||
}
|
||||
|
||||
static int
|
||||
preparePalData (int method, gamePalette pals[], int palCount)
|
||||
preparePalData (gamePalette pals[], int palCount)
|
||||
{
|
||||
xml = mxmlNewXML("1.0");
|
||||
mxmlSetWrapMargin(0); // disable line wrapping
|
||||
@ -251,9 +255,8 @@ preparePalData (int method, gamePalette pals[], int palCount)
|
||||
data = mxmlNewElement(xml, "palette");
|
||||
mxmlElementSetAttr(data, "app", APPNAME);
|
||||
mxmlElementSetAttr(data, "version", APPVERSION);
|
||||
for (int i=0; i<palCount; i++) {
|
||||
for (int i=0; i<palCount; i++)
|
||||
createXMLPalette(&pals[i], false);
|
||||
}
|
||||
|
||||
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSavePalCallback);
|
||||
|
||||
@ -262,7 +265,6 @@ preparePalData (int method, gamePalette pals[], int palCount)
|
||||
return datasize;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* loadXMLSetting
|
||||
*
|
||||
@ -328,53 +330,77 @@ static void loadXMLController(unsigned int controller[], const char * name)
|
||||
|
||||
static void loadXMLPaletteFromSection(gamePalette &pal)
|
||||
{
|
||||
if (section) {
|
||||
if (section)
|
||||
{
|
||||
strncpy(pal.gameName, mxmlElementGetAttr(section, "name"), 17);
|
||||
item = mxmlFindElement(section, xml, "bkgr", NULL, NULL, MXML_DESCEND);
|
||||
if(item) {
|
||||
if (item)
|
||||
{
|
||||
const char * tmp = mxmlElementGetAttr(item, "c0");
|
||||
if(tmp) pal.palette[0] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[0] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c1");
|
||||
if(tmp) pal.palette[1] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[1] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c2");
|
||||
if(tmp) pal.palette[2] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[2] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c3");
|
||||
if(tmp) pal.palette[3] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[3] = strtoul(tmp, NULL, 16);
|
||||
}
|
||||
item = mxmlFindElement(section, xml, "wind", NULL, NULL, MXML_DESCEND);
|
||||
if(item) {
|
||||
if (item)
|
||||
{
|
||||
const char * tmp = mxmlElementGetAttr(item, "c0");
|
||||
if(tmp) pal.palette[4] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[4] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c1");
|
||||
if(tmp) pal.palette[5] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[5] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c2");
|
||||
if(tmp) pal.palette[6] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[6] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c3");
|
||||
if(tmp) pal.palette[7] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[7] = strtoul(tmp, NULL, 16);
|
||||
}
|
||||
item = mxmlFindElement(section, xml, "obj0", NULL, NULL, MXML_DESCEND);
|
||||
if(item) {
|
||||
if (item)
|
||||
{
|
||||
const char * tmp = mxmlElementGetAttr(item, "c0");
|
||||
if(tmp) pal.palette[8] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[8] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c1");
|
||||
if(tmp) pal.palette[9] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[9] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c2");
|
||||
if(tmp) pal.palette[10] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[10] = strtoul(tmp, NULL, 16);
|
||||
}
|
||||
item = mxmlFindElement(section, xml, "obj1", NULL, NULL, MXML_DESCEND);
|
||||
if(item) {
|
||||
if (item)
|
||||
{
|
||||
const char * tmp = mxmlElementGetAttr(item, "c0");
|
||||
if(tmp) pal.palette[11] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[11] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c1");
|
||||
if(tmp) pal.palette[12] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[12] = strtoul(tmp, NULL, 16);
|
||||
tmp = mxmlElementGetAttr(item, "c2");
|
||||
if(tmp) pal.palette[13] = strtoul(tmp, NULL, 16);
|
||||
if (tmp)
|
||||
pal.palette[13] = strtoul(tmp, NULL, 16);
|
||||
}
|
||||
const char *use = mxmlElementGetAttr(section, "use");
|
||||
if (use) {
|
||||
if (atoi(use)==0) pal.use = 0;
|
||||
else pal.use = 1;
|
||||
} else {
|
||||
if (use)
|
||||
{
|
||||
if (atoi(use) == 0)
|
||||
pal.use = 0;
|
||||
else
|
||||
pal.use = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pal.use = 1;
|
||||
}
|
||||
}
|
||||
@ -387,7 +413,7 @@ static void loadXMLPaletteFromSection(gamePalette &pal)
|
||||
***************************************************************************/
|
||||
|
||||
static bool
|
||||
decodePrefsData (int method)
|
||||
decodePrefsData ()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@ -480,7 +506,7 @@ decodePrefsData (int method)
|
||||
}
|
||||
|
||||
static bool
|
||||
decodePalsData (int method)
|
||||
decodePalsData ()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@ -520,23 +546,40 @@ decodePalsData (int method)
|
||||
/****************************************************************************
|
||||
* Save Preferences
|
||||
***************************************************************************/
|
||||
static char prefpath[MAXPATHLEN] = { 0 };
|
||||
|
||||
bool
|
||||
SavePrefs (bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
char filepath[MAXPATHLEN];
|
||||
int datasize;
|
||||
int offset = 0;
|
||||
int method = appLoadMethod;
|
||||
|
||||
// We'll save using the first available method (probably SD) since this
|
||||
// is the method preferences will be loaded from by default
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||
int device = 0;
|
||||
|
||||
if(prefpath[0] != 0)
|
||||
{
|
||||
strcpy(filepath, prefpath);
|
||||
FindDevice(filepath, &device);
|
||||
}
|
||||
else if(appPath[0] != 0)
|
||||
{
|
||||
sprintf(filepath, "%s%s", appPath, PREF_FILE_NAME);
|
||||
FindDevice(filepath, &device);
|
||||
}
|
||||
else
|
||||
{
|
||||
device = autoLoadMethod();
|
||||
|
||||
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, "%ssnes9x/%s", pathPrefix[device], PREF_FILE_NAME);
|
||||
}
|
||||
|
||||
if(device == 0)
|
||||
return false;
|
||||
|
||||
if (!silent)
|
||||
@ -545,9 +588,9 @@ SavePrefs (bool silent)
|
||||
FixInvalidSettings();
|
||||
|
||||
AllocSaveBuffer ();
|
||||
datasize = preparePrefsData (method);
|
||||
datasize = preparePrefsData ();
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||
{
|
||||
// Set the comments
|
||||
char prefscomment[2][32];
|
||||
@ -557,7 +600,7 @@ SavePrefs (bool silent)
|
||||
SetMCSaveComments(prefscomment);
|
||||
}
|
||||
|
||||
offset = SaveFile(filepath, datasize, method, silent);
|
||||
offset = SaveFile(filepath, datasize, silent);
|
||||
|
||||
FreeSaveBuffer ();
|
||||
|
||||
@ -573,26 +616,25 @@ SavePrefs (bool silent)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Load Preferences from specified method
|
||||
* Load Preferences from specified filepath
|
||||
***************************************************************************/
|
||||
bool
|
||||
LoadPrefsFromMethod (int method)
|
||||
LoadPrefsFromMethod (char * filepath)
|
||||
{
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||
return false;
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
offset = LoadFile(filepath, method, SILENT);
|
||||
offset = LoadFile(filepath, SILENT);
|
||||
|
||||
if (offset > 0)
|
||||
retval = decodePrefsData (method);
|
||||
retval = decodePrefsData ();
|
||||
|
||||
FreeSaveBuffer ();
|
||||
|
||||
if(retval)
|
||||
strcpy(prefpath, filepath);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -609,29 +651,28 @@ bool LoadPrefs()
|
||||
return true;
|
||||
|
||||
bool prefFound = false;
|
||||
char filepath[4][MAXPATHLEN];
|
||||
int numDevices;
|
||||
|
||||
#ifdef HW_RVL
|
||||
numDevices = 3;
|
||||
sprintf(filepath[0], "%s/%s", appPath, PREF_FILE_NAME);
|
||||
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
||||
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PREF_FILE_NAME);
|
||||
#else
|
||||
numDevices = 4;
|
||||
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
|
||||
|
||||
if(appLoadMethod == METHOD_SD)
|
||||
for(int i=0; i<numDevices; i++)
|
||||
{
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
||||
}
|
||||
else if(appLoadMethod == METHOD_USB)
|
||||
{
|
||||
if(ChangeInterface(METHOD_USB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
||||
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
||||
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
||||
prefFound = LoadPrefsFromMethod(filepath[i]);
|
||||
|
||||
if(prefFound)
|
||||
break;
|
||||
}
|
||||
|
||||
prefLoaded = true; // attempted to load preferences
|
||||
@ -647,15 +688,32 @@ bool SavePalettes(bool silent)
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset = 0;
|
||||
int method = GCSettings.SaveMethod;
|
||||
int device = 0;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
if (!MakeFilePath(filepath, FILE_PAL, method))
|
||||
if(prefpath[0] != 0)
|
||||
{
|
||||
strcpy(filepath, prefpath);
|
||||
FindDevice(filepath, &device);
|
||||
}
|
||||
else if(appPath[0] != 0)
|
||||
{
|
||||
sprintf(filepath, "%s%s", appPath, PAL_FILE_NAME);
|
||||
FindDevice(filepath, &device);
|
||||
}
|
||||
else
|
||||
{
|
||||
device = autoLoadMethod();
|
||||
|
||||
if(device == 0)
|
||||
return false;
|
||||
|
||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||
sprintf(filepath, "%s%s", pathPrefix[device], PAL_FILE_NAME);
|
||||
else
|
||||
sprintf(filepath, "%ssnes9x/%s", pathPrefix[device], PAL_FILE_NAME);
|
||||
}
|
||||
|
||||
if(device == 0)
|
||||
return false;
|
||||
|
||||
// Now create the XML palette file
|
||||
@ -664,9 +722,9 @@ bool SavePalettes(bool silent)
|
||||
ShowAction("Saving palette...");
|
||||
|
||||
AllocSaveBuffer();
|
||||
datasize = preparePalData(method, palettes, loadedPalettes);
|
||||
datasize = preparePalData(palettes, loadedPalettes);
|
||||
|
||||
if (method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
if (device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||
{
|
||||
// Set the comments
|
||||
char prefscomment[2][32];
|
||||
@ -676,7 +734,7 @@ bool SavePalettes(bool silent)
|
||||
SetMCSaveComments(prefscomment);
|
||||
}
|
||||
|
||||
offset = SaveFile(filepath, datasize, method, silent);
|
||||
offset = SaveFile(filepath, datasize, silent);
|
||||
|
||||
FreeSaveBuffer();
|
||||
|
||||
@ -694,12 +752,16 @@ bool SavePalettes(bool silent)
|
||||
static void AddPalette(gamePalette pal, const char *gameName, bool overwrite)
|
||||
{
|
||||
for (int i=0; i < loadedPalettes; i++)
|
||||
if (strcmp(palettes[i].gameName, gameName)==0) {
|
||||
if (overwrite) {
|
||||
if (strcmp(palettes[i].gameName, gameName)==0)
|
||||
{
|
||||
if (overwrite)
|
||||
{
|
||||
palettes[i] = pal;
|
||||
strncpy(palettes[i].gameName, gameName, 17);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -722,25 +784,35 @@ bool SavePaletteAs(bool silent, const char *name)
|
||||
bool LoadPalettes()
|
||||
{
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
int method = GCSettings.SaveMethod;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(SILENT);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PAL, method))
|
||||
return false;
|
||||
|
||||
char filepath[4][MAXPATHLEN];
|
||||
int numDevices;
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
#ifdef HW_RVL
|
||||
numDevices = 3;
|
||||
sprintf(filepath[0], "%s/%s", appPath, PAL_FILE_NAME);
|
||||
sprintf(filepath[1], "sd:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
||||
sprintf(filepath[2], "usb:/%s/%s", APPFOLDER, PAL_FILE_NAME);
|
||||
#else
|
||||
numDevices = 4;
|
||||
sprintf(filepath[0], "carda:/%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
|
||||
|
||||
offset = LoadFile(filepath, method, SILENT);
|
||||
for(int i=0; i<numDevices; i++)
|
||||
{
|
||||
offset = LoadFile(filepath[i], SILENT);
|
||||
|
||||
if(offset > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
retval = decodePalsData (method);
|
||||
retval = decodePalsData ();
|
||||
|
||||
FreeSaveBuffer ();
|
||||
|
||||
@ -751,7 +823,7 @@ bool LoadPalettes()
|
||||
if (!retval)
|
||||
retval = SavePalettes(SILENT);
|
||||
|
||||
return true;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void SetPalette(const char *gameName)
|
||||
|
@ -52,8 +52,7 @@ int ConfigRequested = 0;
|
||||
int ShutdownRequested = 0;
|
||||
int ResetRequested = 0;
|
||||
int ExitRequested = 0;
|
||||
char appPath[1024];
|
||||
int appLoadMethod = METHOD_AUTO;
|
||||
char appPath[1024] = { 0 };
|
||||
|
||||
extern FILE *out;
|
||||
|
||||
@ -89,7 +88,7 @@ void ExitApp()
|
||||
SavePrefs(SILENT);
|
||||
|
||||
if (ROMLoaded && !ConfigRequested && GCSettings.AutoSave == 1)
|
||||
SaveBatteryOrStateAuto(GCSettings.SaveMethod, FILE_SRAM, SILENT);
|
||||
SaveBatteryOrStateAuto(FILE_SRAM, SILENT);
|
||||
|
||||
ExitCleanup();
|
||||
|
||||
@ -176,35 +175,6 @@ static void ipl_set_config(unsigned char c)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void CreateAppPath(char origpath[])
|
||||
{
|
||||
#ifdef HW_DOL
|
||||
sprintf(appPath, GCSettings.SaveFolder);
|
||||
#else
|
||||
char path[1024];
|
||||
strncpy(path, origpath, 1024); // make a copy so we don't mess up original
|
||||
|
||||
char * loc;
|
||||
int pos = -1;
|
||||
|
||||
if(strncmp(path, "sd:/", 5) == 0 || strncmp(path, "fat:/", 5) == 0)
|
||||
appLoadMethod = METHOD_SD;
|
||||
else if(strncmp(path, "usb:/", 5) == 0)
|
||||
appLoadMethod = METHOD_USB;
|
||||
|
||||
loc = strrchr(path,'/');
|
||||
if (loc != NULL)
|
||||
*loc = 0; // strip file name
|
||||
|
||||
loc = strchr(path,'/'); // looking for first / (after sd: or usb:)
|
||||
if (loc != NULL)
|
||||
pos = loc - path + 1;
|
||||
|
||||
if(pos >= 0 && pos < 1024)
|
||||
sprintf(appPath, &(path[pos]));
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* USB Gecko Debugging
|
||||
***************************************************************************/
|
||||
@ -318,9 +288,10 @@ int main(int argc, char *argv[])
|
||||
InitGUIThreads();
|
||||
|
||||
// store path app was loaded from
|
||||
sprintf(appPath, "vbagx");
|
||||
#ifdef HW_RVL
|
||||
if(argc > 0 && argv[0] != NULL)
|
||||
CreateAppPath(argv[0]);
|
||||
#endif
|
||||
|
||||
StartWiiKeyboardMouse();
|
||||
|
||||
|
@ -17,31 +17,32 @@
|
||||
|
||||
#define APPNAME "Visual Boy Advance GX"
|
||||
#define APPVERSION "2.0.7"
|
||||
#define APPFOLDER "vbagx"
|
||||
#define PREF_FILE_NAME "settings.xml"
|
||||
#define PAL_FILE_NAME "palettes.xml"
|
||||
|
||||
#define NOTSILENT 0
|
||||
#define SILENT 1
|
||||
|
||||
const char pathPrefix[9][8] =
|
||||
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "mca:/", "mcb:/", "carda:/", "cardb:/" };
|
||||
|
||||
enum {
|
||||
METHOD_AUTO,
|
||||
METHOD_SD,
|
||||
METHOD_USB,
|
||||
METHOD_DVD,
|
||||
METHOD_SMB,
|
||||
METHOD_MC_SLOTA,
|
||||
METHOD_MC_SLOTB,
|
||||
METHOD_SD_SLOTA,
|
||||
METHOD_SD_SLOTB
|
||||
DEVICE_AUTO,
|
||||
DEVICE_SD,
|
||||
DEVICE_USB,
|
||||
DEVICE_DVD,
|
||||
DEVICE_SMB,
|
||||
DEVICE_MC_SLOTA,
|
||||
DEVICE_MC_SLOTB,
|
||||
DEVICE_SD_SLOTA,
|
||||
DEVICE_SD_SLOTB
|
||||
};
|
||||
|
||||
enum {
|
||||
FILE_SRAM,
|
||||
FILE_SNAPSHOT,
|
||||
FILE_ROM,
|
||||
FILE_CHEAT,
|
||||
FILE_PREF,
|
||||
FILE_PAL
|
||||
FILE_ROM
|
||||
};
|
||||
|
||||
struct SGCSettings{
|
||||
@ -83,7 +84,6 @@ extern int ConfigRequested;
|
||||
extern int ShutdownRequested;
|
||||
extern int ExitRequested;
|
||||
extern char appPath[];
|
||||
extern int appLoadMethod;
|
||||
extern FreeTypeGX *fontSystem[];
|
||||
|
||||
#endif
|
||||
|
@ -51,8 +51,8 @@ DefaultSettings ()
|
||||
/************** GameCube/Wii Settings *********************/
|
||||
ResetControls(); // controller button mappings
|
||||
|
||||
GCSettings.LoadMethod = METHOD_AUTO; // Auto, SD, DVD, USB, Network (SMB)
|
||||
GCSettings.SaveMethod = METHOD_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB)
|
||||
GCSettings.LoadMethod = DEVICE_AUTO; // Auto, SD, DVD, USB, Network (SMB)
|
||||
GCSettings.SaveMethod = DEVICE_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB)
|
||||
sprintf (GCSettings.LoadFolder,"vbagx/roms"); // Path to game files
|
||||
sprintf (GCSettings.SaveFolder,"vbagx/saves"); // Path to save files
|
||||
sprintf (GCSettings.CheatFolder,"vbagx/cheats"); // Path to cheat files
|
||||
|
@ -258,21 +258,19 @@ int MemCPUWriteBatteryFile(char * membuffer)
|
||||
* action = FILE_SNAPSHOT - Load state
|
||||
****************************************************************************/
|
||||
|
||||
bool LoadBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
bool LoadBatteryOrState(char * filepath, int action, bool silent)
|
||||
{
|
||||
bool result = false;
|
||||
int offset = 0;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
int device;
|
||||
|
||||
if(!FindDevice(filepath, &device))
|
||||
return 0;
|
||||
|
||||
AllocSaveBuffer();
|
||||
|
||||
// load the file into savebuffer
|
||||
offset = LoadFile(filepath, method, silent);
|
||||
offset = LoadFile(filepath, silent);
|
||||
|
||||
// load savebuffer into VBA memory
|
||||
if (offset > 0)
|
||||
@ -312,44 +310,34 @@ bool LoadBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool LoadBatteryOrStateAuto(int method, int action, bool silent)
|
||||
bool LoadBatteryOrStateAuto(int action, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
char filepath[MAXPATHLEN];
|
||||
char fullpath[MAXPATHLEN];
|
||||
char filepath2[MAXPATHLEN];
|
||||
char fullpath2[MAXPATHLEN];
|
||||
|
||||
if(!MakeFilePath(filepath, action, method, ROMFilename, 0))
|
||||
if(!MakeFilePath(filepath, action, ROMFilename, 0))
|
||||
return false;
|
||||
|
||||
if (action==FILE_SRAM)
|
||||
{
|
||||
if (LoadBatteryOrState(filepath, method, action, SILENT))
|
||||
if (LoadBatteryOrState(filepath, action, SILENT))
|
||||
return true;
|
||||
|
||||
// look for file with no number or Auto appended
|
||||
if(!MakeFilePath(filepath2, action, method, ROMFilename, -1))
|
||||
if(!MakeFilePath(filepath2, action, ROMFilename, -1))
|
||||
return false;
|
||||
|
||||
if(LoadBatteryOrState(filepath2, method, action, silent))
|
||||
if(LoadBatteryOrState(filepath2, action, silent))
|
||||
{
|
||||
// rename this file - append Auto
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to path
|
||||
sprintf(fullpath2, "%s%s", rootdir, filepath2); // add device to path
|
||||
rename(fullpath2, fullpath); // rename file (to avoid duplicates)
|
||||
rename(filepath2, filepath); // rename file (to avoid duplicates)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LoadBatteryOrState(filepath, method, action, silent);
|
||||
return LoadBatteryOrState(filepath, action, silent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,21 +348,19 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent)
|
||||
* action = 1 - Save state
|
||||
****************************************************************************/
|
||||
|
||||
bool SaveBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
bool SaveBatteryOrState(char * filepath, int action, bool silent)
|
||||
{
|
||||
bool result = false;
|
||||
int offset = 0;
|
||||
int datasize = 0; // we need the actual size of the data written
|
||||
int imgSize = 0; // image screenshot bytes written
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
int device;
|
||||
|
||||
if(!FindDevice(filepath, &device))
|
||||
return 0;
|
||||
|
||||
// save screenshot - I would prefer to do this from gameScreenTex
|
||||
if(action == FILE_SNAPSHOT && gameScreenTex2 != NULL && method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
||||
if(action == FILE_SNAPSHOT && gameScreenTex2 != NULL && device != DEVICE_MC_SLOTA && device != DEVICE_MC_SLOTB)
|
||||
{
|
||||
AllocSaveBuffer ();
|
||||
|
||||
@ -392,7 +378,7 @@ bool SaveBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
strncpy(screenpath, filepath, 1024);
|
||||
screenpath[strlen(screenpath)-4] = 0;
|
||||
sprintf(screenpath, "%s.png", screenpath);
|
||||
SaveFile(screenpath, imgSize, method, silent);
|
||||
SaveFile(screenpath, imgSize, silent);
|
||||
}
|
||||
|
||||
FreeSaveBuffer ();
|
||||
@ -401,7 +387,7 @@ bool SaveBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
AllocSaveBuffer();
|
||||
|
||||
// set comments for Memory Card saves
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||
{
|
||||
char savecomments[2][32];
|
||||
char savetype[10];
|
||||
@ -468,7 +454,7 @@ bool SaveBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
// write savebuffer into file
|
||||
if(datasize > 0)
|
||||
{
|
||||
offset = SaveFile(filepath, datasize, method, silent);
|
||||
offset = SaveFile(filepath, datasize, silent);
|
||||
|
||||
if(offset > 0)
|
||||
{
|
||||
@ -488,20 +474,14 @@ bool SaveBatteryOrState(char * filepath, int method, int action, bool silent)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SaveBatteryOrStateAuto(int method, int action, bool silent)
|
||||
bool SaveBatteryOrStateAuto(int action, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
char filepath[1024];
|
||||
|
||||
if(!MakeFilePath(filepath, action, method, ROMFilename, 0))
|
||||
if(!MakeFilePath(filepath, action, ROMFilename, 0))
|
||||
return false;
|
||||
|
||||
return SaveBatteryOrState(filepath, method, action, silent);
|
||||
return SaveBatteryOrState(filepath, action, silent);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -878,7 +858,7 @@ static void ApplyPerImagePreferences()
|
||||
}
|
||||
}
|
||||
|
||||
void LoadPatch(int method)
|
||||
void LoadPatch()
|
||||
{
|
||||
int patchsize = 0;
|
||||
int patchtype;
|
||||
@ -893,7 +873,7 @@ void LoadPatch(int method)
|
||||
|
||||
for(patchtype=0; patchtype<3; patchtype++)
|
||||
{
|
||||
patchsize = LoadFile(patchpath[patchtype], method, SILENT);
|
||||
patchsize = LoadFile(patchpath[patchtype], SILENT);
|
||||
|
||||
if(patchsize)
|
||||
break;
|
||||
@ -932,7 +912,7 @@ void LoadPatch(int method)
|
||||
|
||||
extern bool gbUpdateSizes();
|
||||
|
||||
bool LoadGBROM(int method)
|
||||
bool LoadGBROM()
|
||||
{
|
||||
gbRom = (u8 *)memalign(32, 1024*1024*4); // allocate 4 MB to GB ROM
|
||||
bios = (u8 *)calloc(1,0x100);
|
||||
@ -943,21 +923,23 @@ bool LoadGBROM(int method)
|
||||
{
|
||||
char filepath[1024];
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
||||
if(!MakeFilePath(filepath, FILE_ROM))
|
||||
return false;
|
||||
|
||||
gbRomSize = LoadFile ((char *)gbRom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
||||
gbRomSize = LoadFile ((char *)gbRom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (method)
|
||||
int device = GCSettings.LoadMethod;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
case METHOD_SMB:
|
||||
case DEVICE_SD:
|
||||
case DEVICE_USB:
|
||||
case DEVICE_SMB:
|
||||
gbRomSize = LoadSzFile(szpath, (unsigned char *)gbRom);
|
||||
break;
|
||||
case METHOD_DVD:
|
||||
case DEVICE_DVD:
|
||||
gbRomSize = SzExtractFile(browserList[browser.selIndex].offset, (unsigned char *)gbRom);
|
||||
break;
|
||||
}
|
||||
@ -969,7 +951,7 @@ bool LoadGBROM(int method)
|
||||
return gbUpdateSizes();
|
||||
}
|
||||
|
||||
bool LoadVBAROM(int method)
|
||||
bool LoadVBAROM()
|
||||
{
|
||||
cartridgeType = 0;
|
||||
bool loaded = false;
|
||||
@ -982,7 +964,7 @@ bool LoadVBAROM(int method)
|
||||
else if(utilIsZipFile(browserList[browser.selIndex].filename))
|
||||
{
|
||||
// we need to check the file extension of the first file in the archive
|
||||
char * zippedFilename = GetFirstZipFilename (method);
|
||||
char * zippedFilename = GetFirstZipFilename ();
|
||||
|
||||
if(zippedFilename != NULL)
|
||||
{
|
||||
@ -1023,7 +1005,7 @@ bool LoadVBAROM(int method)
|
||||
emulator = GBASystem;
|
||||
srcWidth = 240;
|
||||
srcHeight = 160;
|
||||
loaded = VMCPULoadROM(method);
|
||||
loaded = VMCPULoadROM();
|
||||
srcPitch = 484;
|
||||
soundSetSampleRate(44100 / 2);
|
||||
cpuSaveType = 0;
|
||||
@ -1051,7 +1033,7 @@ bool LoadVBAROM(int method)
|
||||
gbBorderRowSkip = 0;
|
||||
}
|
||||
|
||||
loaded = LoadGBROM(method);
|
||||
loaded = LoadGBROM();
|
||||
srcPitch = 324;
|
||||
soundSetSampleRate(44100);
|
||||
break;
|
||||
@ -1075,7 +1057,7 @@ bool LoadVBAROM(int method)
|
||||
//if (gbHardware & 5)
|
||||
//gbCPUInit(gbBiosFileName, useBios);
|
||||
|
||||
LoadPatch(method);
|
||||
LoadPatch();
|
||||
|
||||
// Apply preferences specific to this game
|
||||
gbApplyPerImagePreferences();
|
||||
@ -1099,7 +1081,7 @@ bool LoadVBAROM(int method)
|
||||
|
||||
soundReset();
|
||||
CPUInit(NULL, false);
|
||||
LoadPatch(method);
|
||||
LoadPatch();
|
||||
CPUReset();
|
||||
}
|
||||
|
||||
@ -1124,9 +1106,6 @@ bool LoadVBAROM(int method)
|
||||
|
||||
void InitialisePalette()
|
||||
{
|
||||
#ifdef CARLLOG
|
||||
log("InitialisePalette();");
|
||||
#endif
|
||||
int i;
|
||||
// Build GBPalette
|
||||
for( i = 0; i < 24; )
|
||||
|
@ -20,12 +20,12 @@ extern u32 RomIdCode;
|
||||
extern bool TiltSideways;
|
||||
extern char RomTitle[];
|
||||
|
||||
bool LoadVBAROM(int method);
|
||||
bool LoadVBAROM();
|
||||
void InitialisePalette();
|
||||
bool IsGameboyGame();
|
||||
bool LoadBatteryOrState(char * filepath, int method, int action, bool silent);
|
||||
bool LoadBatteryOrStateAuto(int method, int action, bool silent);
|
||||
bool SaveBatteryOrState(char * filepath, int method, int action, bool silent);
|
||||
bool SaveBatteryOrStateAuto(int method, int action, bool silent);
|
||||
bool LoadBatteryOrState(char * filepath, int action, bool silent);
|
||||
bool LoadBatteryOrStateAuto(int action, bool silent);
|
||||
bool SaveBatteryOrState(char * filepath, int action, bool silent);
|
||||
bool SaveBatteryOrStateAuto(int action, bool silent);
|
||||
|
||||
#endif
|
||||
|
@ -155,32 +155,33 @@ static void VMAllocGBA( void )
|
||||
* MEM2 version of GBA CPULoadROM
|
||||
****************************************************************************/
|
||||
|
||||
bool VMCPULoadROM(int method)
|
||||
bool VMCPULoadROM()
|
||||
{
|
||||
VMClose();
|
||||
VMAllocGBA();
|
||||
GBAROMSize = 0;
|
||||
int device = GCSettings.LoadMethod;
|
||||
rom = (u8 *)MEM2Storage;
|
||||
|
||||
if(!inSz)
|
||||
{
|
||||
char filepath[1024];
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
||||
if(!MakeFilePath(filepath, FILE_ROM))
|
||||
return false;
|
||||
|
||||
GBAROMSize = LoadFile ((char *)rom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
||||
GBAROMSize = LoadFile ((char *)rom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (method)
|
||||
switch (device)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
case METHOD_SMB:
|
||||
case DEVICE_SD:
|
||||
case DEVICE_USB:
|
||||
case DEVICE_SMB:
|
||||
GBAROMSize = LoadSzFile(szpath, (unsigned char *)rom);
|
||||
break;
|
||||
case METHOD_DVD:
|
||||
case DEVICE_DVD:
|
||||
GBAROMSize = SzExtractFile(browserList[browser.selIndex].offset, (unsigned char *)rom);
|
||||
break;
|
||||
}
|
||||
@ -271,27 +272,13 @@ static void VMInit( void )
|
||||
* VM version of GBA CPULoadROM
|
||||
****************************************************************************/
|
||||
|
||||
int VMCPULoadROM(int method)
|
||||
int VMCPULoadROM()
|
||||
{
|
||||
int res;
|
||||
char msg[512];
|
||||
char filepath[MAXPATHLEN];
|
||||
|
||||
if(!ChangeInterface(method, NOTSILENT))
|
||||
return 0;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0; // not implemented
|
||||
break;
|
||||
}
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
||||
if(!MakeFilePath(filepath, FILE_ROM))
|
||||
return false;
|
||||
|
||||
// loading compressed files via VM is not supported
|
||||
@ -301,14 +288,10 @@ int VMCPULoadROM(int method)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
|
||||
if (romfile != NULL)
|
||||
fclose(romfile);
|
||||
|
||||
romfile = fopen(fullpath, "rb");
|
||||
romfile = fopen(filepath, "rb");
|
||||
|
||||
if (romfile == NULL)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef __VBAVMHDR__
|
||||
#define __VBAVMHDR__
|
||||
|
||||
bool VMCPULoadROM(int method);
|
||||
bool VMCPULoadROM();
|
||||
void VMClose();
|
||||
|
||||
#ifdef USE_VM
|
||||
|
Loading…
Reference in New Issue
Block a user