summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/luaengine.cpp49
-rw-r--r--src/emu/luaengine.h1
2 files changed, 50 insertions, 0 deletions
diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp
index 5ef7b935b0e..cd55b2bde4c 100644
--- a/src/emu/luaengine.cpp
+++ b/src/emu/luaengine.cpp
@@ -838,6 +838,54 @@ int lua_engine::lua_screen::l_width(lua_State *L)
return 1;
}
+
+//-------------------------------------------------
+// screen_orientation - return screen orientation
+// -> manager:machine().screens[":screen"]:orientation()
+// -> rotation_angle (0, 90, 180, 270)
+// -> flipx (true, false)
+// -> flipy (true, false)
+//-------------------------------------------------
+
+int lua_engine::lua_screen::l_orientation(lua_State *L)
+{
+ UINT32 flags = (luaThis->machine().system().flags & ORIENTATION_MASK);
+
+ int rotation_angle = 0;
+ switch (flags)
+ {
+ case ORIENTATION_FLIP_X:
+ rotation_angle = 0;
+ break;
+ case ORIENTATION_SWAP_XY:
+ case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X:
+ rotation_angle = 90;
+ break;
+ case ORIENTATION_FLIP_Y:
+ case ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
+ rotation_angle = 180;
+ break;
+ case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y:
+ case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
+ rotation_angle = 270;
+ break;
+ }
+
+ lua_createtable(L, 2, 2);
+ lua_pushliteral(L, "rotation_angle");
+ lua_pushinteger(L, rotation_angle);
+
+ lua_settable(L, -3);
+ lua_pushliteral(L, "flipx");
+ lua_pushboolean(L, (flags & ORIENTATION_FLIP_X));
+
+ lua_settable(L, -3);
+ lua_pushliteral(L, "flipy");
+ lua_pushboolean(L, (flags & ORIENTATION_FLIP_Y));
+ lua_settable(L, -3);
+ return 1;
+}
+
//-------------------------------------------------
// screen_refresh - return screen refresh rate
// -> manager:machine().screens[":screen"]:refresh()
@@ -1579,6 +1627,7 @@ void lua_engine::initialize()
.addCFunction ("draw_text", &lua_screen::l_draw_text)
.addCFunction ("height", &lua_screen::l_height)
.addCFunction ("width", &lua_screen::l_width)
+ .addCFunction ("orientation", &lua_screen::l_orientation)
.addCFunction ("refresh", &lua_screen::l_refresh)
.addCFunction ("snapshot", &lua_screen::l_snapshot)
.addCFunction ("type", &lua_screen::l_type)
diff --git a/src/emu/luaengine.h b/src/emu/luaengine.h
index 908a82a8f0b..0ec72f501d5 100644
--- a/src/emu/luaengine.h
+++ b/src/emu/luaengine.h
@@ -138,6 +138,7 @@ private:
struct lua_screen {
int l_height(lua_State *L);
int l_width(lua_State *L);
+ int l_orientation(lua_State *L);
int l_refresh(lua_State *L);
int l_type(lua_State *L);
int l_snapshot(lua_State *L);