From b5249e1957e378ba5b29df29c2c5bee1419dd8d2 Mon Sep 17 00:00:00 2001 From: Firew0lf Date: Wed, 19 Aug 2015 01:46:04 +0200 Subject: [PATCH] Improved the gfx.startFrame() function to select a screen, Fixed some values now defined with the C ones --- sdcard/ctruLua/main.lua | 2 +- source/gfx.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sdcard/ctruLua/main.lua b/sdcard/ctruLua/main.lua index 29147b4..fb17f6e 100644 --- a/sdcard/ctruLua/main.lua +++ b/sdcard/ctruLua/main.lua @@ -18,7 +18,7 @@ while os.run() do if keys.held.up then y = y - 1 end if keys.held.down then y = y + 1 end - gfx.startFrame() + gfx.startFrame(gfx.GFX_TOP) gfx.color.setDefault(0xFF0000FF) gfx.rectangle(x, y, 10, 10, angle) diff --git a/source/gfx.c b/source/gfx.c index 8ef974f..9ad83bc 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -8,7 +8,10 @@ int load_color_lib(lua_State *L); u32 color_default; static int gfx_startFrame(lua_State *L) { - sf2d_start_frame(GFX_TOP, GFX_LEFT); + u8 screen = luaL_checkinteger(L, 1); + u8 eye = luaL_optinteger(L, 2, GFX_LEFT); + + sf2d_start_frame(screen, eye); return 0; } @@ -91,14 +94,14 @@ static const struct luaL_Reg gfx_lib[] = { // constants struct { char *name; int value; } gfx_constants[] = { - { "GFX_TOP", 0 }, - { "GFX_BOTTOM", 1 }, - { "GFX_LEFT", 0 }, - { "GFX_RIGHT", 1 }, - { "TOP_HEIGHT", 240 }, - { "TOP_WIDTH", 400 }, - { "BOTTOM_HEIGHT", 240 }, - { "BOTTOM_WIDTH", 320 }, + { "GFX_TOP", GFX_TOP }, + { "GFX_BOTTOM", GFX_BOTTOM }, + { "GFX_LEFT", GFX_LEFT }, + { "GFX_RIGHT", GFX_RIGHT }, + { "TOP_HEIGHT", 240 }, + { "TOP_WIDTH", 400 }, + { "BOTTOM_HEIGHT", 240 }, + { "BOTTOM_WIDTH", 320 }, { NULL, 0 } };