diff --git a/include/lupi.h b/include/lupi.h index 6c1420b..5fe4066 100644 --- a/include/lupi.h +++ b/include/lupi.h @@ -9,6 +9,7 @@ #define pushctuple(state, name, value) lua_pushstring((state), (name)); lua_pushcfunction((state), (value)); lua_settable((state), -3) void run_init(); +void luanative_start(lua_State *L); void setup_modules(lua_State *L); void termutils_start(lua_State *L); #endif diff --git a/src/c/lnative.c b/src/c/lnative.c new file mode 100644 index 0000000..ddd0d05 --- /dev/null +++ b/src/c/lnative.c @@ -0,0 +1,19 @@ +#include "lupi.h" +#include +#include +#include +#include +#include + +static int l_sleep (lua_State *L) { + int t = lua_tonumber(L, 1); + usleep(t); + return 0; +} + +void luanative_start(lua_State *L) { + lua_createtable (L, 0, 1); + pushctuple(L, "sleep", l_sleep); + + lua_setglobal(L, "native"); +} \ No newline at end of file diff --git a/src/c/run.c b/src/c/run.c index 835290b..39867c3 100644 --- a/src/c/run.c +++ b/src/c/run.c @@ -8,9 +8,10 @@ void run_init() { lua_State *L; L = luaL_newstate(); - + luaL_openlibs (L); setup_modules (L); + luanative_start (L); termutils_start (L); int status = luaL_loadstring(L, lua_init); diff --git a/src/lua/core/boot.lua b/src/lua/core/boot.lua index 15a4053..e61fc55 100644 --- a/src/lua/core/boot.lua +++ b/src/lua/core/boot.lua @@ -5,8 +5,10 @@ function boot.boot() local w, h = gpu.getResolution() print("r= " .. tostring(w) .. " " .. tostring(h)) gpu.fill(0, 0, w, h, " ") + gpu.set(10, 5, "HHHHHHHHHHHHH") print("LuPI L2 INIT") print("FIXME: boot stub") + native.sleep(1000000) error("Unable to boot") end