From cfbbe9a21d866bed243c31e72660d63b1e69f9e2 Mon Sep 17 00:00:00 2001 From: dborth Date: Thu, 9 Apr 2009 07:49:28 +0000 Subject: [PATCH] minor bugfixes --- source/ngc/fceugx.cpp | 32 ++++++++++++++++++++++++-------- source/ngc/fceuram.cpp | 23 +++++++++++++++++++++-- source/ngc/filebrowser.cpp | 29 +++++++++++++++++++++++------ source/ngc/filebrowser.h | 2 +- source/ngc/gcvideo.cpp | 2 +- source/ngc/menu.cpp | 3 +-- source/ngc/preferences.cpp | 2 +- 7 files changed, 72 insertions(+), 21 deletions(-) diff --git a/source/ngc/fceugx.cpp b/source/ngc/fceugx.cpp index 5c4ad80..a0209cd 100644 --- a/source/ngc/fceugx.cpp +++ b/source/ngc/fceugx.cpp @@ -53,15 +53,18 @@ extern uint8 FDSBIOS[8192]; void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); } -unsigned char * nesrom = NULL; +static uint8 *xbsave=NULL; +static int fskipc = 0; +static int videoReset = 0; +static int currentMode = 0; +static int ResetRequested = 0; int ConfigRequested = 0; int ShutdownRequested = 0; -int ResetRequested = 0; int ExitRequested = 0; char appPath[1024]; FreeTypeGX *fontSystem; -uint8 *xbsave=NULL; int frameskip = 0; +unsigned char * nesrom = NULL; /**************************************************************************** * Shutdown / Reboot / Exit @@ -274,6 +277,8 @@ int main(int argc, char *argv[]) else MainMenu(MENU_GAME); + videoReset = -1; + currentMode = GCSettings.render; ConfigRequested = 0; SwitchAudioMode(0); @@ -286,7 +291,7 @@ int main(int argc, char *argv[]) setFrameTimer(); // set frametimer method before emulation SetPalette(); - static int fskipc=0; + fskipc=0; while(1) // emulation loop { @@ -313,10 +318,21 @@ int main(int argc, char *argv[]) } if(ConfigRequested) { - TakeScreenshot(); - ResetVideo_Menu(); - ConfigRequested = 0; - break; // leave emulation loop + if((GCSettings.render != 0 && videoReset == -1) || videoReset == 0) + { + TakeScreenshot(); + ResetVideo_Menu(); + ConfigRequested = 0; + GCSettings.render = currentMode; + break; // leave emulation loop + } + else if(videoReset == -1) + { + GCSettings.render = 2; + videoReset = 2; + ResetVideo_Emu(); + } + videoReset--; } } // emulation loop } // main loop diff --git a/source/ngc/fceuram.cpp b/source/ngc/fceuram.cpp index 8f7f4ae..3cb200c 100644 --- a/source/ngc/fceuram.cpp +++ b/source/ngc/fceuram.cpp @@ -182,10 +182,29 @@ LoadRAMAuto (int method, bool silent) if(method == METHOD_AUTO) return false; - char filepath[1024]; + char filepath[MAXPATHLEN]; + char fullpath[MAXPATHLEN]; + char filepath2[MAXPATHLEN]; + char fullpath2[MAXPATHLEN]; + // look for Auto save file if(!MakeFilePath(filepath, FILE_RAM, method, romFilename, 0)) return false; - return LoadRAM(filepath, method, silent); + if (LoadRAM(filepath, method, silent)) + return true; + + // look for file with no number or Auto appended + if(!MakeFilePath(filepath2, action, method, romFilename, -1)) + return false; + + if(LoadRAM(filepath2, method, silent)) + { + // rename this file - append Auto + sprintf(fullpath, "%s%s", rootdir, filepath); // add device to path + sprintf(fullpath2, "%s%s", rootdir, filepath2); // add device to path + rename(fullpath2, fullpath); // rename file (to avoid duplicates) + return true; + } + return false; } diff --git a/source/ngc/filebrowser.cpp b/source/ngc/filebrowser.cpp index 38f62f4..091083c 100644 --- a/source/ngc/filebrowser.cpp +++ b/source/ngc/filebrowser.cpp @@ -211,16 +211,30 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi if(type == FILE_RAM) sprintf(ext, "sav"); else sprintf(ext, "fcs"); - if(filenum >= 0) + if(filenum >= -1) { if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) { - filename[26] = 0; // truncate filename - sprintf(file, "%s%i.%s", filename, filenum, ext); + if(filenum > 9) + { + return false; + } + else if(filenum == -1) + { + filename[27] = 0; // truncate filename + sprintf(file, "%s.%s", filename, ext); + } + else + { + filename[26] = 0; // truncate filename + sprintf(file, "%s%i.%s", filename, filenum, ext); + } } else { - if(filenum == 0) + if(filenum == -1) + sprintf(file, "%s.%s", filename, ext); + else if(filenum == 0) sprintf(file, "%s Auto.%s", filename, ext); else sprintf(file, "%s %i.%s", filename, filenum, ext); @@ -394,8 +408,11 @@ int BrowserLoadSz(int method) return 0; // add device to filepath - sprintf(filepath, "%s%s", rootdir, szpath); - memcpy(szpath, filepath, MAXPATHLEN); + if(method != METHOD_DVD) + { + sprintf(filepath, "%s%s", rootdir, szpath); + memcpy(szpath, filepath, MAXPATHLEN); + } int szfiles = SzParse(szpath, method); if(szfiles) diff --git a/source/ngc/filebrowser.h b/source/ngc/filebrowser.h index ec57150..4476b42 100644 --- a/source/ngc/filebrowser.h +++ b/source/ngc/filebrowser.h @@ -42,7 +42,7 @@ extern char rootdir[10]; extern char romFilename[]; extern int nesGameType; -bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1); +bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -2); int UpdateDirName(int method); int OpenGameList(); int autoLoadMethod(); diff --git a/source/ngc/gcvideo.cpp b/source/ngc/gcvideo.cpp index a7c4b2f..b5d72b4 100644 --- a/source/ngc/gcvideo.cpp +++ b/source/ngc/gcvideo.cpp @@ -536,7 +536,7 @@ InitGCVideo () // configure VI VIDEO_Configure (vmode); - screenheight = vmode->xfbHeight; + screenheight = 480; screenwidth = vmode->fbWidth; // Allocate the video buffers diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index e789c4f..59b7b88 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -609,8 +609,7 @@ static void OnScreenKeyboard(char * var, u32 maxlen) if(save) { - strncpy(var, keyboard.kbtextstr, 100); - var[100] = 0; + snprintf(var, maxlen, "%s", keyboard.kbtextstr); } HaltGui(); diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index 9ec1253..f6a49d1 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -258,7 +258,7 @@ decodePrefsData (int method) verMinor >= 0 && verMinor <= 9 && verPoint >= 0 && verPoint <= 9)) result = false; - else if(verMajor <= 3) // less than version 3.0.0 + else if(verMajor < 3) // less than version 3.0.0 result = false; // reset settings else if(verMajor > curMajor || verMinor > curMinor || verPoint > curPoint) // some future version result = false; // reset settings