diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 79d9d4121..7b7100e49 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -591,7 +591,7 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi buf[4] = 0; if (advsc.checkDB(buf, gameInfo.crc)) { - u8 sv = advsc.getSaveType() + 1; // skip autodetect description in save_types[] struct + u8 sv = advsc.getSaveType(); printf("Found in game database by %s:\n",advsc.getIdMethod()); printf("\t* ROM save type: "); if (sv == 0xFF) @@ -601,9 +601,9 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi printf("None"); else { - printf("%s", save_types[sv].descr); + printf("%s", save_types[sv + 1].descr); if (CommonSettings.autodetectBackupMethod == 1) - backup_setManualBackupType(sv+1); + backup_setManualBackupType(sv + 1); } printf("\n\t* ROM crc: %08X\n", advsc.getCRC32()); } diff --git a/desmume/src/mc.cpp b/desmume/src/mc.cpp index 06dd4cc49..b0dc200c8 100644 --- a/desmume/src/mc.cpp +++ b/desmume/src/mc.cpp @@ -1038,7 +1038,8 @@ void BackupDevice::loadfile() info.type = advsc.getSaveType(); if (info.type != 0xFF && info.type != 0xFE) { - u32 adv_size = save_types[info.type+1].size; + info.type++; + u32 adv_size = save_types[info.type].size; if (info.size > adv_size) info.size = adv_size; else @@ -1065,6 +1066,7 @@ void BackupDevice::loadfile() info.type = searchFileSaveType(info.size); if (info.type == 0xFF) info.type = 0; } + u32 ss = info.size * 8 / 1024; if (ss >= 1024) { diff --git a/desmume/src/windows/importSave.cpp b/desmume/src/windows/importSave.cpp index 8347351fa..2256967cf 100644 --- a/desmume/src/windows/importSave.cpp +++ b/desmume/src/windows/importSave.cpp @@ -40,7 +40,7 @@ BOOL CALLBACK ImportSizeSelect_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l { memset(&buf, 0, sizeof(buf)); - u8 sv = advsc.getSaveType() + 1; + u8 sv = advsc.getSaveType(); if (sv == 0xFF) { strcpy(buf, "Unknown"); @@ -53,13 +53,20 @@ BOOL CALLBACK ImportSizeSelect_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_ADVANSCENE), false); } else - strcpy(buf, save_types[sv].descr); + strcpy(buf, save_types[sv + 1].descr); SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_ADVANSCENE), buf); } else EnableWindow(GetDlgItem(hDlg, IDC_IMP_AUTO_ADVANSCENE), false); - SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_CURRENT), save_types[MMU_new.backupDevice.info.type+1].descr); + { + u8 type = MMU_new.backupDevice.searchFileSaveType(MMU_new.backupDevice.info.size); + if (type == 0xFF) + SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_CURRENT), "NA"); + else + SetWindowText(GetDlgItem(hDlg, IDC_IMP_INFO_CURRENT), save_types[type + 1].descr); + } + SendDlgItemMessage(hDlg, IDC_IMP_AUTO_CURRENT, BM_SETCHECK, true, 0); for (u8 i = 1; i <= MAX_SAVE_TYPES; i++)