diff --git a/desmume/src/windows/main.c b/desmume/src/windows/main.c index 1d3336e87..32d265b87 100644 --- a/desmume/src/windows/main.c +++ b/desmume/src/windows/main.c @@ -59,7 +59,7 @@ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char SavName[MAX_PATH] = ""; -char SavName2[MAX_PATH] = ""; +char ImportSavName[MAX_PATH] = ""; char szClassName[ ] = "DeSmuME"; int romnum = 0; @@ -506,6 +506,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); EnableMenuItem(menu, IDM_RESET, MF_ENABLED); EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); romloaded = TRUE; NDS_UnPause(); } @@ -515,6 +516,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, EnableMenuItem(menu, IDM_PAUSE, MF_GRAYED); EnableMenuItem(menu, IDM_RESET, MF_GRAYED); EnableMenuItem(menu, IDM_GAME_INFO, MF_GRAYED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_GRAYED); } CheckMenuItem(menu, IDC_SAVETYPE1, MF_BYCOMMAND | MF_CHECKED); @@ -613,6 +615,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); EnableMenuItem(menu, IDM_RESET, MF_ENABLED); EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); romloaded = TRUE; NDS_UnPause(); } @@ -870,6 +873,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); EnableMenuItem(menu, IDM_RESET, MF_ENABLED); EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); romloaded = TRUE; NDS_UnPause(); } @@ -1002,6 +1006,30 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDM_STATE_LOAD_F10: StateLoadSlot(10); return 0; + case IDM_IMPORTBACKUPMEMORY: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Action Replay DS Save (*.duc)\0*.duc\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = ImportSavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "duc"; + + if(!GetOpenFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + if (!NDS_ImportSave(ImportSavName)) + MessageBox(hwnd,"Save was not successfully imported","Error",MB_OK); + NDS_UnPause(); + return 0; + } case IDM_SOUNDSETTINGS: { DialogBox(GetModuleHandle(NULL), "SoundSettingsDlg", hwnd, (DLGPROC)SoundSettingsDlgProc); diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 141c15fbf..575ecc26e 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -131,6 +131,8 @@ void refreshAll(); #define IDC_FRAMESKIP8 199 #define IDC_FRAMESKIP9 200 +#define IDM_IMPORTBACKUPMEMORY 201 + #define IDD_MEM_VIEWER 301 #define IDC_8_BIT 302 #define IDC_16_BIT 303 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 53b92b340..719d62d0c 100644 --- a/desmume/src/windows/resources.rc +++ b/desmume/src/windows/resources.rc @@ -344,6 +344,8 @@ MENU_PRINCIPAL MENU MENUITEM "10", IDM_STATE_LOAD_F10 } MENUITEM SEPARATOR + MENUITEM "Import Backup Memory", IDM_IMPORTBACKUPMEMORY + MENUITEM SEPARATOR MENUITEM "Save Screenshot &As", IDM_PRINTSCREEN MENUITEM "&Quick Screenshot", IDM_QUICK_PRINTSCREEN MENUITEM SEPARATOR