diff --git a/desmume/src/GPU_osd.h b/desmume/src/GPU_osd.h index 7e19bd871..872c2eb3f 100644 --- a/desmume/src/GPU_osd.h +++ b/desmume/src/GPU_osd.h @@ -48,10 +48,16 @@ struct HudStruct { public: HudStruct() - : fps(0) - , fps3d(0) - , clicked(false) - {} + { + resetTransient(); + } + + void resetTransient() + { + fps = 0; + fps3d = 0; + clicked = false; + } HudCoordinates SavestateSlots; HudCoordinates FpsDisplay; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 61e2f4e68..4be01037f 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2693,6 +2693,8 @@ static BOOL OpenCore(const char* filename) if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, ARRAY_SIZE(s_nonRomExtensions))) return FALSE; + StopAllLuaScripts(); + if(LoadROM(filename, LogicalName)) { romloaded = TRUE; @@ -2791,6 +2793,17 @@ LRESULT OpenFile() return 0; } +void CloseRom() +{ + StopAllLuaScripts(); +// cheatsSearchClose(); + NDS_FreeROM(); + romloaded = false; + execute = false; + Hud.resetTransient(); + NDS_Reset(); +} + //TODO - async key state? for real? int GetModifiers(int key) { @@ -3014,6 +3027,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM DesEnableMenuItem(mainMenu, IDM_FILE_RECORDAVI, romloaded); DesEnableMenuItem(mainMenu, IDM_FILE_RECORDWAV, romloaded); DesEnableMenuItem(mainMenu, IDM_RESET, romloaded); + DesEnableMenuItem(mainMenu, IDM_CLOSEROM, romloaded); DesEnableMenuItem(mainMenu, IDM_SHUT_UP, romloaded); DesEnableMenuItem(mainMenu, IDM_CHEATS_LIST, romloaded); DesEnableMenuItem(mainMenu, IDM_CHEATS_SEARCH, romloaded); @@ -3525,6 +3539,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM return 0; case IDM_OPEN: return OpenFile(); + case IDM_CLOSEROM: + return CloseRom(),0; case IDM_PRINTSCREEN: HK_PrintScreen(0); return 0; diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 4583e01f1..da72a874a 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -120,6 +120,7 @@ #define IDC_PNG 325 #define IDC_BMP 326 #define IDC_FORMATSTATIC 327 +#define IDM_CLOSEROM 328 #define IDM_PATHSETTINGS 350 #define IDC_ROMPATHEDIT 351 #define IDC_BROWSEROMS 352 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 4089fe3c1..5d09cd6db 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ