diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index c4ff0b9ad..d376a6e60 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -591,6 +591,8 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename) else { printf("%s", save_names[sv]); + if (CommonSettings.autodetectBackupMethod == 1) + backup_setManualBackupType(sv); } printf("\n\t* ROM crc: %08X\n", advsc.getCRC32()); } diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 8e3f1a2aa..9897b2ddf 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -489,6 +489,7 @@ extern struct TCommonSettings { , micMode(InternalNoise) , spuInterpolationMode(SPUInterpolation_Linear) , manualBackupType(0) + , autodetectBackupMethod(0) , spu_captureMuted(false) , spu_advanced(false) , StylusPressure(50) @@ -563,6 +564,7 @@ extern struct TCommonSettings { //this is a temporary hack until we straighten out the flushing logic and/or gxfifo //int gfx3d_flushMode; + int autodetectBackupMethod; //this is the user's choice of manual backup type, for cases when the autodetection can't be trusted int manualBackupType; diff --git a/desmume/src/commandline.cpp b/desmume/src/commandline.cpp index 9e6f7cb27..01758a2c6 100644 --- a/desmume/src/commandline.cpp +++ b/desmume/src/commandline.cpp @@ -56,6 +56,7 @@ CommandLine::CommandLine() , arm9_gdb_port(0) , arm7_gdb_port(0) , start_paused(FALSE) +, autodetect_method(-1) { #ifndef _MSC_VER disable_sound = 0; @@ -106,6 +107,7 @@ void CommandLine::loadCommonOptions() { "arm9gdb", 0, 0, G_OPTION_ARG_INT, &arm9_gdb_port, "Enable the ARM9 GDB stub on the given port", "PORT_NUM"}, { "arm7gdb", 0, 0, G_OPTION_ARG_INT, &arm7_gdb_port, "Enable the ARM7 GDB stub on the given port", "PORT_NUM"}, #endif + { "autodetect_method", 0, 0, G_OPTION_ARG_INT, &autodetect_method, "Autodetect backup method (0 - internal, 1 - from database)", "AUTODETECT_METHOD"}, { NULL } }; @@ -140,6 +142,9 @@ bool CommandLine::parse(int argc,char **argv) if(dsi_mode != -1) CommonSettings.DSI = (dsi_mode==1); + if(autodetect_method != -1) + CommonSettings.autodetectBackupMethod = autodetect_method; + //TODO MAX PRIORITY! change ARM9BIOS etc to be a std::string if(_bios_arm9) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM9BIOS,_bios_arm9); } if(_bios_arm7) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM7BIOS,_bios_arm7); } @@ -196,6 +201,11 @@ bool CommandLine::validate() if((_cflash_image && _gbaslot_rom) || (_cflash_path && _gbaslot_rom)) { g_printerr("Cannot specify both cflash and gbaslot rom (both occupy SLOT-2)\n"); } + + if ((autodetect_method < 0) || (autodetect_method > 1)) { + g_printerr("Invalid autodetect save method (0 - internal, 1 - from database)\n"); + } + return true; } diff --git a/desmume/src/commandline.h b/desmume/src/commandline.h index 5a853c271..f1b0d7641 100644 --- a/desmume/src/commandline.h +++ b/desmume/src/commandline.h @@ -39,6 +39,7 @@ public: int depth_threshold; int debug_console; int dsi_mode; + int autodetect_method; std::string nds_file; std::string play_movie_file; std::string record_movie_file; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 6c3550217..61095b4ab 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2579,6 +2579,7 @@ int _main() path.ReadPathSettings(); CommonSettings.cheatsDisable = GetPrivateProfileBool("General", "cheatsDisable", false, IniName); + CommonSettings.autodetectBackupMethod = GetPrivateProfileInt("General", "autoDetectMethod", 0, IniName); ColorCtrl_Register(); if (!RegWndClass("DeSmuME", WindowProcedure, CS_DBLCLKS, LoadIcon(hAppInst, MAKEINTRESOURCE(ICONDESMUME)))) @@ -4109,6 +4110,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindow->checkMenu(IDC_SAVETYPE+i, false); MainWindow->checkMenu(IDC_SAVETYPE+CommonSettings.manualBackupType, true); + MainWindow->checkMenu(IDM_AUTODETECTSAVETYPE_INTERNAL+CommonSettings.autodetectBackupMethod, true); // recent/active scripts menu PopulateLuaSubmenu(); @@ -5601,6 +5603,12 @@ DOKEYDOWN: } return 0; + case IDM_AUTODETECTSAVETYPE_INTERNAL: + case IDM_AUTODETECTSAVETYPE_FROMDATABASE: + CommonSettings.autodetectBackupMethod = LOWORD(wParam) - IDM_AUTODETECTSAVETYPE_INTERNAL; + WritePrivateProfileInt("General", "autoDetectMethod", CommonSettings.autodetectBackupMethod, IniName); + return 0; + case IDC_SAVETYPE_FORCE: backup_forceManualBackupType(); return 0; default: diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 93000ee7b..81c43c436 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -884,6 +884,8 @@ #define ID_40093 40093 #define IDM_SLOT1 40097 #define IDM_FILE_IMPORT_DB 40103 +#define IDM_AUTODETECTSAVETYPE_INTERNAL 40104 +#define IDM_AUTODETECTSAVETYPE_FROMDATABASE 40105 #define IDC_LABEL_UP 50000 #define IDC_LABEL_RIGHT 50001 #define IDC_LABEL_LEFT 50002 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index beb114852..905148fcf 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ