diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 88950e61..91f862d2 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -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),