From c6e9dce0d74a9afab93b0777f06feea71553b09a Mon Sep 17 00:00:00 2001 From: dborth Date: Mon, 17 Nov 2008 08:02:22 +0000 Subject: [PATCH] change pref file to /settings.xml --- source/ngc/filesel.cpp | 2 +- source/ngc/smbop.cpp | 2 +- source/ngc/vba.cpp | 36 +++++++++++++++++++++++++++++++++--- source/ngc/vba.h | 9 +++++---- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/source/ngc/filesel.cpp b/source/ngc/filesel.cpp index b871b28..2de9d78 100644 --- a/source/ngc/filesel.cpp +++ b/source/ngc/filesel.cpp @@ -229,7 +229,7 @@ bool MakeFilePath(char filepath[], int type, int method) sprintf(file, "%s.cht", ROMFilename); break; case FILE_PREF: - sprintf(folder, GCSettings.SaveFolder); + sprintf(folder, appPath); sprintf(file, "%s", PREF_FILE_NAME); break; } diff --git a/source/ngc/smbop.cpp b/source/ngc/smbop.cpp index 83ae73c..fd731c4 100644 --- a/source/ngc/smbop.cpp +++ b/source/ngc/smbop.cpp @@ -88,7 +88,7 @@ ConnectShare (bool silent) strlen(GCSettings.smbip) == 0) { if(!silent) - WaitPrompt((char*) "Invalid network settings. Check VBAGX.xml."); + WaitPrompt((char*) "Invalid network settings. Check settings.xml."); return false; } diff --git a/source/ngc/vba.cpp b/source/ngc/vba.cpp index d5cc76d..54caa21 100644 --- a/source/ngc/vba.cpp +++ b/source/ngc/vba.cpp @@ -44,6 +44,7 @@ extern int emulating; int ConfigRequested = 0; int ShutdownRequested = 0; int ResetRequested = 0; +char appPath[1024]; /**************************************************************************** * Shutdown / Reboot / Exit @@ -124,12 +125,38 @@ void ipl_set_config(unsigned char c) } #endif +void CreateAppPath(char origpath[]) +{ +#ifdef HW_DOL + sprintf(appPath, GCSettings.SaveFolder); +#else + char path[1024]; + strcpy(path, origpath); // make a copy so we don't mess up original + + char * loc; + int pos = -1; + + loc = strrchr(path,'/'); + if (loc != NULL) + *loc = 0; // strip file name + + loc = strchr(path,'/'); // looking for / from fat:/ + if (loc != NULL) + pos = loc - path + 1; + + if(pos >= 0 && pos < 1024) + sprintf(appPath, &(path[pos])); + else + sprintf(appPath, "/"); +#endif +} + /**************************************************************************** * main * * Program entry ****************************************************************************/ -int main() +int main(int argc, char *argv[]) { #ifdef HW_DOL ipl_set_config(6); // disable Qoob modchip @@ -149,11 +176,11 @@ int main() PAD_Init (); // Wii Power/Reset buttons -#ifdef HW_RVL + #ifdef HW_RVL WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); SYS_SetPowerCallback(ShutdownCB); SYS_SetResetCallback(ResetCB); -#endif + #endif int selectedMenu = -1; @@ -185,6 +212,9 @@ int main() // Set defaults DefaultSettings (); + // store path app was loaded from + CreateAppPath(argv[0]); + // Load preferences if(!LoadPrefs()) { diff --git a/source/ngc/vba.h b/source/ngc/vba.h index f031e73..461607c 100644 --- a/source/ngc/vba.h +++ b/source/ngc/vba.h @@ -11,10 +11,10 @@ #define _VBA_H_ #include -#define VERSIONNUM "1.0.4" -#define VERSIONSTR "VBA GX 1.0.4" -#define VERSIONSTRFULL "Visual Boy Advance GX 1.0.4" -#define PREF_FILE_NAME "VBAGX.xml" +#define VERSIONNUM "1.0.5" +#define VERSIONSTR "VBA GX 1.0.5" +#define VERSIONSTRFULL "Visual Boy Advance GX 1.0.5" +#define PREF_FILE_NAME "settings.xml" #define NOTSILENT 0 #define SILENT 1 @@ -67,5 +67,6 @@ void ShutdownWii(); extern struct SGCSettings GCSettings; extern int ConfigRequested; extern int ShutdownRequested; +extern char appPath[]; #endif