Minor cleanup of lua engine load rom update for SDL port.

This commit is contained in:
Matthew Budd 2020-10-21 20:45:50 -04:00
parent 58e87898f2
commit fede6f5690
4 changed files with 20 additions and 6 deletions

View File

@ -81,7 +81,7 @@ else(WIN32)
pkg_check_modules( SDL2 REQUIRED sdl2) pkg_check_modules( SDL2 REQUIRED sdl2)
if ( ${SDL2_FOUND} ) if ( ${SDL2_FOUND} )
add_definitions( ${SDL2_CFLAGS} ) add_definitions( ${SDL2_CFLAGS} -D__SDL__ )
endif() endif()
# Check for LUA # Check for LUA

View File

@ -209,7 +209,8 @@ DriverKill()
/** /**
* Reloads last game * Reloads last game
*/ */
int reloadLastGame() { int reloadLastGame(void)
{
std::string lastRom; std::string lastRom;
g_config->getOption(std::string("SDL.LastOpenFile"), &lastRom); g_config->getOption(std::string("SDL.LastOpenFile"), &lastRom);
return LoadGame(lastRom.c_str(), false); return LoadGame(lastRom.c_str(), false);

View File

@ -21,6 +21,7 @@ extern Config *g_config;
int LoadGame(const char *path, bool silent = false); int LoadGame(const char *path, bool silent = false);
int CloseGame(void); int CloseGame(void);
int reloadLastGame(void);
int fceuWrapperInit( int argc, char *argv[] ); int fceuWrapperInit( int argc, char *argv[] );
int fceuWrapperClose( void ); int fceuWrapperClose( void );

View File

@ -42,6 +42,17 @@ extern char FileBase[];
extern TASEDITOR_LUA taseditor_lua; extern TASEDITOR_LUA taseditor_lua;
#endif #endif
#ifdef __SDL__
#ifdef __QT_DRIVER__
#include "drivers/Qt/fceuWrapper.h"
#else
int LoadGame(const char *path, bool silent = false);
int reloadLastGame(void);
#endif
#endif
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -520,13 +531,14 @@ static int emu_getdir(lua_State *L) {
extern void ReloadRom(void); extern void ReloadRom(void);
extern int LoadGame(const char*, bool);
// emu.loadrom(string filename) // emu.loadrom(string filename)
// //
// Loads the rom from the directory relative to the lua script or from the absolute path. // Loads the rom from the directory relative to the lua script or from the absolute path.
// If the rom can't be loaded, loads the most recent one. // If the rom can't be loaded, loads the most recent one.
static int emu_loadrom(lua_State *L) { static int emu_loadrom(lua_State *L)
{
#ifdef WIN32 #ifdef WIN32
const char* str = lua_tostring(L,1); const char* str = lua_tostring(L,1);
@ -550,8 +562,8 @@ static int emu_loadrom(lua_State *L) {
const char *nameo2 = luaL_checkstring(L,1); const char *nameo2 = luaL_checkstring(L,1);
char nameo[2048]; char nameo[2048];
strncpy(nameo, nameo2, sizeof(nameo)); strncpy(nameo, nameo2, sizeof(nameo));
if(!LoadGame(nameo, true)) { if (!LoadGame(nameo, true))
extern void reloadLastGame(); {
reloadLastGame(); reloadLastGame();
return 0; return 0;
} else { } else {