merge changes from cebolleto

This commit is contained in:
dborth 2014-10-24 02:51:36 +00:00
parent b68a302c9f
commit 2037f6cfa1
11 changed files with 4132 additions and 4045 deletions

View File

@ -63,7 +63,7 @@ int ShutdownRequested = 0;
int ResetRequested = 0; int ResetRequested = 0;
int ExitRequested = 0; int ExitRequested = 0;
char appPath[1024] = { 0 }; char appPath[1024] = { 0 };
char loadedFile[1024] = { 0 };
int frameskip = 0; int frameskip = 0;
int turbomode = 0; int turbomode = 0;
unsigned char * nesrom = NULL; unsigned char * nesrom = NULL;

View File

@ -76,13 +76,15 @@ enum {
struct SGCSettings{ struct SGCSettings{
int AutoLoad; int AutoLoad;
int AutoSave; int AutoSave;
int LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB) int LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB)
int SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, USB, SMB int SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, USB, SMB
char LoadFolder[MAXPATHLEN]; // Path to game files char LoadFolder[MAXPATHLEN]; // Path to game files
char LastFileLoaded[MAXPATHLEN]; //Last file loaded filename
char SaveFolder[MAXPATHLEN]; // Path to save files char SaveFolder[MAXPATHLEN]; // Path to save files
char CheatFolder[MAXPATHLEN]; // Path to cheat files char CheatFolder[MAXPATHLEN]; // Path to cheat files
char ScreenshotsFolder[MAXPATHLEN]; //Path to screenshots files
char smbip[80]; char smbip[80];
char smbuser[20]; char smbuser[20];
char smbpwd[20]; char smbpwd[20];
@ -120,7 +122,6 @@ extern int ConfigRequested;
extern int ShutdownRequested; extern int ShutdownRequested;
extern int ExitRequested; extern int ExitRequested;
extern char appPath[]; extern char appPath[];
extern char loadedFile[];
extern int frameskip; extern int frameskip;
extern int fskip; extern int fskip;
extern int fskipc; extern int fskipc;

View File

@ -36,7 +36,8 @@ BROWSERINFO browser;
BROWSERENTRY * browserList = NULL; // list of files/folders in browser BROWSERENTRY * browserList = NULL; // list of files/folders in browser
static char szpath[MAXPATHLEN]; static char szpath[MAXPATHLEN];
static bool inSz = false; char szname[MAXPATHLEN];
bool inSz = false;
char romFilename[256]; char romFilename[256];
bool loadingFile = false; bool loadingFile = false;
@ -211,6 +212,8 @@ int UpdateDirName()
/* remove last subdirectory name */ /* remove last subdirectory name */
size = strlen(browser.dir) - size - 1; size = strlen(browser.dir) - size - 1;
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;
browser.dir[size] = 0; browser.dir[size] = 0;
} }
@ -429,12 +432,11 @@ void StripExt(char* returnstring, char * inputstring)
***************************************************************************/ ***************************************************************************/
int BrowserLoadSz() int BrowserLoadSz()
{ {
char filepath[MAXPATHLEN]; memset(szpath, 0, MAXPATHLEN);
memset(filepath, 0, MAXPATHLEN); strncpy(szpath, browser.dir, strlen(browser.dir) - 1);
// we'll store the 7z filepath for extraction later strncpy(szname, strrchr(szpath, '/') + 1, strrchr(szpath, '.') - strrchr(szpath, '/'));
if(!MakeFilePath(szpath, FILE_ROM)) *strrchr(szname, '.') = '\0';
return 0;
int szfiles = SzParse(szpath); int szfiles = SzParse(szpath);
if(szfiles) if(szfiles)
@ -500,7 +502,7 @@ int BrowserLoadFile()
{ {
// store the filename (w/o ext) - used for ram/state naming // store the filename (w/o ext) - used for ram/state naming
StripExt(romFilename, browserList[browser.selIndex].filename); StripExt(romFilename, browserList[browser.selIndex].filename);
strcpy(loadedFile, browserList[browser.selIndex].filename); snprintf(GCSettings.LastFileLoaded, MAXPATHLEN, "%s", browserList[browser.selIndex].filename);
// load UPS/IPS/PPF patch // load UPS/IPS/PPF patch
filesize = LoadPatch(filesize); filesize = LoadPatch(filesize);
@ -540,21 +542,31 @@ int BrowserChangeFolder()
SzClose(); SzClose();
} }
if(!UpdateDirName()) if(!UpdateDirName())
return -1; return -1;
HaltParseThread(); // halt parsing HaltParseThread();
CleanupPath(browser.dir); CleanupPath(browser.dir);
ResetBrowser(); // reset browser ResetBrowser();
if(browser.dir[0] != 0) if(browser.dir[0] != 0)
ParseDirectory(); {
if(strstr(browser.dir, ".7z"))
{
BrowserLoadSz();
}
else
{
ParseDirectory(true, true);
}
FindAndSelectLastLoadedFile();
}
if(browser.numEntries == 0) if(browser.numEntries == 0)
{ {
browser.dir[0] = 0; browser.dir[0] = 0;
int i=0; int i=0;
#ifdef HW_RVL #ifdef HW_RVL
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "sd:/"); sprintf(browserList[i].filename, "sd:/");

View File

@ -55,6 +55,8 @@ enum
extern char romFilename[]; extern char romFilename[];
extern bool loadingFile; extern bool loadingFile;
extern char szname[MAXPATHLEN];
extern bool inSz;
bool MakeFilePath(char filepath[], int type, char * filename = NULL, int filenum = -2); bool MakeFilePath(char filepath[], int type, char * filename = NULL, int filenum = -2);
int UpdateDirName(); int UpdateDirName();

View File

@ -55,7 +55,7 @@ bool isMounted[7] = { false, false, false, false, false, false, false };
// folder parsing thread // folder parsing thread
static lwp_t parsethread = LWP_THREAD_NULL; static lwp_t parsethread = LWP_THREAD_NULL;
static DIR * dir = NULL; static DIR *dir = NULL;
static bool parseHalt = true; static bool parseHalt = true;
static bool parseFilter = true; static bool parseFilter = true;
static bool ParseDirEntries(); static bool ParseDirEntries();
@ -480,7 +480,7 @@ bool GetFileSize(int i)
{ {
if(browserList[i].length > 0) if(browserList[i].length > 0)
return true; return true;
struct stat filestat; struct stat filestat;
char path[MAXPATHLEN+1]; char path[MAXPATHLEN+1];
snprintf(path, MAXPATHLEN, "%s%s", browser.dir, browserList[i].filename); snprintf(path, MAXPATHLEN, "%s%s", browser.dir, browserList[i].filename);
@ -492,6 +492,40 @@ bool GetFileSize(int i)
return true; return true;
} }
void FindAndSelectLastLoadedFile ()
{
int indexFound = -1;
for(int j=1; j < browser.numEntries; j++)
{
if(strcmp(browserList[j].filename, GCSettings.LastFileLoaded) == 0)
{
indexFound = j;
break;
}
}
// move to this file
if(indexFound > 0)
{
if(indexFound >= FILE_PAGESIZE)
{
int newIndex = (floor(indexFound/(float)FILE_PAGESIZE)) * FILE_PAGESIZE;
if(newIndex + FILE_PAGESIZE > browser.numEntries)
newIndex = browser.numEntries - FILE_PAGESIZE;
if(newIndex < 0)
newIndex = 0;
browser.pageIndex = newIndex;
}
browser.selIndex = indexFound;
}
selectLoadedFile = 2; // selecting done
}
static bool ParseDirEntries() static bool ParseDirEntries()
{ {
if(!dir) if(!dir)
@ -528,7 +562,7 @@ static bool ParseDirEntries()
if(parseFilter && !isdir) if(parseFilter && !isdir)
{ {
ext = GetExt(entry->d_name); ext = GetExt(entry->d_name);
if(ext == NULL) if(ext == NULL)
continue; continue;
@ -577,40 +611,7 @@ static bool ParseDirEntries()
{ {
closedir(dir); // close directory closedir(dir); // close directory
dir = NULL; dir = NULL;
// try to find and select the last loaded file
if(selectLoadedFile == 1 && !parseHalt && loadedFile[0] != 0 && browser.dir[0] != 0)
{
int indexFound = -1;
for(int j=1; j < browser.numEntries; j++)
{
if(strcmp(browserList[j].filename, loadedFile) == 0)
{
indexFound = j;
break;
}
}
// move to this file
if(indexFound > 0)
{
if(indexFound >= FILE_PAGESIZE)
{
int newIndex = (floor(indexFound/(float)FILE_PAGESIZE)) * FILE_PAGESIZE;
if(newIndex + FILE_PAGESIZE > browser.numEntries)
newIndex = browser.numEntries - FILE_PAGESIZE;
if(newIndex < 0)
newIndex = 0;
browser.pageIndex = newIndex;
}
browser.selIndex = indexFound;
}
selectLoadedFile = 2; // selecting done
}
return false; // no more entries return false; // no more entries
} }
return true; // more entries return true; // more entries

View File

@ -30,6 +30,7 @@ bool ChangeInterface(int device, bool silent);
bool ChangeInterface(char * filepath, bool silent); bool ChangeInterface(char * filepath, bool silent);
void CreateAppPath(char * origpath); void CreateAppPath(char * origpath);
bool GetFileSize(int i); bool GetFileSize(int i);
void FindAndSelectLastLoadedFile();
int ParseDirectory(bool waitParse = false, bool filter = true); int ParseDirectory(bool waitParse = false, bool filter = true);
void AllocSaveBuffer(); void AllocSaveBuffer();
void FreeSaveBuffer(); void FreeSaveBuffer();

View File

@ -368,14 +368,15 @@ int SzParse(char * filepath)
int device; int device;
if(!FindDevice(browser.dir, &device) || !GetFileSize(browser.selIndex)) struct stat filestat;
if(stat(filepath, &filestat) < 0)
return 0;
unsigned int filelen = filestat.st_size;
if(!FindDevice(filepath, &device) || !filelen)
return 0; return 0;
int nbfiles = 0; int nbfiles = 0;
// save the length/offset of this file
unsigned int filelen = browserList[browser.selIndex].length;
// setup archive stream // setup archive stream
SzArchiveStream.offset = 0; SzArchiveStream.offset = 0;
SzArchiveStream.len = filelen; SzArchiveStream.len = filelen;
@ -424,7 +425,7 @@ int SzParse(char * filepath)
// add '..' folder in case the user wants exit the 7z // add '..' folder in case the user wants exit the 7z
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[0].filename, "..");
sprintf(browserList[0].displayname, "Up One Level"); sprintf(browserList[0].displayname, "Up One Level");
browserList[0].isdir = 1; browserList[0].isdir = 1;
browserList[0].length = filelen; browserList[0].length = filelen;
@ -453,6 +454,12 @@ int SzParse(char * filepath)
// parse information about this file to the file list structure // parse information about this file to the file list structure
snprintf(browserList[SzJ].filename, MAXJOLIET, "%s", SzF->Name); snprintf(browserList[SzJ].filename, MAXJOLIET, "%s", SzF->Name);
StripExt(browserList[SzJ].displayname, browserList[SzJ].filename); StripExt(browserList[SzJ].displayname, browserList[SzJ].filename);
char* strPos = strstr(browserList[SzJ].displayname, szname);
if(strPos)
{
snprintf(browserList[SzJ].displayname, MAXJOLIET, "%s", strPos + strlen(szname));
}
browserList[SzJ].length = SzF->Size; // filesize browserList[SzJ].length = SzF->Size; // filesize
browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags) browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags)
browserList[SzJ].filenum = SzI; // the extraction function identifies the file with this number browserList[SzJ].filenum = SzI; // the extraction function identifies the file with this number

View File

@ -240,7 +240,7 @@ class GuiElement
//!Constructor //!Constructor
GuiElement(); GuiElement();
//!Destructor //!Destructor
~GuiElement(); virtual ~GuiElement();
//!Set the element's parent //!Set the element's parent
//!\param e Pointer to parent element //!\param e Pointer to parent element
void SetParent(GuiElement * e); void SetParent(GuiElement * e);

File diff suppressed because it is too large Load Diff

View File

@ -124,9 +124,11 @@ preparePrefsData ()
createXMLSetting("LoadMethod", "Load Method", toStr(GCSettings.LoadMethod)); createXMLSetting("LoadMethod", "Load Method", toStr(GCSettings.LoadMethod));
createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod)); createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod));
createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder); createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
createXMLSetting("LastFileLoaded", "Last File Loaded", GCSettings.LastFileLoaded);
createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder); createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder); createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
createXMLSetting("gamegenie", "Game Genie", toStr(GCSettings.gamegenie)); createXMLSetting("gamegenie", "Game Genie", toStr(GCSettings.gamegenie));
createXMLSetting("ScreenshotsFolder", "Screenshots Folder", GCSettings.ScreenshotsFolder);
createXMLSection("Network", "Network Settings"); createXMLSection("Network", "Network Settings");
@ -296,9 +298,11 @@ decodePrefsData ()
loadXMLSetting(&GCSettings.LoadMethod, "LoadMethod"); loadXMLSetting(&GCSettings.LoadMethod, "LoadMethod");
loadXMLSetting(&GCSettings.SaveMethod, "SaveMethod"); loadXMLSetting(&GCSettings.SaveMethod, "SaveMethod");
loadXMLSetting(GCSettings.LoadFolder, "LoadFolder", sizeof(GCSettings.LoadFolder)); loadXMLSetting(GCSettings.LoadFolder, "LoadFolder", sizeof(GCSettings.LoadFolder));
loadXMLSetting(GCSettings.LastFileLoaded, "LastFileLoaded", sizeof(GCSettings.LastFileLoaded));
loadXMLSetting(GCSettings.SaveFolder, "SaveFolder", sizeof(GCSettings.SaveFolder)); loadXMLSetting(GCSettings.SaveFolder, "SaveFolder", sizeof(GCSettings.SaveFolder));
loadXMLSetting(GCSettings.CheatFolder, "CheatFolder", sizeof(GCSettings.CheatFolder)); loadXMLSetting(GCSettings.CheatFolder, "CheatFolder", sizeof(GCSettings.CheatFolder));
loadXMLSetting(&GCSettings.gamegenie, "gamegenie"); loadXMLSetting(&GCSettings.gamegenie, "gamegenie");
loadXMLSetting(GCSettings.ScreenshotsFolder, "ScreenshotsFolder", sizeof(GCSettings.ScreenshotsFolder));
// Network Settings // Network Settings
@ -433,6 +437,7 @@ DefaultSettings ()
sprintf (GCSettings.LoadFolder, "%s/roms", APPFOLDER); // Path to game files sprintf (GCSettings.LoadFolder, "%s/roms", APPFOLDER); // Path to game files
sprintf (GCSettings.SaveFolder, "%s/saves", APPFOLDER); // Path to save files sprintf (GCSettings.SaveFolder, "%s/saves", APPFOLDER); // Path to save files
sprintf (GCSettings.CheatFolder, "%s/cheats", APPFOLDER); // Path to cheat files sprintf (GCSettings.CheatFolder, "%s/cheats", APPFOLDER); // Path to cheat files
sprintf (GCSettings.CheatFolder, "%s/screenshots", APPFOLDER); // Path to cheat files
GCSettings.AutoLoad = 1; // Auto Load RAM GCSettings.AutoLoad = 1; // Auto Load RAM
GCSettings.AutoSave = 1; // Auto Save RAM GCSettings.AutoSave = 1; // Auto Save RAM
} }

View File

@ -311,7 +311,7 @@ static int pngu_decode (IMGCTX ctx, u32 width, u32 height, u32 stripAlpha)
return PNGU_INVALID_WIDTH_OR_HEIGHT; return PNGU_INVALID_WIDTH_OR_HEIGHT;
// Check if color type is supported by PNGU // Check if color type is supported by PNGU
if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_PALETTE) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN) ) if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN)
return PNGU_UNSUPPORTED_COLOR_TYPE; return PNGU_UNSUPPORTED_COLOR_TYPE;
// Scale 16 bit samples to 8 bit // Scale 16 bit samples to 8 bit
@ -329,6 +329,10 @@ static int pngu_decode (IMGCTX ctx, u32 width, u32 height, u32 stripAlpha)
// Transform grayscale images to RGB // Transform grayscale images to RGB
if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA) ) if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA) )
png_set_gray_to_rgb (ctx->png_ptr); png_set_gray_to_rgb (ctx->png_ptr);
// Transform palette images to RGB
if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(ctx->png_ptr);
// Flush transformations // Flush transformations
png_read_update_info (ctx->png_ptr, ctx->info_ptr); png_read_update_info (ctx->png_ptr, ctx->info_ptr);