Merge pull request #1 from randomCharacter/lua-loadrom-linux
Added support for loading ROM files from Lua script on Linux
This commit is contained in:
commit
e1419b5fd8
|
@ -44,7 +44,7 @@ void LockConsole(void);
|
||||||
void UnlockConsole(void);
|
void UnlockConsole(void);
|
||||||
void ToggleFS(); /* SDL */
|
void ToggleFS(); /* SDL */
|
||||||
|
|
||||||
int LoadGame(const char *path);
|
int LoadGame(const char *path, bool silent = false);
|
||||||
int CloseGame(void);
|
int CloseGame(void);
|
||||||
int GUI_Init(int argc, char **argv, int (*dofunc)(void));
|
int GUI_Init(int argc, char **argv, int (*dofunc)(void));
|
||||||
int GUI_Idle(void);
|
int GUI_Idle(void);
|
||||||
|
|
|
@ -275,12 +275,12 @@ static void DoArgs(int argc, char *argv[])
|
||||||
provides data necessary for the driver code(number of scanlines to
|
provides data necessary for the driver code(number of scanlines to
|
||||||
render, what virtual input devices to use, etc.).
|
render, what virtual input devices to use, etc.).
|
||||||
*/
|
*/
|
||||||
int LoadGame(const char *path)
|
int LoadGame(const char *path, bool silent)
|
||||||
{
|
{
|
||||||
FCEUGI *tmp;
|
FCEUGI *tmp;
|
||||||
|
|
||||||
CloseGame();
|
CloseGame();
|
||||||
if(!(tmp=FCEUI_LoadGame(path,1)))
|
if(!(tmp=FCEUI_LoadGame(path,1,silent)))
|
||||||
return 0;
|
return 0;
|
||||||
CurGame=tmp;
|
CurGame=tmp;
|
||||||
ParseGI(tmp);
|
ParseGI(tmp);
|
||||||
|
|
|
@ -29,7 +29,7 @@ void LockConsole(void);
|
||||||
void UnlockConsole(void);
|
void UnlockConsole(void);
|
||||||
void ToggleFS(); /* SDL */
|
void ToggleFS(); /* SDL */
|
||||||
|
|
||||||
int LoadGame(const char *path);
|
int LoadGame(const char *path, bool silent);
|
||||||
//int CloseGame(void);
|
//int CloseGame(void);
|
||||||
|
|
||||||
void Giggles(int);
|
void Giggles(int);
|
||||||
|
|
|
@ -206,13 +206,22 @@ DriverKill()
|
||||||
inited=0;
|
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
|
* Loads a game, given a full path/filename. The driver code must be
|
||||||
* initialized after the game is loaded, because the emulator code
|
* initialized after the game is loaded, because the emulator code
|
||||||
* provides data necessary for the driver code(number of scanlines to
|
* provides data necessary for the driver code(number of scanlines to
|
||||||
* render, what virtual input devices to use, etc.).
|
* 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;
|
int gg_enabled, autoLoadDebug, autoOpenDebugger;
|
||||||
|
|
||||||
|
@ -227,7 +236,7 @@ int LoadGame(const char *path)
|
||||||
|
|
||||||
FCEUI_SetGameGenie (gg_enabled);
|
FCEUI_SetGameGenie (gg_enabled);
|
||||||
|
|
||||||
if(!FCEUI_LoadGame(path, 1)) {
|
if(!FCEUI_LoadGame(path, 1, silent)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ extern unsigned int gui_draw_area_height;
|
||||||
// global configuration object
|
// global configuration object
|
||||||
extern Config *g_config;
|
extern Config *g_config;
|
||||||
|
|
||||||
int LoadGame(const char *path);
|
int LoadGame(const char *path, bool silent = false);
|
||||||
int CloseGame(void);
|
int CloseGame(void);
|
||||||
|
|
||||||
int fceuWrapperInit( int argc, char *argv[] );
|
int fceuWrapperInit( int argc, char *argv[] );
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern int dendy;
|
||||||
extern int pal_emulation;
|
extern int pal_emulation;
|
||||||
extern bool swapDuty;
|
extern bool swapDuty;
|
||||||
|
|
||||||
int LoadGame(const char *path);
|
int LoadGame(const char *path, bool silent);
|
||||||
int CloseGame(void);
|
int CloseGame(void);
|
||||||
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
|
||||||
uint64 FCEUD_GetTime();
|
uint64 FCEUD_GetTime();
|
||||||
|
|
|
@ -29,7 +29,7 @@ void LockConsole(void);
|
||||||
void UnlockConsole(void);
|
void UnlockConsole(void);
|
||||||
void ToggleFS(); /* SDL */
|
void ToggleFS(); /* SDL */
|
||||||
|
|
||||||
int LoadGame(const char *path);
|
int LoadGame(const char *path, bool silent);
|
||||||
//int CloseGame(void);
|
//int CloseGame(void);
|
||||||
|
|
||||||
void Giggles(int);
|
void Giggles(int);
|
||||||
|
|
|
@ -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
|
* Loads a game, given a full path/filename. The driver code must be
|
||||||
* initialized after the game is loaded, because the emulator code
|
* initialized after the game is loaded, because the emulator code
|
||||||
* provides data necessary for the driver code(number of scanlines to
|
* provides data necessary for the driver code(number of scanlines to
|
||||||
* render, what virtual input devices to use, etc.).
|
* render, what virtual input devices to use, etc.).
|
||||||
*/
|
*/
|
||||||
int LoadGame(const char *path)
|
int LoadGame(const char *path, bool silent)
|
||||||
{
|
{
|
||||||
if (isloaded){
|
if (isloaded){
|
||||||
CloseGame();
|
CloseGame();
|
||||||
}
|
}
|
||||||
if(!FCEUI_LoadGame(path, 1)) {
|
if(!FCEUI_LoadGame(path, 1, silent)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern int dendy;
|
||||||
extern int pal_emulation;
|
extern int pal_emulation;
|
||||||
extern bool swapDuty;
|
extern bool swapDuty;
|
||||||
|
|
||||||
int LoadGame(const char *path);
|
int LoadGame(const char *path, bool silent = false);
|
||||||
int CloseGame(void);
|
int CloseGame(void);
|
||||||
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
|
||||||
uint64 FCEUD_GetTime();
|
uint64 FCEUD_GetTime();
|
||||||
|
|
|
@ -520,6 +520,7 @@ 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)
|
||||||
//
|
//
|
||||||
|
@ -545,6 +546,17 @@ static int emu_loadrom(lua_State *L) {
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
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
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue