From 40e98737cef85bc7772f35724507f586dbf0fa9d Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 14 Feb 2025 14:14:26 +0100 Subject: [PATCH] =?UTF-8?q?-=20Tota=20la=20API=20canviada.=20Fent=20la=20d?= =?UTF-8?q?ocumentaci=C3=B3.=20-=20v1.0=20RC1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- data/main.lua | 20 +- lua.cpp | 1285 ++++++++++++++++++++++--------------------------- mini.cpp | 16 +- version.h | 2 +- 5 files changed, 603 insertions(+), 722 deletions(-) diff --git a/Makefile b/Makefile index bd0a340..cae4971 100644 --- a/Makefile +++ b/Makefile @@ -24,4 +24,4 @@ linux: strip -s -R .comment -R .gnu.version --strip-unneeded "$(executable)" linux_debug: - g++ $(source) -D LUA_USE_LINUX -D DEBUG -g -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lSDL2 -o "$(executable)_debug" + g++ $(source) -D LUA_USE_LINUX -D DEBUG -g -Wall -lSDL2 -o "$(executable)_debug" diff --git a/data/main.lua b/data/main.lua index 9be4afa..91753ab 100644 --- a/data/main.lua +++ b/data/main.lua @@ -1,18 +1,24 @@ -other = require "other" +--other = require "other" x=0 function _init() - text=other.peiv() - keyRight = tonumber(getconf("keyright")) or KEY_RIGHT - keyLeft = tonumber(getconf("keyleft")) or KEY_LEFT - _update=normal_update + --text=other.peiv() + --keyRight = tonumber(getconf("keyright")) or KEY_RIGHT + --keyLeft = tonumber(getconf("keyleft")) or KEY_LEFT + --_update=normal_update --turbo(false) - local perico = "péricòñ" - print(utf8.len(perico)) + --local perico = "péricòñ" + --print(utf8.len(perico)) end function _update() + if key.press(key.ESCAPE) then + sys.quit() + end + + draw.cls(5) + draw.print("HOLA",0,0) end function normal_update() diff --git a/lua.cpp b/lua.cpp index f9d5260..5a4ab74 100644 --- a/lua.cpp +++ b/lua.cpp @@ -7,69 +7,41 @@ namespace fs = std::filesystem; extern "C" { - static int cpp_newsurf(lua_State *L) { + + // surf + // =============================================== + + static int cpp_surf_new(lua_State *L) { int w = luaL_checknumber(L, 1); int h = luaL_checknumber(L, 2); lua_pushinteger(L, newsurf(w, h)); return 1; } - static int cpp_loadsurf(lua_State *L) { + static int cpp_surf_load(lua_State *L) { const char* str = luaL_checkstring(L, 1); lua_pushinteger(L, loadsurf(str)); return 1; } - static int cpp_freesurf(lua_State *L) { + static int cpp_surf_free(lua_State *L) { uint8_t surface = luaL_checkinteger(L, 1); freesurf(surface); return 0; } - static int cpp_surfsize(lua_State *L) { + static int cpp_surf_size(lua_State *L) { uint8_t surface = luaL_checkinteger(L, 1); lua_pushinteger(L, surfw(surface)); lua_pushinteger(L, surfh(surface)); return 2; } - static int cpp_setdest(lua_State *L) { - uint8_t surface = luaL_checkinteger(L, 1); - setdest(surface); - return 0; - } - static int cpp_setsource(lua_State *L) { - uint8_t surface = luaL_checkinteger(L, 1); - setsource(surface); - return 0; - } + // pal + // =============================================== - static int cpp_setmap(lua_State *L) { - uint8_t surface = luaL_checkinteger(L, 1); - setmap(surface); - return 0; - } - - static int cpp_cls(lua_State *L) { - uint8_t color = luaL_optinteger(L, 1, 0); - cls(color); - return 0; - } - - static int cpp_color(lua_State *L) { - uint8_t col = luaL_optinteger(L, 1, 6); - color(col); - return 0; - } - - static int cpp_bcolor(lua_State *L) { - uint8_t col = luaL_optinteger(L, 1, 6); - bcolor(col); - return 0; - } - - static int cpp_loadpal(lua_State *L) { + static int cpp_pal_load(lua_State *L) { const char* str = luaL_checkstring(L, 1); uint32_t *pal = loadpal(str); lua_createtable(L, 2, 0); @@ -92,7 +64,7 @@ extern "C" { return 1; } - static int cpp_setpal(lua_State *L) { + static int cpp_pal_set(lua_State *L) { int r,g,b; if (lua_istable(L, -1)) { uint32_t pal[256]; @@ -116,7 +88,7 @@ extern "C" { return 0; } - static int cpp_palcolor(lua_State *L) { + static int cpp_pal_color(lua_State *L) { if (lua_gettop(L) >= 1) { uint8_t index = luaL_checkinteger(L, 1); if (lua_gettop(L) > 1) { @@ -137,7 +109,7 @@ extern "C" { return 0; } - static int cpp_paltrans(lua_State *L) { + static int cpp_pal_trans(lua_State *L) { if (lua_gettop(L) == 0) { lua_pushinteger(L, gettrans()); return 1; @@ -148,19 +120,7 @@ extern "C" { } } - static int cpp_setcolor(lua_State *L) { - return luaL_error(L, "Function 'setcolor' is DEPRECATED. Use 'palcolor' instead."); - } - static int cpp_getcolor(lua_State *L) { - return luaL_error(L, "Function 'getcolor' is DEPRECATED. Use 'palcolor' instead."); - } - static int cpp_settrans(lua_State *L) { - return luaL_error(L, "Function 'settrans' is DEPRECATED. Use 'paltrans' instead."); - } - static int cpp_gettrans(lua_State *L) { - return luaL_error(L, "Function 'gettrans' is DEPRECATED. Use 'paltrans' instead."); - } - static int cpp_subpal(lua_State *L) { + static int cpp_pal_sub(lua_State *L) { const int numargs = lua_gettop(L); uint8_t index, index2, color; switch (numargs) { @@ -186,26 +146,154 @@ extern "C" { return 0; } - static int cpp_pset(lua_State *L) { - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - if (lua_gettop(L) > 2) { - uint8_t color = luaL_checkinteger(L, 3); - pset(x, y, color); + + // draw + // =============================================== + + static int cpp_draw_dest(lua_State *L) { + const int numargs = lua_gettop(L); + switch (numargs) { + case 0: { + setdest(0); + return 0; + } + case 1: { + uint8_t surface = luaL_checkinteger(L, 1); + setdest(surface); + return 0; + } + case 2: { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + lua_pushinteger(L, pget(x, y)); + return 1; + } + case 3: { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + uint8_t color = luaL_checkinteger(L, 3); + pset(x, y, color); + return 0; + } + default: + return luaL_error(L, "Function 'draw.dest' Unexpected number of parameters."); + }; + } + + static int cpp_draw_source(lua_State *L) { + const int numargs = lua_gettop(L); + switch (numargs) { + case 1: { + uint8_t surface = luaL_checkinteger(L, 1); + setsource(surface); + return 0; + } + case 2: { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + lua_pushinteger(L, sget(x, y)); + return 1; + } + case 3: { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + uint8_t color = luaL_checkinteger(L, 3); + sset(x, y, color); + return 0; + } + default: + return luaL_error(L, "Function 'draw.source' Unexpected number of parameters."); + }; + } + + static int cpp_draw_map(lua_State *L) { + const int numargs = lua_gettop(L); + switch (numargs) { + case 1: { + uint8_t surface = luaL_checkinteger(L, 1); + setmap(surface); + return 0; + } + case 2: { + int celx = luaL_checknumber(L, 1); + int cely = luaL_checknumber(L, 2); + lua_pushinteger(L, mget(celx, cely)); + return 1; + } + case 3: { + int celx = luaL_checknumber(L, 1); + int cely = luaL_checknumber(L, 2); + uint8_t snum = luaL_checkinteger(L, 3); + mset(celx, cely, snum); + return 0; + } + default: { + uint8_t celx = luaL_checknumber(L, 1); + uint8_t cely = luaL_checknumber(L, 2); + int sx = luaL_checknumber(L, 3); + int sy = luaL_checknumber(L, 4); + uint8_t celw = luaL_checknumber(L, 5); + uint8_t celh = luaL_checknumber(L, 6); + uint8_t layer = luaL_optinteger(L, 7, 0); + map(celx, cely, sx, sy, celw, celh, layer); + return 0; + } + }; + } + + static int cpp_draw_cls(lua_State *L) { + uint8_t color = luaL_optinteger(L, 1, 0); + cls(color); + return 0; + } + + static int cpp_draw_clip(lua_State *L) { + if (lua_gettop(L) == 0) { + clip(); } else { - pset(x, y); + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + int w = luaL_checknumber(L, 3); + int h = luaL_checknumber(L, 4); + clip(x, y, w, h); } return 0; } - static int cpp_pget(lua_State *L) { - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - lua_pushinteger(L, pget(x, y)); - return 1; + static int cpp_draw_origin(lua_State *L) { + if (lua_gettop(L) == 0) { + lua_pushinteger(L, camx()); + lua_pushinteger(L, camy()); + return 2; + } else { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + origin(x, y); + return 0; + } } - static int cpp_line(lua_State *L) { + static int cpp_draw_tolocal(lua_State *L) { + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + lua_pushinteger(L, x+camx()); + lua_pushinteger(L, y+camy()); + return 2; + } + + static int cpp_draw_pen(lua_State *L) { + uint8_t col = luaL_optinteger(L, 1, 6); + color(col); + return 0; + } + + static int cpp_draw_paper(lua_State *L) { + uint8_t col = luaL_optinteger(L, 1, 6); + bcolor(col); + return 0; + } + + static int cpp_draw_line(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); int x1 = luaL_checknumber(L, 3); @@ -219,7 +307,7 @@ extern "C" { return 0; } - static int cpp_hline(lua_State *L) { + static int cpp_draw_hline(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); int x1 = luaL_checknumber(L, 3); @@ -232,7 +320,7 @@ extern "C" { return 0; } - static int cpp_vline(lua_State *L) { + static int cpp_draw_vline(lua_State *L) { int x = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); int y1 = luaL_checknumber(L, 3); @@ -245,7 +333,7 @@ extern "C" { return 0; } - static int cpp_rect(lua_State *L) { + static int cpp_draw_rect(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); int x1 = luaL_checknumber(L, 3); @@ -259,7 +347,7 @@ extern "C" { return 0; } - static int cpp_rectfill(lua_State *L) { + static int cpp_draw_rectfill(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); int x1 = luaL_checknumber(L, 3); @@ -273,69 +361,7 @@ extern "C" { return 0; } - static int cpp_fillp(lua_State *L) { - uint16_t pat = luaL_checkinteger(L, 1); - bool transparent = lua_toboolean(L, 2); - fillp(pat, transparent); - return 0; - } - - static int cpp_print(lua_State *L) { - const char* str = luaL_checkstring(L, 1); - int x = luaL_checknumber(L, 2); - int y = luaL_checknumber(L, 3); - if (lua_gettop(L) > 3) { - uint8_t color = luaL_checkinteger(L, 4); - print(str, x, y, color); - } else { - print(str, x, y); - } - return 0; - } - - static int cpp_clip(lua_State *L) { - if (lua_gettop(L) == 0) { - clip(); - } else { - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - int w = luaL_checknumber(L, 3); - int h = luaL_checknumber(L, 4); - clip(x, y, w, h); - } - return 0; - } - - static int cpp_camera(lua_State *L) { - return luaL_error(L, "Function 'camera' is DEPRECATED. Use 'origin' and 'clip' instead."); - } - - static int cpp_view(lua_State *L) { - return luaL_error(L, "Function 'view' is DEPRECATED. Use 'origin' and 'clip' instead."); - } - - static int cpp_origin(lua_State *L) { - if (lua_gettop(L) == 0) { - lua_pushinteger(L, camx()); - lua_pushinteger(L, camy()); - return 2; - } else { - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - origin(x, y); - return 0; - } - } - - static int cpp_tolocal(lua_State *L) { - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - lua_pushinteger(L, x+camx()); - lua_pushinteger(L, y+camy()); - return 2; - } - - static int cpp_circ(lua_State *L) { + static int cpp_draw_circ(lua_State *L) { int x = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); int r = luaL_optnumber(L, 3, 4); @@ -348,7 +374,7 @@ extern "C" { return 0; } - static int cpp_circfill(lua_State *L) { + static int cpp_draw_circfill(lua_State *L) { int x = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); int r = luaL_optnumber(L, 3, 4); @@ -361,7 +387,7 @@ extern "C" { return 0; } - static int cpp_oval(lua_State *L) { + static int cpp_draw_oval(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); int x1 = luaL_checknumber(L, 3); @@ -375,7 +401,7 @@ extern "C" { return 0; } - static int cpp_ovalfill(lua_State *L) { + static int cpp_draw_ovalfill(lua_State *L) { int x0 = luaL_checknumber(L, 1); int y0 = luaL_checknumber(L, 2); int x1 = luaL_checknumber(L, 3); @@ -389,38 +415,51 @@ extern "C" { return 0; } - static int cpp_sset(lua_State *L) { - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - if (lua_gettop(L) > 2) { - uint8_t color = luaL_checkinteger(L, 3); - sset(x, y, color); - } else { - sset(x, y); - } + static int cpp_draw_pattern(lua_State *L) { + uint16_t pat = luaL_checkinteger(L, 1); + bool transparent = lua_toboolean(L, 2); + fillp(pat, transparent); return 0; } - static int cpp_sget(lua_State *L) { - int x = luaL_checknumber(L, 1); + static int cpp_draw_tline(lua_State *L) { + int x0 = luaL_checknumber(L, 1); + int y0 = luaL_checknumber(L, 2); + int x1 = luaL_checknumber(L, 3); + int y1 = luaL_checknumber(L, 4); + float mx = luaL_checknumber(L, 5); + float my = luaL_checknumber(L, 6); + float mdx = luaL_optnumber(L, 7, 0.125f); + float mdy = luaL_optnumber(L, 8, 0.0f); + tline(x0, y0, x1, y1, mx, my, mdx, mdy); + return 0; + } + + static int cpp_draw_thline(lua_State *L) { + int x0 = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); - lua_pushinteger(L, sget(x, y)); - return 1; + int x1 = luaL_checknumber(L, 3); + float mx = luaL_checknumber(L, 4); + float my = luaL_checknumber(L, 5); + float mdx = luaL_optnumber(L, 6, 0.125f); + float mdy = luaL_optnumber(L, 7, 0.0f); + thline(x0, y, x1, mx, my, mdx, mdy); + return 0; } - static int cpp_spr(lua_State *L) { - return luaL_error(L, "Function 'spr' is DEPRECATED. No direct replacement. Use 'blit' instead."); + static int cpp_draw_tvline(lua_State *L) { + int x = luaL_checknumber(L, 1); + int y0 = luaL_checknumber(L, 2); + int y1 = luaL_checknumber(L, 3); + float mx = luaL_checknumber(L, 4); + float my = luaL_checknumber(L, 5); + float mdx = luaL_optnumber(L, 6, 0.0f); + float mdy = luaL_optnumber(L, 7, 0.125f); + tvline(x, y0, y1, mx, my, mdx, mdy); + return 0; } - static int cpp_sspr(lua_State *L) { - return luaL_error(L, "Function 'sspr' is DEPRECATED. Use 'blit' instead."); - } - - static int cpp_spr_r(lua_State *L) { - return luaL_error(L, "Function 'spr_r' is DEPRECATED. Use 'blit_r' instead."); - } - - static int cpp_blit(lua_State *L) { + static int cpp_draw_blit(lua_State *L) { int sx = luaL_checknumber(L, 1); int sy = luaL_checknumber(L, 2); int sw = luaL_checknumber(L, 3); @@ -436,7 +475,7 @@ extern "C" { return 0; } - static int cpp_blit_r(lua_State *L) { + static int cpp_draw_blit_r(lua_State *L) { int sx = luaL_checknumber(L, 1); int sy = luaL_checknumber(L, 2); int sw = luaL_checknumber(L, 3); @@ -448,284 +487,47 @@ extern "C" { return 0; } - static int cpp_tline(lua_State *L) { - int x0 = luaL_checknumber(L, 1); - int y0 = luaL_checknumber(L, 2); - int x1 = luaL_checknumber(L, 3); - int y1 = luaL_checknumber(L, 4); - float mx = luaL_checknumber(L, 5); - float my = luaL_checknumber(L, 6); - float mdx = luaL_optnumber(L, 7, 0.125f); - float mdy = luaL_optnumber(L, 8, 0.0f); - tline(x0, y0, x1, y1, mx, my, mdx, mdy); - return 0; - } - - static int cpp_thline(lua_State *L) { - int x0 = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - int x1 = luaL_checknumber(L, 3); - float mx = luaL_checknumber(L, 4); - float my = luaL_checknumber(L, 5); - float mdx = luaL_optnumber(L, 6, 0.125f); - float mdy = luaL_optnumber(L, 7, 0.0f); - thline(x0, y, x1, mx, my, mdx, mdy); - return 0; - } - - static int cpp_tvline(lua_State *L) { - int x = luaL_checknumber(L, 1); - int y0 = luaL_checknumber(L, 2); - int y1 = luaL_checknumber(L, 3); - float mx = luaL_checknumber(L, 4); - float my = luaL_checknumber(L, 5); - float mdx = luaL_optnumber(L, 6, 0.0f); - float mdy = luaL_optnumber(L, 7, 0.125f); - tvline(x, y0, y1, mx, my, mdx, mdy); - return 0; - } - - static int cpp_mset(lua_State *L) { - int celx = luaL_checknumber(L, 1); - int cely = luaL_checknumber(L, 2); - uint8_t snum = luaL_checkinteger(L, 3); - mset(celx, cely, snum); - return 0; - } - - static int cpp_mget(lua_State *L) { - int celx = luaL_checknumber(L, 1); - int cely = luaL_checknumber(L, 2); - lua_pushinteger(L, mget(celx, cely)); - return 1; - } - - static int cpp_map(lua_State *L) { - uint8_t celx = luaL_checknumber(L, 1); - uint8_t cely = luaL_checknumber(L, 2); - int sx = luaL_checknumber(L, 3); - int sy = luaL_checknumber(L, 4); - uint8_t celw = luaL_checknumber(L, 5); - uint8_t celh = luaL_checknumber(L, 6); - uint8_t layer = luaL_optinteger(L, 7, 0); - map(celx, cely, sx, sy, celw, celh, layer); - return 0; - } - - static int cpp_btn(lua_State *L) { - uint8_t i = luaL_checkinteger(L, 1); - lua_pushboolean(L, btn(i)); - return 1; - } - - static int cpp_btnp(lua_State *L) { - if (lua_gettop(L) >=1 ) { - uint8_t i = luaL_checkinteger(L, 1); - lua_pushboolean(L, btnp(i)); + static int cpp_draw_print(lua_State *L) { + const char* str = luaL_checkstring(L, 1); + int x = luaL_checknumber(L, 2); + int y = luaL_checknumber(L, 3); + if (lua_gettop(L) > 3) { + uint8_t color = luaL_checkinteger(L, 4); + print(str, x, y, color); } else { - lua_pushinteger(L, wbtnp()); + print(str, x, y); } - return 1; - } - - static int cpp_anykey(lua_State *L) { - lua_pushboolean(L, anykey()); - return 1; - } - - static int cpp_pad(lua_State *L) { - int8_t i = luaL_checkinteger(L, 1); - lua_pushboolean(L, pad(i)); - return 1; - } - - static int cpp_padp(lua_State *L) { - if (lua_gettop(L) >=1 ) { - int8_t i = luaL_checkinteger(L, 1); - lua_pushboolean(L, padp(i)); - } else { - lua_pushinteger(L, wpad()); - } - return 1; - } - - static int cpp_mouse(lua_State *L) { - lua_pushinteger(L, mousex()); - lua_pushinteger(L, mousey()); - return 2; - } - - static int cpp_mousex(lua_State *L) { - return luaL_error(L, "Function 'mousex' is DEPRECATED. Use 'mouse' instead."); - } - - static int cpp_mousey(lua_State *L) { - return luaL_error(L, "Function 'mousey' is DEPRECATED. Use 'mouse' instead."); - } - - static int cpp_mwheel(lua_State *L) { - lua_pushinteger(L, mwheel()); - return 1; - } - - static int cpp_mbtn(lua_State *L) { - uint8_t i = luaL_checkinteger(L, 1); - lua_pushboolean(L, mbtn(i)); - return 1; - } - - static int cpp_mbtnp(lua_State *L) { - uint8_t i = luaL_checkinteger(L, 1); - lua_pushboolean(L, mbtnp(i)); - return 1; - } - - static int cpp_time(lua_State *L) { - lua_pushnumber(L, time()); - return 1; - } - - static int cpp_beat(lua_State *L) { - int16_t beats = luaL_optnumber(L, 1, -1); - lua_pushboolean(L, beat(beats)); - return 1; - } - - static int cpp_abs(lua_State *L) { - return luaL_error(L, "Function 'abs' is DEPRECATED. Use 'math.abs' instead."); - } - static int cpp_ceil(lua_State *L) { - return luaL_error(L, "Function 'ceil' is DEPRECATED. Use 'math.ceil' instead."); - } - static int cpp_flr(lua_State *L) { - return luaL_error(L, "Function 'flr' is DEPRECATED. Use 'math.floor' instead."); - } - static int cpp_sgn(lua_State *L) { - return luaL_error(L, "Function 'sgn' is DEPRECATED. No direct replacement though..."); - } - static int cpp_sin(lua_State *L) { - return luaL_error(L, "Function 'sin' is DEPRECATED. Use 'math.sin' instead."); - } - static int cpp_cos(lua_State *L) { - return luaL_error(L, "Function 'cos' is DEPRECATED. Use 'math.cos' instead."); - } - static int cpp_atan2(lua_State *L) { - return luaL_error(L, "Function 'atan2' is DEPRECATED. Use 'math.atan2' instead."); - } - static int cpp_sqrt(lua_State *L) { - return luaL_error(L, "Function 'sqrt' is DEPRECATED. Use 'math.sqrt' instead."); - } - static int cpp_max(lua_State *L) { - return luaL_error(L, "Function 'max' is DEPRECATED. Use 'math.max' instead."); - } - static int cpp_mid(lua_State *L) { - return luaL_error(L, "Function 'mid' is DEPRECATED. No direct replacement though..."); - } - static int cpp_min(lua_State *L) { - return luaL_error(L, "Function 'min' is DEPRECATED. Use 'math.min' instead."); - } - static int cpp_rnd(lua_State *L) { - int x = luaL_checkinteger(L, 1); - lua_pushinteger(L, rnd(x)); - return 1; - } - static int cpp_srand(lua_State *L) { - int x = luaL_checkinteger(L, 1); - srand(x); return 0; } - static int cpp_tostr(lua_State *L) { - return luaL_error(L, "Function 'tostr' is DEPRECATED. Use Lua's own methods instead."); - } - static int cpp_ascii(lua_State *L) { - return luaL_error(L, "Function 'ascii' is DEPRECATED. Use 'string.byte' instead (1 based indexing though...)."); - } - static int cpp_strlen(lua_State *L) { - return luaL_error(L, "Function 'strlen' is DEPRECATED. Use 'utf8.len' instead."); - } - static int cpp_fopen(lua_State *L) { - return luaL_error(L, "Function 'fopen' is DEPRECATED. Use Lua's own io methods instead."); - } - static int cpp_fopenres(lua_State *L) { - return luaL_error(L, "Function 'fopenres' is DEPRECATED. Use Lua's own io methods instead."); - } - static int cpp_fclose(lua_State *L) { - return luaL_error(L, "Function 'fclose' is DEPRECATED. Use Lua's own io methods instead."); - } - static int cpp_feof(lua_State *L) { - return luaL_error(L, "Function 'feof' is DEPRECATED. Use Lua's own io methods instead."); - } + // music + // =============================================== - static int cpp_fwritei(lua_State *L) { - return luaL_error(L, "Function 'fwritei' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_fwrited(lua_State *L) { - return luaL_error(L, "Function 'fwrited' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_fwrites(lua_State *L) { - return luaL_error(L, "Function 'fwrites' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_fwritew(lua_State *L) { - return luaL_error(L, "Function 'fwritew' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_fwriteb(lua_State *L) { - return luaL_error(L, "Function 'fwriteb' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_fwriteln(lua_State *L) { - return luaL_error(L, "Function 'fwriteln' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_freadi(lua_State *L) { - return luaL_error(L, "Function 'freadi' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_freadd(lua_State *L) { - return luaL_error(L, "Function 'freadd' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_freads(lua_State *L) { - return luaL_error(L, "Function 'freads' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_freadw(lua_State *L) { - return luaL_error(L, "Function 'freadw' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_freadb(lua_State *L) { - return luaL_error(L, "Function 'freadb' is DEPRECATED. Use Lua's own io methods instead."); - } - - static int cpp_playmusic(lua_State *L) { + static int cpp_music_play(lua_State *L) { const char* str = luaL_checkstring(L, 1); const int loop = luaL_optinteger(L, 2, -1); playmusic(str, loop); return 0; } - static int cpp_pausemusic(lua_State *L) { + static int cpp_music_pause(lua_State *L) { pausemusic(); return 0; } - static int cpp_resumemusic(lua_State *L) { + static int cpp_music_resume(lua_State *L) { resumemusic(); return 0; } - static int cpp_stopmusic(lua_State *L) { + static int cpp_music_stop(lua_State *L) { const int time = luaL_optinteger(L, 1, 1000); stopmusic(time); return 0; } - static int cpp_musicpos(lua_State *L) { + static int cpp_music_pos(lua_State *L) { if (lua_gettop(L) >= 1) { musicpos(luaL_checknumber(L, 1)); return 0; @@ -735,32 +537,81 @@ extern "C" { } } - static int cpp_loadsound(lua_State *L) { + + // sound + // =============================================== + + static int cpp_sound_load(lua_State *L) { const char* str = luaL_checkstring(L, 1); lua_pushinteger(L,loadsound(str)); return 1; } - static int cpp_freesound(lua_State *L) { + static int cpp_sound_free(lua_State *L) { const int sound = luaL_checknumber(L, 1); freesound(sound); return 0; } - static int cpp_playsound(lua_State *L) { + static int cpp_sound_play(lua_State *L) { const int sound = luaL_checknumber(L, 1); const int volume = luaL_optinteger(L, 2, -1); lua_pushinteger(L,playsound(sound, volume)); return 1; } - static int cpp_stopsound(lua_State *L) { + static int cpp_sound_stop(lua_State *L) { const int sound = luaL_checknumber(L, 1); stopsound(sound); return 0; } - static int cpp_zoom(lua_State *L) { + + // sys + // =============================================== + + static int cpp_sys_time(lua_State *L) { + lua_pushnumber(L, time()); + return 1; + } + + static int cpp_sys_beat(lua_State *L) { + int16_t beats = luaL_optnumber(L, 1, -1); + lua_pushboolean(L, beat(beats)); + return 1; + } + + static int cpp_sys_turbo(lua_State *L) { + if (lua_gettop(L) >= 1) { + setturbo(lua_toboolean(L, 1)); + return 0; + } else { + setturbo(true); + return 0; + } + } + + static int cpp_sys_dir(lua_State *L) { + lua_newtable(L); + int i=1; + for (const auto& entry : fs::directory_iterator("./data")) { + lua_pushstring(L, entry.path().u8string().c_str()); + lua_rawseti(L, -2, i++); + } + + return 1; + } + + static int cpp_sys_exit(lua_State *L) { + exit(); + return 0; + } + + + // win + // =============================================== + + static int cpp_win_zoom(lua_State *L) { const int value = luaL_optinteger(L, 1, 0); if (value==0) { lua_pushinteger(L, getzoom()); @@ -771,7 +622,7 @@ extern "C" { } } - static int cpp_fullscreen(lua_State *L) { + static int cpp_win_fullscreen(lua_State *L) { if (lua_gettop(L) >= 1) { setfullscreen(lua_toboolean(L, 1)); return 0; @@ -781,7 +632,7 @@ extern "C" { } } - static int cpp_cursor(lua_State *L) { + static int cpp_win_cursor(lua_State *L) { if (lua_gettop(L) >= 1) { setcursor(lua_toboolean(L, 1)); return 0; @@ -791,7 +642,7 @@ extern "C" { } } - static int cpp_res(lua_State *L) { + static int cpp_win_res(lua_State *L) { if (lua_gettop(L) >= 2) { const int w = luaL_optinteger(L, 1, 160); const int h = luaL_optinteger(L, 2, 120); @@ -804,53 +655,108 @@ extern "C" { } } - static int cpp_getconf(lua_State *L) { + + // conf + // =============================================== + + static int cpp_conf_key(lua_State *L) { + const int numargs = lua_gettop(L); const char* key = luaL_checkstring(L, 1); - const char* value = getconfig(key); - if (value==NULL) { - lua_pushnil(L); - } else { - lua_pushstring(L, value); + switch (numargs) { + case 1: { + const char* value = getconfig(key); + if (value==NULL) { + lua_pushnil(L); + } else { + lua_pushstring(L, value); + } + return 1; + } + case 2: { + const char* value = luaL_checkstring(L, 2); + setconfig(key, value); + return 0; + } + default: + return luaL_error(L, "Function 'conf.key' Unexpected number of parameters."); } - return 1; } - static int cpp_setconf(lua_State *L) { - const char* key = luaL_checkstring(L, 1); - const char* value = luaL_checkstring(L, 2); - setconfig(key, value); - return 0; - } - - static int cpp_configfolder(lua_State *L) { + static int cpp_conf_folder(lua_State *L) { lua_pushstring(L, configfolder()); return 1; } - static int cpp_turbo(lua_State *L) { - if (lua_gettop(L) >= 1) { - setturbo(lua_toboolean(L, 1)); - return 0; - } else { - setturbo(true); - return 0; - } + + // mouse + // =============================================== + + static int cpp_mouse_pos(lua_State *L) { + lua_pushinteger(L, mousex()); + lua_pushinteger(L, mousey()); + return 2; } - static int cpp_dir(lua_State *L) { - lua_newtable(L); - int i=1; - for (const auto& entry : fs::directory_iterator("./data")) { - lua_pushstring(L, entry.path().u8string().c_str()); - lua_rawseti(L, -2, i++); - } - + static int cpp_mouse_wheel(lua_State *L) { + lua_pushinteger(L, mwheel()); return 1; } - static int cpp_exit(lua_State *L) { - exit(); - return 0; + static int cpp_mouse_down(lua_State *L) { + uint8_t i = luaL_checkinteger(L, 1); + lua_pushboolean(L, mbtn(i)); + return 1; + } + + static int cpp_mouse_press(lua_State *L) { + uint8_t i = luaL_checkinteger(L, 1); + lua_pushboolean(L, mbtnp(i)); + return 1; + } + + + // key + // =============================================== + + static int cpp_key_down(lua_State *L) { + uint8_t i = luaL_checkinteger(L, 1); + lua_pushboolean(L, btn(i)); + return 1; + } + + static int cpp_key_press(lua_State *L) { + if (lua_gettop(L) >=1 ) { + uint8_t i = luaL_checkinteger(L, 1); + lua_pushboolean(L, btnp(i)); + } else { + lua_pushinteger(L, wbtnp()); + } + return 1; + } + + static int cpp_key_any(lua_State *L) { + lua_pushboolean(L, anykey()); + return 1; + } + + + // pad + // =============================================== + + static int cpp_pad_down(lua_State *L) { + int8_t i = luaL_checkinteger(L, 1); + lua_pushboolean(L, pad(i)); + return 1; + } + + static int cpp_pad_press(lua_State *L) { + if (lua_gettop(L) >=1 ) { + int8_t i = luaL_checkinteger(L, 1); + lua_pushboolean(L, padp(i)); + } else { + lua_pushinteger(L, wpad()); + } + return 1; } } @@ -865,271 +771,234 @@ bool lua_is_playing() { } void push_lua_funcs() { - lua_pushcfunction(L,cpp_newsurf); lua_setglobal(L, "newsurf"); - lua_pushcfunction(L,cpp_loadsurf); lua_setglobal(L, "loadsurf"); - lua_pushcfunction(L,cpp_freesurf); lua_setglobal(L, "freesurf"); - lua_pushcfunction(L,cpp_surfsize); lua_setglobal(L, "surfsize"); - lua_pushcfunction(L,cpp_setdest); lua_setglobal(L, "setdest"); - lua_pushcfunction(L,cpp_setsource); lua_setglobal(L, "setsource"); - lua_pushcfunction(L,cpp_setmap); lua_setglobal(L, "setmap"); + lua_newtable(L); + lua_pushcfunction(L,cpp_surf_new); lua_setfield(L, -2, "new"); + lua_pushcfunction(L,cpp_surf_load); lua_setfield(L, -2, "load"); + lua_pushcfunction(L,cpp_surf_free); lua_setfield(L, -2, "free"); + lua_pushcfunction(L,cpp_surf_size); lua_setfield(L, -2, "size"); + lua_setglobal(L, "surf"); - lua_pushcfunction(L,cpp_cls); lua_setglobal(L, "cls"); - lua_pushcfunction(L,cpp_color); lua_setglobal(L, "color"); - lua_pushcfunction(L,cpp_bcolor); lua_setglobal(L, "bcolor"); + lua_newtable(L); + lua_pushcfunction(L,cpp_pal_load); lua_setfield(L, -2, "load"); + lua_pushcfunction(L,cpp_pal_set); lua_setfield(L, -2, "set"); + lua_pushcfunction(L,cpp_pal_color); lua_setfield(L, -2, "color"); + lua_pushcfunction(L,cpp_pal_trans); lua_setfield(L, -2, "trans"); + lua_pushcfunction(L,cpp_pal_sub); lua_setfield(L, -2, "sub"); + lua_setglobal(L, "pal"); - lua_pushcfunction(L,cpp_loadpal); lua_setglobal(L, "loadpal"); - lua_pushcfunction(L,cpp_setpal); lua_setglobal(L, "setpal"); - lua_pushcfunction(L,cpp_palcolor); lua_setglobal(L, "palcolor"); - lua_pushcfunction(L,cpp_paltrans); lua_setglobal(L, "paltrans"); - lua_pushcfunction(L,cpp_setcolor); lua_setglobal(L, "setcolor"); - lua_pushcfunction(L,cpp_getcolor); lua_setglobal(L, "getcolor"); - lua_pushcfunction(L,cpp_settrans); lua_setglobal(L, "settrans"); - lua_pushcfunction(L,cpp_gettrans); lua_setglobal(L, "gettrans"); - lua_pushcfunction(L,cpp_subpal); lua_setglobal(L, "subpal"); + lua_newtable(L); + lua_pushcfunction(L,cpp_draw_dest); lua_setfield(L, -2, "dest"); + lua_pushcfunction(L,cpp_draw_source); lua_setfield(L, -2, "source"); + lua_pushcfunction(L,cpp_draw_map); lua_setfield(L, -2, "map"); + lua_pushcfunction(L,cpp_draw_cls); lua_setfield(L, -2, "cls"); + lua_pushcfunction(L,cpp_draw_clip); lua_setfield(L, -2, "clip"); + lua_pushcfunction(L,cpp_draw_origin); lua_setfield(L, -2, "origin"); + lua_pushcfunction(L,cpp_draw_tolocal); lua_setfield(L, -2, "tolocal"); + lua_pushcfunction(L,cpp_draw_pen); lua_setfield(L, -2, "pen"); + lua_pushcfunction(L,cpp_draw_paper); lua_setfield(L, -2, "paper"); + lua_pushcfunction(L,cpp_draw_line); lua_setfield(L, -2, "line"); + lua_pushcfunction(L,cpp_draw_hline); lua_setfield(L, -2, "hline"); + lua_pushcfunction(L,cpp_draw_vline); lua_setfield(L, -2, "vline"); + lua_pushcfunction(L,cpp_draw_rect); lua_setfield(L, -2, "rect"); + lua_pushcfunction(L,cpp_draw_rectfill); lua_setfield(L, -2, "rectfill"); + lua_pushcfunction(L,cpp_draw_circ); lua_setfield(L, -2, "circ"); + lua_pushcfunction(L,cpp_draw_circfill); lua_setfield(L, -2, "circfill"); + lua_pushcfunction(L,cpp_draw_oval); lua_setfield(L, -2, "oval"); + lua_pushcfunction(L,cpp_draw_ovalfill); lua_setfield(L, -2, "ovalfill"); + lua_pushcfunction(L,cpp_draw_pattern); lua_setfield(L, -2, "pattern"); + lua_pushcfunction(L,cpp_draw_tline); lua_setfield(L, -2, "tline"); + lua_pushcfunction(L,cpp_draw_thline); lua_setfield(L, -2, "thline"); + lua_pushcfunction(L,cpp_draw_tvline); lua_setfield(L, -2, "tvline"); + lua_pushcfunction(L,cpp_draw_blit); lua_setfield(L, -2, "blit"); + lua_pushcfunction(L,cpp_draw_blit_r); lua_setfield(L, -2, "blit_r"); + lua_pushcfunction(L,cpp_draw_print); lua_setfield(L, -2, "print"); + lua_setglobal(L, "draw"); - lua_pushcfunction(L,cpp_pset); lua_setglobal(L, "pset"); - lua_pushcfunction(L,cpp_pget); lua_setglobal(L, "pget"); - lua_pushcfunction(L,cpp_line); lua_setglobal(L, "line"); - lua_pushcfunction(L,cpp_hline); lua_setglobal(L, "hline"); - lua_pushcfunction(L,cpp_vline); lua_setglobal(L, "vline"); - lua_pushcfunction(L,cpp_rect); lua_setglobal(L, "rect"); - lua_pushcfunction(L,cpp_rectfill); lua_setglobal(L, "rectfill"); - lua_pushcfunction(L,cpp_fillp); lua_setglobal(L, "fillp"); - lua_pushcfunction(L,cpp_print); lua_setglobal(L, "prnt"); - lua_pushcfunction(L,cpp_clip); lua_setglobal(L, "clip"); - lua_pushcfunction(L,cpp_camera); lua_setglobal(L, "camera"); - lua_pushcfunction(L,cpp_view); lua_setglobal(L, "view"); - lua_pushcfunction(L,cpp_origin); lua_setglobal(L, "origin"); - lua_pushcfunction(L,cpp_tolocal); lua_setglobal(L, "tolocal"); - lua_pushcfunction(L,cpp_circ); lua_setglobal(L, "circ"); - lua_pushcfunction(L,cpp_circfill); lua_setglobal(L, "circfill"); - lua_pushcfunction(L,cpp_oval); lua_setglobal(L, "oval"); - lua_pushcfunction(L,cpp_ovalfill); lua_setglobal(L, "ovalfill"); - lua_pushcfunction(L,cpp_sset); lua_setglobal(L, "sset"); - lua_pushcfunction(L,cpp_sget); lua_setglobal(L, "sget"); - lua_pushcfunction(L,cpp_spr); lua_setglobal(L, "spr"); - lua_pushcfunction(L,cpp_sspr); lua_setglobal(L, "sspr"); - lua_pushcfunction(L,cpp_spr_r); lua_setglobal(L, "spr_r"); - lua_pushcfunction(L,cpp_blit); lua_setglobal(L, "blit"); - lua_pushcfunction(L,cpp_blit_r); lua_setglobal(L, "blit_r"); - lua_pushcfunction(L,cpp_tline); lua_setglobal(L, "tline"); - lua_pushcfunction(L,cpp_thline); lua_setglobal(L, "thline"); - lua_pushcfunction(L,cpp_tvline); lua_setglobal(L, "tvline"); - lua_pushcfunction(L,cpp_mget); lua_setglobal(L, "mget"); - lua_pushcfunction(L,cpp_mset); lua_setglobal(L, "mset"); - lua_pushcfunction(L,cpp_map); lua_setglobal(L, "map"); - lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn"); - lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp"); - lua_pushcfunction(L,cpp_anykey); lua_setglobal(L, "anykey"); - lua_pushcfunction(L,cpp_pad); lua_setglobal(L, "pad"); - lua_pushcfunction(L,cpp_padp); lua_setglobal(L, "padp"); - lua_pushcfunction(L,cpp_mouse); lua_setglobal(L, "mouse"); - lua_pushcfunction(L,cpp_mousex); lua_setglobal(L, "mousex"); - lua_pushcfunction(L,cpp_mousey); lua_setglobal(L, "mousey"); - lua_pushcfunction(L,cpp_mwheel); lua_setglobal(L, "mwheel"); - lua_pushcfunction(L,cpp_mbtn); lua_setglobal(L, "mbtn"); - lua_pushcfunction(L,cpp_mbtnp); lua_setglobal(L, "mbtnp"); + lua_newtable(L); + lua_pushcfunction(L,cpp_music_play); lua_setfield(L, -2, "play"); + lua_pushcfunction(L,cpp_music_pause); lua_setfield(L, -2, "pause"); + lua_pushcfunction(L,cpp_music_resume); lua_setfield(L, -2, "resume"); + lua_pushcfunction(L,cpp_music_stop); lua_setfield(L, -2, "stop"); + lua_pushcfunction(L,cpp_music_pos); lua_setfield(L, -2, "pos"); + lua_setglobal(L, "music"); - lua_pushcfunction(L,cpp_time); lua_setglobal(L, "time"); - lua_pushcfunction(L,cpp_beat); lua_setglobal(L, "beat"); + lua_newtable(L); + lua_pushcfunction(L,cpp_sound_load); lua_setfield(L, -2, "load"); + lua_pushcfunction(L,cpp_sound_free); lua_setfield(L, -2, "free"); + lua_pushcfunction(L,cpp_sound_play); lua_setfield(L, -2, "play"); + lua_pushcfunction(L,cpp_sound_stop); lua_setfield(L, -2, "stop"); + lua_setglobal(L, "sound"); + lua_newtable(L); + lua_pushcfunction(L,cpp_sys_time); lua_setfield(L, -2, "time"); + lua_pushcfunction(L,cpp_sys_beat); lua_setfield(L, -2, "beat"); + lua_pushcfunction(L,cpp_sys_turbo); lua_setfield(L, -2, "turbo"); + lua_pushcfunction(L,cpp_sys_dir); lua_setfield(L, -2, "dir"); + lua_pushcfunction(L,cpp_sys_exit); lua_setfield(L, -2, "quit"); + lua_setglobal(L, "sys"); - /* [BEGIN DEPRECADES] */ - lua_pushcfunction(L,cpp_abs); lua_setglobal(L, "abs"); - lua_pushcfunction(L,cpp_ceil); lua_setglobal(L, "ceil"); - lua_pushcfunction(L,cpp_flr); lua_setglobal(L, "flr"); - lua_pushcfunction(L,cpp_sgn); lua_setglobal(L, "sgn"); - lua_pushcfunction(L,cpp_sin); lua_setglobal(L, "sin"); - lua_pushcfunction(L,cpp_cos); lua_setglobal(L, "cos"); - lua_pushcfunction(L,cpp_atan2); lua_setglobal(L, "atan2"); - lua_pushcfunction(L,cpp_sqrt); lua_setglobal(L, "sqrt"); - lua_pushcfunction(L,cpp_max); lua_setglobal(L, "max"); - lua_pushcfunction(L,cpp_mid); lua_setglobal(L, "mid"); - lua_pushcfunction(L,cpp_min); lua_setglobal(L, "min"); - /* [END DEPRECADES] */ + lua_newtable(L); + lua_pushcfunction(L,cpp_win_zoom); lua_setfield(L, -2, "zoom"); + lua_pushcfunction(L,cpp_win_fullscreen);lua_setfield(L, -2, "fullscreen"); + lua_pushcfunction(L,cpp_win_cursor); lua_setfield(L, -2, "cursor"); + lua_pushcfunction(L,cpp_win_res); lua_setfield(L, -2, "res"); + lua_setglobal(L, "win"); - lua_pushcfunction(L,cpp_rnd); lua_setglobal(L, "rnd"); - lua_pushcfunction(L,cpp_srand); lua_setglobal(L, "srand"); - lua_pushcfunction(L,cpp_tostr); lua_setglobal(L, "tostr"); - lua_pushcfunction(L,cpp_ascii); lua_setglobal(L, "ascii"); - lua_pushcfunction(L,cpp_strlen); lua_setglobal(L, "strlen"); + lua_newtable(L); + lua_pushcfunction(L,cpp_conf_key); lua_setfield(L, -2, "key"); + lua_pushcfunction(L,cpp_conf_folder); lua_setfield(L, -2, "folder"); + lua_setglobal(L, "conf"); - /* [BEGIN DEPRECADES] */ - lua_pushcfunction(L,cpp_fopen); lua_setglobal(L, "fopen"); - lua_pushcfunction(L,cpp_fopenres); lua_setglobal(L, "fopenres"); - lua_pushcfunction(L,cpp_fclose); lua_setglobal(L, "fclose"); - lua_pushcfunction(L,cpp_feof); lua_setglobal(L, "feof"); - lua_pushcfunction(L,cpp_fwritei); lua_setglobal(L, "fwritei"); - lua_pushcfunction(L,cpp_fwrited); lua_setglobal(L, "fwrited"); - lua_pushcfunction(L,cpp_fwrites); lua_setglobal(L, "fwrites"); - lua_pushcfunction(L,cpp_fwritew); lua_setglobal(L, "fwritew"); - lua_pushcfunction(L,cpp_fwriteb); lua_setglobal(L, "fwriteb"); - lua_pushcfunction(L,cpp_fwriteln); lua_setglobal(L, "fwriteln"); - lua_pushcfunction(L,cpp_freadi); lua_setglobal(L, "freadi"); - lua_pushcfunction(L,cpp_freadd); lua_setglobal(L, "freadd"); - lua_pushcfunction(L,cpp_freads); lua_setglobal(L, "freads"); - lua_pushcfunction(L,cpp_freadw); lua_setglobal(L, "freadw"); - lua_pushcfunction(L,cpp_freadb); lua_setglobal(L, "freadb"); - /* [END DEPRECADES] */ + lua_newtable(L); + lua_pushcfunction(L,cpp_mouse_pos); lua_setfield(L, -2, "pos"); + lua_pushcfunction(L,cpp_mouse_wheel); lua_setfield(L, -2, "wheel"); + lua_pushcfunction(L,cpp_mouse_down); lua_setfield(L, -2, "down"); + lua_pushcfunction(L,cpp_mouse_press); lua_setfield(L, -2, "press"); + lua_setglobal(L, "mouse"); - lua_pushcfunction(L,cpp_playmusic); lua_setglobal(L, "playmusic"); - lua_pushcfunction(L,cpp_pausemusic); lua_setglobal(L, "pausemusic"); - lua_pushcfunction(L,cpp_resumemusic); lua_setglobal(L, "resumemusic"); - lua_pushcfunction(L,cpp_stopmusic); lua_setglobal(L, "stopmusic"); - lua_pushcfunction(L,cpp_musicpos); lua_setglobal(L, "musicpos"); - lua_pushcfunction(L,cpp_loadsound); lua_setglobal(L, "loadsound"); - lua_pushcfunction(L,cpp_freesound); lua_setglobal(L, "freesound"); - lua_pushcfunction(L,cpp_playsound); lua_setglobal(L, "playsound"); - lua_pushcfunction(L,cpp_stopsound); lua_setglobal(L, "stopsound"); + lua_newtable(L); + lua_pushcfunction(L,cpp_key_down); lua_setfield(L, -2, "down"); + lua_pushcfunction(L,cpp_key_press); lua_setfield(L, -2, "press"); + lua_pushcfunction(L,cpp_key_any); lua_setfield(L, -2, "any"); - lua_pushcfunction(L,cpp_zoom); lua_setglobal(L, "zoom"); - lua_pushcfunction(L,cpp_fullscreen); lua_setglobal(L, "fullscreen"); - lua_pushcfunction(L,cpp_cursor); lua_setglobal(L, "cursor"); - lua_pushcfunction(L,cpp_res); lua_setglobal(L, "res"); + lua_pushinteger(L, 0); lua_setfield(L, -2, "UNKNOWN"); + lua_pushinteger(L, 4); lua_setfield(L, -2, "A"); + lua_pushinteger(L, 5); lua_setfield(L, -2, "B"); + lua_pushinteger(L, 6); lua_setfield(L, -2, "C"); + lua_pushinteger(L, 7); lua_setfield(L, -2, "D"); + lua_pushinteger(L, 8); lua_setfield(L, -2, "E"); + lua_pushinteger(L, 9); lua_setfield(L, -2, "F"); + lua_pushinteger(L, 10); lua_setfield(L, -2, "G"); + lua_pushinteger(L, 11); lua_setfield(L, -2, "H"); + lua_pushinteger(L, 12); lua_setfield(L, -2, "I"); + lua_pushinteger(L, 13); lua_setfield(L, -2, "J"); + lua_pushinteger(L, 14); lua_setfield(L, -2, "K"); + lua_pushinteger(L, 15); lua_setfield(L, -2, "L"); + lua_pushinteger(L, 16); lua_setfield(L, -2, "M"); + lua_pushinteger(L, 17); lua_setfield(L, -2, "N"); + lua_pushinteger(L, 18); lua_setfield(L, -2, "O"); + lua_pushinteger(L, 19); lua_setfield(L, -2, "P"); + lua_pushinteger(L, 20); lua_setfield(L, -2, "Q"); + lua_pushinteger(L, 21); lua_setfield(L, -2, "R"); + lua_pushinteger(L, 22); lua_setfield(L, -2, "S"); + lua_pushinteger(L, 23); lua_setfield(L, -2, "T"); + lua_pushinteger(L, 24); lua_setfield(L, -2, "U"); + lua_pushinteger(L, 25); lua_setfield(L, -2, "V"); + lua_pushinteger(L, 26); lua_setfield(L, -2, "W"); + lua_pushinteger(L, 27); lua_setfield(L, -2, "X"); + lua_pushinteger(L, 28); lua_setfield(L, -2, "Y"); + lua_pushinteger(L, 29); lua_setfield(L, -2, "Z"); + lua_pushinteger(L, 30); lua_setfield(L, -2, "1"); + lua_pushinteger(L, 31); lua_setfield(L, -2, "2"); + lua_pushinteger(L, 32); lua_setfield(L, -2, "3"); + lua_pushinteger(L, 33); lua_setfield(L, -2, "4"); + lua_pushinteger(L, 34); lua_setfield(L, -2, "5"); + lua_pushinteger(L, 35); lua_setfield(L, -2, "6"); + lua_pushinteger(L, 36); lua_setfield(L, -2, "7"); + lua_pushinteger(L, 37); lua_setfield(L, -2, "8"); + lua_pushinteger(L, 38); lua_setfield(L, -2, "9"); + lua_pushinteger(L, 39); lua_setfield(L, -2, "0"); + lua_pushinteger(L, 40); lua_setfield(L, -2, "RETURN"); + lua_pushinteger(L, 41); lua_setfield(L, -2, "ESCAPE"); + lua_pushinteger(L, 42); lua_setfield(L, -2, "BACKSPACE"); + lua_pushinteger(L, 43); lua_setfield(L, -2, "TAB"); + lua_pushinteger(L, 44); lua_setfield(L, -2, "SPACE"); + lua_pushinteger(L, 45); lua_setfield(L, -2, "MINUS"); + lua_pushinteger(L, 46); lua_setfield(L, -2, "EQUALS"); + lua_pushinteger(L, 47); lua_setfield(L, -2, "LEFTBRACKET"); + lua_pushinteger(L, 48); lua_setfield(L, -2, "RIGHTBRACKET"); + lua_pushinteger(L, 49); lua_setfield(L, -2, "BACKSLASH"); + lua_pushinteger(L, 50); lua_setfield(L, -2, "NONUSHASH"); + lua_pushinteger(L, 51); lua_setfield(L, -2, "SEMICOLON"); + lua_pushinteger(L, 52); lua_setfield(L, -2, "APOSTROPHE"); + lua_pushinteger(L, 53); lua_setfield(L, -2, "GRAVE"); + lua_pushinteger(L, 54); lua_setfield(L, -2, "COMMA"); + lua_pushinteger(L, 55); lua_setfield(L, -2, "PERIOD"); + lua_pushinteger(L, 56); lua_setfield(L, -2, "SLASH"); + lua_pushinteger(L, 57); lua_setfield(L, -2, "CAPSLOCK"); + lua_pushinteger(L, 58); lua_setfield(L, -2, "F1"); + lua_pushinteger(L, 59); lua_setfield(L, -2, "F2"); + lua_pushinteger(L, 60); lua_setfield(L, -2, "F3"); + lua_pushinteger(L, 61); lua_setfield(L, -2, "F4"); + lua_pushinteger(L, 62); lua_setfield(L, -2, "F5"); + lua_pushinteger(L, 63); lua_setfield(L, -2, "F6"); + lua_pushinteger(L, 64); lua_setfield(L, -2, "F7"); + lua_pushinteger(L, 65); lua_setfield(L, -2, "F8"); + lua_pushinteger(L, 66); lua_setfield(L, -2, "F9"); + lua_pushinteger(L, 67); lua_setfield(L, -2, "F10"); + lua_pushinteger(L, 68); lua_setfield(L, -2, "F11"); + lua_pushinteger(L, 69); lua_setfield(L, -2, "F12"); + lua_pushinteger(L, 70); lua_setfield(L, -2, "PRINTSCREEN"); + lua_pushinteger(L, 71); lua_setfield(L, -2, "SCROLLLOCK"); + lua_pushinteger(L, 72); lua_setfield(L, -2, "PAUSE"); + lua_pushinteger(L, 73); lua_setfield(L, -2, "INSERT"); + lua_pushinteger(L, 74); lua_setfield(L, -2, "HOME"); + lua_pushinteger(L, 75); lua_setfield(L, -2, "PAGEUP"); + lua_pushinteger(L, 76); lua_setfield(L, -2, "DELETE"); + lua_pushinteger(L, 77); lua_setfield(L, -2, "END"); + lua_pushinteger(L, 78); lua_setfield(L, -2, "PAGEDOWN"); + lua_pushinteger(L, 79); lua_setfield(L, -2, "RIGHT"); + lua_pushinteger(L, 80); lua_setfield(L, -2, "LEFT"); + lua_pushinteger(L, 81); lua_setfield(L, -2, "DOWN"); + lua_pushinteger(L, 82); lua_setfield(L, -2, "UP"); + lua_pushinteger(L, 83); lua_setfield(L, -2, "NUMLOCKCLEAR"); + lua_pushinteger(L, 84); lua_setfield(L, -2, "KP_DIVIDE"); + lua_pushinteger(L, 85); lua_setfield(L, -2, "KP_MULTIPLY"); + lua_pushinteger(L, 86); lua_setfield(L, -2, "KP_MINUS"); + lua_pushinteger(L, 87); lua_setfield(L, -2, "KP_PLUS"); + lua_pushinteger(L, 88); lua_setfield(L, -2, "KP_ENTER"); + lua_pushinteger(L, 89); lua_setfield(L, -2, "KP_1"); + lua_pushinteger(L, 90); lua_setfield(L, -2, "KP_2"); + lua_pushinteger(L, 91); lua_setfield(L, -2, "KP_3"); + lua_pushinteger(L, 92); lua_setfield(L, -2, "KP_4"); + lua_pushinteger(L, 93); lua_setfield(L, -2, "KP_5"); + lua_pushinteger(L, 94); lua_setfield(L, -2, "KP_6"); + lua_pushinteger(L, 95); lua_setfield(L, -2, "KP_7"); + lua_pushinteger(L, 96); lua_setfield(L, -2, "KP_8"); + lua_pushinteger(L, 97); lua_setfield(L, -2, "KP_9"); + lua_pushinteger(L, 98); lua_setfield(L, -2, "KP_0"); + lua_pushinteger(L, 99); lua_setfield(L, -2, "KP_PERIOD"); + lua_pushinteger(L, 100); lua_setfield(L, -2, "NONUSBACKSLASH"); + lua_pushinteger(L, 101); lua_setfield(L, -2, "APPLICATION"); + lua_pushinteger(L, 224); lua_setfield(L, -2, "LCTRL"); + lua_pushinteger(L, 225); lua_setfield(L, -2, "LSHIFT"); + lua_pushinteger(L, 226); lua_setfield(L, -2, "LALT"); + lua_pushinteger(L, 227); lua_setfield(L, -2, "LGUI"); + lua_pushinteger(L, 228); lua_setfield(L, -2, "RCTRL"); + lua_pushinteger(L, 229); lua_setfield(L, -2, "RSHIFT"); + lua_pushinteger(L, 230); lua_setfield(L, -2, "RALT"); + lua_pushinteger(L, 231); lua_setfield(L, -2, "RGUI"); - lua_pushcfunction(L,cpp_getconf); lua_setglobal(L, "getconf"); - lua_pushcfunction(L,cpp_setconf); lua_setglobal(L, "setconf"); - lua_pushcfunction(L,cpp_configfolder); lua_setglobal(L, "configfolder"); + lua_setglobal(L, "key"); - lua_pushcfunction(L,cpp_turbo); lua_setglobal(L, "turbo"); - - lua_pushcfunction(L,cpp_dir); lua_setglobal(L, "dir"); + lua_newtable(L); + lua_pushcfunction(L,cpp_pad_down); lua_setfield(L, -2, "down"); + lua_pushcfunction(L,cpp_pad_press); lua_setfield(L, -2, "press"); - lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "quit"); + lua_pushinteger(L, -1); lua_setfield(L, -2, "INVALID"); + lua_pushinteger(L, 0); lua_setfield(L, -2, "A"); + lua_pushinteger(L, 1); lua_setfield(L, -2, "B"); + lua_pushinteger(L, 2); lua_setfield(L, -2, "X"); + lua_pushinteger(L, 3); lua_setfield(L, -2, "Y"); + lua_pushinteger(L, 4); lua_setfield(L, -2, "BACK"); + lua_pushinteger(L, 5); lua_setfield(L, -2, "GUIDE"); + lua_pushinteger(L, 6); lua_setfield(L, -2, "START"); + lua_pushinteger(L, 7); lua_setfield(L, -2, "LEFTSTICK"); + lua_pushinteger(L, 8); lua_setfield(L, -2, "RIGHTSTICK"); + lua_pushinteger(L, 9); lua_setfield(L, -2, "LEFTSHOULDER"); + lua_pushinteger(L, 10); lua_setfield(L, -2, "RIGHTSHOULDER"); + lua_pushinteger(L, 11); lua_setfield(L, -2, "UP"); + lua_pushinteger(L, 12); lua_setfield(L, -2, "DOWN"); + lua_pushinteger(L, 13); lua_setfield(L, -2, "LEFT"); + lua_pushinteger(L, 14); lua_setfield(L, -2, "RIGHT"); + lua_pushinteger(L, 15); lua_setfield(L, -2, "MISC1"); + lua_pushinteger(L, 16); lua_setfield(L, -2, "PADDLE1"); + lua_pushinteger(L, 17); lua_setfield(L, -2, "PADDLE2"); + lua_pushinteger(L, 18); lua_setfield(L, -2, "PADDLE3"); + lua_pushinteger(L, 19); lua_setfield(L, -2, "PADDLE4"); + lua_pushinteger(L, 20); lua_setfield(L, -2, "TOUCHPAD"); - lua_pushinteger(L, 0); lua_setglobal(L, "KEY_UNKNOWN"); - lua_pushinteger(L, 4); lua_setglobal(L, "KEY_A"); - lua_pushinteger(L, 5); lua_setglobal(L, "KEY_B"); - lua_pushinteger(L, 6); lua_setglobal(L, "KEY_C"); - lua_pushinteger(L, 7); lua_setglobal(L, "KEY_D"); - lua_pushinteger(L, 8); lua_setglobal(L, "KEY_E"); - lua_pushinteger(L, 9); lua_setglobal(L, "KEY_F"); - lua_pushinteger(L, 10); lua_setglobal(L, "KEY_G"); - lua_pushinteger(L, 11); lua_setglobal(L, "KEY_H"); - lua_pushinteger(L, 12); lua_setglobal(L, "KEY_I"); - lua_pushinteger(L, 13); lua_setglobal(L, "KEY_J"); - lua_pushinteger(L, 14); lua_setglobal(L, "KEY_K"); - lua_pushinteger(L, 15); lua_setglobal(L, "KEY_L"); - lua_pushinteger(L, 16); lua_setglobal(L, "KEY_M"); - lua_pushinteger(L, 17); lua_setglobal(L, "KEY_N"); - lua_pushinteger(L, 18); lua_setglobal(L, "KEY_O"); - lua_pushinteger(L, 19); lua_setglobal(L, "KEY_P"); - lua_pushinteger(L, 20); lua_setglobal(L, "KEY_Q"); - lua_pushinteger(L, 21); lua_setglobal(L, "KEY_R"); - lua_pushinteger(L, 22); lua_setglobal(L, "KEY_S"); - lua_pushinteger(L, 23); lua_setglobal(L, "KEY_T"); - lua_pushinteger(L, 24); lua_setglobal(L, "KEY_U"); - lua_pushinteger(L, 25); lua_setglobal(L, "KEY_V"); - lua_pushinteger(L, 26); lua_setglobal(L, "KEY_W"); - lua_pushinteger(L, 27); lua_setglobal(L, "KEY_X"); - lua_pushinteger(L, 28); lua_setglobal(L, "KEY_Y"); - lua_pushinteger(L, 29); lua_setglobal(L, "KEY_Z"); - lua_pushinteger(L, 30); lua_setglobal(L, "KEY_1"); - lua_pushinteger(L, 31); lua_setglobal(L, "KEY_2"); - lua_pushinteger(L, 32); lua_setglobal(L, "KEY_3"); - lua_pushinteger(L, 33); lua_setglobal(L, "KEY_4"); - lua_pushinteger(L, 34); lua_setglobal(L, "KEY_5"); - lua_pushinteger(L, 35); lua_setglobal(L, "KEY_6"); - lua_pushinteger(L, 36); lua_setglobal(L, "KEY_7"); - lua_pushinteger(L, 37); lua_setglobal(L, "KEY_8"); - lua_pushinteger(L, 38); lua_setglobal(L, "KEY_9"); - lua_pushinteger(L, 39); lua_setglobal(L, "KEY_0"); - lua_pushinteger(L, 40); lua_setglobal(L, "KEY_RETURN"); - lua_pushinteger(L, 41); lua_setglobal(L, "KEY_ESCAPE"); - lua_pushinteger(L, 42); lua_setglobal(L, "KEY_BACKSPACE"); - lua_pushinteger(L, 43); lua_setglobal(L, "KEY_TAB"); - lua_pushinteger(L, 44); lua_setglobal(L, "KEY_SPACE"); - lua_pushinteger(L, 45); lua_setglobal(L, "KEY_MINUS"); - lua_pushinteger(L, 46); lua_setglobal(L, "KEY_EQUALS"); - lua_pushinteger(L, 47); lua_setglobal(L, "KEY_LEFTBRACKET"); - lua_pushinteger(L, 48); lua_setglobal(L, "KEY_RIGHTBRACKET"); - lua_pushinteger(L, 49); lua_setglobal(L, "KEY_BACKSLASH"); - lua_pushinteger(L, 50); lua_setglobal(L, "KEY_NONUSHASH"); - lua_pushinteger(L, 51); lua_setglobal(L, "KEY_SEMICOLON"); - lua_pushinteger(L, 52); lua_setglobal(L, "KEY_APOSTROPHE"); - lua_pushinteger(L, 53); lua_setglobal(L, "KEY_GRAVE"); - lua_pushinteger(L, 54); lua_setglobal(L, "KEY_COMMA"); - lua_pushinteger(L, 55); lua_setglobal(L, "KEY_PERIOD"); - lua_pushinteger(L, 56); lua_setglobal(L, "KEY_SLASH"); - lua_pushinteger(L, 57); lua_setglobal(L, "KEY_CAPSLOCK"); - lua_pushinteger(L, 58); lua_setglobal(L, "KEY_F1"); - lua_pushinteger(L, 59); lua_setglobal(L, "KEY_F2"); - lua_pushinteger(L, 60); lua_setglobal(L, "KEY_F3"); - lua_pushinteger(L, 61); lua_setglobal(L, "KEY_F4"); - lua_pushinteger(L, 62); lua_setglobal(L, "KEY_F5"); - lua_pushinteger(L, 63); lua_setglobal(L, "KEY_F6"); - lua_pushinteger(L, 64); lua_setglobal(L, "KEY_F7"); - lua_pushinteger(L, 65); lua_setglobal(L, "KEY_F8"); - lua_pushinteger(L, 66); lua_setglobal(L, "KEY_F9"); - lua_pushinteger(L, 67); lua_setglobal(L, "KEY_F10"); - lua_pushinteger(L, 68); lua_setglobal(L, "KEY_F11"); - lua_pushinteger(L, 69); lua_setglobal(L, "KEY_F12"); - lua_pushinteger(L, 70); lua_setglobal(L, "KEY_PRINTSCREEN"); - lua_pushinteger(L, 71); lua_setglobal(L, "KEY_SCROLLLOCK"); - lua_pushinteger(L, 72); lua_setglobal(L, "KEY_PAUSE"); - lua_pushinteger(L, 73); lua_setglobal(L, "KEY_INSERT"); - lua_pushinteger(L, 74); lua_setglobal(L, "KEY_HOME"); - lua_pushinteger(L, 75); lua_setglobal(L, "KEY_PAGEUP"); - lua_pushinteger(L, 76); lua_setglobal(L, "KEY_DELETE"); - lua_pushinteger(L, 77); lua_setglobal(L, "KEY_END"); - lua_pushinteger(L, 78); lua_setglobal(L, "KEY_PAGEDOWN"); - lua_pushinteger(L, 79); lua_setglobal(L, "KEY_RIGHT"); - lua_pushinteger(L, 80); lua_setglobal(L, "KEY_LEFT"); - lua_pushinteger(L, 81); lua_setglobal(L, "KEY_DOWN"); - lua_pushinteger(L, 82); lua_setglobal(L, "KEY_UP"); - lua_pushinteger(L, 83); lua_setglobal(L, "KEY_NUMLOCKCLEAR"); - lua_pushinteger(L, 84); lua_setglobal(L, "KEY_KP_DIVIDE"); - lua_pushinteger(L, 85); lua_setglobal(L, "KEY_KP_MULTIPLY"); - lua_pushinteger(L, 86); lua_setglobal(L, "KEY_KP_MINUS"); - lua_pushinteger(L, 87); lua_setglobal(L, "KEY_KP_PLUS"); - lua_pushinteger(L, 88); lua_setglobal(L, "KEY_KP_ENTER"); - lua_pushinteger(L, 89); lua_setglobal(L, "KEY_KP_1"); - lua_pushinteger(L, 90); lua_setglobal(L, "KEY_KP_2"); - lua_pushinteger(L, 91); lua_setglobal(L, "KEY_KP_3"); - lua_pushinteger(L, 92); lua_setglobal(L, "KEY_KP_4"); - lua_pushinteger(L, 93); lua_setglobal(L, "KEY_KP_5"); - lua_pushinteger(L, 94); lua_setglobal(L, "KEY_KP_6"); - lua_pushinteger(L, 95); lua_setglobal(L, "KEY_KP_7"); - lua_pushinteger(L, 96); lua_setglobal(L, "KEY_KP_8"); - lua_pushinteger(L, 97); lua_setglobal(L, "KEY_KP_9"); - lua_pushinteger(L, 98); lua_setglobal(L, "KEY_KP_0"); - lua_pushinteger(L, 99); lua_setglobal(L, "KEY_KP_PERIOD"); - lua_pushinteger(L, 100); lua_setglobal(L, "KEY_NONUSBACKSLASH"); - lua_pushinteger(L, 101); lua_setglobal(L, "KEY_APPLICATION"); - lua_pushinteger(L, 224); lua_setglobal(L, "KEY_LCTRL"); - lua_pushinteger(L, 225); lua_setglobal(L, "KEY_LSHIFT"); - lua_pushinteger(L, 226); lua_setglobal(L, "KEY_LALT"); - lua_pushinteger(L, 227); lua_setglobal(L, "KEY_LGUI"); - lua_pushinteger(L, 228); lua_setglobal(L, "KEY_RCTRL"); - lua_pushinteger(L, 229); lua_setglobal(L, "KEY_RSHIFT"); - lua_pushinteger(L, 230); lua_setglobal(L, "KEY_RALT"); - lua_pushinteger(L, 231); lua_setglobal(L, "KEY_RGUI"); - - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_INVALID); lua_setglobal(L, "BTN_INVALID"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_A); lua_setglobal(L, "BTN_A"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_B); lua_setglobal(L, "BTN_B"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_X); lua_setglobal(L, "BTN_X"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_Y); lua_setglobal(L, "BTN_Y"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_BACK); lua_setglobal(L, "BTN_BACK"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_GUIDE); lua_setglobal(L, "BTN_GUIDE"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_START); lua_setglobal(L, "BTN_START"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_LEFTSTICK); lua_setglobal(L, "BTN_LEFTSTICK"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_RIGHTSTICK); lua_setglobal(L, "BTN_RIGHTSTICK"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); lua_setglobal(L, "BTN_LEFTSHOULDER"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); lua_setglobal(L, "BTN_RIGHTSHOULDER"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_DPAD_UP); lua_setglobal(L, "BTN_UP"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_DPAD_DOWN); lua_setglobal(L, "BTN_DOWN"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_DPAD_LEFT); lua_setglobal(L, "BTN_LEFT"); - lua_pushinteger(L, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); lua_setglobal(L, "BTN_RIGHT"); - lua_pushinteger(L, 15); lua_setglobal(L, "BTN_MISC1"); - lua_pushinteger(L, 16); lua_setglobal(L, "BTN_PADDLE1"); - lua_pushinteger(L, 17); lua_setglobal(L, "BTN_PADDLE2"); - lua_pushinteger(L, 18); lua_setglobal(L, "BTN_PADDLE3"); - lua_pushinteger(L, 19); lua_setglobal(L, "BTN_PADDLE4"); - lua_pushinteger(L, 20); lua_setglobal(L, "BTN_TOUCHPAD"); - - lua_pushinteger(L, 0); lua_setglobal(L, "FILE_READ"); - lua_pushinteger(L, 1); lua_setglobal(L, "FILE_WRITE"); + lua_setglobal(L, "pad"); } int MiniLoader(lua_State *L) { diff --git a/mini.cpp b/mini.cpp index f83ca65..729e73a 100644 --- a/mini.cpp +++ b/mini.cpp @@ -294,11 +294,17 @@ int main(int argc,char*argv[]){ if (argc>1) { - file_setresourcefolder("./"); - file_setsource(SOURCE_FOLDER); - strcpy(main_lua_file, argv[1]); - strcpy(window_title, argv[1]); - override_ini = true; + if (strstr(argv[1], ".lua")!=nullptr) { + file_setresourcefolder("./"); + file_setsource(SOURCE_FOLDER); + strcpy(main_lua_file, argv[1]); + strcpy(window_title, argv[1]); + override_ini = true; + } else { + char path[256] = "./"; + strcat(path, argv[1]); + file_setresourcefolder(path); + } } while (!should_quit) { diff --git a/version.h b/version.h index 54ea118..9ad20e5 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "0.9.98b" +#define MINI_VERSION "1.0 RC1"