mirror of
https://github.com/dborth/fceugx.git
synced 2024-11-01 06:55:05 +01:00
code restructure, revamp filebrowser
This commit is contained in:
parent
3d812c139b
commit
d9a5ade126
@ -124,20 +124,20 @@ SetupCheats()
|
|||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
int method = GCSettings.SaveMethod;
|
int device = GCSettings.SaveMethod;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(device == DEVICE_AUTO)
|
||||||
method = autoSaveMethod(SILENT);
|
device = autoSaveMethod(SILENT);
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(device == DEVICE_AUTO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_CHEAT, method))
|
if(!MakeFilePath(filepath, FILE_CHEAT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, SILENT);
|
offset = LoadFile(filepath, SILENT);
|
||||||
|
|
||||||
// load cheat file if present
|
// load cheat file if present
|
||||||
if(offset > 0)
|
if(offset > 0)
|
||||||
@ -160,9 +160,9 @@ void OpenGameGenie()
|
|||||||
return;
|
return;
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if (MakeFilePath(filepath, FILE_GGROM, GCSettings.LoadMethod))
|
if (MakeFilePath(filepath, FILE_GGROM))
|
||||||
{
|
{
|
||||||
romSize = LoadFile(tmpbuffer, filepath, 0, GCSettings.LoadMethod, SILENT);
|
romSize = LoadFile(tmpbuffer, filepath, 0, SILENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (romSize > 0)
|
if (romSize > 0)
|
||||||
|
@ -472,6 +472,9 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
browserList[entrycount].offset <<= 11;
|
browserList[entrycount].offset <<= 11;
|
||||||
browserList[entrycount].isdir = browserList[entrycount].isdir & 2;
|
browserList[entrycount].isdir = browserList[entrycount].isdir & 2;
|
||||||
|
|
||||||
|
if(browserList[entrycount].isdir)
|
||||||
|
browserList[entrycount].icon = ICON_FOLDER;
|
||||||
|
|
||||||
/*** Prepare for next entry ***/
|
/*** Prepare for next entry ***/
|
||||||
|
|
||||||
diroffset += dvdbuffer[diroffset];
|
diroffset += dvdbuffer[diroffset];
|
||||||
@ -588,7 +591,7 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
|||||||
|
|
||||||
if(browserList[dirindex].isdir) // only parse directories
|
if(browserList[dirindex].isdir) // only parse directories
|
||||||
{
|
{
|
||||||
UpdateDirName(METHOD_DVD);
|
UpdateDirName();
|
||||||
ParseDVDdirectory();
|
ParseDVDdirectory();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -667,7 +670,7 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
|
|
||||||
if (IsZipFile (readbuffer))
|
if (IsZipFile (readbuffer))
|
||||||
{
|
{
|
||||||
result = UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
result = UnZipBuffer (buffer, DEVICE_DVD); // unzip from dvd
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -82,8 +82,8 @@ DefaultSettings ()
|
|||||||
GCSettings.SFXVolume = 40;
|
GCSettings.SFXVolume = 40;
|
||||||
GCSettings.Rumble = 1;
|
GCSettings.Rumble = 1;
|
||||||
|
|
||||||
GCSettings.LoadMethod = METHOD_AUTO; // Auto, SD, DVD, USB, Network (SMB)
|
GCSettings.LoadMethod = DEVICE_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.SaveMethod = DEVICE_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB)
|
||||||
sprintf (GCSettings.LoadFolder,"fceugx/roms"); // Path to game files
|
sprintf (GCSettings.LoadFolder,"fceugx/roms"); // Path to game files
|
||||||
sprintf (GCSettings.SaveFolder,"fceugx/saves"); // Path to save files
|
sprintf (GCSettings.SaveFolder,"fceugx/saves"); // Path to save files
|
||||||
sprintf (GCSettings.CheatFolder,"fceugx/cheats"); // Path to cheat files
|
sprintf (GCSettings.CheatFolder,"fceugx/cheats"); // Path to cheat files
|
||||||
|
@ -60,8 +60,7 @@ int ConfigRequested = 0;
|
|||||||
int ShutdownRequested = 0;
|
int ShutdownRequested = 0;
|
||||||
int ResetRequested = 0;
|
int ResetRequested = 0;
|
||||||
int ExitRequested = 0;
|
int ExitRequested = 0;
|
||||||
char appPath[1024];
|
char appPath[1024] = { 0 };
|
||||||
int appLoadMethod = METHOD_AUTO;
|
|
||||||
int frameskip = 0;
|
int frameskip = 0;
|
||||||
unsigned char * nesrom = NULL;
|
unsigned char * nesrom = NULL;
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ void ExitApp()
|
|||||||
SavePrefs(SILENT);
|
SavePrefs(SILENT);
|
||||||
|
|
||||||
if (romLoaded && !ConfigRequested && GCSettings.AutoSave == 1)
|
if (romLoaded && !ConfigRequested && GCSettings.AutoSave == 1)
|
||||||
SaveRAMAuto(GCSettings.SaveMethod, SILENT);
|
SaveRAMAuto(SILENT);
|
||||||
|
|
||||||
ExitCleanup();
|
ExitCleanup();
|
||||||
|
|
||||||
@ -183,35 +182,6 @@ static void ipl_set_config(unsigned char c)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
* USB Gecko Debugging
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -313,9 +283,10 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// store path app was loaded from
|
// store path app was loaded from
|
||||||
sprintf(appPath, "fceugx");
|
#ifdef HW_RVL
|
||||||
if(argc > 0 && argv[0] != NULL)
|
if(argc > 0 && argv[0] != NULL)
|
||||||
CreateAppPath(argv[0]);
|
CreateAppPath(argv[0]);
|
||||||
|
#endif
|
||||||
|
|
||||||
MountAllFAT(); // Initialize libFAT for SD and USB
|
MountAllFAT(); // Initialize libFAT for SD and USB
|
||||||
|
|
||||||
|
@ -18,21 +18,25 @@
|
|||||||
|
|
||||||
#define APPNAME "FCE Ultra GX"
|
#define APPNAME "FCE Ultra GX"
|
||||||
#define APPVERSION "3.0.9"
|
#define APPVERSION "3.0.9"
|
||||||
|
#define APPFOLDER "fceugx"
|
||||||
#define PREF_FILE_NAME "settings.xml"
|
#define PREF_FILE_NAME "settings.xml"
|
||||||
|
|
||||||
#define NOTSILENT 0
|
#define NOTSILENT 0
|
||||||
#define SILENT 1
|
#define SILENT 1
|
||||||
|
|
||||||
|
const char pathPrefix[9][8] =
|
||||||
|
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "mca:/", "mcb:/", "carda:/", "cardb:/" };
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
METHOD_AUTO,
|
DEVICE_AUTO,
|
||||||
METHOD_SD,
|
DEVICE_SD,
|
||||||
METHOD_USB,
|
DEVICE_USB,
|
||||||
METHOD_DVD,
|
DEVICE_DVD,
|
||||||
METHOD_SMB,
|
DEVICE_SMB,
|
||||||
METHOD_MC_SLOTA,
|
DEVICE_MC_SLOTA,
|
||||||
METHOD_MC_SLOTB,
|
DEVICE_MC_SLOTB,
|
||||||
METHOD_SD_SLOTA,
|
DEVICE_SD_SLOTA,
|
||||||
METHOD_SD_SLOTB
|
DEVICE_SD_SLOTB
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -41,8 +45,7 @@ enum {
|
|||||||
FILE_ROM,
|
FILE_ROM,
|
||||||
FILE_FDSBIOS,
|
FILE_FDSBIOS,
|
||||||
FILE_GGROM,
|
FILE_GGROM,
|
||||||
FILE_CHEAT,
|
FILE_CHEAT
|
||||||
FILE_PREF
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -100,7 +103,6 @@ extern int ConfigRequested;
|
|||||||
extern int ShutdownRequested;
|
extern int ShutdownRequested;
|
||||||
extern int ExitRequested;
|
extern int ExitRequested;
|
||||||
extern char appPath[];
|
extern char appPath[];
|
||||||
extern int appLoadMethod;
|
|
||||||
extern int frameskip;
|
extern int frameskip;
|
||||||
extern bool romLoaded;
|
extern bool romLoaded;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ bool romLoaded = false;
|
|||||||
|
|
||||||
#define SAMPLERATE 48000
|
#define SAMPLERATE 48000
|
||||||
|
|
||||||
int GCMemROM(int method, int size)
|
int GCMemROM(int size)
|
||||||
{
|
{
|
||||||
ResetGameLoaded();
|
ResetGameLoaded();
|
||||||
|
|
||||||
@ -94,9 +94,9 @@ int GCMemROM(int method, int size)
|
|||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if (MakeFilePath(filepath, FILE_FDSBIOS, method))
|
if (MakeFilePath(filepath, FILE_FDSBIOS))
|
||||||
{
|
{
|
||||||
biosSize = LoadFile(tmpbuffer, filepath, 0, method, SILENT);
|
biosSize = LoadFile(tmpbuffer, filepath, 0, SILENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biosSize == 8192)
|
if (biosSize == 8192)
|
||||||
|
@ -9,5 +9,5 @@
|
|||||||
* NES Memory Load Game
|
* NES Memory Load Game
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int GCMemROM(int method, int size);
|
int GCMemROM(int size);
|
||||||
extern bool romLoaded;
|
extern bool romLoaded;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
|
||||||
static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation)
|
||||||
{
|
{
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
|
|
||||||
@ -50,11 +50,15 @@ static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveRAM (char * filepath, int method, bool silent)
|
bool SaveRAM (char * filepath, bool silent)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
int datasize = 0;
|
int datasize = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
int device;
|
||||||
|
|
||||||
|
if(!FindDevice(filepath, &device))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(GameInfo->type == GIT_FDS)
|
if(GameInfo->type == GIT_FDS)
|
||||||
{
|
{
|
||||||
@ -63,23 +67,17 @@ bool SaveRAM (char * filepath, int method, bool silent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
// save game save to savebuffer
|
// save game save to savebuffer
|
||||||
if(GameInfo->type == GIT_CART)
|
if(GameInfo->type == GIT_CART)
|
||||||
datasize = NGCFCEU_GameSave(&iNESCart, 0, method);
|
datasize = NGCFCEU_GameSave(&iNESCart, 0);
|
||||||
else if(GameInfo->type == GIT_VSUNI)
|
else if(GameInfo->type == GIT_VSUNI)
|
||||||
datasize = NGCFCEU_GameSave(&UNIFCart, 0, method);
|
datasize = NGCFCEU_GameSave(&UNIFCart, 0);
|
||||||
|
|
||||||
if (datasize)
|
if (datasize)
|
||||||
{
|
{
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||||
{
|
{
|
||||||
// Set the comments
|
// Set the comments
|
||||||
char comments[2][32];
|
char comments[2][32];
|
||||||
@ -89,7 +87,7 @@ bool SaveRAM (char * filepath, int method, bool silent)
|
|||||||
SetMCSaveComments(comments);
|
SetMCSaveComments(comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
offset = SaveFile(filepath, datasize, silent);
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
@ -108,46 +106,38 @@ bool SaveRAM (char * filepath, int method, bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SaveRAMAuto (int method, bool silent)
|
SaveRAMAuto (bool silent)
|
||||||
{
|
{
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_RAM, method, romFilename, 0))
|
if(!MakeFilePath(filepath, FILE_RAM, romFilename, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return SaveRAM(filepath, method, silent);
|
return SaveRAM(filepath, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadRAM (char * filepath, int method, bool silent)
|
bool LoadRAM (char * filepath, bool silent)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
int device;
|
||||||
|
|
||||||
|
if(!FindDevice(filepath, &device))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(GameInfo->type == GIT_FDS) // RAM saves don't exist for FDS games
|
if(GameInfo->type == GIT_FDS) // RAM saves don't exist for FDS games
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, silent);
|
offset = LoadFile(filepath, silent);
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
if(GameInfo->type == GIT_CART)
|
if(GameInfo->type == GIT_CART)
|
||||||
NGCFCEU_GameSave(&iNESCart, 1, method);
|
NGCFCEU_GameSave(&iNESCart, 1);
|
||||||
else if(GameInfo->type == GIT_VSUNI)
|
else if(GameInfo->type == GIT_VSUNI)
|
||||||
NGCFCEU_GameSave(&UNIFCart, 1, method);
|
NGCFCEU_GameSave(&UNIFCart, 1);
|
||||||
|
|
||||||
ResetNES();
|
ResetNES();
|
||||||
retval = true;
|
retval = true;
|
||||||
@ -163,36 +153,26 @@ bool LoadRAM (char * filepath, int method, bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LoadRAMAuto (int method, bool silent)
|
LoadRAMAuto (bool silent)
|
||||||
{
|
{
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char filepath[MAXPATHLEN];
|
char filepath[MAXPATHLEN];
|
||||||
char fullpath[MAXPATHLEN];
|
|
||||||
char filepath2[MAXPATHLEN];
|
char filepath2[MAXPATHLEN];
|
||||||
char fullpath2[MAXPATHLEN];
|
|
||||||
|
|
||||||
// look for Auto save file
|
// look for Auto save file
|
||||||
if(!MakeFilePath(filepath, FILE_RAM, method, romFilename, 0))
|
if(!MakeFilePath(filepath, FILE_RAM, romFilename, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (LoadRAM(filepath, method, silent))
|
if (LoadRAM(filepath, silent))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// look for file with no number or Auto appended
|
// look for file with no number or Auto appended
|
||||||
if(!MakeFilePath(filepath2, FILE_RAM, method, romFilename, -1))
|
if(!MakeFilePath(filepath2, FILE_RAM, romFilename, -1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(LoadRAM(filepath2, method, silent))
|
if(LoadRAM(filepath2, silent))
|
||||||
{
|
{
|
||||||
// rename this file - append Auto
|
// rename this file - append Auto
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to path
|
rename(filepath2, filepath); // rename file (to avoid duplicates)
|
||||||
sprintf(fullpath2, "%s%s", rootdir, filepath2); // add device to path
|
|
||||||
rename(fullpath2, fullpath); // rename file (to avoid duplicates)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* Memory Based Load/Save RAM Manager
|
* Memory Based Load/Save RAM Manager
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool SaveRAM (char * filepath, int method, bool silent);
|
bool SaveRAM (char * filepath, bool silent);
|
||||||
bool SaveRAMAuto (int method, bool silent);
|
bool SaveRAMAuto (bool silent);
|
||||||
bool LoadRAM (char * filepath, int method, bool silent);
|
bool LoadRAM (char * filepath, bool silent);
|
||||||
bool LoadRAMAuto (int method, bool silent);
|
bool LoadRAMAuto (bool silent);
|
||||||
|
@ -28,21 +28,19 @@
|
|||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "gcvideo.h"
|
#include "gcvideo.h"
|
||||||
|
|
||||||
bool SaveState (char * filepath, int method, bool silent)
|
bool SaveState (char * filepath, bool silent)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
int datasize;
|
int datasize;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int imgSize = 0; // image screenshot bytes written
|
int imgSize = 0; // image screenshot bytes written
|
||||||
|
int device;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(!FindDevice(filepath, &device))
|
||||||
method = autoSaveMethod(silent);
|
return 0;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// save screenshot - I would prefer to do this from gameScreenTex
|
// save screenshot - I would prefer to do this from gameScreenTex
|
||||||
if(gameScreenTex2 != NULL && method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
if(gameScreenTex2 != NULL && device != DEVICE_MC_SLOTA && device != DEVICE_MC_SLOTB)
|
||||||
{
|
{
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ bool SaveState (char * filepath, int method, bool silent)
|
|||||||
strncpy(screenpath, filepath, 1024);
|
strncpy(screenpath, filepath, 1024);
|
||||||
screenpath[strlen(screenpath)-4] = 0;
|
screenpath[strlen(screenpath)-4] = 0;
|
||||||
sprintf(screenpath, "%s.png", screenpath);
|
sprintf(screenpath, "%s.png", screenpath);
|
||||||
SaveFile(screenpath, imgSize, method, silent);
|
SaveFile(screenpath, imgSize, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
@ -73,7 +71,7 @@ bool SaveState (char * filepath, int method, bool silent)
|
|||||||
|
|
||||||
if (datasize)
|
if (datasize)
|
||||||
{
|
{
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||||
{
|
{
|
||||||
// Set the comments
|
// Set the comments
|
||||||
char comments[2][32];
|
char comments[2][32];
|
||||||
@ -82,7 +80,7 @@ bool SaveState (char * filepath, int method, bool silent)
|
|||||||
snprintf (comments[1], 32, romFilename);
|
snprintf (comments[1], 32, romFilename);
|
||||||
SetMCSaveComments(comments);
|
SetMCSaveComments(comments);
|
||||||
}
|
}
|
||||||
offset = SaveFile(save.buf(), filepath, datasize, method, silent);
|
offset = SaveFile(save.buf(), filepath, datasize, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
@ -95,36 +93,28 @@ bool SaveState (char * filepath, int method, bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SaveStateAuto (int method, bool silent)
|
SaveStateAuto (bool silent)
|
||||||
{
|
{
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_STATE, method, romFilename, 0))
|
if(!MakeFilePath(filepath, FILE_STATE, romFilename, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return SaveState(filepath, method, silent);
|
return SaveState(filepath, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadState (char * filepath, int method, bool silent)
|
bool LoadState (char * filepath, bool silent)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
int device;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(!FindDevice(filepath, &device))
|
||||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
return 0;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, silent);
|
offset = LoadFile(filepath, silent);
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
@ -143,18 +133,12 @@ bool LoadState (char * filepath, int method, bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LoadStateAuto (int method, bool silent)
|
LoadStateAuto (bool silent)
|
||||||
{
|
{
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_STATE, method, romFilename, 0))
|
if(!MakeFilePath(filepath, FILE_STATE, romFilename, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return LoadState(filepath, method, silent);
|
return LoadState(filepath, silent);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* Memory Based Load/Save State Manager
|
* Memory Based Load/Save State Manager
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool SaveState (char * filepath, int method, bool silent);
|
bool SaveState (char * filepath, bool silent);
|
||||||
bool SaveStateAuto (int method, bool silent);
|
bool SaveStateAuto (bool silent);
|
||||||
bool LoadState (char * filepath, int method, bool silent);
|
bool LoadState (char * filepath, bool silent);
|
||||||
bool LoadStateAuto (int method, bool silent);
|
bool LoadStateAuto (bool silent);
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
BROWSERINFO browser;
|
BROWSERINFO browser;
|
||||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||||
|
|
||||||
char rootdir[10];
|
|
||||||
static char szpath[MAXPATHLEN];
|
static char szpath[MAXPATHLEN];
|
||||||
static bool inSz = false;
|
static bool inSz = false;
|
||||||
|
|
||||||
@ -45,62 +44,62 @@ char romFilename[256];
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* autoLoadMethod()
|
* autoLoadMethod()
|
||||||
* Auto-determines and sets the load method
|
* Auto-determines and sets the load device
|
||||||
* Returns method set
|
* Returns device set
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int autoLoadMethod()
|
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))
|
if(ChangeInterface(DEVICE_SD, SILENT))
|
||||||
method = METHOD_SD;
|
device = DEVICE_SD;
|
||||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
else if(ChangeInterface(DEVICE_USB, SILENT))
|
||||||
method = METHOD_USB;
|
device = DEVICE_USB;
|
||||||
else if(ChangeInterface(METHOD_DVD, SILENT))
|
else if(ChangeInterface(DEVICE_DVD, SILENT))
|
||||||
method = METHOD_DVD;
|
device = DEVICE_DVD;
|
||||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
else if(ChangeInterface(DEVICE_SMB, SILENT))
|
||||||
method = METHOD_SMB;
|
device = DEVICE_SMB;
|
||||||
else
|
else
|
||||||
ErrorPrompt("Unable to auto-determine load method!");
|
ErrorPrompt("Unable to locate a load device!");
|
||||||
|
|
||||||
if(GCSettings.LoadMethod == METHOD_AUTO)
|
if(GCSettings.LoadMethod == DEVICE_AUTO)
|
||||||
GCSettings.LoadMethod = method; // save method found for later use
|
GCSettings.LoadMethod = device; // save device found for later use
|
||||||
CancelAction();
|
CancelAction();
|
||||||
return method;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* autoSaveMethod()
|
* autoSaveMethod()
|
||||||
* Auto-determines and sets the save method
|
* Auto-determines and sets the save device
|
||||||
* Returns method set
|
* Returns device set
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int autoSaveMethod(bool silent)
|
int autoSaveMethod(bool silent)
|
||||||
{
|
{
|
||||||
if(!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))
|
if(ChangeInterface(DEVICE_SD, SILENT))
|
||||||
method = METHOD_SD;
|
device = DEVICE_SD;
|
||||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
else if(ChangeInterface(DEVICE_USB, SILENT))
|
||||||
method = METHOD_USB;
|
device = DEVICE_USB;
|
||||||
else if(ChangeInterface(METHOD_MC_SLOTA, SILENT))
|
else if(ChangeInterface(DEVICE_MC_SLOTA, SILENT))
|
||||||
method = METHOD_MC_SLOTA;
|
device = DEVICE_MC_SLOTA;
|
||||||
else if(ChangeInterface(METHOD_MC_SLOTB, SILENT))
|
else if(ChangeInterface(DEVICE_MC_SLOTB, SILENT))
|
||||||
method = METHOD_MC_SLOTB;
|
device = DEVICE_MC_SLOTB;
|
||||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
else if(ChangeInterface(DEVICE_SMB, SILENT))
|
||||||
method = METHOD_SMB;
|
device = DEVICE_SMB;
|
||||||
else if(!silent)
|
else if(!silent)
|
||||||
ErrorPrompt("Unable to auto-determine save method!");
|
ErrorPrompt("Unable to locate a save device!");
|
||||||
|
|
||||||
if(GCSettings.SaveMethod == METHOD_AUTO)
|
if(GCSettings.SaveMethod == DEVICE_AUTO)
|
||||||
GCSettings.SaveMethod = method; // save method found for later use
|
GCSettings.SaveMethod = device; // save device found for later use
|
||||||
|
|
||||||
CancelAction();
|
CancelAction();
|
||||||
return method;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -122,6 +121,26 @@ void ResetBrowser()
|
|||||||
// set aside space for 1 entry
|
// set aside space for 1 entry
|
||||||
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
|
||||||
memset(browserList, 0, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -130,6 +149,9 @@ void ResetBrowser()
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static void CleanupPath(char * path)
|
static void CleanupPath(char * path)
|
||||||
{
|
{
|
||||||
|
if(!path || path[0] == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
int pathlen = strlen(path);
|
int pathlen = strlen(path);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for(int i=0; i < pathlen && i < MAXPATHLEN; i++)
|
for(int i=0; i < pathlen && i < MAXPATHLEN; i++)
|
||||||
@ -141,23 +163,41 @@ static void CleanupPath(char * path)
|
|||||||
path[j++] = path[i];
|
path[j++] = path[i];
|
||||||
}
|
}
|
||||||
path[j] = 0;
|
path[j] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen(path) == 0)
|
bool IsDeviceRoot(char * path)
|
||||||
sprintf(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()
|
* UpdateDirName()
|
||||||
* Update curent directory name for file browser
|
* Update curent directory name for file browser
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int UpdateDirName(int method)
|
int UpdateDirName()
|
||||||
{
|
{
|
||||||
int size=0;
|
int size=0;
|
||||||
char * test;
|
char * test;
|
||||||
char temp[1024];
|
char temp[1024];
|
||||||
|
int device = 0;
|
||||||
|
|
||||||
|
if(browser.numEntries == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
FindDevice(browser.dir, &device);
|
||||||
|
|
||||||
// update DVD directory
|
// update DVD directory
|
||||||
if(method == METHOD_DVD)
|
if(device == DEVICE_DVD)
|
||||||
SetDVDdirectory(browserList[browser.selIndex].offset, browserList[browser.selIndex].length);
|
SetDVDdirectory(browserList[browser.selIndex].offset, browserList[browser.selIndex].length);
|
||||||
|
|
||||||
/* current directory doesn't change */
|
/* current directory doesn't change */
|
||||||
@ -168,18 +208,26 @@ int UpdateDirName(int method)
|
|||||||
/* go up to parent directory */
|
/* go up to parent directory */
|
||||||
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
|
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
|
||||||
{
|
{
|
||||||
/* determine last subdirectory namelength */
|
// already at the top level
|
||||||
sprintf(temp,"%s",browser.dir);
|
if(IsDeviceRoot(browser.dir))
|
||||||
test = strtok(temp,"/");
|
|
||||||
while (test != NULL)
|
|
||||||
{
|
{
|
||||||
size = strlen(test);
|
browser.dir[0] = 0; // remove device - we are going to the device listing screen
|
||||||
test = strtok(NULL,"/");
|
|
||||||
}
|
}
|
||||||
|
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 */
|
/* remove last subdirectory name */
|
||||||
size = strlen(browser.dir) - size - 1;
|
size = strlen(browser.dir) - size - 1;
|
||||||
browser.dir[size] = 0;
|
browser.dir[size] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -201,7 +249,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 file[512];
|
||||||
char folder[1024];
|
char folder[1024];
|
||||||
@ -235,7 +283,7 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
|
|||||||
|
|
||||||
if(filenum >= -1)
|
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)
|
if(filenum > 9)
|
||||||
{
|
{
|
||||||
@ -272,28 +320,26 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
|
|||||||
sprintf(folder, "fceugx");
|
sprintf(folder, "fceugx");
|
||||||
sprintf(file, "disksys.rom");
|
sprintf(file, "disksys.rom");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_GGROM:
|
case FILE_GGROM:
|
||||||
sprintf(folder, "fceugx");
|
sprintf(folder, "fceugx");
|
||||||
sprintf(file, "gg.rom");
|
sprintf(file, "gg.rom");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_CHEAT:
|
case FILE_CHEAT:
|
||||||
sprintf(folder, GCSettings.CheatFolder);
|
sprintf(folder, GCSettings.CheatFolder);
|
||||||
sprintf(file, "%s.cht", romFilename);
|
sprintf(file, "%s.cht", romFilename);
|
||||||
break;
|
break;
|
||||||
case FILE_PREF:
|
|
||||||
sprintf(folder, appPath);
|
|
||||||
sprintf(file, "%s", PREF_FILE_NAME);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
switch(method)
|
switch(GCSettings.SaveMethod)
|
||||||
{
|
{
|
||||||
case METHOD_MC_SLOTA:
|
case DEVICE_MC_SLOTA:
|
||||||
case METHOD_MC_SLOTB:
|
case DEVICE_MC_SLOTB:
|
||||||
sprintf (temppath, "%s", file);
|
sprintf (temppath, "%s%s", pathPrefix[GCSettings.SaveMethod], file);
|
||||||
temppath[31] = 0; // truncate filename
|
temppath[31] = 0; // truncate filename
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf (temppath, "/%s/%s", folder, file);
|
sprintf (temppath, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], folder, file);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +348,7 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/****************************************************************************
|
||||||
* FileSortCallback
|
* FileSortCallback
|
||||||
*
|
*
|
||||||
* Quick sort callback to sort file entries with the following order:
|
* Quick sort callback to sort file entries with the following order:
|
||||||
@ -337,8 +383,7 @@ int FileSortCallback(const void *f1, const void *f2)
|
|||||||
* If the file is a zip, we will check the file extension / file size of the
|
* If the file is a zip, we will check the file extension / file size of the
|
||||||
* first file inside
|
* first file inside
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
static bool IsValidROM()
|
||||||
bool IsValidROM(int method)
|
|
||||||
{
|
{
|
||||||
// file size should be between 8K and 3MB
|
// file size should be between 8K and 3MB
|
||||||
if(browserList[browser.selIndex].length < (1024*8) ||
|
if(browserList[browser.selIndex].length < (1024*8) ||
|
||||||
@ -357,7 +402,7 @@ bool IsValidROM(int method)
|
|||||||
if(stricmp(p, ".zip") == 0 && !inSz)
|
if(stricmp(p, ".zip") == 0 && !inSz)
|
||||||
{
|
{
|
||||||
// we need to check the file extension of the first file in the archive
|
// we need to check the file extension of the first file in the archive
|
||||||
char * zippedFilename = GetFirstZipFilename (method);
|
char * zippedFilename = GetFirstZipFilename ();
|
||||||
|
|
||||||
if(zippedFilename == NULL) // we don't want to run strlen on NULL
|
if(zippedFilename == NULL) // we don't want to run strlen on NULL
|
||||||
p = NULL;
|
p = NULL;
|
||||||
@ -429,23 +474,16 @@ void StripExt(char* returnstring, char * inputstring)
|
|||||||
*
|
*
|
||||||
* Opens the selected 7z file, and parses a listing of the files within
|
* Opens the selected 7z file, and parses a listing of the files within
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int BrowserLoadSz(int method)
|
int BrowserLoadSz()
|
||||||
{
|
{
|
||||||
char filepath[MAXPATHLEN];
|
char filepath[MAXPATHLEN];
|
||||||
memset(filepath, 0, MAXPATHLEN);
|
memset(filepath, 0, MAXPATHLEN);
|
||||||
|
|
||||||
// we'll store the 7z filepath for extraction later
|
// we'll store the 7z filepath for extraction later
|
||||||
if(!MakeFilePath(szpath, FILE_ROM, method))
|
if(!MakeFilePath(szpath, FILE_ROM))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// add device to filepath
|
int szfiles = SzParse(szpath);
|
||||||
if(method != METHOD_DVD)
|
|
||||||
{
|
|
||||||
sprintf(filepath, "%s%s", rootdir, szpath);
|
|
||||||
memcpy(szpath, filepath, MAXPATHLEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
int szfiles = SzParse(szpath, method);
|
|
||||||
if(szfiles)
|
if(szfiles)
|
||||||
{
|
{
|
||||||
browser.numEntries = szfiles;
|
browser.numEntries = szfiles;
|
||||||
@ -462,14 +500,19 @@ int BrowserLoadSz(int method)
|
|||||||
*
|
*
|
||||||
* Loads the selected ROM
|
* Loads the selected ROM
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int BrowserLoadFile(int method)
|
int BrowserLoadFile()
|
||||||
{
|
{
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
romLoaded = false;
|
romLoaded = false;
|
||||||
|
|
||||||
|
int device;
|
||||||
|
|
||||||
|
if(!FindDevice(browser.dir, &device))
|
||||||
|
return 0;
|
||||||
|
|
||||||
// check that this is a valid ROM
|
// check that this is a valid ROM
|
||||||
if(!IsValidROM(method))
|
if(!IsValidROM())
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
// store the filename (w/o ext) - used for ram/state naming
|
// store the filename (w/o ext) - used for ram/state naming
|
||||||
@ -477,16 +520,16 @@ int BrowserLoadFile(int method)
|
|||||||
|
|
||||||
if(!inSz)
|
if(!inSz)
|
||||||
{
|
{
|
||||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
if(!MakeFilePath(filepath, FILE_ROM))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
filesize = LoadFile ((char *)nesrom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
filesize = LoadFile ((char *)nesrom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (method)
|
switch (device)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
case DEVICE_DVD:
|
||||||
filesize = SzExtractFile(browserList[browser.selIndex].offset, nesrom);
|
filesize = SzExtractFile(browserList[browser.selIndex].offset, nesrom);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -496,7 +539,7 @@ int BrowserLoadFile(int method)
|
|||||||
if(filesize <= 0)
|
if(filesize <= 0)
|
||||||
{
|
{
|
||||||
browser.selIndex = 0;
|
browser.selIndex = 0;
|
||||||
BrowserChangeFolder(method);
|
BrowserChangeFolder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,17 +550,17 @@ int BrowserLoadFile(int method)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// load UPS/IPS/PPF patch
|
// load UPS/IPS/PPF patch
|
||||||
filesize = LoadPatch(method, filesize);
|
filesize = LoadPatch(filesize);
|
||||||
|
|
||||||
if(GCMemROM(method, filesize) > 0)
|
if(GCMemROM(filesize) > 0)
|
||||||
{
|
{
|
||||||
romLoaded = true;
|
romLoaded = true;
|
||||||
|
|
||||||
// load RAM or state
|
// load RAM or state
|
||||||
if (GCSettings.AutoLoad == 1)
|
if (GCSettings.AutoLoad == 1)
|
||||||
LoadRAMAuto(GCSettings.SaveMethod, SILENT);
|
LoadRAMAuto(SILENT);
|
||||||
else if (GCSettings.AutoLoad == 2)
|
else if (GCSettings.AutoLoad == 2)
|
||||||
LoadStateAuto(GCSettings.SaveMethod, SILENT);
|
LoadStateAuto(SILENT);
|
||||||
|
|
||||||
ResetNES();
|
ResetNES();
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
@ -533,37 +576,98 @@ done:
|
|||||||
*
|
*
|
||||||
* Update current directory and set new entry list if directory has changed
|
* 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(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);
|
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||||
|
|
||||||
inSz = false;
|
inSz = false;
|
||||||
SzClose();
|
SzClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!UpdateDirName(method))
|
if(!UpdateDirName())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
CleanupPath(browser.dir);
|
CleanupPath(browser.dir);
|
||||||
strcpy(GCSettings.LoadFolder, browser.dir);
|
HaltParseThread(); // halt parsing
|
||||||
|
ResetBrowser(); // reset browser
|
||||||
|
|
||||||
switch (method)
|
if(browser.dir[0] != 0)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
switch (device)
|
||||||
ParseDVDdirectory();
|
{
|
||||||
break;
|
case DEVICE_DVD:
|
||||||
|
ParseDVDdirectory();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ParseDirectory(method);
|
ParseDirectory();
|
||||||
break;
|
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;
|
return browser.numEntries;
|
||||||
@ -576,25 +680,17 @@ int BrowserChangeFolder(int method)
|
|||||||
int
|
int
|
||||||
OpenGameList ()
|
OpenGameList ()
|
||||||
{
|
{
|
||||||
int method = GCSettings.LoadMethod;
|
int device = GCSettings.LoadMethod;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(device == DEVICE_AUTO)
|
||||||
method = autoLoadMethod();
|
device = autoLoadMethod();
|
||||||
|
|
||||||
// change current dir to roms directory
|
// change current dir to roms directory
|
||||||
switch(method)
|
if(device > 0)
|
||||||
{
|
sprintf(browser.dir, "%s%s", pathPrefix[device], GCSettings.LoadFolder);
|
||||||
case METHOD_DVD:
|
else
|
||||||
browser.dir[0] = 0;
|
browser.dir[0] = 0;
|
||||||
if(MountDVD(NOTSILENT))
|
|
||||||
if(ParseDVDdirectory()) // Parse root directory
|
BrowserChangeFolder();
|
||||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sprintf(browser.dir, "/%s/", GCSettings.LoadFolder);
|
|
||||||
CleanupPath(browser.dir);
|
|
||||||
ParseDirectory(method); // Parse root directory
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return browser.numEntries;
|
return browser.numEntries;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ typedef struct
|
|||||||
int numEntries; // # of entries in browserList
|
int numEntries; // # of entries in browserList
|
||||||
int selIndex; // currently selected index of browserList
|
int selIndex; // currently selected index of browserList
|
||||||
int pageIndex; // starting index of browserList page display
|
int pageIndex; // starting index of browserList page display
|
||||||
|
int size; // # of entries browerList has space allocated to store
|
||||||
} BROWSERINFO;
|
} BROWSERINFO;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -32,16 +33,26 @@ typedef struct
|
|||||||
char isdir; // 0 - file, 1 - directory
|
char isdir; // 0 - file, 1 - directory
|
||||||
char filename[MAXJOLIET + 1]; // full filename
|
char filename[MAXJOLIET + 1]; // full filename
|
||||||
char displayname[MAXJOLIET + 1]; // name for browser display
|
char displayname[MAXJOLIET + 1]; // name for browser display
|
||||||
|
int icon; // icon to display
|
||||||
} BROWSERENTRY;
|
} BROWSERENTRY;
|
||||||
|
|
||||||
extern BROWSERINFO browser;
|
extern BROWSERINFO browser;
|
||||||
extern BROWSERENTRY * browserList;
|
extern BROWSERENTRY * browserList;
|
||||||
extern char rootdir[10];
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ICON_NONE,
|
||||||
|
ICON_FOLDER,
|
||||||
|
ICON_SD,
|
||||||
|
ICON_USB,
|
||||||
|
ICON_DVD,
|
||||||
|
ICON_SMB
|
||||||
|
};
|
||||||
|
|
||||||
extern char romFilename[];
|
extern char romFilename[];
|
||||||
|
|
||||||
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -2);
|
bool MakeFilePath(char filepath[], int type, char * filename = NULL, int filenum = -2);
|
||||||
int UpdateDirName(int method);
|
int UpdateDirName();
|
||||||
int OpenGameList();
|
int OpenGameList();
|
||||||
int autoLoadMethod();
|
int autoLoadMethod();
|
||||||
int autoSaveMethod(bool silent);
|
int autoSaveMethod(bool silent);
|
||||||
@ -49,8 +60,10 @@ int FileSortCallback(const void *f1, const void *f2);
|
|||||||
void StripExt(char* returnstring, char * inputstring);
|
void StripExt(char* returnstring, char * inputstring);
|
||||||
bool IsSz();
|
bool IsSz();
|
||||||
void ResetBrowser();
|
void ResetBrowser();
|
||||||
int BrowserLoadSz(int method);
|
bool AddBrowserEntry();
|
||||||
int BrowserChangeFolder(int method);
|
bool IsDeviceRoot(char * path);
|
||||||
int BrowserLoadFile(int method);
|
int BrowserLoadSz();
|
||||||
|
int BrowserChangeFolder();
|
||||||
|
int BrowserLoadFile();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -167,8 +167,20 @@ extern const u32 progressbar_outline_png_size;
|
|||||||
extern const u8 throbber_png[];
|
extern const u8 throbber_png[];
|
||||||
extern const u32 throbber_png_size;
|
extern const u32 throbber_png_size;
|
||||||
|
|
||||||
extern const u8 folder_png[];
|
extern const u8 icon_folder_png[];
|
||||||
extern const u32 folder_png_size;
|
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 u8 battery_png[];
|
||||||
extern const u32 battery_png_size;
|
extern const u32 battery_png_size;
|
||||||
|
@ -90,6 +90,20 @@ HaltDeviceThread()
|
|||||||
usleep(THREAD_SLEEP);
|
usleep(THREAD_SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* HaltParseThread
|
||||||
|
*
|
||||||
|
* Signals the parse thread to stop.
|
||||||
|
***************************************************************************/
|
||||||
|
void
|
||||||
|
HaltParseThread()
|
||||||
|
{
|
||||||
|
parseHalt = true;
|
||||||
|
|
||||||
|
while(!LWP_ThreadIsSuspended(parsethread))
|
||||||
|
usleep(THREAD_SLEEP);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* devicecallback
|
* devicecallback
|
||||||
*
|
*
|
||||||
@ -112,41 +126,41 @@ devicecallback (void *arg)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
if(isMounted[METHOD_SD])
|
if(isMounted[DEVICE_SD])
|
||||||
{
|
{
|
||||||
if(!sd->isInserted()) // check if the device was removed
|
if(!sd->isInserted()) // check if the device was removed
|
||||||
{
|
{
|
||||||
unmountRequired[METHOD_SD] = true;
|
unmountRequired[DEVICE_SD] = true;
|
||||||
isMounted[METHOD_SD] = false;
|
isMounted[DEVICE_SD] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isMounted[METHOD_USB])
|
if(isMounted[DEVICE_USB])
|
||||||
{
|
{
|
||||||
if(!usb->isInserted()) // check if the device was removed
|
if(!usb->isInserted()) // check if the device was removed
|
||||||
{
|
{
|
||||||
unmountRequired[METHOD_USB] = true;
|
unmountRequired[DEVICE_USB] = true;
|
||||||
isMounted[METHOD_USB] = false;
|
isMounted[DEVICE_USB] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateCheck();
|
UpdateCheck();
|
||||||
InitializeNetwork(SILENT);
|
InitializeNetwork(SILENT);
|
||||||
#else
|
#else
|
||||||
if(isMounted[METHOD_SD_SLOTA])
|
if(isMounted[DEVICE_SD_SLOTA])
|
||||||
{
|
{
|
||||||
if(!carda->isInserted()) // check if the device was removed
|
if(!carda->isInserted()) // check if the device was removed
|
||||||
{
|
{
|
||||||
unmountRequired[METHOD_SD_SLOTA] = true;
|
unmountRequired[DEVICE_SD_SLOTA] = true;
|
||||||
isMounted[METHOD_SD_SLOTA] = false;
|
isMounted[DEVICE_SD_SLOTA] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isMounted[METHOD_SD_SLOTB])
|
if(isMounted[DEVICE_SD_SLOTB])
|
||||||
{
|
{
|
||||||
if(!cardb->isInserted()) // check if the device was removed
|
if(!cardb->isInserted()) // check if the device was removed
|
||||||
{
|
{
|
||||||
unmountRequired[METHOD_SD_SLOTB] = true;
|
unmountRequired[DEVICE_SD_SLOTB] = true;
|
||||||
isMounted[METHOD_SD_SLOTB] = false;
|
isMounted[DEVICE_SD_SLOTB] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -211,31 +225,35 @@ void UnmountAllFAT()
|
|||||||
* Sets libfat to use the device by default
|
* 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
|
bool mounted = true; // assume our disc is already mounted
|
||||||
char name[10];
|
char name[10], name2[10];
|
||||||
const DISC_INTERFACE* disc = NULL;
|
const DISC_INTERFACE* disc = NULL;
|
||||||
|
|
||||||
switch(method)
|
switch(device)
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
case METHOD_SD:
|
case DEVICE_SD:
|
||||||
sprintf(name, "sd");
|
sprintf(name, "sd");
|
||||||
|
sprintf(name2, "sd:");
|
||||||
disc = sd;
|
disc = sd;
|
||||||
break;
|
break;
|
||||||
case METHOD_USB:
|
case DEVICE_USB:
|
||||||
sprintf(name, "usb");
|
sprintf(name, "usb");
|
||||||
|
sprintf(name2, "usb:");
|
||||||
disc = usb;
|
disc = usb;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
case METHOD_SD_SLOTA:
|
case DEVICE_SD_SLOTA:
|
||||||
sprintf(name, "carda");
|
sprintf(name, "carda");
|
||||||
|
sprintf(name2, "carda:");
|
||||||
disc = carda;
|
disc = carda;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_SD_SLOTB:
|
case DEVICE_SD_SLOTB:
|
||||||
sprintf(name, "cardb");
|
sprintf(name, "cardb");
|
||||||
|
sprintf(name2, "cardb:");
|
||||||
disc = cardb;
|
disc = cardb;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -243,16 +261,14 @@ bool MountFAT(int method)
|
|||||||
return false; // unknown device
|
return false; // unknown device
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(rootdir, "%s:", name);
|
if(unmountRequired[device])
|
||||||
|
|
||||||
if(unmountRequired[method])
|
|
||||||
{
|
{
|
||||||
unmountRequired[method] = false;
|
unmountRequired[device] = false;
|
||||||
fatUnmount(rootdir);
|
fatUnmount(name2);
|
||||||
disc->shutdown();
|
disc->shutdown();
|
||||||
isMounted[method] = false;
|
isMounted[device] = false;
|
||||||
}
|
}
|
||||||
if(!isMounted[method])
|
if(!isMounted[device])
|
||||||
{
|
{
|
||||||
if(!disc->startup())
|
if(!disc->startup())
|
||||||
mounted = false;
|
mounted = false;
|
||||||
@ -260,78 +276,159 @@ bool MountFAT(int method)
|
|||||||
mounted = false;
|
mounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
isMounted[method] = mounted;
|
if(!mounted && !silent)
|
||||||
|
{
|
||||||
|
if(device == DEVICE_SD)
|
||||||
|
ErrorPrompt("SD card not found!");
|
||||||
|
else
|
||||||
|
ErrorPrompt("USB drive not found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
isMounted[device] = mounted;
|
||||||
return mounted;
|
return mounted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MountAllFAT()
|
void MountAllFAT()
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
MountFAT(METHOD_SD);
|
MountFAT(DEVICE_SD, SILENT);
|
||||||
MountFAT(METHOD_USB);
|
MountFAT(DEVICE_USB, SILENT);
|
||||||
#else
|
#else
|
||||||
MountFAT(METHOD_SD_SLOTA);
|
MountFAT(DEVICE_SD_SLOTA, SILENT);
|
||||||
MountFAT(METHOD_SD_SLOTB);
|
MountFAT(DEVICE_SD_SLOTB, SILENT);
|
||||||
#endif
|
#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
|
* ChangeInterface
|
||||||
* Attempts to mount/configure the device specified
|
* Attempts to mount/configure the device specified
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
bool ChangeInterface(int method, bool silent)
|
bool ChangeInterface(int device, bool silent)
|
||||||
{
|
{
|
||||||
bool mounted = false;
|
bool mounted = false;
|
||||||
|
|
||||||
if(method == METHOD_SD)
|
switch(device)
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
case DEVICE_SD:
|
||||||
mounted = MountFAT(METHOD_SD); // try Wii internal SD
|
case DEVICE_USB:
|
||||||
#else
|
mounted = MountFAT(device, silent);
|
||||||
mounted = MountFAT(METHOD_SD_SLOTA); // try SD Gecko on slot A
|
break;
|
||||||
if(!mounted) // internal SD and SD Gecko (on slot A) not found
|
case DEVICE_DVD:
|
||||||
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
mounted = MountDVD(silent);
|
||||||
#endif
|
break;
|
||||||
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);
|
|
||||||
}
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
else if(method == METHOD_SMB)
|
case DEVICE_SMB:
|
||||||
{
|
mounted = ConnectShare(silent);
|
||||||
mounted = ConnectShare(silent);
|
break;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
else if(method == METHOD_MC_SLOTA)
|
case DEVICE_MC_SLOTA:
|
||||||
{
|
mounted = TestMC(CARD_SLOTA, silent);
|
||||||
mounted = TestMC(CARD_SLOTA, silent);
|
break;
|
||||||
}
|
case DEVICE_MC_SLOTB:
|
||||||
else if(method == METHOD_MC_SLOTB)
|
mounted = TestMC(CARD_SLOTB, silent);
|
||||||
{
|
break;
|
||||||
mounted = TestMC(CARD_SLOTB, silent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!mounted)
|
|
||||||
{
|
|
||||||
sprintf(browser.dir,"/");
|
|
||||||
rootdir[0] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mounted;
|
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()
|
bool ParseDirEntries()
|
||||||
{
|
{
|
||||||
if(!dirIter)
|
if(!dirIter)
|
||||||
@ -355,36 +452,25 @@ bool ParseDirEntries()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (browser.numEntries+i+1) * sizeof(BROWSERENTRY));
|
if(AddBrowserEntry())
|
||||||
|
|
||||||
if(!newBrowserList) // failed to allocate required memory
|
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
strncpy(browserList[browser.numEntries+i].filename, filename, MAXJOLIET);
|
||||||
ErrorPrompt("Out of memory: too many files!");
|
browserList[browser.numEntries+i].length = filestat.st_size;
|
||||||
break;
|
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
|
||||||
else
|
|
||||||
{
|
|
||||||
browserList = newBrowserList;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&(browserList[browser.numEntries+i]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
if(browserList[browser.numEntries+i].isdir)
|
||||||
|
{
|
||||||
strncpy(browserList[browser.numEntries+i].filename, filename, MAXJOLIET);
|
if(strcmp(filename, "..") == 0)
|
||||||
browserList[browser.numEntries+i].length = filestat.st_size;
|
sprintf(browserList[browser.numEntries+i].displayname, "Up One Level");
|
||||||
browserList[browser.numEntries+i].mtime = filestat.st_mtime;
|
else
|
||||||
browserList[browser.numEntries+i].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
strncpy(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename, MAXJOLIET);
|
||||||
|
browserList[browser.numEntries+i].icon = ICON_FOLDER;
|
||||||
if(browserList[browser.numEntries+i].isdir)
|
}
|
||||||
{
|
|
||||||
if(strcmp(filename, "..") == 0)
|
|
||||||
sprintf(browserList[browser.numEntries+i].displayname, "Up One Level");
|
|
||||||
else
|
else
|
||||||
strncpy(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename, MAXJOLIET);
|
{
|
||||||
}
|
StripExt(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename); // hide file extension
|
||||||
else
|
}
|
||||||
{
|
|
||||||
StripExt(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename); // hide file extension
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,54 +494,56 @@ bool ParseDirEntries()
|
|||||||
* Browse subdirectories
|
* Browse subdirectories
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int
|
int
|
||||||
ParseDirectory(int method, bool waitParse)
|
ParseDirectory(bool waitParse)
|
||||||
{
|
{
|
||||||
char fulldir[MAXPATHLEN];
|
|
||||||
char msg[128];
|
char msg[128];
|
||||||
int retry = 1;
|
int retry = 1;
|
||||||
bool mounted = false;
|
bool mounted = false;
|
||||||
|
|
||||||
// halt parsing
|
ResetBrowser(); // reset browser
|
||||||
parseHalt = true;
|
|
||||||
|
|
||||||
while(!LWP_ThreadIsSuspended(parsethread))
|
|
||||||
usleep(THREAD_SLEEP);
|
|
||||||
|
|
||||||
// reset browser
|
|
||||||
dirIter = NULL;
|
|
||||||
ResetBrowser();
|
|
||||||
|
|
||||||
// open the directory
|
// open the directory
|
||||||
while(dirIter == NULL && retry == 1)
|
while(dirIter == NULL && retry == 1)
|
||||||
{
|
{
|
||||||
mounted = ChangeInterface(method, NOTSILENT);
|
mounted = ChangeInterface(browser.dir, NOTSILENT);
|
||||||
sprintf(fulldir, "%s%s", rootdir, browser.dir); // add device to path
|
if(mounted)
|
||||||
if(mounted) dirIter = diropen(fulldir);
|
dirIter = diropen(browser.dir);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
|
||||||
if(dirIter == NULL)
|
if(dirIter == NULL)
|
||||||
{
|
{
|
||||||
unmountRequired[method] = true;
|
sprintf(msg, "Error opening %s", browser.dir);
|
||||||
sprintf(msg, "Error opening %s", fulldir);
|
|
||||||
retry = ErrorPromptRetry(msg);
|
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 (dirIter == NULL)
|
||||||
{
|
{
|
||||||
if(ChangeInterface(method, SILENT))
|
while(!IsDeviceRoot(browser.dir))
|
||||||
{
|
{
|
||||||
sprintf(browser.dir,"/");
|
char * devEnd = strrchr(browser.dir, '/');
|
||||||
sprintf(fulldir, "%s%s", rootdir, browser.dir);
|
devEnd[0] = 0; // strip remaining file listing
|
||||||
dirIter = diropen(fulldir);
|
dirIter = diropen(browser.dir);
|
||||||
if (dirIter == NULL)
|
if (dirIter)
|
||||||
{
|
break;
|
||||||
sprintf(msg, "Error opening %s", rootdir);
|
|
||||||
ErrorPrompt(msg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
parseHalt = false;
|
||||||
ParseDirEntries(); // index first 20 entries
|
ParseDirEntries(); // index first 20 entries
|
||||||
LWP_ResumeThread(parsethread); // index remaining entries
|
LWP_ResumeThread(parsethread); // index remaining entries
|
||||||
@ -537,24 +625,27 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
|||||||
* LoadFile
|
* LoadFile
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
u32
|
u32
|
||||||
LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
LoadFile (char * rbuffer, char *filepath, u32 length, bool silent)
|
||||||
{
|
{
|
||||||
char zipbuffer[2048];
|
char zipbuffer[2048];
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
u32 readsize = 0;
|
u32 readsize = 0;
|
||||||
char fullpath[MAXPATHLEN];
|
|
||||||
int retry = 1;
|
int retry = 1;
|
||||||
|
int device;
|
||||||
|
|
||||||
switch(method)
|
if(!FindDevice(filepath, &device))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch(device)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
case DEVICE_DVD:
|
||||||
return LoadDVDFile (rbuffer, filepath, length, silent);
|
return LoadDVDFile (rbuffer, StripDevice(filepath), length, silent);
|
||||||
break;
|
break;
|
||||||
case METHOD_MC_SLOTA:
|
case DEVICE_MC_SLOTA:
|
||||||
return LoadMCFile (rbuffer, CARD_SLOTA, filepath, silent);
|
return LoadMCFile (rbuffer, CARD_SLOTA, StripDevice(filepath), silent);
|
||||||
break;
|
break;
|
||||||
case METHOD_MC_SLOTB:
|
case DEVICE_MC_SLOTB:
|
||||||
return LoadMCFile (rbuffer, CARD_SLOTB, filepath, silent);
|
return LoadMCFile (rbuffer, CARD_SLOTB, StripDevice(filepath), silent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,10 +659,9 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
// open the file
|
// open the file
|
||||||
while(!size && retry == 1)
|
while(!size && retry == 1)
|
||||||
{
|
{
|
||||||
if(ChangeInterface(method, silent))
|
if(ChangeInterface(device, silent))
|
||||||
{
|
{
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
file = fopen (filepath, "rb");
|
||||||
file = fopen (fullpath, "rb");
|
|
||||||
|
|
||||||
if(file > 0)
|
if(file > 0)
|
||||||
{
|
{
|
||||||
@ -587,7 +677,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
{
|
{
|
||||||
if (IsZipFile (zipbuffer))
|
if (IsZipFile (zipbuffer))
|
||||||
{
|
{
|
||||||
size = UnZipBuffer ((unsigned char *)rbuffer, method); // unzip
|
size = UnZipBuffer ((unsigned char *)rbuffer, device); // unzip
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -628,7 +718,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
{
|
{
|
||||||
unmountRequired[method] = true;
|
unmountRequired[device] = true;
|
||||||
retry = ErrorPromptRetry("Error loading file!");
|
retry = ErrorPromptRetry("Error loading file!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -644,9 +734,9 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
return size;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -654,23 +744,26 @@ u32 LoadFile(char * filepath, int method, bool silent)
|
|||||||
* Write buffer to file
|
* Write buffer to file
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
u32
|
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;
|
u32 written = 0;
|
||||||
int retry = 1;
|
int retry = 1;
|
||||||
|
int device;
|
||||||
|
|
||||||
|
if(!FindDevice(filepath, &device))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(datasize == 0)
|
if(datasize == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ShowAction("Saving...");
|
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)
|
if(device == DEVICE_MC_SLOTA)
|
||||||
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
return SaveMCFile (buffer, CARD_SLOTA, StripDevice(filepath), datasize, silent);
|
||||||
else
|
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
|
// stop checking if devices were removed/inserted
|
||||||
@ -679,10 +772,9 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
|||||||
|
|
||||||
while(!written && retry == 1)
|
while(!written && retry == 1)
|
||||||
{
|
{
|
||||||
if(ChangeInterface(method, silent))
|
if(ChangeInterface(device, silent))
|
||||||
{
|
{
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
file = fopen (filepath, "wb");
|
||||||
file = fopen (fullpath, "wb");
|
|
||||||
|
|
||||||
if (file > 0)
|
if (file > 0)
|
||||||
{
|
{
|
||||||
@ -702,7 +794,7 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
|||||||
}
|
}
|
||||||
if(!written)
|
if(!written)
|
||||||
{
|
{
|
||||||
unmountRequired[method] = true;
|
unmountRequired[device] = true;
|
||||||
if(!silent)
|
if(!silent)
|
||||||
retry = ErrorPromptRetry("Error saving file!");
|
retry = ErrorPromptRetry("Error saving file!");
|
||||||
else
|
else
|
||||||
@ -714,10 +806,10 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
|||||||
ResumeDeviceThread();
|
ResumeDeviceThread();
|
||||||
|
|
||||||
CancelAction();
|
CancelAction();
|
||||||
return written;
|
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);
|
||||||
}
|
}
|
||||||
|
@ -24,17 +24,22 @@
|
|||||||
void InitDeviceThread();
|
void InitDeviceThread();
|
||||||
void ResumeDeviceThread();
|
void ResumeDeviceThread();
|
||||||
void HaltDeviceThread();
|
void HaltDeviceThread();
|
||||||
|
void HaltParseThread();
|
||||||
void MountAllFAT();
|
void MountAllFAT();
|
||||||
void UnmountAllFAT();
|
void UnmountAllFAT();
|
||||||
bool ChangeInterface(int method, bool silent);
|
bool FindDevice(char * filepath, int * device);
|
||||||
int ParseDirectory(int method, bool waitParse = false);
|
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 AllocSaveBuffer();
|
||||||
void FreeSaveBuffer();
|
void FreeSaveBuffer();
|
||||||
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
u32 LoadFile(char * rbuffer, char *filepath, u32 length, bool silent);
|
||||||
u32 LoadFile(char * filepath, int method, bool silent);
|
u32 LoadFile(char * filepath, bool silent);
|
||||||
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||||
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
u32 SaveFile(char * buffer, char *filepath, u32 datasize, bool silent);
|
||||||
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent);
|
u32 SaveFile(char * filepath, u32 datasize, bool silent);
|
||||||
|
|
||||||
extern unsigned char savebuffer[];
|
extern unsigned char savebuffer[];
|
||||||
extern FILE * file;
|
extern FILE * file;
|
||||||
|
@ -102,7 +102,7 @@ IsZipFile (char *buffer)
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
UnZipBuffer (unsigned char *outbuffer, int method)
|
UnZipBuffer (unsigned char *outbuffer, int device)
|
||||||
{
|
{
|
||||||
PKZIPHEADER pkzip;
|
PKZIPHEADER pkzip;
|
||||||
int zipoffset = 0;
|
int zipoffset = 0;
|
||||||
@ -117,9 +117,9 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
int sizeread = 0;
|
int sizeread = 0;
|
||||||
|
|
||||||
// Read Zip Header
|
// Read Zip Header
|
||||||
switch (method)
|
switch (device)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
case DEVICE_DVD:
|
||||||
sizeread = dvd_safe_read (readbuffer, ZIPCHUNK, 0);
|
sizeread = dvd_safe_read (readbuffer, ZIPCHUNK, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -189,9 +189,9 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
zipoffset = 0;
|
zipoffset = 0;
|
||||||
zipchunk = ZIPCHUNK;
|
zipchunk = ZIPCHUNK;
|
||||||
|
|
||||||
switch (method)
|
switch (device)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
case DEVICE_DVD:
|
||||||
readoffset += ZIPCHUNK;
|
readoffset += ZIPCHUNK;
|
||||||
sizeread = dvd_safe_read (readbuffer, ZIPCHUNK, readoffset);
|
sizeread = dvd_safe_read (readbuffer, ZIPCHUNK, readoffset);
|
||||||
break;
|
break;
|
||||||
@ -224,17 +224,17 @@ done:
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
GetFirstZipFilename (int method)
|
GetFirstZipFilename ()
|
||||||
{
|
{
|
||||||
char * firstFilename = NULL;
|
char * firstFilename = NULL;
|
||||||
char tempbuffer[ZIPCHUNK];
|
char tempbuffer[ZIPCHUNK];
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
if(!MakeFilePath(filepath, FILE_ROM))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// read start of ZIP
|
// 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)
|
tempbuffer[28] = 0; // truncate - filename length is 2 bytes long (bytes 26-27)
|
||||||
int namelength = tempbuffer[26]; // filename length starts 26 bytes in
|
int namelength = tempbuffer[26]; // filename length starts 26 bytes in
|
||||||
@ -339,7 +339,7 @@ static SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSi
|
|||||||
// read data
|
// read data
|
||||||
switch (szMethod)
|
switch (szMethod)
|
||||||
{
|
{
|
||||||
case METHOD_DVD:
|
case DEVICE_DVD:
|
||||||
sizeread = dvd_safe_read(sz_buffer, maxRequiredSize, offset);
|
sizeread = dvd_safe_read(sz_buffer, maxRequiredSize, offset);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -384,11 +384,16 @@ static SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
|||||||
* It parses the entire 7z for full browsing capability
|
* It parses the entire 7z for full browsing capability
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int SzParse(char * filepath, int method)
|
int SzParse(char * filepath)
|
||||||
{
|
{
|
||||||
if(!filepath)
|
if(!filepath)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
int device;
|
||||||
|
|
||||||
|
if(!FindDevice(browser.dir, &device))
|
||||||
|
return 0;
|
||||||
|
|
||||||
int nbfiles = 0;
|
int nbfiles = 0;
|
||||||
|
|
||||||
// save the length/offset of this file
|
// save the length/offset of this file
|
||||||
@ -401,22 +406,22 @@ int SzParse(char * filepath, int method)
|
|||||||
SzArchiveStream.pos = 0;
|
SzArchiveStream.pos = 0;
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
switch (method)
|
switch (device)
|
||||||
{
|
{
|
||||||
case METHOD_SD:
|
case DEVICE_SD:
|
||||||
case METHOD_USB:
|
case DEVICE_USB:
|
||||||
case METHOD_SMB:
|
case DEVICE_SMB:
|
||||||
file = fopen (filepath, "rb");
|
file = fopen (filepath, "rb");
|
||||||
if(!file)
|
if(!file)
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case METHOD_DVD:
|
case DEVICE_DVD:
|
||||||
SwitchDVDFolder(filepath);
|
SwitchDVDFolder(filepath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set szMethod to current chosen load method
|
// set szMethod to current chosen load device
|
||||||
szMethod = method;
|
szMethod = device;
|
||||||
|
|
||||||
// set handler functions for reading data from SD/USB/SMB/DVD
|
// set handler functions for reading data from SD/USB/SMB/DVD
|
||||||
SzArchiveStream.InStream.Read = SzFileReadImp;
|
SzArchiveStream.InStream.Read = SzFileReadImp;
|
||||||
@ -503,11 +508,11 @@ int SzParse(char * filepath, int method)
|
|||||||
CancelAction();
|
CancelAction();
|
||||||
|
|
||||||
// close file
|
// close file
|
||||||
switch (method)
|
switch (device)
|
||||||
{
|
{
|
||||||
case METHOD_SD:
|
case DEVICE_SD:
|
||||||
case METHOD_USB:
|
case DEVICE_USB:
|
||||||
case METHOD_SMB:
|
case DEVICE_SMB:
|
||||||
fclose(file);
|
fclose(file);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
#define _GCUNZIP_H_
|
#define _GCUNZIP_H_
|
||||||
|
|
||||||
int IsZipFile (char *buffer);
|
int IsZipFile (char *buffer);
|
||||||
char * GetFirstZipFilename(int method);
|
char * GetFirstZipFilename();
|
||||||
int UnZipBuffer (unsigned char *outbuffer, int method);
|
int UnZipBuffer (unsigned char *outbuffer, int device);
|
||||||
int SzParse(char * filepath, int method);
|
int SzParse(char * filepath);
|
||||||
int SzExtractFile(int i, unsigned char *buffer);
|
int SzExtractFile(int i, unsigned char *buffer);
|
||||||
void SzClose();
|
void SzClose();
|
||||||
|
|
||||||
|
@ -920,7 +920,7 @@ class GuiFileBrowser : public GuiElement
|
|||||||
|
|
||||||
GuiText * fileListText[FILE_PAGESIZE];
|
GuiText * fileListText[FILE_PAGESIZE];
|
||||||
GuiImage * fileListBg[FILE_PAGESIZE];
|
GuiImage * fileListBg[FILE_PAGESIZE];
|
||||||
GuiImage * fileListFolder[FILE_PAGESIZE];
|
GuiImage * fileListIcon[FILE_PAGESIZE];
|
||||||
|
|
||||||
GuiButton * arrowUpBtn;
|
GuiButton * arrowUpBtn;
|
||||||
GuiButton * arrowDownBtn;
|
GuiButton * arrowDownBtn;
|
||||||
@ -937,7 +937,11 @@ class GuiFileBrowser : public GuiElement
|
|||||||
|
|
||||||
GuiImageData * bgFileSelection;
|
GuiImageData * bgFileSelection;
|
||||||
GuiImageData * bgFileSelectionEntry;
|
GuiImageData * bgFileSelectionEntry;
|
||||||
GuiImageData * fileFolder;
|
GuiImageData * iconFolder;
|
||||||
|
GuiImageData * iconSD;
|
||||||
|
GuiImageData * iconUSB;
|
||||||
|
GuiImageData * iconDVD;
|
||||||
|
GuiImageData * iconSMB;
|
||||||
GuiImageData * scrollbar;
|
GuiImageData * scrollbar;
|
||||||
GuiImageData * arrowDown;
|
GuiImageData * arrowDown;
|
||||||
GuiImageData * arrowDownOver;
|
GuiImageData * arrowDownOver;
|
||||||
|
@ -42,7 +42,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
|||||||
bgFileSelectionImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
bgFileSelectionImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||||
|
|
||||||
bgFileSelectionEntry = new GuiImageData(bg_game_selection_entry_png);
|
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);
|
scrollbar = new GuiImageData(scrollbar_png);
|
||||||
scrollbarImg = new GuiImage(scrollbar);
|
scrollbarImg = new GuiImage(scrollbar);
|
||||||
@ -107,7 +112,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
|||||||
fileListText[i]->SetMaxWidth(380);
|
fileListText[i]->SetMaxWidth(380);
|
||||||
|
|
||||||
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
|
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
|
||||||
fileListFolder[i] = new GuiImage(fileFolder);
|
fileListIcon[i] = NULL;
|
||||||
|
|
||||||
fileList[i] = new GuiButton(380, 26);
|
fileList[i] = new GuiButton(380, 26);
|
||||||
fileList[i]->SetParent(this);
|
fileList[i]->SetParent(this);
|
||||||
@ -139,7 +144,11 @@ GuiFileBrowser::~GuiFileBrowser()
|
|||||||
|
|
||||||
delete bgFileSelection;
|
delete bgFileSelection;
|
||||||
delete bgFileSelectionEntry;
|
delete bgFileSelectionEntry;
|
||||||
delete fileFolder;
|
delete iconFolder;
|
||||||
|
delete iconSD;
|
||||||
|
delete iconUSB;
|
||||||
|
delete iconDVD;
|
||||||
|
delete iconSMB;
|
||||||
delete scrollbar;
|
delete scrollbar;
|
||||||
delete arrowDown;
|
delete arrowDown;
|
||||||
delete arrowDownOver;
|
delete arrowDownOver;
|
||||||
@ -158,7 +167,9 @@ GuiFileBrowser::~GuiFileBrowser()
|
|||||||
delete fileListText[i];
|
delete fileListText[i];
|
||||||
delete fileList[i];
|
delete fileList[i];
|
||||||
delete fileListBg[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);
|
fileListText[i]->SetText(browserList[browser.pageIndex+i].displayname);
|
||||||
|
|
||||||
if(browserList[browser.pageIndex+i].isdir) // directory
|
if(fileListIcon[i])
|
||||||
{
|
{
|
||||||
fileList[i]->SetIcon(fileListFolder[i]);
|
delete fileListIcon[i];
|
||||||
fileListText[i]->SetPosition(30,0);
|
fileListIcon[i] = NULL;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fileList[i]->SetIcon(NULL);
|
|
||||||
fileListText[i]->SetPosition(10,0);
|
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
|
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 |
@ -561,19 +561,19 @@ void AutoSave()
|
|||||||
{
|
{
|
||||||
if (GCSettings.AutoSave == 1)
|
if (GCSettings.AutoSave == 1)
|
||||||
{
|
{
|
||||||
SaveRAMAuto(GCSettings.SaveMethod, SILENT);
|
SaveRAMAuto(SILENT);
|
||||||
}
|
}
|
||||||
else if (GCSettings.AutoSave == 2)
|
else if (GCSettings.AutoSave == 2)
|
||||||
{
|
{
|
||||||
if (WindowPrompt("Save", "Save State?", "Save", "Don't Save") )
|
if (WindowPrompt("Save", "Save State?", "Save", "Don't Save") )
|
||||||
SaveStateAuto(GCSettings.SaveMethod, NOTSILENT);
|
SaveStateAuto(NOTSILENT);
|
||||||
}
|
}
|
||||||
else if (GCSettings.AutoSave == 3)
|
else if (GCSettings.AutoSave == 3)
|
||||||
{
|
{
|
||||||
if (WindowPrompt("Save", "Save RAM and State?", "Save", "Don't Save") )
|
if (WindowPrompt("Save", "Save RAM and State?", "Save", "Don't Save") )
|
||||||
{
|
{
|
||||||
SaveRAMAuto(GCSettings.SaveMethod, NOTSILENT);
|
SaveRAMAuto(NOTSILENT);
|
||||||
SaveStateAuto(GCSettings.SaveMethod, NOTSILENT);
|
SaveStateAuto(NOTSILENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -973,76 +973,63 @@ static int MenuGameSelection()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// populate initial directory listing
|
// populate initial directory listing
|
||||||
if(OpenGameList() <= 0)
|
OpenGameList();
|
||||||
{
|
|
||||||
int choice = WindowPrompt(
|
|
||||||
"Error",
|
|
||||||
"Games directory is inaccessible on selected load device.",
|
|
||||||
"Retry",
|
|
||||||
"Check Settings");
|
|
||||||
|
|
||||||
if(choice)
|
gameBrowser.ResetState();
|
||||||
menu = MENU_GAMESELECTION;
|
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||||
else
|
gameBrowser.TriggerUpdate();
|
||||||
menu = MENU_SETTINGS_FILE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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);
|
if(gameBrowser.fileList[i]->GetState() == STATE_CLICKED)
|
||||||
|
|
||||||
// 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)
|
gameBrowser.fileList[i]->ResetState();
|
||||||
|
// check corresponding browser entry
|
||||||
|
if(browserList[browser.selIndex].isdir || IsSz())
|
||||||
{
|
{
|
||||||
gameBrowser.fileList[i]->ResetState();
|
if(IsSz())
|
||||||
// check corresponding browser entry
|
res = BrowserLoadSz();
|
||||||
if(browserList[browser.selIndex].isdir || IsSz())
|
else
|
||||||
{
|
res = BrowserChangeFolder();
|
||||||
if(IsSz())
|
|
||||||
res = BrowserLoadSz(GCSettings.LoadMethod);
|
|
||||||
else
|
|
||||||
res = BrowserChangeFolder(GCSettings.LoadMethod);
|
|
||||||
|
|
||||||
if(res)
|
if(res)
|
||||||
{
|
{
|
||||||
gameBrowser.ResetState();
|
gameBrowser.ResetState();
|
||||||
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
gameBrowser.fileList[0]->SetState(STATE_SELECTED);
|
||||||
gameBrowser.TriggerUpdate();
|
gameBrowser.TriggerUpdate();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
menu = MENU_GAMESELECTION;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
menu = MENU_GAMESELECTION;
|
||||||
ShutoffRumble();
|
break;
|
||||||
#endif
|
|
||||||
mainWindow->SetState(STATE_DISABLED);
|
|
||||||
if(BrowserLoadFile(GCSettings.LoadMethod))
|
|
||||||
menu = MENU_EXIT;
|
|
||||||
else
|
|
||||||
mainWindow->SetState(STATE_DEFAULT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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();
|
HaltGui();
|
||||||
mainWindow->Remove(&titleTxt);
|
mainWindow->Remove(&titleTxt);
|
||||||
mainWindow->Remove(&buttonWindow);
|
mainWindow->Remove(&buttonWindow);
|
||||||
@ -1502,7 +1489,7 @@ static int FindGameSaveNum(char * savefile, int method)
|
|||||||
int romlen = strlen(romFilename);
|
int romlen = strlen(romFilename);
|
||||||
int savelen = strlen(savefile);
|
int savelen = strlen(savefile);
|
||||||
|
|
||||||
if(romlen > 26 && (method == 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
|
romlen = 26; // memory card filenames are a maximum of 32 chars
|
||||||
|
|
||||||
int diff = savelen-romlen;
|
int diff = savelen-romlen;
|
||||||
@ -1510,7 +1497,7 @@ static int FindGameSaveNum(char * savefile, int method)
|
|||||||
if(strncmp(savefile, romFilename, romlen) != 0)
|
if(strncmp(savefile, romFilename, romlen) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
if(method == DEVICE_MC_SLOTA || method == DEVICE_MC_SLOTB)
|
||||||
{
|
{
|
||||||
if(diff == 2)
|
if(diff == 2)
|
||||||
n = atoi(&savefile[savelen-2]);
|
n = atoi(&savefile[savelen-2]);
|
||||||
@ -1550,7 +1537,7 @@ static int MenuGameSaves(int action)
|
|||||||
struct tm * timeinfo;
|
struct tm * timeinfo;
|
||||||
int method = GCSettings.SaveMethod;
|
int method = GCSettings.SaveMethod;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == DEVICE_AUTO)
|
||||||
autoSaveMethod(NOTSILENT);
|
autoSaveMethod(NOTSILENT);
|
||||||
|
|
||||||
if(!ChangeInterface(method, NOTSILENT))
|
if(!ChangeInterface(method, NOTSILENT))
|
||||||
@ -1620,18 +1607,18 @@ static int MenuGameSaves(int action)
|
|||||||
|
|
||||||
memset(&saves, 0, sizeof(saves));
|
memset(&saves, 0, sizeof(saves));
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA)
|
if(method == DEVICE_MC_SLOTA)
|
||||||
{
|
{
|
||||||
ParseMCDirectory(CARD_SLOTA);
|
ParseMCDirectory(CARD_SLOTA);
|
||||||
}
|
}
|
||||||
else if(method == METHOD_MC_SLOTB)
|
else if(method == DEVICE_MC_SLOTB)
|
||||||
{
|
{
|
||||||
ParseMCDirectory(CARD_SLOTB);
|
ParseMCDirectory(CARD_SLOTB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(browser.dir, GCSettings.SaveFolder, 200);
|
sprintf(browser.dir, "%s%s", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder);
|
||||||
ParseDirectory(GCSettings.SaveMethod, true);
|
ParseDirectory(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(romFilename);
|
len = strlen(romFilename);
|
||||||
@ -1661,18 +1648,18 @@ static int MenuGameSaves(int action)
|
|||||||
saves.files[saves.type[j]][n] = 1;
|
saves.files[saves.type[j]][n] = 1;
|
||||||
strncpy(saves.filename[j], browserList[i].filename, MAXJOLIET);
|
strncpy(saves.filename[j], browserList[i].filename, MAXJOLIET);
|
||||||
|
|
||||||
if(method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
|
if(method != DEVICE_MC_SLOTA && method != DEVICE_MC_SLOTB)
|
||||||
{
|
{
|
||||||
if(saves.type[j] == FILE_STATE)
|
if(saves.type[j] == FILE_STATE)
|
||||||
{
|
{
|
||||||
sprintf(scrfile, "%s/%s.png", GCSettings.SaveFolder, tmp);
|
sprintf(scrfile, "%s%s/%s.png", pathPrefix[GCSettings.SaveMethod], GCSettings.SaveFolder, tmp);
|
||||||
|
|
||||||
AllocSaveBuffer();
|
AllocSaveBuffer();
|
||||||
if(LoadFile(scrfile, GCSettings.SaveMethod, SILENT))
|
if(LoadFile(scrfile, SILENT))
|
||||||
saves.previewImg[j] = new GuiImageData(savebuffer);
|
saves.previewImg[j] = new GuiImageData(savebuffer);
|
||||||
FreeSaveBuffer();
|
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)
|
if (stat(filepath, &filestat) == 0)
|
||||||
{
|
{
|
||||||
timeinfo = localtime(&filestat.st_mtime);
|
timeinfo = localtime(&filestat.st_mtime);
|
||||||
@ -1714,14 +1701,14 @@ static int MenuGameSaves(int action)
|
|||||||
|
|
||||||
if(action == 0) // load
|
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])
|
switch(saves.type[ret])
|
||||||
{
|
{
|
||||||
case FILE_RAM:
|
case FILE_RAM:
|
||||||
result = LoadRAM(filepath, GCSettings.SaveMethod, NOTSILENT);
|
result = LoadRAM(filepath, NOTSILENT);
|
||||||
break;
|
break;
|
||||||
case FILE_STATE:
|
case FILE_STATE:
|
||||||
result = LoadState(filepath, GCSettings.SaveMethod, NOTSILENT);
|
result = LoadState(filepath, NOTSILENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(result)
|
if(result)
|
||||||
@ -1737,8 +1724,8 @@ static int MenuGameSaves(int action)
|
|||||||
|
|
||||||
if(i < 100)
|
if(i < 100)
|
||||||
{
|
{
|
||||||
MakeFilePath(filepath, FILE_RAM, method, romFilename, i);
|
MakeFilePath(filepath, FILE_RAM, romFilename, i);
|
||||||
SaveRAM(filepath, GCSettings.SaveMethod, NOTSILENT);
|
SaveRAM(filepath, NOTSILENT);
|
||||||
menu = MENU_GAME_SAVE;
|
menu = MENU_GAME_SAVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1750,21 +1737,21 @@ static int MenuGameSaves(int action)
|
|||||||
|
|
||||||
if(i < 100)
|
if(i < 100)
|
||||||
{
|
{
|
||||||
MakeFilePath(filepath, FILE_STATE, method, romFilename, i);
|
MakeFilePath(filepath, FILE_STATE, romFilename, i);
|
||||||
SaveState(filepath, GCSettings.SaveMethod, NOTSILENT);
|
SaveState(filepath, NOTSILENT);
|
||||||
menu = MENU_GAME_SAVE;
|
menu = MENU_GAME_SAVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // overwrite RAM/State
|
else // overwrite RAM/State
|
||||||
{
|
{
|
||||||
MakeFilePath(filepath, saves.type[ret], method, saves.filename[ret]);
|
MakeFilePath(filepath, saves.type[ret], saves.filename[ret]);
|
||||||
switch(saves.type[ret])
|
switch(saves.type[ret])
|
||||||
{
|
{
|
||||||
case FILE_RAM:
|
case FILE_RAM:
|
||||||
SaveRAM(filepath, GCSettings.SaveMethod, NOTSILENT);
|
SaveRAM(filepath, NOTSILENT);
|
||||||
break;
|
break;
|
||||||
case FILE_STATE:
|
case FILE_STATE:
|
||||||
SaveState(filepath, GCSettings.SaveMethod, NOTSILENT);
|
SaveState(filepath, NOTSILENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
menu = MENU_GAME_SAVE;
|
menu = MENU_GAME_SAVE;
|
||||||
@ -3367,29 +3354,29 @@ static int MenuSettingsFile()
|
|||||||
|
|
||||||
// no USB ports on GameCube
|
// no USB ports on GameCube
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
if(GCSettings.LoadMethod == METHOD_USB)
|
if(GCSettings.LoadMethod == DEVICE_USB)
|
||||||
GCSettings.LoadMethod++;
|
GCSettings.LoadMethod++;
|
||||||
if(GCSettings.SaveMethod == METHOD_USB)
|
if(GCSettings.SaveMethod == DEVICE_USB)
|
||||||
GCSettings.SaveMethod++;
|
GCSettings.SaveMethod++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// saving to DVD is impossible
|
// saving to DVD is impossible
|
||||||
if(GCSettings.SaveMethod == METHOD_DVD)
|
if(GCSettings.SaveMethod == DEVICE_DVD)
|
||||||
GCSettings.SaveMethod++;
|
GCSettings.SaveMethod++;
|
||||||
|
|
||||||
// disable SMB in GC mode (stalls out)
|
// disable SMB in GC mode (stalls out)
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
if(GCSettings.LoadMethod == METHOD_SMB)
|
if(GCSettings.LoadMethod == DEVICE_SMB)
|
||||||
GCSettings.LoadMethod++;
|
GCSettings.LoadMethod++;
|
||||||
if(GCSettings.SaveMethod == METHOD_SMB)
|
if(GCSettings.SaveMethod == DEVICE_SMB)
|
||||||
GCSettings.SaveMethod++;
|
GCSettings.SaveMethod++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// disable MC saving in Wii mode - does not work for some reason!
|
// disable MC saving in Wii mode - does not work for some reason!
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
if(GCSettings.SaveMethod == METHOD_MC_SLOTA)
|
if(GCSettings.SaveMethod == DEVICE_MC_SLOTA)
|
||||||
GCSettings.SaveMethod++;
|
GCSettings.SaveMethod++;
|
||||||
if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
|
if(GCSettings.SaveMethod == DEVICE_MC_SLOTB)
|
||||||
GCSettings.SaveMethod++;
|
GCSettings.SaveMethod++;
|
||||||
options.name[7][0] = 0;
|
options.name[7][0] = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -3400,18 +3387,18 @@ static int MenuSettingsFile()
|
|||||||
if(GCSettings.SaveMethod > 6)
|
if(GCSettings.SaveMethod > 6)
|
||||||
GCSettings.SaveMethod = 0;
|
GCSettings.SaveMethod = 0;
|
||||||
|
|
||||||
if (GCSettings.LoadMethod == METHOD_AUTO) sprintf (options.value[0],"Auto Detect");
|
if (GCSettings.LoadMethod == DEVICE_AUTO) sprintf (options.value[0],"Auto Detect");
|
||||||
else if (GCSettings.LoadMethod == METHOD_SD) sprintf (options.value[0],"SD");
|
else if (GCSettings.LoadMethod == DEVICE_SD) sprintf (options.value[0],"SD");
|
||||||
else if (GCSettings.LoadMethod == METHOD_USB) sprintf (options.value[0],"USB");
|
else if (GCSettings.LoadMethod == DEVICE_USB) sprintf (options.value[0],"USB");
|
||||||
else if (GCSettings.LoadMethod == METHOD_DVD) sprintf (options.value[0],"DVD");
|
else if (GCSettings.LoadMethod == DEVICE_DVD) sprintf (options.value[0],"DVD");
|
||||||
else if (GCSettings.LoadMethod == METHOD_SMB) sprintf (options.value[0],"Network");
|
else if (GCSettings.LoadMethod == DEVICE_SMB) sprintf (options.value[0],"Network");
|
||||||
|
|
||||||
if (GCSettings.SaveMethod == METHOD_AUTO) sprintf (options.value[1],"Auto Detect");
|
if (GCSettings.SaveMethod == DEVICE_AUTO) sprintf (options.value[1],"Auto Detect");
|
||||||
else if (GCSettings.SaveMethod == METHOD_SD) sprintf (options.value[1],"SD");
|
else if (GCSettings.SaveMethod == DEVICE_SD) sprintf (options.value[1],"SD");
|
||||||
else if (GCSettings.SaveMethod == METHOD_USB) sprintf (options.value[1],"USB");
|
else if (GCSettings.SaveMethod == DEVICE_USB) sprintf (options.value[1],"USB");
|
||||||
else if (GCSettings.SaveMethod == METHOD_SMB) sprintf (options.value[1],"Network");
|
else if (GCSettings.SaveMethod == DEVICE_SMB) sprintf (options.value[1],"Network");
|
||||||
else if (GCSettings.SaveMethod == METHOD_MC_SLOTA) sprintf (options.value[1],"MC Slot A");
|
else if (GCSettings.SaveMethod == DEVICE_MC_SLOTA) sprintf (options.value[1],"MC Slot A");
|
||||||
else if (GCSettings.SaveMethod == METHOD_MC_SLOTB) sprintf (options.value[1],"MC Slot B");
|
else if (GCSettings.SaveMethod == DEVICE_MC_SLOTB) sprintf (options.value[1],"MC Slot B");
|
||||||
|
|
||||||
snprintf (options.value[2], 30, "%s", GCSettings.LoadFolder);
|
snprintf (options.value[2], 30, "%s", GCSettings.LoadFolder);
|
||||||
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
|
snprintf (options.value[3], 30, "%s", GCSettings.SaveFolder);
|
||||||
|
@ -40,7 +40,7 @@ bool updateFound = false; // true if an app update was found
|
|||||||
void UpdateCheck()
|
void UpdateCheck()
|
||||||
{
|
{
|
||||||
// we can only check for the update if we have internet + SD
|
// 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];
|
static char url[128];
|
||||||
int retval;
|
int retval;
|
||||||
@ -264,7 +264,7 @@ ConnectShare (bool silent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unmountRequired[METHOD_SMB])
|
if(unmountRequired[DEVICE_SMB])
|
||||||
CloseShare();
|
CloseShare();
|
||||||
|
|
||||||
if(!networkInit)
|
if(!networkInit)
|
||||||
@ -291,9 +291,6 @@ ConnectShare (bool silent)
|
|||||||
ErrorPrompt("Failed to connect to network share.");
|
ErrorPrompt("Failed to connect to network share.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(networkShareInit)
|
|
||||||
sprintf(rootdir, "smb:");
|
|
||||||
|
|
||||||
return networkShareInit;
|
return networkShareInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ bool patchApplyPPF(MFILE *f, u8 **rom, int *size)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadPatch(int method, int size)
|
int LoadPatch(int size)
|
||||||
{
|
{
|
||||||
int newsize = size;
|
int newsize = size;
|
||||||
int patchsize = 0;
|
int patchsize = 0;
|
||||||
@ -422,7 +422,7 @@ int LoadPatch(int method, int size)
|
|||||||
|
|
||||||
for(patchtype=0; patchtype<3; patchtype++)
|
for(patchtype=0; patchtype<3; patchtype++)
|
||||||
{
|
{
|
||||||
patchsize = LoadFile(patchpath[patchtype], method, SILENT);
|
patchsize = LoadFile(patchpath[patchtype], SILENT);
|
||||||
|
|
||||||
if(patchsize)
|
if(patchsize)
|
||||||
break;
|
break;
|
||||||
|
@ -14,6 +14,6 @@
|
|||||||
|
|
||||||
#include "memfile.h"
|
#include "memfile.h"
|
||||||
|
|
||||||
int LoadPatch(int method, int size);
|
int LoadPatch(int size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* Prepare Preferences Data
|
* Prepare Preferences Data
|
||||||
*
|
*
|
||||||
* This sets up the save buffer for saving.
|
* This sets up the save buffer for saving.
|
||||||
****************************************************************************/
|
***************************************************************************/
|
||||||
static mxml_node_t *xml = NULL;
|
static mxml_node_t *xml = NULL;
|
||||||
static mxml_node_t *data = NULL;
|
static mxml_node_t *data = NULL;
|
||||||
static mxml_node_t *section = NULL;
|
static mxml_node_t *section = NULL;
|
||||||
@ -71,8 +71,7 @@ static void createXMLController(unsigned int controller[], const char * name, co
|
|||||||
mxmlElementSetAttr(item, "description", description);
|
mxmlElementSetAttr(item, "description", description);
|
||||||
|
|
||||||
// create buttons
|
// create buttons
|
||||||
int i;
|
for(int i=0; i < MAXJP; i++)
|
||||||
for(i=0; i < MAXJP; i++)
|
|
||||||
{
|
{
|
||||||
elem = mxmlNewElement(item, "button");
|
elem = mxmlNewElement(item, "button");
|
||||||
mxmlElementSetAttr(elem, "number", toStr(i));
|
mxmlElementSetAttr(elem, "number", toStr(i));
|
||||||
@ -108,14 +107,14 @@ static const char * XMLSaveCallback(mxml_node_t *node, int where)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
preparePrefsData (int method)
|
preparePrefsData ()
|
||||||
{
|
{
|
||||||
xml = mxmlNewXML("1.0");
|
xml = mxmlNewXML("1.0");
|
||||||
mxmlSetWrapMargin(0); // disable line wrapping
|
mxmlSetWrapMargin(0); // disable line wrapping
|
||||||
|
|
||||||
data = mxmlNewElement(xml, "file");
|
data = mxmlNewElement(xml, "file");
|
||||||
mxmlElementSetAttr(data, "app",APPNAME);
|
mxmlElementSetAttr(data, "app", APPNAME);
|
||||||
mxmlElementSetAttr(data, "version",APPVERSION);
|
mxmlElementSetAttr(data, "version", APPVERSION);
|
||||||
|
|
||||||
createXMLSection("File", "File Settings");
|
createXMLSection("File", "File Settings");
|
||||||
|
|
||||||
@ -177,8 +176,11 @@ preparePrefsData (int method)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Decode Preferences Data
|
* loadXMLSetting
|
||||||
****************************************************************************/
|
*
|
||||||
|
* Load XML elements into variables for an individual variable
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
static void loadXMLSetting(char * var, const char * name, int maxsize)
|
static void loadXMLSetting(char * var, const char * name, int maxsize)
|
||||||
{
|
{
|
||||||
item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
|
||||||
@ -210,6 +212,12 @@ static void loadXMLSetting(float * var, const char * name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* loadXMLController
|
||||||
|
*
|
||||||
|
* Load XML elements into variables for a controller mapping
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
static void loadXMLController(unsigned int controller[], const char * name)
|
static void loadXMLController(unsigned int controller[], const char * name)
|
||||||
{
|
{
|
||||||
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
||||||
@ -217,8 +225,7 @@ static void loadXMLController(unsigned int controller[], const char * name)
|
|||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
// populate buttons
|
// populate buttons
|
||||||
int i;
|
for(int i=0; i < MAXJP; i++)
|
||||||
for(i=0; i < MAXJP; i++)
|
|
||||||
{
|
{
|
||||||
elem = mxmlFindElement(item, xml, "button", "number", toStr(i), MXML_DESCEND);
|
elem = mxmlFindElement(item, xml, "button", "number", toStr(i), MXML_DESCEND);
|
||||||
if(elem)
|
if(elem)
|
||||||
@ -231,8 +238,14 @@ static void loadXMLController(unsigned int controller[], const char * name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* decodePrefsData
|
||||||
|
*
|
||||||
|
* Decodes preferences - parses XML and loads preferences into the variables
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
decodePrefsData (int method)
|
decodePrefsData ()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@ -244,9 +257,9 @@ decodePrefsData (int method)
|
|||||||
item = mxmlFindElement(xml, xml, "file", "version", NULL, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "file", "version", NULL, MXML_DESCEND);
|
||||||
if(item) // a version entry exists
|
if(item) // a version entry exists
|
||||||
{
|
{
|
||||||
const char * version = (char *)mxmlElementGetAttr(item, "version");
|
const char * version = mxmlElementGetAttr(item, "version");
|
||||||
|
|
||||||
if(version)
|
if(version && strlen(version) == 5)
|
||||||
{
|
{
|
||||||
// this code assumes version in format X.X.X
|
// this code assumes version in format X.X.X
|
||||||
// XX.X.X, X.XX.X, or X.X.XX will NOT work
|
// XX.X.X, X.XX.X, or X.X.XX will NOT work
|
||||||
@ -314,6 +327,7 @@ decodePrefsData (int method)
|
|||||||
loadXMLSetting(&GCSettings.Rumble, "Rumble");
|
loadXMLSetting(&GCSettings.Rumble, "Rumble");
|
||||||
|
|
||||||
// Controller Settings
|
// Controller Settings
|
||||||
|
|
||||||
loadXMLSetting(&GCSettings.Controller, "Controller");
|
loadXMLSetting(&GCSettings.Controller, "Controller");
|
||||||
loadXMLSetting(&GCSettings.crosshair, "crosshair");
|
loadXMLSetting(&GCSettings.crosshair, "crosshair");
|
||||||
|
|
||||||
@ -326,30 +340,46 @@ decodePrefsData (int method)
|
|||||||
}
|
}
|
||||||
mxmlDelete(xml);
|
mxmlDelete(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Save Preferences
|
* Save Preferences
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
static char prefpath[MAXPATHLEN] = { 0 };
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SavePrefs (bool silent)
|
SavePrefs (bool silent)
|
||||||
{
|
{
|
||||||
char filepath[1024];
|
char filepath[MAXPATHLEN];
|
||||||
int datasize;
|
int datasize;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int method = appLoadMethod;
|
int device = 0;
|
||||||
|
|
||||||
// We'll save using the first available method (probably SD) since this
|
if(prefpath[0] != 0)
|
||||||
// is the method preferences will be loaded from by default
|
{
|
||||||
if(method == METHOD_AUTO)
|
strcpy(filepath, prefpath);
|
||||||
method = autoSaveMethod(silent);
|
FindDevice(filepath, &device);
|
||||||
|
}
|
||||||
|
else if(appPath[0] != 0)
|
||||||
|
{
|
||||||
|
sprintf(filepath, "%s%s", appPath, PREF_FILE_NAME);
|
||||||
|
FindDevice(filepath, &device);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
device = autoLoadMethod();
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(device == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
if(device == DEVICE_MC_SLOTA || device == DEVICE_MC_SLOTB)
|
||||||
|
sprintf(filepath, "%s%s", pathPrefix[device], PREF_FILE_NAME);
|
||||||
|
else
|
||||||
|
sprintf(filepath, "%sfceugx/%s", pathPrefix[device], PREF_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(device == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
@ -358,9 +388,9 @@ SavePrefs (bool silent)
|
|||||||
FixInvalidSettings();
|
FixInvalidSettings();
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
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
|
// Set the comments
|
||||||
char prefscomment[2][32];
|
char prefscomment[2][32];
|
||||||
@ -370,7 +400,7 @@ SavePrefs (bool silent)
|
|||||||
SetMCSaveComments(prefscomment);
|
SetMCSaveComments(prefscomment);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
offset = SaveFile(filepath, datasize, silent);
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
|
|
||||||
@ -379,34 +409,35 @@ SavePrefs (bool silent)
|
|||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
InfoPrompt ("Preferences saved");
|
InfoPrompt("Preferences saved");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Load Preferences from specified method
|
* Load Preferences from specified filepath
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
bool
|
bool
|
||||||
LoadPrefsFromMethod (int method)
|
LoadPrefsFromMethod (char * filepath)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
char filepath[1024];
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, SILENT);
|
offset = LoadFile(filepath, SILENT);
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
retval = decodePrefsData (method);
|
retval = decodePrefsData ();
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
|
|
||||||
|
if(retval)
|
||||||
|
{
|
||||||
|
strcpy(prefpath, filepath);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,29 +453,28 @@ bool LoadPrefs()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool prefFound = false;
|
bool prefFound = false;
|
||||||
|
char filepath[4][MAXPATHLEN];
|
||||||
|
int numDevices;
|
||||||
|
|
||||||
if(appLoadMethod == METHOD_SD)
|
#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
|
||||||
|
|
||||||
|
for(int i=0; i<numDevices; i++)
|
||||||
{
|
{
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
prefFound = LoadPrefsFromMethod(filepath[i]);
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
|
||||||
}
|
if(prefFound)
|
||||||
else if(appLoadMethod == METHOD_USB)
|
break;
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prefLoaded = true; // attempted to load preferences
|
prefLoaded = true; // attempted to load preferences
|
||||||
|
Loading…
Reference in New Issue
Block a user