diff options
author | William Wilgus <me.theuser@yahoo.com> | 2018-10-27 06:24:27 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2018-10-30 04:16:23 +0100 |
commit | df8233e4abbd0d626158abc5388957cc28b06c50 (patch) | |
tree | 3b6c151b8dba5201673dd8ae2842350822243cde | |
parent | 80352c2c2d7ff005e0ad63e1b56d1f6ff9af81d8 (diff) | |
download | rockbox-df8233e4abbd0d626158abc5388957cc28b06c50.tar.gz rockbox-df8233e4abbd0d626158abc5388957cc28b06c50.zip |
Lua expand multiple screen support
Some of the lcd functions had support for multiple screens but this wasn't
very safe since the screen number wasn't bounded within the screens[] array
This adds support for all the lcd functions along with checking that screen#
is bounded properly, adds around 600 bytes to devices with a remote screen
devices without a remote screen lock to SCREEN_MAIN
Change-Id: I618bbc7b3919c7b0ff375fb2d71949d7cab43c87
-rw-r--r-- | apps/plugins/lua/rocklib.c | 87 | ||||
-rwxr-xr-x | apps/plugins/lua/rocklib_aux.pl | 8 | ||||
-rw-r--r-- | apps/plugins/lua/rocklib_img.c | 309 |
3 files changed, 303 insertions, 101 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 80124d2165..c9242d99bd 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -56,66 +56,6 @@ | |||
56 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) | 56 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) |
57 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } | 57 | #define SIMPLE_VOID_WRAPPER(func) RB_WRAP(func) { (void)L; func(); return 0; } |
58 | 58 | ||
59 | /* Helper function for opt_viewport */ | ||
60 | static void check_tablevalue(lua_State *L, | ||
61 | const char* key, | ||
62 | int tablepos, | ||
63 | void* res, | ||
64 | bool is_unsigned) | ||
65 | { | ||
66 | lua_getfield(L, tablepos, key); /* Find table[key] */ | ||
67 | |||
68 | int val = lua_tointeger(L, -1); | ||
69 | |||
70 | if(is_unsigned) | ||
71 | *(unsigned*)res = (unsigned) val; | ||
72 | else | ||
73 | *(int*)res = val; | ||
74 | |||
75 | lua_pop(L, 1); /* Pop the value off the stack */ | ||
76 | } | ||
77 | |||
78 | static inline struct viewport* opt_viewport(lua_State *L, | ||
79 | int narg, | ||
80 | struct viewport* vp, | ||
81 | struct viewport* alt) | ||
82 | { | ||
83 | if(lua_isnoneornil(L, narg)) | ||
84 | return alt; | ||
85 | |||
86 | luaL_checktype(L, narg, LUA_TTABLE); | ||
87 | |||
88 | check_tablevalue(L, "x", narg, &vp->x, false); | ||
89 | check_tablevalue(L, "y", narg, &vp->y, false); | ||
90 | check_tablevalue(L, "width", narg, &vp->width, false); | ||
91 | check_tablevalue(L, "height", narg, &vp->height, false); | ||
92 | #ifdef HAVE_LCD_BITMAP | ||
93 | check_tablevalue(L, "font", narg, &vp->font, false); | ||
94 | check_tablevalue(L, "drawmode", narg, &vp->drawmode, false); | ||
95 | #endif | ||
96 | #if LCD_DEPTH > 1 | ||
97 | check_tablevalue(L, "fg_pattern", narg, &vp->fg_pattern, true); | ||
98 | check_tablevalue(L, "bg_pattern", narg, &vp->bg_pattern, true); | ||
99 | #endif | ||
100 | |||
101 | return vp; | ||
102 | } | ||
103 | |||
104 | RB_WRAP(set_viewport) | ||
105 | { | ||
106 | static struct viewport vp; | ||
107 | int screen = luaL_optint(L, 2, SCREEN_MAIN); | ||
108 | rb->screens[screen]->set_viewport(opt_viewport(L, 1, &vp, NULL)); | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | RB_WRAP(clear_viewport) | ||
113 | { | ||
114 | int screen = luaL_optint(L, 1, SCREEN_MAIN); | ||
115 | rb->screens[screen]->clear_viewport(); | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | RB_WRAP(current_tick) | 59 | RB_WRAP(current_tick) |
120 | { | 60 | { |
121 | lua_pushinteger(L, *rb->current_tick); | 61 | lua_pushinteger(L, *rb->current_tick); |
@@ -172,25 +112,6 @@ RB_WRAP(touchscreen_get_mode) | |||
172 | } | 112 | } |
173 | #endif | 113 | #endif |
174 | 114 | ||
175 | RB_WRAP(font_getstringsize) | ||
176 | { | ||
177 | const unsigned char* str = luaL_checkstring(L, 1); | ||
178 | int fontnumber = luaL_checkint(L, 2); | ||
179 | int w, h; | ||
180 | |||
181 | if (fontnumber == FONT_UI) | ||
182 | fontnumber = rb->global_status->font_id[SCREEN_MAIN]; | ||
183 | else | ||
184 | fontnumber = FONT_SYSFIXED; | ||
185 | |||
186 | int result = rb->font_getstringsize(str, &w, &h, fontnumber); | ||
187 | lua_pushinteger(L, result); | ||
188 | lua_pushinteger(L, w); | ||
189 | lua_pushinteger(L, h); | ||
190 | |||
191 | return 3; | ||
192 | } | ||
193 | |||
194 | RB_WRAP(current_path) | 115 | RB_WRAP(current_path) |
195 | { | 116 | { |
196 | return get_current_path(L, 1); | 117 | return get_current_path(L, 1); |
@@ -507,9 +428,6 @@ static const luaL_Reg rocklib[] = | |||
507 | 428 | ||
508 | RB_FUNC(kbd_input), | 429 | RB_FUNC(kbd_input), |
509 | 430 | ||
510 | RB_FUNC(font_getstringsize), | ||
511 | RB_FUNC(set_viewport), | ||
512 | RB_FUNC(clear_viewport), | ||
513 | RB_FUNC(current_path), | 431 | RB_FUNC(current_path), |
514 | RB_FUNC(gui_syncyesno_run), | 432 | RB_FUNC(gui_syncyesno_run), |
515 | RB_FUNC(do_menu), | 433 | RB_FUNC(do_menu), |
@@ -563,6 +481,11 @@ LUALIB_API int luaopen_rock(lua_State *L) | |||
563 | RB_CONSTANT(LCD_DEPTH), | 481 | RB_CONSTANT(LCD_DEPTH), |
564 | RB_CONSTANT(LCD_HEIGHT), | 482 | RB_CONSTANT(LCD_HEIGHT), |
565 | RB_CONSTANT(LCD_WIDTH), | 483 | RB_CONSTANT(LCD_WIDTH), |
484 | #ifdef HAVE_REMOTE_LCD | ||
485 | RB_CONSTANT(LCD_REMOTE_DEPTH), | ||
486 | RB_CONSTANT(LCD_REMOTE_HEIGHT), | ||
487 | RB_CONSTANT(LCD_REMOTE_WIDTH), | ||
488 | #endif | ||
566 | 489 | ||
567 | RB_CONSTANT(FONT_SYSFIXED), | 490 | RB_CONSTANT(FONT_SYSFIXED), |
568 | RB_CONSTANT(FONT_UI), | 491 | RB_CONSTANT(FONT_UI), |
diff --git a/apps/plugins/lua/rocklib_aux.pl b/apps/plugins/lua/rocklib_aux.pl index 5114e7b6f7..8ad59317d6 100755 --- a/apps/plugins/lua/rocklib_aux.pl +++ b/apps/plugins/lua/rocklib_aux.pl | |||
@@ -73,6 +73,14 @@ my @forbidden_functions = ('^open$', | |||
73 | '^codec_', | 73 | '^codec_', |
74 | '^timer_', | 74 | '^timer_', |
75 | '^lcd_(mono_)?+bitmap', | 75 | '^lcd_(mono_)?+bitmap', |
76 | '^lcd_(draw|fill|update_)rect$', | ||
77 | '^lcd_draw(line|pixel)$', | ||
78 | '^lcd_(h|v)line$', | ||
79 | '^lcd_(update|clear_display|set_drawmode)$', | ||
80 | '^lcd_setfont$', | ||
81 | '^lcd_(set|get)_(fore|back)ground$', | ||
82 | '^lcd_put(s|sxy|s_scroll)$', | ||
83 | '^lcd_scroll_stop$', | ||
76 | '^__.+$', | 84 | '^__.+$', |
77 | '^.+_(un)?cached$', | 85 | '^.+_(un)?cached$', |
78 | '^audio_.+$', | 86 | '^audio_.+$', |
diff --git a/apps/plugins/lua/rocklib_img.c b/apps/plugins/lua/rocklib_img.c index 6cece9c836..9d9fb120f8 100644 --- a/apps/plugins/lua/rocklib_img.c +++ b/apps/plugins/lua/rocklib_img.c | |||
@@ -1217,21 +1217,180 @@ static const struct luaL_reg rli_lib [] = | |||
1217 | */ | 1217 | */ |
1218 | 1218 | ||
1219 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) | 1219 | #define RB_WRAP(func) static int rock_##func(lua_State UNUSED_ATTR *L) |
1220 | |||
1221 | #if defined NB_SCREENS && (NB_SCREENS > 1) | ||
1222 | #define RB_SCREENS(luastate, narg, func, ...) \ | ||
1223 | rb->screens[get_screen(luastate, narg)]->func(__VA_ARGS__) | ||
1224 | |||
1225 | static int get_screen(lua_State *L, int narg) | ||
1226 | { | ||
1227 | int screen = luaL_optint(L, narg, SCREEN_MAIN); | ||
1228 | |||
1229 | if(screen < SCREEN_MAIN) | ||
1230 | screen = SCREEN_MAIN; | ||
1231 | else if(screen > NB_SCREENS) | ||
1232 | screen = NB_SCREENS; | ||
1233 | |||
1234 | return screen; | ||
1235 | } | ||
1236 | #else /* only SCREEN_MAIN exists */ | ||
1237 | #define RB_SCREENS(luastate, narg, func, ...) \ | ||
1238 | rb->screens[SCREEN_MAIN]->func(__VA_ARGS__) | ||
1239 | #endif | ||
1240 | |||
1241 | RB_WRAP(lcd_update) | ||
1242 | { | ||
1243 | RB_SCREENS(L, 1, update); | ||
1244 | return 0; | ||
1245 | } | ||
1246 | |||
1247 | RB_WRAP(lcd_clear_display) | ||
1248 | { | ||
1249 | RB_SCREENS(L, 1, clear_display); | ||
1250 | return 0; | ||
1251 | } | ||
1252 | |||
1253 | RB_WRAP(lcd_set_drawmode) | ||
1254 | { | ||
1255 | int mode = (int) luaL_checkint(L, 1); | ||
1256 | RB_SCREENS(L, 2, set_drawmode, mode); | ||
1257 | return 0; | ||
1258 | } | ||
1259 | |||
1260 | /* helper function for lcd_puts functions */ | ||
1261 | static const unsigned char * lcd_putshelper(lua_State *L, int *x, int *y) | ||
1262 | { | ||
1263 | *x = (int) luaL_checkint(L, 1); | ||
1264 | *y = (int) luaL_checkint(L, 2); | ||
1265 | return luaL_checkstring(L, 3); | ||
1266 | } | ||
1267 | |||
1268 | RB_WRAP(lcd_putsxy) | ||
1269 | { | ||
1270 | int x, y; | ||
1271 | const unsigned char *string = lcd_putshelper(L, &x, &y); | ||
1272 | RB_SCREENS(L, 4, putsxy, x, y, string); | ||
1273 | return 0; | ||
1274 | } | ||
1275 | |||
1276 | RB_WRAP(lcd_puts) | ||
1277 | { | ||
1278 | int x, y; | ||
1279 | const unsigned char * string = lcd_putshelper(L, &x, &y); | ||
1280 | RB_SCREENS(L, 4, puts, x, y, string); | ||
1281 | return 0; | ||
1282 | } | ||
1283 | |||
1284 | RB_WRAP(lcd_puts_scroll) | ||
1285 | { | ||
1286 | int x, y; | ||
1287 | const unsigned char * string = lcd_putshelper(L, &x, &y); | ||
1288 | bool result = RB_SCREENS(L, 4, puts_scroll, x, y, string); | ||
1289 | lua_pushboolean(L, result); | ||
1290 | return 1; | ||
1291 | } | ||
1292 | |||
1293 | RB_WRAP(lcd_scroll_stop) | ||
1294 | { | ||
1295 | RB_SCREENS(L, 1, scroll_stop); | ||
1296 | return 0; | ||
1297 | } | ||
1298 | |||
1299 | /* Helper function for opt_viewport */ | ||
1300 | static int check_tablevalue(lua_State *L, const char* key, int tablepos) | ||
1301 | { | ||
1302 | lua_getfield(L, tablepos, key); /* Find table[key] */ | ||
1303 | |||
1304 | int val = lua_tointeger(L, -1); | ||
1305 | |||
1306 | lua_pop(L, 1); /* Pop the value off the stack */ | ||
1307 | return val; | ||
1308 | } | ||
1309 | |||
1310 | static inline struct viewport* opt_viewport(lua_State *L, | ||
1311 | int narg, | ||
1312 | struct viewport* vp, | ||
1313 | struct viewport* alt) | ||
1314 | { | ||
1315 | if(lua_isnoneornil(L, narg)) | ||
1316 | return alt; | ||
1317 | |||
1318 | luaL_checktype(L, narg, LUA_TTABLE); | ||
1319 | |||
1320 | vp->x = check_tablevalue(L, "x", narg); | ||
1321 | vp->y = check_tablevalue(L, "y", narg); | ||
1322 | vp->width = check_tablevalue(L, "width", narg); | ||
1323 | vp->height = check_tablevalue(L, "height", narg); | ||
1220 | #ifdef HAVE_LCD_BITMAP | 1324 | #ifdef HAVE_LCD_BITMAP |
1325 | vp->font = check_tablevalue(L, "font", narg); | ||
1326 | vp->drawmode = check_tablevalue(L, "drawmode", narg); | ||
1327 | #endif | ||
1328 | #if LCD_DEPTH > 1 | ||
1329 | vp->fg_pattern = (unsigned int) check_tablevalue(L, "fg_pattern", narg); | ||
1330 | vp->bg_pattern = (unsigned int) check_tablevalue(L, "bg_pattern", narg); | ||
1331 | #endif | ||
1332 | |||
1333 | return vp; | ||
1334 | } | ||
1335 | |||
1336 | RB_WRAP(set_viewport) | ||
1337 | { | ||
1338 | static struct viewport vp; | ||
1339 | RB_SCREENS(L, 2, set_viewport, opt_viewport(L, 1, &vp, NULL)); | ||
1340 | return 0; | ||
1341 | } | ||
1342 | |||
1343 | RB_WRAP(clear_viewport) | ||
1344 | { | ||
1345 | RB_SCREENS(L, 1, clear_viewport); | ||
1346 | return 0; | ||
1347 | } | ||
1348 | |||
1349 | RB_WRAP(font_getstringsize) | ||
1350 | { | ||
1351 | const unsigned char* str = luaL_checkstring(L, 1); | ||
1352 | int fontnumber = lua_tointeger(L, 2); | ||
1353 | int w, h, result; | ||
1354 | |||
1355 | if (fontnumber == FONT_UI) | ||
1356 | fontnumber = rb->global_status->font_id[SCREEN_MAIN]; | ||
1357 | else | ||
1358 | fontnumber = FONT_SYSFIXED; | ||
1359 | |||
1360 | if lua_isnil(L, 2) | ||
1361 | result = RB_SCREENS(L, 3, getstringsize, str, &w, &h); | ||
1362 | else | ||
1363 | result = rb->font_getstringsize(str, &w, &h, fontnumber); | ||
1364 | |||
1365 | lua_pushinteger(L, result); | ||
1366 | lua_pushinteger(L, w); | ||
1367 | lua_pushinteger(L, h); | ||
1368 | |||
1369 | return 3; | ||
1370 | } | ||
1371 | |||
1372 | #ifdef HAVE_LCD_BITMAP | ||
1373 | |||
1221 | RB_WRAP(lcd_framebuffer) | 1374 | RB_WRAP(lcd_framebuffer) |
1222 | { | 1375 | { |
1223 | rli_wrap(L, rb->lcd_framebuffer, LCD_WIDTH, LCD_HEIGHT); | 1376 | rli_wrap(L, rb->lcd_framebuffer, LCD_WIDTH, LCD_HEIGHT); |
1224 | return 1; | 1377 | return 1; |
1225 | } | 1378 | } |
1226 | 1379 | ||
1227 | /* helper function for lcd_xxx_bitmap functions */ | 1380 | RB_WRAP(lcd_setfont) |
1228 | static int get_bmp_bounds(lua_State *L, int npos, int *x, int *y, int *w, int* h) | 1381 | { |
1382 | int font = (int) luaL_checkint(L, 1); | ||
1383 | RB_SCREENS(L, 2, setfont, font); | ||
1384 | return 0; | ||
1385 | } | ||
1386 | |||
1387 | /* helper function for lcd_xxx_bitmap/rect functions */ | ||
1388 | static void get_rect_bounds(lua_State *L, int narg, int *x, int *y, int *w, int* h) | ||
1229 | { | 1389 | { |
1230 | *x = luaL_checkint(L, npos); | 1390 | *x = luaL_checkint(L, narg); |
1231 | *y = luaL_checkint(L, npos + 1); | 1391 | *y = luaL_checkint(L, narg + 1); |
1232 | *w = luaL_checkint(L, npos + 2); | 1392 | *w = luaL_checkint(L, narg + 2); |
1233 | *h = luaL_checkint(L, npos + 3); | 1393 | *h = luaL_checkint(L, narg + 3); |
1234 | return luaL_optint(L, npos + 4, SCREEN_MAIN); | ||
1235 | } | 1394 | } |
1236 | 1395 | ||
1237 | RB_WRAP(lcd_mono_bitmap_part) | 1396 | RB_WRAP(lcd_mono_bitmap_part) |
@@ -1241,9 +1400,10 @@ RB_WRAP(lcd_mono_bitmap_part) | |||
1241 | int src_y = luaL_checkint(L, 3); | 1400 | int src_y = luaL_checkint(L, 3); |
1242 | int stride = luaL_checkint(L, 4); | 1401 | int stride = luaL_checkint(L, 4); |
1243 | int x, y, width, height; | 1402 | int x, y, width, height; |
1244 | int screen = get_bmp_bounds(L, 5, &x, &y, &width, &height); | 1403 | get_rect_bounds(L, 5, &x, &y, &width, &height); |
1245 | 1404 | ||
1246 | rb->screens[screen]->mono_bitmap_part((const unsigned char *)src->data, src_x, src_y, stride, x, y, width, height); | 1405 | RB_SCREENS(L, 9, mono_bitmap_part, (const unsigned char *)src->data, |
1406 | src_x, src_y, stride, x, y, width, height); | ||
1247 | return 0; | 1407 | return 0; |
1248 | } | 1408 | } |
1249 | 1409 | ||
@@ -1251,9 +1411,9 @@ RB_WRAP(lcd_mono_bitmap) | |||
1251 | { | 1411 | { |
1252 | struct rocklua_image *src = rli_checktype(L, 1); | 1412 | struct rocklua_image *src = rli_checktype(L, 1); |
1253 | int x, y, width, height; | 1413 | int x, y, width, height; |
1254 | int screen = get_bmp_bounds(L, 2, &x, &y, &width, &height); | 1414 | get_rect_bounds(L, 2, &x, &y, &width, &height); |
1255 | 1415 | ||
1256 | rb->screens[screen]->mono_bitmap((const unsigned char *)src->data, x, y, width, height); | 1416 | RB_SCREENS(L, 6, mono_bitmap, (const unsigned char *)src->data, x, y, width, height); |
1257 | return 0; | 1417 | return 0; |
1258 | } | 1418 | } |
1259 | 1419 | ||
@@ -1265,9 +1425,9 @@ RB_WRAP(lcd_bitmap_part) | |||
1265 | int src_y = luaL_checkint(L, 3); | 1425 | int src_y = luaL_checkint(L, 3); |
1266 | int stride = luaL_checkint(L, 4); | 1426 | int stride = luaL_checkint(L, 4); |
1267 | int x, y, width, height; | 1427 | int x, y, width, height; |
1268 | int screen = get_bmp_bounds(L, 5, &x, &y, &width, &height); | 1428 | get_rect_bounds(L, 5, &x, &y, &width, &height); |
1269 | 1429 | ||
1270 | rb->screens[screen]->bitmap_part(src->data, src_x, src_y, stride, x, y, width, height); | 1430 | RB_SCREENS(L, 9, bitmap_part, src->data, src_x, src_y, stride, x, y, width, height); |
1271 | return 0; | 1431 | return 0; |
1272 | } | 1432 | } |
1273 | 1433 | ||
@@ -1275,9 +1435,9 @@ RB_WRAP(lcd_bitmap) | |||
1275 | { | 1435 | { |
1276 | struct rocklua_image *src = rli_checktype(L, 1); | 1436 | struct rocklua_image *src = rli_checktype(L, 1); |
1277 | int x, y, width, height; | 1437 | int x, y, width, height; |
1278 | int screen = get_bmp_bounds(L, 2, &x, &y, &width, &height); | 1438 | get_rect_bounds(L, 2, &x, &y, &width, &height); |
1279 | 1439 | ||
1280 | rb->screens[screen]->bitmap(src->data, x, y, width, height); | 1440 | RB_SCREENS(L, 6, bitmap, src->data, x, y, width, height); |
1281 | return 0; | 1441 | return 0; |
1282 | } | 1442 | } |
1283 | 1443 | ||
@@ -1291,6 +1451,35 @@ RB_WRAP(lcd_get_backdrop) | |||
1291 | 1451 | ||
1292 | return 1; | 1452 | return 1; |
1293 | } | 1453 | } |
1454 | |||
1455 | RB_WRAP(lcd_set_foreground) | ||
1456 | { | ||
1457 | unsigned foreground = (unsigned) luaL_checkint(L, 1); | ||
1458 | RB_SCREENS(L, 2, set_foreground, foreground); | ||
1459 | return 0; | ||
1460 | } | ||
1461 | |||
1462 | RB_WRAP(lcd_get_foreground) | ||
1463 | { | ||
1464 | unsigned result = RB_SCREENS(L, 1, get_foreground); | ||
1465 | lua_pushinteger(L, result); | ||
1466 | return 1; | ||
1467 | } | ||
1468 | |||
1469 | RB_WRAP(lcd_set_background) | ||
1470 | { | ||
1471 | unsigned background = (unsigned) luaL_checkint(L, 1); | ||
1472 | RB_SCREENS(L, 2, set_background, background); | ||
1473 | return 0; | ||
1474 | } | ||
1475 | |||
1476 | RB_WRAP(lcd_get_background) | ||
1477 | { | ||
1478 | unsigned result = RB_SCREENS(L, 1, get_background); | ||
1479 | lua_pushinteger(L, result); | ||
1480 | return 1; | ||
1481 | } | ||
1482 | |||
1294 | #endif /* LCD_DEPTH > 1 */ | 1483 | #endif /* LCD_DEPTH > 1 */ |
1295 | 1484 | ||
1296 | #if LCD_DEPTH == 16 | 1485 | #if LCD_DEPTH == 16 |
@@ -1301,9 +1490,10 @@ RB_WRAP(lcd_bitmap_transparent_part) | |||
1301 | int src_y = luaL_checkint(L, 3); | 1490 | int src_y = luaL_checkint(L, 3); |
1302 | int stride = luaL_checkint(L, 4); | 1491 | int stride = luaL_checkint(L, 4); |
1303 | int x, y, width, height; | 1492 | int x, y, width, height; |
1304 | int screen = get_bmp_bounds(L, 5, &x, &y, &width, &height); | 1493 | get_rect_bounds(L, 5, &x, &y, &width, &height); |
1305 | 1494 | ||
1306 | rb->screens[screen]->transparent_bitmap_part(src->data, src_x, src_y, stride, x, y, width, height); | 1495 | RB_SCREENS(L, 9, transparent_bitmap_part, src->data, src_x, |
1496 | src_y, stride, x, y, width, height); | ||
1307 | return 0; | 1497 | return 0; |
1308 | } | 1498 | } |
1309 | 1499 | ||
@@ -1311,13 +1501,71 @@ RB_WRAP(lcd_bitmap_transparent) | |||
1311 | { | 1501 | { |
1312 | struct rocklua_image *src = rli_checktype(L, 1); | 1502 | struct rocklua_image *src = rli_checktype(L, 1); |
1313 | int x, y, width, height; | 1503 | int x, y, width, height; |
1314 | int screen = get_bmp_bounds(L, 2, &x, &y, &width, &height); | 1504 | get_rect_bounds(L, 2, &x, &y, &width, &height); |
1315 | 1505 | ||
1316 | rb->screens[screen]->transparent_bitmap(src->data, x, y, width, height); | 1506 | RB_SCREENS(L, 6, transparent_bitmap, src->data, x, y, width, height); |
1317 | return 0; | 1507 | return 0; |
1318 | } | 1508 | } |
1319 | #endif /* LCD_DEPTH == 16 */ | 1509 | #endif /* LCD_DEPTH == 16 */ |
1320 | 1510 | ||
1511 | RB_WRAP(lcd_update_rect) | ||
1512 | { | ||
1513 | int x, y, width, height; | ||
1514 | get_rect_bounds(L, 1, &x, &y, &width, &height); | ||
1515 | RB_SCREENS(L, 5, update_rect, x, y, width, height); | ||
1516 | return 0; | ||
1517 | } | ||
1518 | |||
1519 | RB_WRAP(lcd_drawrect) | ||
1520 | { | ||
1521 | int x, y, width, height; | ||
1522 | get_rect_bounds(L, 1, &x, &y, &width, &height); | ||
1523 | RB_SCREENS(L, 5, drawrect, x, y, width, height); | ||
1524 | return 0; | ||
1525 | } | ||
1526 | |||
1527 | RB_WRAP(lcd_fillrect) | ||
1528 | { | ||
1529 | int x, y, width, height; | ||
1530 | get_rect_bounds(L, 1, &x, &y, &width, &height); | ||
1531 | RB_SCREENS(L, 5, fillrect, x, y, width, height); | ||
1532 | return 0; | ||
1533 | } | ||
1534 | |||
1535 | RB_WRAP(lcd_drawline) | ||
1536 | { | ||
1537 | int x1, y1, x2, y2; | ||
1538 | get_rect_bounds(L, 1, &x1, &y1, &x2, &y2); | ||
1539 | RB_SCREENS(L, 5, drawline, x1, y1, x2, y2); | ||
1540 | return 0; | ||
1541 | } | ||
1542 | |||
1543 | RB_WRAP(lcd_hline) | ||
1544 | { | ||
1545 | int x1 = (int) luaL_checkint(L, 1); | ||
1546 | int x2 = (int) luaL_checkint(L, 2); | ||
1547 | int y = (int) luaL_checkint(L, 3); | ||
1548 | RB_SCREENS(L, 4, hline, x1, x2, y); | ||
1549 | return 0; | ||
1550 | } | ||
1551 | |||
1552 | RB_WRAP(lcd_vline) | ||
1553 | { | ||
1554 | int x = (int) luaL_checkint(L, 1); | ||
1555 | int y1 = (int) luaL_checkint(L, 2); | ||
1556 | int y2 = (int) luaL_checkint(L, 3); | ||
1557 | RB_SCREENS(L, 4, vline, x, y1, y2); | ||
1558 | return 0; | ||
1559 | } | ||
1560 | |||
1561 | RB_WRAP(lcd_drawpixel) | ||
1562 | { | ||
1563 | int x = (int) luaL_checkint(L, 1); | ||
1564 | int y = (int) luaL_checkint(L, 2); | ||
1565 | RB_SCREENS(L, 3, drawpixel, x, y); | ||
1566 | return 0; | ||
1567 | } | ||
1568 | |||
1321 | #endif /* defined(LCD_BITMAP) */ | 1569 | #endif /* defined(LCD_BITMAP) */ |
1322 | 1570 | ||
1323 | #ifdef HAVE_LCD_COLOR | 1571 | #ifdef HAVE_LCD_COLOR |
@@ -1377,19 +1625,42 @@ RB_WRAP(read_bmp_file) | |||
1377 | static const luaL_Reg rocklib_img[] = | 1625 | static const luaL_Reg rocklib_img[] = |
1378 | { | 1626 | { |
1379 | /* Graphics */ | 1627 | /* Graphics */ |
1628 | R(lcd_update), | ||
1629 | R(lcd_clear_display), | ||
1630 | R(lcd_set_drawmode), | ||
1631 | R(lcd_putsxy), | ||
1632 | R(lcd_puts), | ||
1633 | R(lcd_puts_scroll), | ||
1634 | R(lcd_scroll_stop), | ||
1635 | R(set_viewport), | ||
1636 | R(clear_viewport), | ||
1637 | R(font_getstringsize), | ||
1380 | #ifdef HAVE_LCD_BITMAP | 1638 | #ifdef HAVE_LCD_BITMAP |
1381 | R(lcd_framebuffer), | 1639 | R(lcd_framebuffer), |
1640 | R(lcd_setfont), | ||
1382 | R(lcd_mono_bitmap_part), | 1641 | R(lcd_mono_bitmap_part), |
1383 | R(lcd_mono_bitmap), | 1642 | R(lcd_mono_bitmap), |
1384 | #if LCD_DEPTH > 1 | 1643 | #if LCD_DEPTH > 1 |
1385 | R(lcd_get_backdrop), | 1644 | R(lcd_get_backdrop), |
1386 | R(lcd_bitmap_part), | 1645 | R(lcd_bitmap_part), |
1387 | R(lcd_bitmap), | 1646 | R(lcd_bitmap), |
1647 | R(lcd_set_foreground), | ||
1648 | R(lcd_get_foreground), | ||
1649 | R(lcd_set_background), | ||
1650 | R(lcd_get_background), | ||
1388 | #endif | 1651 | #endif |
1389 | #if LCD_DEPTH == 16 | 1652 | #if LCD_DEPTH == 16 |
1390 | R(lcd_bitmap_transparent_part), | 1653 | R(lcd_bitmap_transparent_part), |
1391 | R(lcd_bitmap_transparent), | 1654 | R(lcd_bitmap_transparent), |
1392 | #endif | 1655 | #endif |
1656 | R(lcd_update_rect), | ||
1657 | R(lcd_drawrect), | ||
1658 | R(lcd_fillrect), | ||
1659 | R(lcd_drawline), | ||
1660 | R(lcd_hline), | ||
1661 | R(lcd_vline), | ||
1662 | R(lcd_drawpixel), | ||
1663 | |||
1393 | #endif /*HAVE_LCD_BITMAP*/ | 1664 | #endif /*HAVE_LCD_BITMAP*/ |
1394 | #ifdef HAVE_LCD_COLOR | 1665 | #ifdef HAVE_LCD_COLOR |
1395 | R(lcd_rgbpack), | 1666 | R(lcd_rgbpack), |