fceugx/source/filebrowser.cpp

684 lines
17 KiB
C++
Raw Normal View History

2008-09-02 03:57:21 +02:00
/****************************************************************************
2009-07-22 04:05:49 +02:00
* FCE Ultra
2008-09-02 03:57:21 +02:00
* Nintendo Wii/Gamecube Port
*
2009-03-28 18:23:08 +01:00
* Tantric 2008-2009
2008-09-02 03:57:21 +02:00
*
2009-03-28 18:23:08 +01:00
* filebrowser.cpp
2008-09-02 03:57:21 +02:00
*
* Generic file routines - reading, writing, browsing
****************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wiiuse/wpad.h>
#include <sys/dir.h>
#ifdef HW_RVL
2008-09-02 03:57:21 +02:00
#include <di/di.h>
#endif
#include "fceugx.h"
2010-03-22 00:49:24 +01:00
#include "fceusupport.h"
2009-03-28 18:23:08 +01:00
#include "menu.h"
#include "filebrowser.h"
2008-12-24 08:58:23 +01:00
#include "networkop.h"
2008-09-02 03:57:21 +02:00
#include "fileop.h"
#include "pad.h"
#include "fceuload.h"
#include "gcunzip.h"
2009-03-28 18:23:08 +01:00
#include "fceuram.h"
#include "fceustate.h"
2009-07-23 07:39:43 +02:00
#include "patch.h"
#include "pocketnes/goombasav.h"
#include "pocketnes/pocketnesrom.h"
2008-09-02 03:57:21 +02:00
BROWSERINFO browser;
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
static char szpath[MAXPATHLEN];
2014-10-24 04:51:36 +02:00
char szname[MAXPATHLEN];
bool inSz = false;
2009-03-30 10:22:55 +02:00
char romFilename[256];
bool loadingFile = false;
2008-09-02 03:57:21 +02:00
/****************************************************************************
* autoLoadMethod()
2009-10-02 00:21:25 +02:00
* Auto-determines and sets the load device
* Returns device set
2008-09-02 03:57:21 +02:00
****************************************************************************/
int autoLoadMethod()
{
2009-10-02 00:21:25 +02:00
ShowAction ("Attempting to determine load device...");
int device = DEVICE_AUTO;
if(ChangeInterface(DEVICE_SD, SILENT))
device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB;
else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB;
2009-10-02 00:21:25 +02:00
else if(ChangeInterface(DEVICE_DVD, SILENT))
device = DEVICE_DVD;
else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB;
2008-09-02 03:57:21 +02:00
else
2009-10-02 00:21:25 +02:00
ErrorPrompt("Unable to locate a load device!");
2009-10-02 00:21:25 +02:00
if(GCSettings.LoadMethod == DEVICE_AUTO)
GCSettings.LoadMethod = device; // save device found for later use
2009-03-28 18:23:08 +01:00
CancelAction();
2009-10-02 00:21:25 +02:00
return device;
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
* autoSaveMethod()
2009-10-02 00:21:25 +02:00
* Auto-determines and sets the save device
* Returns device set
2008-09-02 03:57:21 +02:00
****************************************************************************/
int autoSaveMethod(bool silent)
2008-09-02 03:57:21 +02:00
{
if(!silent)
2009-10-02 00:21:25 +02:00
ShowAction ("Attempting to determine save device...");
int device = DEVICE_AUTO;
if(ChangeInterface(DEVICE_SD, SILENT))
device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB;
else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB;
2009-10-02 00:21:25 +02:00
else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB;
else if(!silent)
2009-10-02 00:21:25 +02:00
ErrorPrompt("Unable to locate a save device!");
2009-10-02 00:21:25 +02:00
if(GCSettings.SaveMethod == DEVICE_AUTO)
GCSettings.SaveMethod = device; // save device found for later use
2009-03-28 18:23:08 +01:00
CancelAction();
2009-10-02 00:21:25 +02:00
return device;
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
* ResetBrowser()
* Clears the file browser memory, and allocates one initial entry
***************************************************************************/
void ResetBrowser()
{
2009-03-28 18:23:08 +01:00
browser.numEntries = 0;
browser.selIndex = 0;
browser.pageIndex = 0;
2010-06-23 19:22:46 +02:00
browser.size = 0;
2009-10-02 00:21:25 +02:00
}
bool AddBrowserEntry()
{
2010-06-23 19:22:46 +02:00
if(browser.size >= MAX_BROWSER_SIZE)
2009-10-02 00:21:25 +02:00
{
ErrorPrompt("Out of memory: too many files!");
2010-06-23 19:22:46 +02:00
return false; // out of space
2009-10-02 00:21:25 +02:00
}
2010-06-23 19:22:46 +02:00
2009-10-02 00:21:25 +02:00
memset(&(browserList[browser.size]), 0, sizeof(BROWSERENTRY)); // clear the new entry
browser.size++;
return true;
}
2009-06-12 09:48:27 +02:00
/****************************************************************************
* CleanupPath()
* Cleans up the filepath, removing double // and replacing \ with /
***************************************************************************/
static void CleanupPath(char * path)
{
2009-10-02 00:21:25 +02:00
if(!path || path[0] == 0)
return;
2009-06-12 09:48:27 +02:00
int pathlen = strlen(path);
int j = 0;
for(int i=0; i < pathlen && i < MAXPATHLEN; i++)
{
if(path[i] == '\\')
path[i] = '/';
if(j == 0 || !(path[j-1] == '/' && path[i] == '/'))
path[j++] = path[i];
}
path[j] = 0;
2009-10-02 00:21:25 +02:00
}
2009-06-12 09:48:27 +02:00
2009-10-02 00:21:25 +02:00
bool IsDeviceRoot(char * path)
{
if(path == NULL || path[0] == 0)
return false;
if( strcmp(path, "sd:/") == 0 ||
strcmp(path, "usb:/") == 0 ||
strcmp(path, "dvd:/") == 0 ||
strcmp(path, "smb:/") == 0 ||
strcmp(path, "carda:/") == 0 ||
strcmp(path, "cardb:/") == 0)
2009-10-02 00:21:25 +02:00
{
return true;
}
return false;
2009-06-12 09:48:27 +02:00
}
/****************************************************************************
* UpdateDirName()
* Update curent directory name for file browser
2008-09-02 03:57:21 +02:00
***************************************************************************/
2009-10-02 00:21:25 +02:00
int UpdateDirName()
2008-09-02 03:57:21 +02:00
{
int size=0;
2008-11-12 09:40:09 +01:00
char * test;
2008-09-02 03:57:21 +02:00
char temp[1024];
2009-10-02 00:21:25 +02:00
int device = 0;
if(browser.numEntries == 0)
return 1;
FindDevice(browser.dir, &device);
2008-09-02 03:57:21 +02:00
/* current directory doesn't change */
if (strcmp(browserList[browser.selIndex].filename,".") == 0)
2008-09-02 03:57:21 +02:00
{
return 0;
}
/* go up to parent directory */
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
2008-09-02 03:57:21 +02:00
{
2009-10-02 00:21:25 +02:00
// already at the top level
if(IsDeviceRoot(browser.dir))
2008-09-02 03:57:21 +02:00
{
2009-10-02 00:21:25 +02:00
browser.dir[0] = 0; // remove device - we are going to the device listing screen
}
else
{
/* determine last subdirectory namelength */
sprintf(temp,"%s",browser.dir);
test = strtok(temp,"/");
while (test != NULL)
{
size = strlen(test);
test = strtok(NULL,"/");
}
/* remove last subdirectory name */
size = strlen(browser.dir) - size - 1;
2014-10-24 04:51:36 +02:00
strncpy(GCSettings.LastFileLoaded, &browser.dir[size], strlen(browser.dir) - size - 1); //set as loaded file the previous dir
GCSettings.LastFileLoaded[strlen(browser.dir) - size - 1] = 0;
2009-10-02 00:21:25 +02:00
browser.dir[size] = 0;
2008-09-02 03:57:21 +02:00
}
return 1;
}
/* Open a directory */
else
{
/* test new directory namelength */
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) < MAXPATHLEN)
2008-09-02 03:57:21 +02:00
{
/* update current directory name */
2009-06-12 09:48:27 +02:00
sprintf(browser.dir, "%s%s/",browser.dir, browserList[browser.selIndex].filename);
2008-09-02 03:57:21 +02:00
return 1;
}
else
{
2009-03-28 18:23:08 +01:00
ErrorPrompt("Directory name is too long!");
2008-09-02 03:57:21 +02:00
return -1;
}
}
}
2009-10-02 00:21:25 +02:00
bool MakeFilePath(char filepath[], int type, char * filename, int filenum)
2008-10-13 20:15:03 +02:00
{
2008-11-12 09:40:09 +01:00
char file[512];
char folder[1024];
2009-03-28 18:23:08 +01:00
char ext[4];
2008-10-13 20:15:03 +02:00
char temppath[MAXPATHLEN];
2008-11-12 09:40:09 +01:00
if(type == FILE_ROM)
2008-10-13 20:15:03 +02:00
{
2008-11-12 09:40:09 +01:00
// Check path length
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
2008-11-12 09:40:09 +01:00
{
2009-03-28 18:23:08 +01:00
ErrorPrompt("Maximum filepath length reached!");
2008-11-12 09:40:09 +01:00
filepath[0] = 0;
return false;
}
2008-10-13 20:15:03 +02:00
else
2008-11-12 09:40:09 +01:00
{
2009-06-12 09:48:27 +02:00
sprintf(temppath, "%s%s",browser.dir,browserList[browser.selIndex].filename);
2008-11-12 09:40:09 +01:00
}
2008-10-13 20:15:03 +02:00
}
else
{
2009-10-04 01:08:40 +02:00
if(GCSettings.SaveMethod == DEVICE_AUTO)
GCSettings.SaveMethod = autoSaveMethod(SILENT);
if(GCSettings.SaveMethod == DEVICE_AUTO)
return false;
2008-11-12 09:40:09 +01:00
switch(type)
{
case FILE_RAM:
case FILE_STATE:
sprintf(folder, GCSettings.SaveFolder);
2009-03-28 18:23:08 +01:00
if(type == FILE_RAM) sprintf(ext, "sav");
else sprintf(ext, "fcs");
2009-04-09 09:49:28 +02:00
if(filenum >= -1)
2009-03-28 18:23:08 +01:00
{
2009-11-29 08:55:21 +01:00
if(filenum == -1)
sprintf(file, "%s.%s", filename, ext);
else if(filenum == 0)
if (GCSettings.AppendAuto <= 0)
sprintf(file, "%s.%s", filename, ext);
else
sprintf(file, "%s Auto.%s", filename, ext);
2009-03-28 18:23:08 +01:00
else
2009-11-29 08:55:21 +01:00
sprintf(file, "%s %i.%s", filename, filenum, ext);
2009-03-28 18:23:08 +01:00
}
else
{
sprintf(file, "%s", filename);
}
2008-11-12 09:40:09 +01:00
break;
2009-03-28 18:23:08 +01:00
2009-07-22 03:58:45 +02:00
case FILE_CHEAT:
sprintf(folder, GCSettings.CheatFolder);
sprintf(file, "%s.cht", romFilename);
break;
2008-11-12 09:40:09 +01:00
}
2009-11-29 08:55:21 +01:00
sprintf (temppath, "%s%s/%s", pathPrefix[GCSettings.SaveMethod], folder, file);
2008-11-12 09:40:09 +01:00
}
2009-06-12 09:48:27 +02:00
CleanupPath(temppath); // cleanup path
2011-03-20 18:16:07 +01:00
snprintf(filepath, MAXPATHLEN, "%s", temppath);
2008-11-12 09:40:09 +01:00
return true;
}
2009-10-02 00:21:25 +02:00
/****************************************************************************
2008-09-02 03:57:21 +02:00
* FileSortCallback
*
* Quick sort callback to sort file entries with the following order:
* .
* ..
* <dirs>
* <files>
***************************************************************************/
int FileSortCallback(const void *f1, const void *f2)
{
/* Special case for implicit directories */
if(((BROWSERENTRY *)f1)->filename[0] == '.' || ((BROWSERENTRY *)f2)->filename[0] == '.')
2008-09-02 03:57:21 +02:00
{
if(strcmp(((BROWSERENTRY *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((BROWSERENTRY *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((BROWSERENTRY *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((BROWSERENTRY *)f2)->filename, "..") == 0) { return 1; }
2008-09-02 03:57:21 +02:00
}
/* If one is a file and one is a directory the directory is first. */
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
2008-09-02 03:57:21 +02:00
return strcasecmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
* IsValidROM
*
* Checks if the specified file is a valid ROM
* For now we will just check the file extension and file size
* If the file is a zip, we will check the file extension / file size of the
* first file inside
***************************************************************************/
2009-10-02 00:21:25 +02:00
static bool IsValidROM()
{
if (strlen(browserList[browser.selIndex].filename) > 4)
{
char * p = strrchr(browserList[browser.selIndex].filename, '.');
if (p != NULL)
{
if(strcasecmp(p, ".gba") == 0)
{
// File will be checked for GBA ROMs later.
return true;
}
char * zippedFilename = NULL;
if(strcasecmp(p, ".zip") == 0 && !inSz)
{
// we need to check the file extension of the first file in the archive
zippedFilename = GetFirstZipFilename ();
if(zippedFilename && strlen(zippedFilename) > 4)
p = strrchr(zippedFilename, '.');
else
p = NULL;
}
if(p != NULL)
{
if (
strcasecmp(p, ".nes") == 0 ||
strcasecmp(p, ".fds") == 0 ||
strcasecmp(p, ".nsf") == 0 ||
strcasecmp(p, ".unf") == 0 ||
strcasecmp(p, ".nez") == 0 ||
strcasecmp(p, ".unif") == 0
)
{
if(zippedFilename) free(zippedFilename);
return true;
}
}
if(zippedFilename) free(zippedFilename);
}
}
2009-03-28 18:23:08 +01:00
ErrorPrompt("Unknown file type!");
return false;
}
2008-10-13 20:15:03 +02:00
/****************************************************************************
* IsSz
*
* Checks if the specified file is a 7z
***************************************************************************/
bool IsSz()
{
if (strlen(browserList[browser.selIndex].filename) > 4)
2008-10-13 20:15:03 +02:00
{
char * p = strrchr(browserList[browser.selIndex].filename, '.');
2008-10-13 20:15:03 +02:00
if (p != NULL)
if(strcasecmp(p, ".7z") == 0)
2008-10-13 20:15:03 +02:00
return true;
}
return false;
}
2008-09-02 03:57:21 +02:00
/****************************************************************************
* StripExt
*
* Strips an extension from a filename
2009-03-28 18:23:08 +01:00
***************************************************************************/
2008-09-02 03:57:21 +02:00
void StripExt(char* returnstring, char * inputstring)
{
char* loc_dot;
2011-03-20 18:16:07 +01:00
snprintf(returnstring, MAXJOLIET, "%s", inputstring);
2009-03-28 18:23:08 +01:00
if(inputstring == NULL || strlen(inputstring) < 4)
return;
2008-09-02 03:57:21 +02:00
loc_dot = strrchr(returnstring,'.');
if (loc_dot != NULL)
2009-03-28 18:23:08 +01:00
*loc_dot = 0; // strip file extension
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
2009-03-28 18:23:08 +01:00
* BrowserLoadSz
2008-09-02 03:57:21 +02:00
*
2009-03-28 18:23:08 +01:00
* Opens the selected 7z file, and parses a listing of the files within
***************************************************************************/
2009-10-02 00:21:25 +02:00
int BrowserLoadSz()
2008-09-02 03:57:21 +02:00
{
2014-10-24 04:51:36 +02:00
memset(szpath, 0, MAXPATHLEN);
strncpy(szpath, browser.dir, strlen(browser.dir) - 1);
strncpy(szname, strrchr(szpath, '/') + 1, strrchr(szpath, '.') - strrchr(szpath, '/'));
*strrchr(szname, '.') = '\0';
2008-10-13 20:15:03 +02:00
2009-10-02 00:21:25 +02:00
int szfiles = SzParse(szpath);
2009-03-28 18:23:08 +01:00
if(szfiles)
{
browser.numEntries = szfiles;
inSz = true;
}
else
ErrorPrompt("Error opening archive!");
2008-10-13 20:15:03 +02:00
2009-03-28 18:23:08 +01:00
return szfiles;
}
2008-09-02 03:57:21 +02:00
2009-03-28 18:23:08 +01:00
/****************************************************************************
* BrowserLoadFile
*
* Loads the selected ROM
***************************************************************************/
2009-10-02 00:21:25 +02:00
int BrowserLoadFile()
2009-03-28 18:23:08 +01:00
{
char filepath[1024];
2009-10-03 21:10:34 +02:00
size_t filesize = 0;
2009-03-28 18:23:08 +01:00
romLoaded = false;
2008-09-02 03:57:21 +02:00
2009-10-02 00:21:25 +02:00
int device;
if(!FindDevice(browser.dir, &device))
return 0;
2009-03-28 18:23:08 +01:00
// check that this is a valid ROM
2009-10-02 00:21:25 +02:00
if(!IsValidROM())
2009-03-28 18:23:08 +01:00
goto done;
2008-11-12 09:40:09 +01:00
loadingFile = true;
2009-03-28 18:23:08 +01:00
if(!inSz)
{
2009-10-02 00:21:25 +02:00
if(!MakeFilePath(filepath, FILE_ROM))
2009-03-28 18:23:08 +01:00
goto done;
2008-10-06 00:46:15 +02:00
filesize = LoadFile ((char *)nesrom, filepath, 0, (1024*1024*4), NOTSILENT);
if(filesize > 0) {
// check nesrom for PocketNES embedded roms
const char *ext = strrchr(filepath, '.');
if (ext != NULL && strcmp(ext, ".gba") == 0)
{
const pocketnes_romheader* rom1 = pocketnes_first_rom(nesrom, filesize);
const pocketnes_romheader* rom2 = NULL;
if (rom1 != NULL) {
rom2 = pocketnes_next_rom(nesrom, filesize, rom1);
}
if (rom1 == NULL)
ErrorPrompt("No NES ROMs found in this file.");
else if (rom2 != NULL)
ErrorPrompt("More than one NES ROM found in this file. Only files with one ROM are supported.");
else
{
const void* rom = rom1 + 1;
filesize = little_endian_conv_32(rom1->filesize);
memcpy(nesrom, rom, filesize);
}
}
}
2009-03-28 18:23:08 +01:00
}
else
{
filesize = LoadSzFile(szpath, nesrom);
2009-07-09 23:49:26 +02:00
if(filesize <= 0)
{
browser.selIndex = 0;
2009-10-02 00:21:25 +02:00
BrowserChangeFolder();
2009-07-09 23:49:26 +02:00
}
2009-03-28 18:23:08 +01:00
}
loadingFile = false;
2008-09-02 03:57:21 +02:00
2009-03-28 18:23:08 +01:00
if (filesize <= 0)
{
2010-03-18 00:20:00 +01:00
ErrorPrompt("Error loading game!");
2009-03-28 18:23:08 +01:00
}
else
{
2010-04-10 08:36:58 +02:00
// store the filename (w/o ext) - used for ram/state naming
StripExt(romFilename, browserList[browser.selIndex].filename);
2014-10-24 04:51:36 +02:00
snprintf(GCSettings.LastFileLoaded, MAXPATHLEN, "%s", browserList[browser.selIndex].filename);
2010-04-10 08:36:58 +02:00
2009-07-23 07:39:43 +02:00
// load UPS/IPS/PPF patch
2009-10-02 00:21:25 +02:00
filesize = LoadPatch(filesize);
2009-07-23 07:39:43 +02:00
2009-10-02 00:21:25 +02:00
if(GCMemROM(filesize) > 0)
2009-03-28 18:23:08 +01:00
{
romLoaded = true;
2008-10-02 07:28:01 +02:00
2009-03-28 18:23:08 +01:00
// load RAM or state
if (GCSettings.AutoLoad == 1)
2009-10-02 00:21:25 +02:00
LoadRAMAuto(SILENT);
2009-03-28 18:23:08 +01:00
else if (GCSettings.AutoLoad == 2)
2009-10-02 00:21:25 +02:00
LoadStateAuto(SILENT);
2008-09-02 03:57:21 +02:00
2009-03-28 18:23:08 +01:00
ResetNES();
ResetBrowser();
}
}
done:
CancelAction();
return romLoaded;
}
2008-09-02 03:57:21 +02:00
2009-03-28 18:23:08 +01:00
/****************************************************************************
* BrowserChangeFolder
*
* Update current directory and set new entry list if directory has changed
***************************************************************************/
2009-10-02 00:21:25 +02:00
int BrowserChangeFolder()
2009-03-28 18:23:08 +01:00
{
2009-10-02 00:21:25 +02:00
int device = 0;
FindDevice(browser.dir, &device);
2009-03-28 18:23:08 +01:00
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
{
inSz = false;
SzClose();
}
2008-11-12 09:40:09 +01:00
2014-10-24 04:51:36 +02:00
if(!UpdateDirName())
2009-03-28 18:23:08 +01:00
return -1;
2008-10-13 20:15:03 +02:00
2014-10-24 04:51:36 +02:00
HaltParseThread();
2011-03-20 18:16:07 +01:00
CleanupPath(browser.dir);
2014-10-24 04:51:36 +02:00
ResetBrowser();
2009-06-12 09:48:27 +02:00
2009-10-02 00:21:25 +02:00
if(browser.dir[0] != 0)
2014-10-24 04:51:36 +02:00
{
if(strstr(browser.dir, ".7z"))
{
BrowserLoadSz();
}
else
{
ParseDirectory(true, true);
}
FindAndSelectLastLoadedFile();
}
2009-10-02 00:21:25 +02:00
if(browser.numEntries == 0)
{
browser.dir[0] = 0;
int i=0;
2014-10-24 04:51:36 +02:00
#ifdef HW_RVL
2009-10-02 00:21:25 +02:00
AddBrowserEntry();
sprintf(browserList[i].filename, "sd:/");
sprintf(browserList[i].displayname, "SD Card");
browserList[i].length = 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].isdir = 1;
browserList[i].icon = ICON_USB;
i++;
#else
AddBrowserEntry();
sprintf(browserList[i].filename, "carda:/");
sprintf(browserList[i].displayname, "SD Gecko Slot A");
browserList[i].length = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
AddBrowserEntry();
sprintf(browserList[i].filename, "cardb:/");
sprintf(browserList[i].displayname, "SD Gecko Slot B");
browserList[i].length = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
2009-10-02 00:21:25 +02:00
#endif
AddBrowserEntry();
sprintf(browserList[i].filename, "smb:/");
sprintf(browserList[i].displayname, "Network Share");
browserList[i].length = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SMB;
i++;
2009-10-02 00:21:25 +02:00
AddBrowserEntry();
sprintf(browserList[i].filename, "dvd:/");
sprintf(browserList[i].displayname, "Data DVD");
browserList[i].length = 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
2009-03-28 18:23:08 +01:00
{
2009-10-02 00:21:25 +02:00
char * path = StripDevice(browser.dir);
if(path != NULL)
strcpy(GCSettings.LoadFolder, path);
FindDevice(browser.dir, &GCSettings.LoadMethod);
}
2009-03-28 18:23:08 +01:00
return browser.numEntries;
2008-09-02 03:57:21 +02:00
}
/****************************************************************************
* OpenROM
2009-03-28 18:23:08 +01:00
* Displays a list of ROMS on load device
***************************************************************************/
2008-09-02 03:57:21 +02:00
int
2009-03-28 18:23:08 +01:00
OpenGameList ()
2008-09-02 03:57:21 +02:00
{
2009-10-02 00:21:25 +02:00
int device = GCSettings.LoadMethod;
2009-03-28 18:23:08 +01:00
2009-10-06 08:38:32 +02:00
if(device == DEVICE_AUTO && strlen(GCSettings.LoadFolder) > 0)
2009-10-02 00:21:25 +02:00
device = autoLoadMethod();
2008-09-02 03:57:21 +02:00
2009-03-28 18:23:08 +01:00
// change current dir to roms directory
2009-10-02 00:21:25 +02:00
if(device > 0)
2009-10-02 05:14:04 +02:00
sprintf(browser.dir, "%s%s/", pathPrefix[device], GCSettings.LoadFolder);
2009-10-02 00:21:25 +02:00
else
browser.dir[0] = 0;
BrowserChangeFolder();
2009-03-28 18:23:08 +01:00
return browser.numEntries;
2008-09-02 03:57:21 +02:00
}