diff --git a/desmume/src/commandline.cpp b/desmume/src/commandline.cpp index d4ba0eb67..25b65553e 100644 --- a/desmume/src/commandline.cpp +++ b/desmume/src/commandline.cpp @@ -124,6 +124,13 @@ void CommandLine::loadCommonOptions() static char mytoupper(char c) { return ::toupper(c); } +static std::string strtoupper(const std::string& str) +{ + std::string ret = str; + std::transform(ret.begin(), ret.end(), ret.begin(), ::mytoupper); + return ret; +} + bool CommandLine::parse(int argc,char **argv) { g_option_context_parse (ctx, &argc, &argv, &error); @@ -134,9 +141,8 @@ bool CommandLine::parse(int argc,char **argv) } if(_slot1_fat_dir) slot1_fat_dir = _slot1_fat_dir; - if(_slot1) slot1 = _slot1; + if(_slot1) slot1 = _slot1; slot1 = strtoupper(slot1); if(_console_type) console_type = _console_type; - if(slot1.size() != 0) str_lcase((char*)&slot1[0]); if(_play_movie_file) play_movie_file = _play_movie_file; if(_record_movie_file) record_movie_file = _record_movie_file; if(_cflash_image) cflash_image = _cflash_image; @@ -163,7 +169,7 @@ bool CommandLine::parse(int argc,char **argv) //process console type CommonSettings.DebugConsole = false; CommonSettings.ConsoleType = NDS_CONSOLE_TYPE_FAT; - std::transform(console_type.begin(), console_type.end(), console_type.begin(), ::mytoupper); + console_type = strtoupper(console_type); if(console_type == "") {} else if(console_type == "FAT") CommonSettings.ConsoleType = NDS_CONSOLE_TYPE_FAT; else if(console_type == "LITE") CommonSettings.ConsoleType = NDS_CONSOLE_TYPE_LITE; @@ -198,7 +204,7 @@ bool CommandLine::validate() if(slot1 != "") { - if(slot1 != "r4" && slot1 != "retail" && slot1 != "none") { + if(slot1 != "R4" && slot1 != "RETAIL" && slot1 != "NONE" && slot1 != "RETAILNAND") { g_printerr("Invalid slot1 device specified.\n"); return false; } @@ -274,27 +280,27 @@ void CommandLine::process_movieCommands() void CommandLine::process_addonCommands() { - if (cflash_image != "") + if (cflash_image != "") { CFlash_Mode = ADDON_CFLASH_MODE_File; - CFlash_Path = cflash_image; + CFlash_Path = cflash_image; is_cflash_configured = true; - } - if (cflash_path != "") + } + if (cflash_path != "") { CFlash_Mode = ADDON_CFLASH_MODE_Path; - CFlash_Path = cflash_path; + CFlash_Path = cflash_path; is_cflash_configured = true; - } + } if(slot1_fat_dir != "") slot1SetFatDir(slot1_fat_dir); - if(slot1 == "retail") + if(slot1 == "RETAIL") slot1Change(NDS_SLOT1_RETAIL); - else if(slot1 == "r4") + else if(slot1 == "R4") slot1Change(NDS_SLOT1_R4); - else if(slot1 == "retailNAND") - slot1Change(NDS_SLOT1_RETAIL_NAND); + else if(slot1 == "RETAILNAND") + slot1Change(NDS_SLOT1_RETAIL_NAND); } diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index a1cdbab7e..0fb1f14b3 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -3061,7 +3061,6 @@ int _main() ViewLights = new TOOLSCLASS(hAppInst, IDD_LIGHT_VIEWER, (DLGPROC) ViewLightsProc); // Slot 1 / Slot 2 (GBA slot) - int slot1_device_type = (NDS_SLOT1_TYPE)GetPrivateProfileInt("Slot1", "type", NDS_SLOT1_RETAIL, IniName); cmdline.slot1_fat_dir = GetPrivateProfileStdString("Slot1", "fat_path", ""); addon_type = (NDS_ADDON_TYPE)GetPrivateProfileInt("GBAslot", "type", NDS_ADDON_NONE, IniName); @@ -3118,9 +3117,16 @@ int _main() break; } - slot1Change((NDS_SLOT1_TYPE)slot1_device_type); addonsChangePak(addon_type); + //override slot1 type with commandline, if present + int slot1_device_type = (NDS_SLOT1_TYPE)GetPrivateProfileInt("Slot1", "type", NDS_SLOT1_RETAIL, IniName); + if(cmdline.slot1 != "") + WritePrivateProfileInt("Slot1","type",slot1_device_type,IniName); + else + slot1Change((NDS_SLOT1_TYPE)slot1_device_type); + + CommonSettings.wifi.mode = GetPrivateProfileInt("Wifi", "Mode", 0, IniName); CommonSettings.wifi.infraBridgeAdapter = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName);