2013-10-29 13:52:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static class BitLuaLibrary
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static string Name = "bit";
|
|
|
|
|
public static string[] Functions = new[]
|
|
|
|
|
{
|
|
|
|
|
"band",
|
|
|
|
|
"bnot",
|
|
|
|
|
"bor",
|
|
|
|
|
"bxor",
|
|
|
|
|
"lshift",
|
|
|
|
|
"rol",
|
|
|
|
|
"ror",
|
|
|
|
|
"rshift",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static uint bit_band(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)(LuaCommon.LuaInt(val) & LuaCommon.LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_bnot(object val)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)(~LuaCommon.LuaInt(val));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_bor(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)(LuaCommon.LuaInt(val) | LuaCommon.LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_bxor(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)(LuaCommon.LuaInt(val) ^ LuaCommon.LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_lshift(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)(LuaCommon.LuaInt(val) << LuaCommon.LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_rol(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)((LuaCommon.LuaInt(val) << LuaCommon.LuaInt(amt))
|
|
|
|
|
| (LuaCommon.LuaInt(val) >> (32 - LuaCommon.LuaInt(amt))));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_ror(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)((LuaCommon.LuaInt(val) >> LuaCommon.LuaInt(amt))
|
|
|
|
|
| (LuaCommon.LuaInt(val) << (32 - LuaCommon.LuaInt(amt))));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 13:52:59 +00:00
|
|
|
|
public static uint bit_rshift(object val, object amt)
|
2013-10-28 19:13:01 +00:00
|
|
|
|
{
|
2013-10-29 13:52:59 +00:00
|
|
|
|
return (uint)(LuaCommon.LuaInt(val) >> LuaCommon.LuaInt(amt));
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|