From 54f771536ecd1b3f8251431f2c33beed8cb75e1f Mon Sep 17 00:00:00 2001 From: nitsuja Date: Sat, 5 Sep 2009 17:39:22 +0000 Subject: [PATCH] added Close ROM menu command and made Lua scripts stop when opening or closing a ROM --- desmume/src/GPU_osd.h | 14 ++++++++++---- desmume/src/windows/main.cpp | 16 ++++++++++++++++ desmume/src/windows/resource.h | 1 + desmume/src/windows/resources.rc | Bin 691148 -> 691644 bytes 4 files changed, 27 insertions(+), 4 deletions(-) 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 4089fe3c169b65f9315b9ac9cef86109951d3007..5d09cd6dbabfe4ffdae1111cf9bd7679c14b3c84 100644 GIT binary patch delta 220 zcmX>zU2D&5tqnhfCg0;>V^v@XV(_1S(11mMaswO7^a4&6E_NRVe}-TN*U7#@x|0Jm zteTC4+l_=7ftYE#kuY=4BX%VQABIwf?CA?-IgPPun{L3u;xhftH)gKwZ@w~L`7(Xm zKNh~}OJq4MIGurd;l{Tgc*O$5tU$~L#O&J-yy6Hkp6(#W!or!#P{feS03<=y7-F~# ZsFdXx-}D$=PO0`UI-J|T=y2VL0{}%-MuY$W delta 83 zcmdlpTkFhptqnhfCQneXYF;PYzD}4Ch?%yp6K2kNG+lv{#b*1ZZ_LlWOh538#jU;S f4GR#n0x=s9vv03@!@*|^k@8aD-0r2oRg?<=F%cxJ