diff --git a/src/attic/pc/dface.h b/src/attic/pc/dface.h index 9981bd08..55fe169a 100644 --- a/src/attic/pc/dface.h +++ b/src/attic/pc/dface.h @@ -44,7 +44,7 @@ void LockConsole(void); void UnlockConsole(void); void ToggleFS(); /* SDL */ -int LoadGame(const char *path); +int LoadGame(const char *path, bool silent = false); int CloseGame(void); int GUI_Init(int argc, char **argv, int (*dofunc)(void)); int GUI_Idle(void); diff --git a/src/attic/pc/main.c b/src/attic/pc/main.c index 6bdd7ce7..1e4bef03 100644 --- a/src/attic/pc/main.c +++ b/src/attic/pc/main.c @@ -275,12 +275,12 @@ static void DoArgs(int argc, char *argv[]) provides data necessary for the driver code(number of scanlines to render, what virtual input devices to use, etc.). */ -int LoadGame(const char *path) +int LoadGame(const char *path, bool silent) { FCEUGI *tmp; CloseGame(); - if(!(tmp=FCEUI_LoadGame(path,1))) + if(!(tmp=FCEUI_LoadGame(path,1,silent))) return 0; CurGame=tmp; ParseGI(tmp); diff --git a/src/drivers/Qt/dface.h b/src/drivers/Qt/dface.h index 12c515ee..16de524b 100644 --- a/src/drivers/Qt/dface.h +++ b/src/drivers/Qt/dface.h @@ -29,7 +29,7 @@ void LockConsole(void); void UnlockConsole(void); void ToggleFS(); /* SDL */ -int LoadGame(const char *path); +int LoadGame(const char *path, bool silent); //int CloseGame(void); void Giggles(int); diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index ddc1b0e2..e833c8be 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -206,13 +206,22 @@ DriverKill() inited=0; } +/** + * Reloads last game + */ +int reloadLastGame() { + std::string lastRom; + g_config->getOption(std::string("SDL.LastOpenFile"), &lastRom); + return LoadGame(lastRom.c_str(), false); +} + /** * Loads a game, given a full path/filename. The driver code must be * initialized after the game is loaded, because the emulator code * provides data necessary for the driver code(number of scanlines to * render, what virtual input devices to use, etc.). */ -int LoadGame(const char *path) +int LoadGame(const char *path, bool silent) { int gg_enabled, autoLoadDebug, autoOpenDebugger; @@ -227,7 +236,7 @@ int LoadGame(const char *path) FCEUI_SetGameGenie (gg_enabled); - if(!FCEUI_LoadGame(path, 1)) { + if(!FCEUI_LoadGame(path, 1, silent)) { return 0; } diff --git a/src/drivers/Qt/fceuWrapper.h b/src/drivers/Qt/fceuWrapper.h index e0928e09..6b196856 100644 --- a/src/drivers/Qt/fceuWrapper.h +++ b/src/drivers/Qt/fceuWrapper.h @@ -19,7 +19,7 @@ extern unsigned int gui_draw_area_height; // global configuration object extern Config *g_config; -int LoadGame(const char *path); +int LoadGame(const char *path, bool silent = false); int CloseGame(void); int fceuWrapperInit( int argc, char *argv[] ); diff --git a/src/drivers/Qt/sdl.h b/src/drivers/Qt/sdl.h index 82870040..20c5c58f 100644 --- a/src/drivers/Qt/sdl.h +++ b/src/drivers/Qt/sdl.h @@ -24,7 +24,7 @@ extern int dendy; extern int pal_emulation; extern bool swapDuty; -int LoadGame(const char *path); +int LoadGame(const char *path, bool silent); int CloseGame(void); void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); uint64 FCEUD_GetTime(); diff --git a/src/drivers/sdl/dface.h b/src/drivers/sdl/dface.h index 827bbfaf..e92be90d 100644 --- a/src/drivers/sdl/dface.h +++ b/src/drivers/sdl/dface.h @@ -29,7 +29,7 @@ void LockConsole(void); void UnlockConsole(void); void ToggleFS(); /* SDL */ -int LoadGame(const char *path); +int LoadGame(const char *path, bool silent); //int CloseGame(void); void Giggles(int); diff --git a/src/drivers/sdl/sdl.cpp b/src/drivers/sdl/sdl.cpp index 25f7f0aa..424dc53c 100644 --- a/src/drivers/sdl/sdl.cpp +++ b/src/drivers/sdl/sdl.cpp @@ -189,18 +189,27 @@ static void ShowUsage(char *prog) } +/** + * Reloads last game. + */ +int reloadLastGame() { + std::string lastRom; + g_config->getOption(std::string("SDL.LastOpenFile"), &lastRom); + return LoadGame(lastRom.c_str()); +} + /** * Loads a game, given a full path/filename. The driver code must be * initialized after the game is loaded, because the emulator code * provides data necessary for the driver code(number of scanlines to * render, what virtual input devices to use, etc.). */ -int LoadGame(const char *path) +int LoadGame(const char *path, bool silent) { if (isloaded){ CloseGame(); } - if(!FCEUI_LoadGame(path, 1)) { + if(!FCEUI_LoadGame(path, 1, silent)) { return 0; } diff --git a/src/drivers/sdl/sdl.h b/src/drivers/sdl/sdl.h index 91c6414d..e667da25 100644 --- a/src/drivers/sdl/sdl.h +++ b/src/drivers/sdl/sdl.h @@ -24,7 +24,7 @@ extern int dendy; extern int pal_emulation; extern bool swapDuty; -int LoadGame(const char *path); +int LoadGame(const char *path, bool silent = false); int CloseGame(void); void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); uint64 FCEUD_GetTime(); diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 42344162..6f8d90f7 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -520,6 +520,7 @@ static int emu_getdir(lua_State *L) { extern void ReloadRom(void); +extern int LoadGame(const char*, bool); // emu.loadrom(string filename) // @@ -545,6 +546,17 @@ static int emu_loadrom(lua_State *L) { } else { return 1; } +#else + const char *nameo2 = luaL_checkstring(L,1); + char nameo[2048]; + strncpy(nameo, nameo2, sizeof(nameo)); + if(!LoadGame(nameo, true)) { + extern void reloadLastGame(); + reloadLastGame(); + return 0; + } else { + return 1; + } #endif return 1; }