Update lua-engine.cpp

Added LUA functions in the Emu API to allow for inserting and ejecting a disk from the FDS, as well as switching the disk side.
This commit is contained in:
Artur Bekker 2022-11-25 15:25:50 -05:00 committed by GitHub
parent 6d6a67766e
commit a620ac6d35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -5442,6 +5442,17 @@ static int cdl_resetcdlog(lua_State *L)
return 0;
}
static int emugator_yieldwithflag(lua_State* L)
{
frameAdvanceWaiting = TRUE;
luaYieldFlag = true;
return lua_yield(L, 0);
// It's actually rather disappointing...
}
static int doPopup(lua_State *L, const char* deftype, const char* deficon) {
@ -6284,6 +6295,12 @@ static const struct luaL_reg cdloglib[] = {
{ NULL,NULL }
};
static const struct luaL_reg emugatorlib[] = {
{"yieldwithflag", emugator_yieldwithflag},
{NULL,NULL}
};
void CallExitFunction()
{
if (!L)
@ -6381,6 +6398,7 @@ void FCEU_LuaFrameBoundary()
*
* Returns true on success, false on failure.
*/
int FCEU_LoadLuaCode(const char *filename, const char *arg)
{
if (!DemandLua())
@ -6446,6 +6464,9 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg)
luaL_register(L, "bit", bit_funcs); // LuaBitOp library
lua_settop(L, 0);
luaL_register(L, "emugator", emugatorlib); // LuaBitOp library
lua_settop(L, 0);
// register a few utility functions outside of libraries (in the global namespace)
lua_register(L, "print", print);
lua_register(L, "gethash", gethash),