trunk/src/emu/luaengine.c
| r242985 | r242986 | |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | //------------------------------------------------- |
| 540 | // screen_height - return screen visible height |
| 541 | // -> manager:machine().screens[":screen"]:height() |
| 542 | //------------------------------------------------- |
| 543 | |
| 544 | int lua_engine::lua_screen::l_height(lua_State *L) |
| 545 | { |
| 546 | screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1); |
| 547 | if(!sc) { |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | lua_pushunsigned(L, sc->visible_area().height()); |
| 552 | return 1; |
| 553 | } |
| 554 | |
| 555 | //------------------------------------------------- |
| 556 | // screen_width - return screen visible width |
| 557 | // -> manager:machine().screens[":screen"]:width() |
| 558 | //------------------------------------------------- |
| 559 | |
| 560 | int lua_engine::lua_screen::l_width(lua_State *L) |
| 561 | { |
| 562 | screen_device *sc = luabridge::Stack<screen_device *>::get(L, 1); |
| 563 | if(!sc) { |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | lua_pushunsigned(L, sc->visible_area().width()); |
| 568 | return 1; |
| 569 | } |
| 570 | |
| 571 | //------------------------------------------------- |
| 540 | 572 | // draw_box - draw a box on a screen container |
| 541 | 573 | // -> manager:machine().screens[":screen"]:draw_box(x1, y1, x2, y2, bgcolor, linecolor) |
| 542 | 574 | //------------------------------------------------- |
| r242985 | r242986 | |
| 558 | 590 | |
| 559 | 591 | // retrieve all parameters |
| 560 | 592 | float x1, y1, x2, y2; |
| 561 | | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f); |
| 562 | | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f); |
| 563 | | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f); |
| 564 | | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f); |
| 593 | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 594 | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 595 | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 596 | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 565 | 597 | UINT32 bgcolor = lua_tounsigned(L, 6); |
| 566 | 598 | UINT32 fgcolor = lua_tounsigned(L, 7); |
| 567 | 599 | |
| r242985 | r242986 | |
| 594 | 626 | |
| 595 | 627 | // retrieve all parameters |
| 596 | 628 | float x1, y1, x2, y2; |
| 597 | | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f); |
| 598 | | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f); |
| 599 | | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->width()) , 1.0f); |
| 600 | | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->height()), 1.0f); |
| 629 | x1 = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 630 | y1 = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 631 | x2 = MIN(lua_tounsigned(L, 4) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 632 | y2 = MIN(lua_tounsigned(L, 5) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 601 | 633 | UINT32 color = lua_tounsigned(L, 6); |
| 602 | 634 | |
| 603 | 635 | // draw the line |
| r242985 | r242986 | |
| 623 | 655 | luaL_argcheck(L, lua_isstring(L, 4), 4, "message (string) expected"); |
| 624 | 656 | |
| 625 | 657 | // retrieve all parameters |
| 626 | | float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->width()) , 1.0f); |
| 627 | | float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->height()), 1.0f); |
| 658 | float x = MIN(lua_tounsigned(L, 2) / static_cast<float>(sc->visible_area().width()) , 1.0f); |
| 659 | float y = MIN(lua_tounsigned(L, 3) / static_cast<float>(sc->visible_area().height()), 1.0f); |
| 628 | 660 | const char *msg = luaL_checkstring(L,4); |
| 629 | 661 | // TODO: add optional parameters (colors, etc.) |
| 630 | 662 | |
| r242985 | r242986 | |
| 900 | 932 | .addCFunction ("draw_box", &lua_screen::l_draw_box) |
| 901 | 933 | .addCFunction ("draw_line", &lua_screen::l_draw_line) |
| 902 | 934 | .addCFunction ("draw_text", &lua_screen::l_draw_text) |
| 935 | .addCFunction ("height", &lua_screen::l_height) |
| 936 | .addCFunction ("width", &lua_screen::l_width) |
| 903 | 937 | .endClass() |
| 904 | 938 | .deriveClass <screen_device, lua_screen> ("screen_dev") |
| 905 | 939 | .addFunction ("name", &screen_device::name) |
| 906 | 940 | .addFunction ("shortname", &screen_device::shortname) |
| 907 | 941 | .addFunction ("tag", &screen_device::tag) |
| 908 | | .addFunction ("height", &screen_device::height) |
| 909 | | .addFunction ("width", &screen_device::width) |
| 910 | 942 | .endClass() |
| 911 | 943 | .beginClass <device_state_entry> ("dev_space") |
| 912 | 944 | .addFunction ("name", &device_state_entry::symbol) |