1 #include "core/command.hpp"
2 #include "lua/internal.hpp"
3 #include "core/framerate.hpp"
4 #include "core/moviefile.hpp"
5 #include "core/moviedata.hpp"
6 #include "core/window.hpp"
7 #include "interface/romtype.hpp"
11 function_ptr_luafun
lua_print(LS
, "print", [](lua_state
& L
, const std::string
& fname
) -> int {
13 while(!L
.isnone(stacksize
+ 1))
17 for(int i
= 0; i
< stacksize
; i
++) {
19 const char* tmp
= NULL
;
23 } else if(L
.isboolean(i
+ 1) && L
.toboolean(i
+ 1)) {
26 } else if(L
.isboolean(i
+ 1) && !L
.toboolean(i
+ 1)) {
30 tmp
= L
.tolstring(i
+ 1, &len
);
32 tmp
= "(unprintable)";
36 std::string
localmsg(tmp
, tmp
+ len
);
40 toprint
= toprint
+ "\t" + localmsg
;
43 platform::message(toprint
);
47 function_ptr_luafun
lua_exec(LS
, "exec", [](lua_state
& L
, const std::string
& fname
) -> int {
48 std::string text
= L
.get_string(1, fname
.c_str());
49 lsnes_cmd
.invoke(text
);
53 function_ptr_luafun
lua_booted(LS
, "emulator_ready", [](lua_state
& L
, const std::string
& fname
) -> int {
54 L
.pushboolean(lua_booted_flag
? 1 : 0);
58 function_ptr_luafun
lua_utime(LS
, "utime", [](lua_state
& L
, const std::string
& fname
) -> int {
59 uint64_t t
= get_utime();
60 L
.pushnumber(t
/ 1000000);
61 L
.pushnumber(t
% 1000000);
65 function_ptr_luafun
lua_idle_time(LS
, "set_idle_timeout", [](lua_state
& L
, const std::string
& fname
) -> int {
66 lua_idle_hook_time
= get_utime() + L
.get_numeric_argument
<uint64_t>(1, fname
.c_str());
70 function_ptr_luafun
lua_timer_time(LS
, "set_timer_timeout", [](lua_state
& L
, const std::string
& fname
) ->
72 lua_timer_hook_time
= get_utime() + L
.get_numeric_argument
<uint64_t>(1, fname
.c_str());
76 function_ptr_luafun
lua_busaddr(LS
, "bus_address", [](lua_state
& L
, const std::string
& fname
) -> int {
77 uint64_t addr
= L
.get_numeric_argument
<uint64_t>(1, fname
.c_str());
78 auto busrange
= our_rom
->rtype
->get_bus_map();
79 if(!busrange
.second
) {
80 L
.pushstring("This platform does not have bus mapping");
84 L
.pushnumber(busrange
.first
+ (addr
% busrange
.second
));