summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--plugins/boot.lua2
-rw-r--r--plugins/cheat/init.lua20
-rw-r--r--plugins/dummy/init.lua6
-rw-r--r--plugins/hiscore/init.lua18
-rw-r--r--src/emu/luaengine.cpp47
-rw-r--r--src/emu/luaengine.h5
6 files changed, 75 insertions, 23 deletions
diff --git a/plugins/boot.lua b/plugins/boot.lua
index 8417a979fb1..4662b6bff0c 100644
--- a/plugins/boot.lua
+++ b/plugins/boot.lua
@@ -19,7 +19,7 @@ for file in lfs.dir("plugins") do
if (meta["plugin"]["type"]=="plugin") and (manager:plugins().entries[meta["plugin"]["name"]]~=nil) then
local entry = manager:plugins().entries[meta["plugin"]["name"]]
if (entry:value()==true) then
- print("Starting plugin " .. meta["plugin"]["name"] .. "...")
+ emu.print_verbose("Starting plugin " .. meta["plugin"]["name"] .. "...")
plugin = require(meta["plugin"]["name"])
if plugin.set_folder~=nil then plugin.set_folder("plugins/" .. file) end
plugin.startplugin();
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index ec5078fedf0..ea6f4bba3fb 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -112,7 +112,7 @@ function cheat.startplugin()
line = line + 1
end
if not screen then
- print("draw_text: invalid screen")
+ emu.print_verbose("draw_text: invalid screen")
return
end
if type(x) == "string" then
@@ -123,7 +123,7 @@ function cheat.startplugin()
local function draw_line(screen, x1, y1, x2, y2, color)
if not screen then
- print("draw_line: invalid screen")
+ emu.print_verbose("draw_line: invalid screen")
return
end
output[#output + 1] = { type = "line", scr = screen, x1 = x1, x2 = x2, y1 = y1, y2 = y2, color = color }
@@ -131,7 +131,7 @@ function cheat.startplugin()
local function draw_box(screen, x1, y1, x2, y2, bgcolor, linecolor)
if not screen then
- print("draw_box: invalid screen")
+ emu.print_verbose("draw_box: invalid screen")
return
end
output[#output + 1] = { type = "box", scr = screen, x1 = x1, x2 = x2, y1 = y1, y2 = y2, bgcolor = bgcolor, linecolor = linecolor }
@@ -184,7 +184,7 @@ function cheat.startplugin()
for name, script in pairs(cheat.script) do
script, err = load(script, cheat.desc .. name, "t", cheat.cheat_env)
if not script then
- print("error loading cheat script: " .. cheat.desc .. " " .. err)
+ emu.print_verbose("error loading cheat script: " .. cheat.desc .. " " .. err)
cheat = { desc = cheat.desc .. " error" }
return
end
@@ -199,7 +199,7 @@ function cheat.startplugin()
local cpu, mem
cpu = manager:machine().devices[space.tag]
if not cpu then
- print("error loading cheat script: " .. cheat.desc)
+ emu.print_verbose("error loading cheat script: " .. cheat.desc)
cheat = { desc = cheat.desc .. " error" }
return
end
@@ -209,7 +209,7 @@ function cheat.startplugin()
mem = cpu.spaces["program"]
end
if not mem then
- print("error loading cheat script: " .. cheat.desc)
+ emu.print_verbose("error loading cheat script: " .. cheat.desc)
cheat = { desc = cheat.desc .. " error" }
return
end
@@ -232,7 +232,7 @@ function cheat.startplugin()
local mem
mem = manager:machine():memory().regions[region]
if not mem then
- print("error loading cheat script: " .. cheat.desc)
+ emu.print_verbose("error loading cheat script: " .. cheat.desc)
cheat = { desc = cheat.desc .. " error" }
return
end
@@ -244,7 +244,7 @@ function cheat.startplugin()
local ram
ram = manager:machine().devices[ram]
if not ram then
- print("error loading cheat script: " .. cheat.desc)
+ emu.print_verbose("error loading cheat script: " .. cheat.desc)
cheat = { desc = cheat.desc .. " error" }
return
end
@@ -531,14 +531,14 @@ function cheat.startplugin()
cheat = cheats[index]
if cheat then
for k, v in pairs(cheat.cheat_env) do
- print(k, v)
+ emu.print_verbose(k, v)
end
end
end
function ce.list()
for num, cheat in pairs(cheats) do
- print(num, cheat.desc)
+ emu.print_verbose(num, cheat.desc)
end
end
diff --git a/plugins/dummy/init.lua b/plugins/dummy/init.lua
index 8058bcad452..1f78851a936 100644
--- a/plugins/dummy/init.lua
+++ b/plugins/dummy/init.lua
@@ -11,11 +11,11 @@ local dummy = exports
function dummy.startplugin()
emu.register_start(function()
- print("Starting " .. emu.gamename())
+ emu.print_verbose("Starting " .. emu.gamename())
end)
emu.register_stop(function()
- print("Exiting " .. emu.gamename())
+ emu.print_verbose("Exiting " .. emu.gamename())
end)
local function menu_populate()
@@ -23,7 +23,7 @@ function dummy.startplugin()
end
local function menu_callback(index, event)
- print("index: " .. index .. " event: " .. event)
+ emu.print_verbose("index: " .. index .. " event: " .. event)
return false
end
diff --git a/plugins/hiscore/init.lua b/plugins/hiscore/init.lua
index 647aca11608..877c8372c70 100644
--- a/plugins/hiscore/init.lua
+++ b/plugins/hiscore/init.lua
@@ -129,14 +129,14 @@ function hiscore.startplugin()
local function write_scores ( posdata )
- print("write_scores")
+ emu.print_verbose("write_scores")
local output = io.open(get_file_name(), "wb");
if not output then
-- attempt to create the directory, and try again
lfs.mkdir( hiscore_path );
output = io.open(get_file_name(), "wb");
end
- print("write_scores output")
+ emu.print_verbose("write_scores output")
if output then
for ri,row in ipairs(posdata) do
t = {};
@@ -147,7 +147,7 @@ function hiscore.startplugin()
end
output:close();
end
- print("write_scores end")
+ emu.print_verbose("write_scores end")
end
@@ -184,10 +184,10 @@ function hiscore.startplugin()
if check_mem( positions ) then
default_checksum = check_scores( positions );
if read_scores( positions ) then
- print( "scores read", "OK" );
+ emu.print_verbose( "scores read", "OK" );
else
-- likely there simply isn't a .hi file around yet
- print( "scores read", "FAIL" );
+ emu.print_verbose( "scores read", "FAIL" );
end
scores_have_been_read = true;
current_checksum = check_scores( positions );
@@ -219,7 +219,7 @@ function hiscore.startplugin()
write_scores( positions );
current_checksum = checksum;
last_write_time = emu.time();
- -- print( "SAVE SCORES EVENT!", last_write_time );
+ -- emu.print_verbose( "SAVE SCORES EVENT!", last_write_time );
end
end
end
@@ -243,13 +243,13 @@ function hiscore.startplugin()
mem_check_passed = false
scores_have_been_read = false;
last_write_time = -10
- print("Starting " .. emu.gamename())
+ emu.print_verbose("Starting " .. emu.gamename())
local dat = read_hiscore_dat()
if dat and dat ~= "" then
- print( "found hiscore.dat entry for " .. emu.romname() );
+ emu.print_verbose( "found hiscore.dat entry for " .. emu.romname() );
positions = parse_table( dat );
if not positions then
- print("hiscore.dat parse error");
+ emu.print_error("hiscore.dat parse error");
return;
end
found_hiscore_entry = true
diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp
index 331d2b1372e..8e1ddbf8d93 100644
--- a/src/emu/luaengine.cpp
+++ b/src/emu/luaengine.cpp
@@ -2075,6 +2075,49 @@ int lua_engine::lua_machine::l_logerror(lua_State *L)
return 0;
}
+std::string lua_engine::get_print_buffer(lua_State *L)
+{
+ int nargs = lua_gettop(L);
+
+ const std::string sep = " ";
+
+ std::ostringstream ss;
+ bool first = true;
+
+ for (int i = 1; i <= nargs; i++) {
+ const char* c = lua_tostring(L, i);
+ const std::string str = c ? c : "<nil>";
+ if (first) first = false;
+ else ss << sep;
+ ss << str;
+ }
+
+ return ss.str();
+}
+int lua_engine::l_osd_printf_verbose(lua_State *L)
+{
+ osd_printf_verbose("%s\n",get_print_buffer(L).c_str());
+ return 0;
+}
+
+int lua_engine::l_osd_printf_error(lua_State *L)
+{
+ osd_printf_error("%s\n",get_print_buffer(L).c_str());
+ return 0;
+}
+
+int lua_engine::l_osd_printf_info(lua_State *L)
+{
+ osd_printf_info("%s\n",get_print_buffer(L).c_str());
+ return 0;
+}
+
+int lua_engine::l_osd_printf_debug(lua_State *L)
+{
+ osd_printf_debug("%s\n",get_print_buffer(L).c_str());
+ return 0;
+}
+
//-------------------------------------------------
// initialize - initialize lua hookup to emu engine
//-------------------------------------------------
@@ -2106,6 +2149,10 @@ void lua_engine::initialize()
.addCFunction ("register_frame", l_emu_register_frame )
.addCFunction ("register_frame_done", l_emu_register_frame_done )
.addCFunction ("register_menu", l_emu_register_menu )
+ .addCFunction ("print_verbose", l_osd_printf_verbose )
+ .addCFunction ("print_error", l_osd_printf_error )
+ .addCFunction ("print_info", l_osd_printf_info )
+ .addCFunction ("print_debug", l_osd_printf_debug )
.beginClass <machine_manager> ("manager")
.addFunction ("machine", &machine_manager::machine)
.addFunction ("options", &machine_manager::options)
diff --git a/src/emu/luaengine.h b/src/emu/luaengine.h
index 269ea3d46b3..3b4c85ce939 100644
--- a/src/emu/luaengine.h
+++ b/src/emu/luaengine.h
@@ -141,6 +141,11 @@ private:
static int l_emu_register_frame(lua_State *L);
static int l_emu_register_frame_done(lua_State *L);
static int l_emu_register_menu(lua_State *L);
+ static std::string get_print_buffer(lua_State *L);
+ static int l_osd_printf_verbose(lua_State *L);
+ static int l_osd_printf_error(lua_State *L);
+ static int l_osd_printf_info(lua_State *L);
+ static int l_osd_printf_debug(lua_State *L);
static int register_function(lua_State *L, const char *id);
// "emu.machine" namespace