diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp index f3c4719a..6bda4edd 100644 --- a/src/common/ConfigManager.cpp +++ b/src/common/ConfigManager.cpp @@ -61,6 +61,8 @@ enum named_opts OPT_CAPTURE_FORMAT, OPT_CHEAT, OPT_CPU_SAVE_TYPE, + OPT_DOTCODE_FILE_NAME_LOAD, + OPT_DOTCODE_FILE_NAME_SAVE, OPT_EMULATOR_TYPE, OPT_FS_ADAPTER, OPT_FS_COLOR_DEPTH, @@ -124,6 +126,8 @@ char* batteryDir; char* biosFileNameGB; char* biosFileNameGBA; char* biosFileNameGBC; +char* loadDotCodeFile; +char* saveDotCodeFile; char* linkHostAddr; char* movieRecordDir; char* rewindMemory = NULL; @@ -282,6 +286,8 @@ struct option argOptions[] = { { "disable-mmx", no_argument, &disableMMX, 1 }, { "disable-sfx", no_argument, &cpuDisableSfx, 1 }, { "disable-status-messages", no_argument, &disableStatusMessages, 1 }, + { "dotcode-file-name-load", required_argument, 0, OPT_DOTCODE_FILE_NAME_LOAD }, + { "dotcode-file-name-save", required_argument, 0, OPT_DOTCODE_FILE_NAME_SAVE }, { "emulator-type", required_argument, 0, OPT_EMULATOR_TYPE }, { "filter", required_argument, 0, 'f' }, { "filter-enable-multi-threading", no_argument, &filterMT, 1 }, @@ -539,6 +545,9 @@ void LoadConfig() biosFileNameGBA = ReadPrefString("biosFileGBA"); biosFileNameGBC = ReadPrefString("biosFileGBC"); + loadDotCodeFile = ReadPrefString("loadDotCodeFile"); + saveDotCodeFile = ReadPrefString("saveDotCodeFile"); + aviRecordDir = ReadPrefString("aviRecordDir"); movieRecordDir = ReadPrefString("movieRecordDir"); soundRecordDir = ReadPrefString("soundRecordDir"); @@ -1264,67 +1273,67 @@ int ReadOpts(int argc, char ** argv) case OPT_BIOS_FILE_NAME_GB: // --bios-file-name-gb - strcpy(biosFileNameGB, optarg); + biosFileNameGB = optarg; break; case OPT_BIOS_FILE_NAME_GBA: // --bios-file-name-gba - strcpy(biosFileNameGBA, optarg); + biosFileNameGBA = optarg; break; case OPT_BIOS_FILE_NAME_GBC: // --bios-file-name-gbc - strcpy(biosFileNameGBC, optarg); + biosFileNameGBC = optarg; break; case OPT_AVI_RECORD_DIR: // --avi-record-dir - strcpy(aviRecordDir, optarg); + aviRecordDir = optarg; break; case OPT_MOVIE_RECORD_DIR: // --movie-record-dir - strcpy(movieRecordDir, optarg); + movieRecordDir = optarg; break; case OPT_SOUND_RECORD_DIR: // --sound-record-dir - strcpy(soundRecordDir, optarg); + soundRecordDir = optarg; break; case OPT_SCREEN_SHOT_DIR: // --screen-shot-dir - strcpy(screenShotDir, optarg); + screenShotDir = optarg; break; case OPT_SAVE_DIR: // --save-dir - strcpy(saveDir, optarg); + saveDir = optarg; break; case OPT_BATTERY_DIR: // --battery-dir - strcpy(batteryDir, optarg); + batteryDir = optarg; break; case OPT_ROM_DIR_GBC: // --rom-dir-gbc - strcpy(romDirGBC, optarg); + romDirGBC = optarg; break; case OPT_ROM_DIR_GB: // --rom-dir-gb - strcpy(romDirGB, optarg); + romDirGB = optarg; break; case OPT_ROM_DIR_GBA: // --rom-dir-gba - strcpy(romDirGBA, optarg); + romDirGBA = optarg; break; case OPT_LINK_HOST_ADDR: // --link-host-addr - strcpy(linkHostAddr, optarg); + linkHostAddr = optarg; break; case OPT_CPU_SAVE_TYPE: @@ -1341,6 +1350,15 @@ int ReadOpts(int argc, char ** argv) } break; + case OPT_DOTCODE_FILE_NAME_LOAD: + // --dotcode-file-name-load + loadDotCodeFile = optarg; + break; + + case OPT_DOTCODE_FILE_NAME_SAVE: + // --dotcode-file-name-save + saveDotCodeFile = optarg; + break; } } return op; diff --git a/src/common/ConfigManager.h b/src/common/ConfigManager.h index 0504689a..8d1bd81f 100644 --- a/src/common/ConfigManager.h +++ b/src/common/ConfigManager.h @@ -24,6 +24,8 @@ extern char* aviRecordDir; extern char* biosFileNameGB; extern char* biosFileNameGBA; extern char* biosFileNameGBC; +extern char* loadDotCodeFile; +extern char* saveDotCodeFile; extern char* linkHostAddr; extern char* movieRecordDir; extern char* romDirGB; diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index a0a18e40..a6e18dcb 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -166,9 +166,6 @@ u8 memoryWaitSeq32[16] = u8 biosProtected[4]; -const char *loadDotCodeFile; -const char *saveDotCodeFile; - #ifdef WORDS_BIGENDIAN bool cpuBiosSwapped = false; #endif @@ -1795,12 +1792,12 @@ const char* GetSaveDotCodeFile() void SetLoadDotCodeFile(const char *szFile) { - loadDotCodeFile = szFile; + loadDotCodeFile = strdup(szFile); } void SetSaveDotCodeFile(const char *szFile) { - saveDotCodeFile = szFile; + saveDotCodeFile = strdup(szFile); } void CPUUpdateRender() diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index d80203fb..d8858087 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -1116,9 +1116,7 @@ void MainWnd::OnFileLoadDotCode() FALSE); if (file.DoModal() == IDOK) { - const char* filename = file.GetPathName(); - strcpy(loadDotCodeFile, filename); - SetLoadDotCodeFile(loadDotCodeFile); + loadDotCodeFile = strdup(file.GetPathName()); } } @@ -1139,9 +1137,7 @@ void MainWnd::OnFileSaveDotCode() TRUE); if (file.DoModal() == IDOK) { - const char* filename = file.GetPathName(); - strcpy(saveDotCodeFile, filename); - SetLoadDotCodeFile(saveDotCodeFile); + saveDotCodeFile = strdup(file.GetPathName()); } } diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 45b3799b..c02985c0 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -204,7 +204,7 @@ void GameArea::LoadGame(const wxString &name) cpuSaveType = gopts.save_type; if (cpuSaveType == 0) - utilGBAFindSave(size); + utilGBAFindSave(rom_size); else saveType = cpuSaveType; @@ -216,7 +216,7 @@ void GameArea::LoadGame(const wxString &name) flashSetSize(0x10000 << gopts.flash_size); cpuSaveType = gopts.save_type; if (cpuSaveType == 0) - utilGBAFindSave(size); + utilGBAFindSave(rom_size); else saveType = cpuSaveType; // mirroring short ROMs is such an uncommon thing that any