From 1a0e98b7ad7a41d0818fb32e32d8e31992bb560f Mon Sep 17 00:00:00 2001 From: pasky1382 Date: Sun, 19 Jan 2014 17:42:21 +0000 Subject: [PATCH] Lua bit.checkbit() function, returns if a specified bit is on/off. --- BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs index 1fd615319b..f9ee97935d 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Bit.cs @@ -1,4 +1,5 @@ -namespace BizHawk.Client.Common +using System; +namespace BizHawk.Client.Common { public class BitLuaLibrary : LuaLibraryBase { @@ -17,6 +18,7 @@ "rol", "ror", "rshift", + "check", }; } } @@ -62,5 +64,11 @@ { return (uint)(LuaInt(val) >> LuaInt(amt)); } + + public static bool bit_check(object num, object pos) + { + var value = Convert.ToInt64(LuaLong(num)); + return (value & (1 << (int)(LuaInt(pos)))) != 0; + } } }