From 1fea325020709bfa2dd3dd6e0fa9ac0f2c0df720 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 19 Apr 2017 05:37:19 +0000 Subject: [PATCH] fix #785 - emu.loadrom() should reload the current rom nicely --- trunk/src/input.cpp | 4 ++-- trunk/src/lua-engine.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/trunk/src/input.cpp b/trunk/src/input.cpp index a5318fd9..adb5b624 100644 --- a/trunk/src/input.cpp +++ b/trunk/src/input.cpp @@ -745,7 +745,7 @@ static void DebuggerStepInto(void); static void FA_SkipLag(void); static void OpenRom(void); static void CloseRom(void); -static void ReloadRom(void); +void ReloadRom(void); static void MovieSubtitleToggle(void); static void UndoRedoSavestate(void); static void FCEUI_DoExit(void); @@ -1232,7 +1232,7 @@ static void CloseRom(void) #endif } -static void ReloadRom(void) +void ReloadRom(void) { #ifdef WIN32 if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR)) diff --git a/trunk/src/lua-engine.cpp b/trunk/src/lua-engine.cpp index e9ffa507..b4455993 100644 --- a/trunk/src/lua-engine.cpp +++ b/trunk/src/lua-engine.cpp @@ -486,12 +486,23 @@ static int emu_getdir(lua_State *L) { #endif } + +extern void ReloadRom(void); + // emu.loadrom(string filename) // // Loads the rom from the directory relative to the lua script or from the absolute path. // If the rom can't e loaded, loads the most recent one. static int emu_loadrom(lua_State *L) { #ifdef WIN32 + const char* str = lua_tostring(L,1); + + //special case: reload rom + if(!str) { + ReloadRom(); + return 0; + } + const char *nameo2 = luaL_checkstring(L,1); char nameo[2048]; strncpy(nameo, nameo2, sizeof(nameo));