fix #785 - emu.loadrom() should reload the current rom nicely

This commit is contained in:
zeromus 2017-04-19 05:37:19 +00:00
parent a9d305da3f
commit 1fea325020
2 changed files with 13 additions and 2 deletions

View File

@ -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))

View File

@ -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));