Added bit.clear() bit.set() to lua, and LuaULong()
This commit is contained in:
parent
8ab655d963
commit
4012f93f31
|
@ -19,6 +19,8 @@ namespace BizHawk.Client.Common
|
|||
"ror",
|
||||
"rshift",
|
||||
"check",
|
||||
"set",
|
||||
"clear",
|
||||
"byteswap_16",
|
||||
"byteswap_32",
|
||||
"byteswap_64",
|
||||
|
@ -70,8 +72,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public static bool bit_check(object num, object pos)
|
||||
{
|
||||
var value = Convert.ToInt64(LuaLong(num));
|
||||
return (value & (1 << (int)(LuaInt(pos)))) != 0;
|
||||
return (LuaLong(num) & (1 << (LuaInt(pos)))) != 0;
|
||||
}
|
||||
|
||||
public static uint bit_set(object num, object pos)
|
||||
{
|
||||
return (uint) (LuaInt(num) | 1 << LuaInt(pos));
|
||||
}
|
||||
|
||||
public static uint bit_clear(object num, object pos)
|
||||
{
|
||||
return (uint) (LuaInt(num) & ~(1 << LuaInt(pos)));
|
||||
}
|
||||
|
||||
public static uint bit_byteswap_16(object short_)
|
||||
|
|
|
@ -38,7 +38,12 @@ namespace BizHawk.Client.Common
|
|||
protected static long LuaLong(object luaArg)
|
||||
{
|
||||
return (long)(double)luaArg;
|
||||
}
|
||||
}
|
||||
|
||||
protected static ulong LuaULong(object luaArg)
|
||||
{
|
||||
return (ulong)(double)luaArg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LuaInterface requires the exact match of parameter count, except optional parameters.
|
||||
|
|
Loading…
Reference in New Issue