mirror of
https://github.com/libretro/mame2016-libretro.git
synced 2025-02-18 17:08:26 +00:00
plugins/layout: layout embedded script helper plugin [Carl]
luaengine: callbacks for plugins (nw) rendlay: layout tag external handler support (nw) fidel_csc and mdndclab: example layout scripts (nw) -- Neither layout script is complete. The chess doesn't handle castling or en passant and the Dungeons and Dragons only does the walls.
This commit is contained in:
parent
7d635eec4b
commit
29d7699569
@ -171,6 +171,7 @@ function cheat.startplugin()
|
||||
frombcd = frombcd,
|
||||
pairs = pairs,
|
||||
ipairs = ipairs,
|
||||
outputs = manager:machine():outputs(),
|
||||
time = time,
|
||||
table =
|
||||
{ insert = table.insert,
|
||||
|
50
plugins/layout/init.lua
Normal file
50
plugins/layout/init.lua
Normal file
@ -0,0 +1,50 @@
|
||||
-- license:BSD-3-Clause
|
||||
-- copyright-holders:Carl
|
||||
-- Layout scripts should return a table and a string. The table can have two optional keys reset and frame
|
||||
-- which have functions for values called on reset and frame draw respectively and the string is a unique name.
|
||||
local exports = {}
|
||||
exports.name = "layout"
|
||||
exports.version = "0.0.1"
|
||||
exports.description = "Layout helper plugin"
|
||||
exports.license = "The BSD 3-Clause License"
|
||||
exports.author = { name = "Carl" }
|
||||
|
||||
local layout = exports
|
||||
|
||||
function layout.startplugin()
|
||||
local scripts = {}
|
||||
local function prepare_layout(script)
|
||||
local env = { machine = manager:machine(), pairs = pairs, ipairs = ipairs,
|
||||
table = { insert = table.insert, remove = table.remove } }
|
||||
local script, err = load(script, script, "t", env)
|
||||
if not script then
|
||||
emu.print_verbose("error loading layout script " .. err)
|
||||
return
|
||||
end
|
||||
local name
|
||||
script, name = script()
|
||||
scripts[name] = script
|
||||
end
|
||||
|
||||
emu.register_callback(prepare_layout, "layout")
|
||||
emu.register_frame(function()
|
||||
if manager:machine().paused then
|
||||
return
|
||||
end
|
||||
for num, scr in pairs(scripts) do
|
||||
if scr.frame then
|
||||
scr.frame()
|
||||
end
|
||||
end
|
||||
end)
|
||||
emu.register_start(function()
|
||||
for num, scr in pairs(scripts) do
|
||||
if scr.reset then
|
||||
scr.reset()
|
||||
end
|
||||
end
|
||||
end)
|
||||
emu.register_stop(function() scripts = {} end)
|
||||
end
|
||||
|
||||
return exports
|
10
plugins/layout/plugin.json
Normal file
10
plugins/layout/plugin.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"plugin": {
|
||||
"name": "layout",
|
||||
"description": "Layout helper plugin",
|
||||
"version": "0.0.1",
|
||||
"author": "Carl",
|
||||
"type": "plugin",
|
||||
"start": "false"
|
||||
}
|
||||
}
|
@ -59,6 +59,7 @@ public:
|
||||
static void draw_user_interface(running_machine& machine);
|
||||
static void periodic_check();
|
||||
static bool frame_hook();
|
||||
static void layout_file_cb(xml_data_node &layout);
|
||||
};
|
||||
|
||||
// ======================> machine_manager
|
||||
|
@ -1732,6 +1732,8 @@ bool render_target::load_layout_file(const char *dirname, const char *filename)
|
||||
result = false;
|
||||
}
|
||||
|
||||
emulator_info::layout_file_cb(*rootnode);
|
||||
|
||||
// free the root node
|
||||
xml_file_free(rootnode);
|
||||
return result;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "emuopts.h"
|
||||
#include "ui/ui.h"
|
||||
#include "luaengine.h"
|
||||
#include "uiinput.h"
|
||||
#include <mutex>
|
||||
|
||||
#ifdef __clang__
|
||||
@ -1531,6 +1532,19 @@ int lua_engine::lua_emu_file::l_emu_file_read(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_engine::lua_ui_input::l_ui_input_find_mouse(lua_State *L)
|
||||
{
|
||||
ui_input_manager *ui_input = luabridge::Stack<ui_input_manager *>::get(L, 1);
|
||||
INT32 x, y;
|
||||
bool button;
|
||||
render_target *target = ui_input->find_mouse(&x, &y, &button);
|
||||
lua_pushnumber(L, x);
|
||||
lua_pushnumber(L, y);
|
||||
lua_pushboolean(L, button);
|
||||
luabridge::Stack<render_target *>::push(L, target);
|
||||
return 4;
|
||||
}
|
||||
|
||||
void *lua_engine::checkparam(lua_State *L, int idx, const char *tname)
|
||||
{
|
||||
const char *name;
|
||||
@ -1718,121 +1732,38 @@ lua_engine::~lua_engine()
|
||||
close();
|
||||
}
|
||||
|
||||
int lua_engine::compile_with_env(const char *envname, const char *script, const char *env)
|
||||
void lua_engine::call_plugin(const char *data, const char *name)
|
||||
{
|
||||
std::string field = std::string("env_").append(envname);
|
||||
std::string field("cb_");
|
||||
field += name;
|
||||
lua_settop(m_lua_state, 0);
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
|
||||
if(!lua_isfunction(m_lua_state, -1))
|
||||
{
|
||||
lua_pop(m_lua_state, 1);
|
||||
return;
|
||||
}
|
||||
lua_pushstring(m_lua_state, data);
|
||||
int error;
|
||||
lua_settop(m_lua_state, 0);
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
|
||||
if(!lua_istable(m_lua_state, -1))
|
||||
{
|
||||
lua_newtable(m_lua_state);
|
||||
lua_setfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
}
|
||||
|
||||
// optionally load a string to prepare the environment
|
||||
if(env)
|
||||
{
|
||||
error = luaL_loadstring(m_lua_state, env);
|
||||
if(error == LUA_OK)
|
||||
lua_pushvalue(m_lua_state, -2);
|
||||
if((error != LUA_OK) || ((error = lua_pcall(m_lua_state, 1, 0, 0)) != LUA_OK))
|
||||
{
|
||||
if((error == LUA_ERRSYNTAX) || (error == LUA_ERRRUN))
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
}
|
||||
|
||||
if((error = luaL_loadstring(m_lua_state, script)) != LUA_OK)
|
||||
{
|
||||
if(error == LUA_ERRSYNTAX)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
lua_tostring(m_lua_state, -1);
|
||||
lua_pop(m_lua_state, 2);
|
||||
return -1;
|
||||
}
|
||||
lua_pushvalue(m_lua_state, -2);
|
||||
lua_setupvalue(m_lua_state, -2, 1);
|
||||
int ref = luaL_ref(m_lua_state, -2);
|
||||
lua_pop(m_lua_state, 1);
|
||||
return ref;
|
||||
}
|
||||
|
||||
template <typename Tout, typename Tin>
|
||||
Tout lua_engine::run(const char *env, int ref, Tin in)
|
||||
{
|
||||
Tout ret;
|
||||
lua_settop(m_lua_state, 0);
|
||||
luabridge::Stack<Tin>::push(m_lua_state, in);
|
||||
run_internal(env, ref);
|
||||
if(lua_isnil(m_lua_state, 1))
|
||||
ret = Tout(0);
|
||||
else
|
||||
ret = luabridge::Stack<Tout>::get(m_lua_state, 1);
|
||||
lua_pop(m_lua_state, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Tout>
|
||||
Tout lua_engine::run(const char *env, int ref)
|
||||
{
|
||||
Tout ret;
|
||||
lua_settop(m_lua_state, 0);
|
||||
lua_pushnil(m_lua_state);
|
||||
run_internal(env, ref);
|
||||
if(lua_isnil(m_lua_state, 1))
|
||||
ret = Tout(0);
|
||||
else
|
||||
ret = luabridge::Stack<Tout>::get(m_lua_state, 1);
|
||||
lua_pop(m_lua_state, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Tin>
|
||||
void lua_engine::run(const char *env, int ref, Tin in)
|
||||
{
|
||||
lua_settop(m_lua_state, 0);
|
||||
luabridge::Stack<Tin>::push(m_lua_state, in);
|
||||
run_internal(env, ref);
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
|
||||
void lua_engine::run(const char *env, int ref)
|
||||
{
|
||||
lua_settop(m_lua_state, 0);
|
||||
lua_pushnil(m_lua_state);
|
||||
run_internal(env, ref);
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
// create specialization so luabridge doesn't have to be included everywhere
|
||||
template int lua_engine::run<int>(const char *env, int ref);
|
||||
|
||||
void lua_engine::run_internal(const char *env, int ref)
|
||||
{
|
||||
std::string field = std::string("env_").append(env);
|
||||
lua_getfield(m_lua_state, LUA_REGISTRYINDEX, field.c_str());
|
||||
if(lua_istable(m_lua_state, -1))
|
||||
{
|
||||
lua_rawgeti(m_lua_state, -1, ref);
|
||||
if(lua_isfunction(m_lua_state, -1))
|
||||
{
|
||||
lua_pushvalue(m_lua_state, -3);
|
||||
int error;
|
||||
if((error = lua_pcall(m_lua_state, 1, 1, 0)) != LUA_OK)
|
||||
if((error = lua_pcall(m_lua_state, 1, 0, 0)) != LUA_OK)
|
||||
{
|
||||
if(error == LUA_ERRRUN)
|
||||
printf("%s\n", lua_tostring(m_lua_state, -1));
|
||||
lua_pop(m_lua_state, 1);
|
||||
lua_pushnil(m_lua_state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_replace(m_lua_state, 1);
|
||||
lua_pop(m_lua_state, 1);
|
||||
}
|
||||
|
||||
int lua_engine::l_emu_register_callback(lua_State *L)
|
||||
{
|
||||
luaL_argcheck(L, lua_isfunction(L, 1), 1, "callback function expected");
|
||||
luaL_argcheck(L, lua_isstring(L, 2), 2, "name (string) expected");
|
||||
std::string name = luaL_checkstring(L, 2);
|
||||
std::string field = "cb_" + name;
|
||||
lua_pushvalue(L, 1);
|
||||
lua_setfield(L, LUA_REGISTRYINDEX, field.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
void lua_engine::menu_populate(std::string &menu, std::vector<menu_item> &menu_list)
|
||||
@ -2165,6 +2096,7 @@ 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 ("register_callback", l_emu_register_callback )
|
||||
.addCFunction ("print_verbose", l_osd_printf_verbose )
|
||||
.addCFunction ("print_error", l_osd_printf_error )
|
||||
.addCFunction ("print_info", l_osd_printf_info )
|
||||
@ -2196,6 +2128,8 @@ void lua_engine::initialize()
|
||||
.addFunction ("memory", &running_machine::memory)
|
||||
.addFunction ("options", &running_machine::options)
|
||||
.addFunction ("outputs", &running_machine::output)
|
||||
.addFunction ("input", &running_machine::ui_input)
|
||||
.addProperty <bool> ("paused", &running_machine::paused)
|
||||
.addProperty <luabridge::LuaRef, void> ("devices", &lua_engine::l_machine_get_devices)
|
||||
.addProperty <luabridge::LuaRef, void> ("screens", &lua_engine::l_machine_get_screens)
|
||||
.addProperty <luabridge::LuaRef, void> ("images", &lua_engine::l_machine_get_images)
|
||||
@ -2369,6 +2303,12 @@ void lua_engine::initialize()
|
||||
.addFunction("name", &address_space::name)
|
||||
.addProperty <luabridge::LuaRef, void> ("map", &lua_engine::l_addr_space_map)
|
||||
.endClass()
|
||||
.beginClass <lua_ui_input> ("lua_input")
|
||||
.addCFunction ("find_mouse", &lua_ui_input::l_ui_input_find_mouse)
|
||||
.endClass()
|
||||
.deriveClass <ui_input_manager, lua_ui_input> ("input")
|
||||
.addFunction ("pressed", &ui_input_manager::pressed)
|
||||
.endClass()
|
||||
.beginClass <render_target> ("target")
|
||||
.addFunction ("width", &render_target::width)
|
||||
.addFunction ("height", &render_target::height)
|
||||
|
@ -62,12 +62,8 @@ public:
|
||||
std::vector<std::string> &get_menu() { return m_menu; }
|
||||
void attach_notifiers();
|
||||
void on_frame_done();
|
||||
void call_plugin(const char *data, const char *name);
|
||||
|
||||
int compile_with_env(const char *envname, const char *script, const char *env = nullptr);
|
||||
template <typename Tout, typename Tin> Tout run(const char *envname, int ref, Tin in);
|
||||
template <typename Tout> Tout run(const char *envname, int ref);
|
||||
template <typename Tin> void run(const char *envname, int ref, Tin in);
|
||||
void run(const char *envname, int ref);
|
||||
private:
|
||||
struct hook {
|
||||
lua_State *L;
|
||||
@ -141,6 +137,7 @@ 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 int l_emu_register_callback(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);
|
||||
@ -207,6 +204,10 @@ private:
|
||||
template<typename T> int l_region_write(lua_State *L);
|
||||
};
|
||||
|
||||
struct lua_ui_input {
|
||||
int l_ui_input_find_mouse(lua_State *L);
|
||||
};
|
||||
|
||||
struct lua_emu_file {
|
||||
lua_emu_file(const char *searchpath, UINT32 openflags) :
|
||||
path(searchpath),
|
||||
@ -233,7 +234,6 @@ private:
|
||||
int l_item_read_block(lua_State *L);
|
||||
int l_item_write(lua_State *L);
|
||||
};
|
||||
void run_internal(const char *env, int ref);
|
||||
|
||||
void resume(void *L, INT32 param);
|
||||
void start();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "cheat.h"
|
||||
#include "ui/datfile.h"
|
||||
#include "ui/inifile.h"
|
||||
#include "xmlfile.h"
|
||||
|
||||
//**************************************************************************
|
||||
// MACHINE MANAGER
|
||||
@ -336,3 +337,14 @@ bool emulator_info::frame_hook()
|
||||
{
|
||||
return mame_machine_manager::instance()->lua()->frame_hook();
|
||||
}
|
||||
|
||||
void emulator_info::layout_file_cb(xml_data_node &layout)
|
||||
{
|
||||
xml_data_node *mamelayout = xml_get_sibling(layout.child, "mamelayout");
|
||||
if(mamelayout)
|
||||
{
|
||||
xml_data_node *script = xml_get_sibling(mamelayout->child, "script");
|
||||
if(script)
|
||||
mame_machine_manager::instance()->lua()->call_plugin(script->value, "layout");
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,83 @@
|
||||
<!-- other than panel button mappings, layout is identical to vsc -->
|
||||
|
||||
<!-- define elements -->
|
||||
<script>
|
||||
local layout = {}
|
||||
local board
|
||||
local first_sq
|
||||
local curr_sq = {x = 0, y = 0}
|
||||
|
||||
local port_tags = { ":IN.0", ":IN.1", ":IN.2", ":IN.3", ":IN.4", ":IN.5", ":IN.6", ":IN.7" }
|
||||
local ports
|
||||
|
||||
local function move_piece(from, to)
|
||||
if board[from.y][from.x] == 0 then
|
||||
return false
|
||||
end
|
||||
board[to.y][to.x] = board[from.y][from.x]
|
||||
board[from.y][from.x] = 0
|
||||
machine:outputs():set_indexed_value("pos", (to.y * 10) + to.x, board[to.y][to.x])
|
||||
machine:outputs():set_indexed_value("pos", (from.y * 10) + from.x, 0)
|
||||
return true
|
||||
end
|
||||
|
||||
function layout.reset()
|
||||
board =
|
||||
{{ 3, 5, 4, 2, 1, 4, 5, 3},
|
||||
{ 6, 6, 6, 6, 6, 6, 6, 6},
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{12,12,12,12,12,12,12,12},
|
||||
{ 9,11,10, 8, 7,10,11, 9}}
|
||||
|
||||
for y, row in ipairs(board) do
|
||||
for x, cell in ipairs(row) do
|
||||
machine:outputs():set_indexed_value("pos", (y * 10) + x, board[y][x])
|
||||
end
|
||||
end
|
||||
ports = machine:ioport().ports
|
||||
end
|
||||
|
||||
function layout.frame()
|
||||
local value = ports[":IN.8"]:read()
|
||||
if value & 0x80 ~= 0 then
|
||||
layout.reset()
|
||||
return
|
||||
end
|
||||
|
||||
for x, tag in ipairs(port_tags) do
|
||||
local port = ports[tag]
|
||||
if port then
|
||||
local newvalue = port:read()
|
||||
if newvalue ~= 0 then
|
||||
for y = 8, 1, -1 do
|
||||
if newvalue & 1 == 1 then
|
||||
if (curr_sq.y == y) and (curr_sq.x == x) then
|
||||
return
|
||||
end
|
||||
if not first_sq then
|
||||
first_sq = {x = x, y = y}
|
||||
else
|
||||
if move_piece(first_sq, {x = x, y = y}) then
|
||||
first_sq = nil
|
||||
else
|
||||
first_sq = {x = x, y = y}
|
||||
end
|
||||
end
|
||||
curr_sq = {x = x, y = y}
|
||||
return
|
||||
end
|
||||
newvalue = newvalue >> 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return layout, "fidel_csc"
|
||||
</script>
|
||||
|
||||
<element name="static_black"><rect><color red="0.0" green="0.0" blue="0.0" /></rect></element>
|
||||
|
||||
@ -176,6 +253,21 @@
|
||||
<text string="LV"><color red="0.81" green="0.8" blue="0.79" /></text>
|
||||
</element>
|
||||
|
||||
<element name="piece" defstate="0">
|
||||
<text string="♚" state="1"><color red="0.27" green="0.25" blue="0.25" /></text>
|
||||
<text string="♛" state="2"><color red="0.27" green="0.25" blue="0.25" /></text>
|
||||
<text string="♜" state="3"><color red="0.27" green="0.25" blue="0.25" /></text>
|
||||
<text string="♝" state="4"><color red="0.27" green="0.25" blue="0.25" /></text>
|
||||
<text string="♞" state="5"><color red="0.27" green="0.25" blue="0.25" /></text>
|
||||
<text string="♟" state="6"><color red="0.27" green="0.25" blue="0.25" /></text>
|
||||
|
||||
<text string="♚" state="7"><color red="0.71" green="0.7" blue="0.69" /></text>
|
||||
<text string="♛" state="8"><color red="0.71" green="0.7" blue="0.69" /></text>
|
||||
<text string="♜" state="9"><color red="0.71" green="0.7" blue="0.69" /></text>
|
||||
<text string="♝" state="10"><color red="0.71" green="0.7" blue="0.69" /></text>
|
||||
<text string="♞" state="11"><color red="0.71" green="0.7" blue="0.69" /></text>
|
||||
<text string="♟" state="12"><color red="0.71" green="0.7" blue="0.69" /></text>
|
||||
</element>
|
||||
|
||||
<!-- build screen -->
|
||||
|
||||
@ -252,6 +344,79 @@
|
||||
<bezel element="black"><bounds x="43" y="73" width="10" height="10.5" /></bezel>
|
||||
<bezel element="black"><bounds x="63" y="73" width="10" height="10.5" /></bezel>
|
||||
|
||||
|
||||
<bezel name="pos11" element="piece"><bounds x="3" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos12" element="piece"><bounds x="13" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos13" element="piece"><bounds x="23" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos14" element="piece"><bounds x="33" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos15" element="piece"><bounds x="43" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos16" element="piece"><bounds x="53" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos17" element="piece"><bounds x="63" y="3" width="10" height="10" /></bezel>
|
||||
<bezel name="pos18" element="piece"><bounds x="73" y="3" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos21" element="piece"><bounds x="3" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos22" element="piece"><bounds x="13" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos23" element="piece"><bounds x="23" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos24" element="piece"><bounds x="33" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos25" element="piece"><bounds x="43" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos26" element="piece"><bounds x="53" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos27" element="piece"><bounds x="63" y="13" width="10" height="10" /></bezel>
|
||||
<bezel name="pos28" element="piece"><bounds x="73" y="13" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos31" element="piece"><bounds x="3" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos32" element="piece"><bounds x="13" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos33" element="piece"><bounds x="23" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos34" element="piece"><bounds x="33" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos35" element="piece"><bounds x="43" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos36" element="piece"><bounds x="53" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos37" element="piece"><bounds x="63" y="23" width="10" height="10" /></bezel>
|
||||
<bezel name="pos38" element="piece"><bounds x="73" y="23" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos41" element="piece"><bounds x="3" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos42" element="piece"><bounds x="13" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos43" element="piece"><bounds x="23" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos44" element="piece"><bounds x="33" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos45" element="piece"><bounds x="43" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos46" element="piece"><bounds x="53" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos47" element="piece"><bounds x="63" y="33" width="10" height="10" /></bezel>
|
||||
<bezel name="pos48" element="piece"><bounds x="73" y="33" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos51" element="piece"><bounds x="3" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos52" element="piece"><bounds x="13" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos53" element="piece"><bounds x="23" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos54" element="piece"><bounds x="33" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos55" element="piece"><bounds x="43" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos56" element="piece"><bounds x="53" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos57" element="piece"><bounds x="63" y="43" width="10" height="10" /></bezel>
|
||||
<bezel name="pos58" element="piece"><bounds x="73" y="43" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos61" element="piece"><bounds x="3" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos62" element="piece"><bounds x="13" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos63" element="piece"><bounds x="23" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos64" element="piece"><bounds x="33" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos65" element="piece"><bounds x="43" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos66" element="piece"><bounds x="53" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos67" element="piece"><bounds x="63" y="53" width="10" height="10" /></bezel>
|
||||
<bezel name="pos68" element="piece"><bounds x="73" y="53" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos71" element="piece"><bounds x="3" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos72" element="piece"><bounds x="13" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos73" element="piece"><bounds x="23" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos74" element="piece"><bounds x="33" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos75" element="piece"><bounds x="43" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos76" element="piece"><bounds x="53" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos77" element="piece"><bounds x="63" y="63" width="10" height="10" /></bezel>
|
||||
<bezel name="pos78" element="piece"><bounds x="73" y="63" width="10" height="10" /></bezel>
|
||||
|
||||
<bezel name="pos81" element="piece"><bounds x="3" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos82" element="piece"><bounds x="13" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos83" element="piece"><bounds x="23" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos84" element="piece"><bounds x="33" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos85" element="piece"><bounds x="43" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos86" element="piece"><bounds x="53" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos87" element="piece"><bounds x="63" y="73" width="10" height="10" /></bezel>
|
||||
<bezel name="pos88" element="piece"><bounds x="73" y="73" width="10" height="10" /></bezel>
|
||||
|
||||
<!-- chessboard leds -->
|
||||
|
||||
<bezel name="4.7" element="led"><bounds x="3.2" y="11.3" width="1.5" height="1.5" /></bezel>
|
||||
|
@ -1,6 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<mamelayout version="2">
|
||||
|
||||
<script>
|
||||
local layout = {}
|
||||
local walls = { { 7.5, {0, 10, 20, 30, 40, 50, 60, 70}},
|
||||
{17.5, {0, 10, 20, 30, 40, 50, 60, 70}},
|
||||
{27.5, {0, 10, 20, 30, 40, 50, 60, 70}},
|
||||
{37.5, {0, 10, 20, 30, 40, 50, 60, 70}},
|
||||
{47.5, {0, 10, 20, 30, 40, 50, 60, 70}},
|
||||
{57.5, {0, 10, 20, 30, 40, 50, 60, 70}},
|
||||
{67.5, {0, 10, 20, 30, 40, 50, 60, 70}} }
|
||||
|
||||
local last_state = false
|
||||
|
||||
local function get_mouse()
|
||||
local x, y, button, target = machine:input():find_mouse()
|
||||
if not button then
|
||||
last_state = false
|
||||
return nil
|
||||
end
|
||||
if last_state then
|
||||
return nil
|
||||
end
|
||||
last_state = true
|
||||
x = ((x / target:width()) * 95) - 15
|
||||
y = ((y / target:height()) * 82.5) - 2.5
|
||||
return x, y
|
||||
end
|
||||
|
||||
function layout.reset()
|
||||
for num, col in pairs(walls) do
|
||||
for num2, wall in pairs(col[2]) do
|
||||
machine:outputs():set_indexed_value("colwall", (num * 10) + num2, 0)
|
||||
end
|
||||
end
|
||||
for num, row in pairs(walls) do
|
||||
for num2, wall in pairs(row[2]) do
|
||||
machine:outputs():set_indexed_value("rowwall", (num * 10) + num2, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function layout.frame()
|
||||
local x, y = get_mouse()
|
||||
if not x or x < 0 or y < 0 then
|
||||
return
|
||||
end
|
||||
for num, col in pairs(walls) do
|
||||
if col[1] < x and (col[1] + 2.5) > x then
|
||||
for num2, wall in pairs(col[2]) do
|
||||
if wall < y and (wall + 7.5) > y then
|
||||
local state = machine:outputs():get_indexed_value("colwall", (num * 10) + num2)
|
||||
machine:outputs():set_indexed_value("colwall", (num * 10) + num2, (~state) & 1)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for num, row in pairs(walls) do
|
||||
if row[1] < y and (row[1] + 2.5) > y then
|
||||
for num2, wall in pairs(row[2]) do
|
||||
if wall < x and (wall + 7.5) > x then
|
||||
local state = machine:outputs():get_indexed_value("rowwall", (num * 10) + num2)
|
||||
machine:outputs():set_indexed_value("rowwall", (num * 10) + num2, (~state) & 1)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return layout, "mdndclab"
|
||||
</script>
|
||||
|
||||
<!-- define elements -->
|
||||
|
||||
<element name="static_black"><rect><color red="0.07" green="0.07" blue="0.06" /></rect></element>
|
||||
@ -122,6 +193,9 @@
|
||||
<text string="Treasure"><color red="0.8" green="0.75" blue="0.7" /></text>
|
||||
</element>
|
||||
|
||||
<element name="wall" defstate="0">
|
||||
<rect state="1"><color red="0.55" green="0.1" blue="0.05" /></rect>
|
||||
</element>
|
||||
|
||||
<!-- build screen -->
|
||||
|
||||
@ -205,6 +279,120 @@
|
||||
<bezel element="hlr" inputtag="IN.6" inputmask="0x08"><bounds x="60" y="70" width="7.5" height="7.5" /></bezel>
|
||||
<bezel element="hlr" inputtag="IN.7" inputmask="0x08"><bounds x="70" y="70" width="7.5" height="7.5" /></bezel>
|
||||
|
||||
<bezel name="colwall11" element="wall"><bounds x= "7.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall12" element="wall"><bounds x= "7.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall13" element="wall"><bounds x= "7.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall14" element="wall"><bounds x= "7.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall15" element="wall"><bounds x= "7.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall16" element="wall"><bounds x= "7.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall17" element="wall"><bounds x= "7.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall18" element="wall"><bounds x= "7.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall21" element="wall"><bounds x="17.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall22" element="wall"><bounds x="17.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall23" element="wall"><bounds x="17.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall24" element="wall"><bounds x="17.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall25" element="wall"><bounds x="17.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall26" element="wall"><bounds x="17.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall27" element="wall"><bounds x="17.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall28" element="wall"><bounds x="17.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall31" element="wall"><bounds x="27.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall32" element="wall"><bounds x="27.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall33" element="wall"><bounds x="27.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall34" element="wall"><bounds x="27.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall35" element="wall"><bounds x="27.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall36" element="wall"><bounds x="27.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall37" element="wall"><bounds x="27.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall38" element="wall"><bounds x="27.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall41" element="wall"><bounds x="37.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall42" element="wall"><bounds x="37.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall43" element="wall"><bounds x="37.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall44" element="wall"><bounds x="37.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall45" element="wall"><bounds x="37.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall46" element="wall"><bounds x="37.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall47" element="wall"><bounds x="37.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall48" element="wall"><bounds x="37.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall51" element="wall"><bounds x="47.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall52" element="wall"><bounds x="47.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall53" element="wall"><bounds x="47.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall54" element="wall"><bounds x="47.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall55" element="wall"><bounds x="47.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall56" element="wall"><bounds x="47.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall57" element="wall"><bounds x="47.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall58" element="wall"><bounds x="47.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall61" element="wall"><bounds x="57.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall62" element="wall"><bounds x="57.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall63" element="wall"><bounds x="57.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall64" element="wall"><bounds x="57.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall65" element="wall"><bounds x="57.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall66" element="wall"><bounds x="57.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall67" element="wall"><bounds x="57.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall68" element="wall"><bounds x="57.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall71" element="wall"><bounds x="67.5" y= "0" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall72" element="wall"><bounds x="67.5" y="10" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall73" element="wall"><bounds x="67.5" y="20" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall74" element="wall"><bounds x="67.5" y="30" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall75" element="wall"><bounds x="67.5" y="40" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall76" element="wall"><bounds x="67.5" y="50" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall77" element="wall"><bounds x="67.5" y="60" width="2.5" height="7.5" /></bezel>
|
||||
<bezel name="colwall78" element="wall"><bounds x="67.5" y="70" width="2.5" height="7.5" /></bezel>
|
||||
|
||||
<bezel name="rowwall11" element="wall"><bounds x= "0" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall12" element="wall"><bounds x="10" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall13" element="wall"><bounds x="20" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall14" element="wall"><bounds x="30" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall15" element="wall"><bounds x="40" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall16" element="wall"><bounds x="50" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall17" element="wall"><bounds x="60" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall18" element="wall"><bounds x="70" y= "7.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall21" element="wall"><bounds x= "0" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall22" element="wall"><bounds x="10" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall23" element="wall"><bounds x="20" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall24" element="wall"><bounds x="30" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall25" element="wall"><bounds x="40" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall26" element="wall"><bounds x="50" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall27" element="wall"><bounds x="60" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall28" element="wall"><bounds x="70" y="17.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall31" element="wall"><bounds x= "0" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall32" element="wall"><bounds x="10" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall33" element="wall"><bounds x="20" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall34" element="wall"><bounds x="30" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall35" element="wall"><bounds x="40" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall36" element="wall"><bounds x="50" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall37" element="wall"><bounds x="60" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall38" element="wall"><bounds x="70" y="27.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall41" element="wall"><bounds x= "0" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall42" element="wall"><bounds x="10" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall43" element="wall"><bounds x="20" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall44" element="wall"><bounds x="30" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall45" element="wall"><bounds x="40" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall46" element="wall"><bounds x="50" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall47" element="wall"><bounds x="60" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall48" element="wall"><bounds x="70" y="37.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall51" element="wall"><bounds x= "0" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall52" element="wall"><bounds x="10" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall53" element="wall"><bounds x="20" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall54" element="wall"><bounds x="30" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall55" element="wall"><bounds x="40" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall56" element="wall"><bounds x="50" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall57" element="wall"><bounds x="60" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall58" element="wall"><bounds x="70" y="47.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall61" element="wall"><bounds x= "0" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall62" element="wall"><bounds x="10" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall63" element="wall"><bounds x="20" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall64" element="wall"><bounds x="30" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall65" element="wall"><bounds x="40" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall66" element="wall"><bounds x="50" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall67" element="wall"><bounds x="60" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall68" element="wall"><bounds x="70" y="57.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall71" element="wall"><bounds x= "0" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall72" element="wall"><bounds x="10" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall73" element="wall"><bounds x="20" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall74" element="wall"><bounds x="30" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall75" element="wall"><bounds x="40" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall76" element="wall"><bounds x="50" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall77" element="wall"><bounds x="60" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
<bezel name="rowwall78" element="wall"><bounds x="70" y="67.5" width="7.5" height="2.5" /></bezel>
|
||||
|
||||
<!-- left side -->
|
||||
|
||||
<bezel element="static_red"><bounds x="-12.5" y="0" width="7.5" height="7.5" /></bezel>
|
||||
|
Loading…
x
Reference in New Issue
Block a user