Lua - clean up a lot of params by making them strongly typed numbers instead of object, and simplify a lot of logic as a result
This commit is contained in:
parent
055c08179f
commit
ce9f282d67
|
@ -161,11 +161,11 @@ namespace BizHawk.Client.Common
|
|||
"onmemoryexecute",
|
||||
"Fires after the given address is executed by the core"
|
||||
)]
|
||||
public string OnMemoryExecute(LuaFunction luaf, object address, string name = null)
|
||||
public string OnMemoryExecute(LuaFunction luaf, uint address, string name = null)
|
||||
{
|
||||
var nlf = new NamedLuaFunction(luaf, "OnMemoryExecute", LogOutputCallback, CurrentThread, name);
|
||||
_luaFunctions.Add(nlf);
|
||||
Global.CoreComm.MemoryCallbackSystem.AddExecute(nlf.Callback, LuaUInt(address));
|
||||
Global.CoreComm.MemoryCallbackSystem.AddExecute(nlf.Callback, address);
|
||||
return nlf.Guid.ToString();
|
||||
}
|
||||
|
||||
|
@ -173,11 +173,11 @@ namespace BizHawk.Client.Common
|
|||
"onmemoryread",
|
||||
"Fires after the given address is read by the core. If no address is given, it will attach to every memory read"
|
||||
)]
|
||||
public string OnMemoryRead(LuaFunction luaf, object address = null, string name = null)
|
||||
public string OnMemoryRead(LuaFunction luaf, uint? address = null, string name = null)
|
||||
{
|
||||
var nlf = new NamedLuaFunction(luaf, "OnMemoryRead", LogOutputCallback, CurrentThread, name);
|
||||
_luaFunctions.Add(nlf);
|
||||
Global.CoreComm.MemoryCallbackSystem.AddRead(nlf.Callback, address != null ? LuaUInt(address) : (uint?)null);
|
||||
Global.CoreComm.MemoryCallbackSystem.AddRead(nlf.Callback, address);
|
||||
return nlf.Guid.ToString();
|
||||
}
|
||||
|
||||
|
@ -185,11 +185,11 @@ namespace BizHawk.Client.Common
|
|||
"onmemorywrite",
|
||||
"Fires after the given address is written by the core. If no address is given, it will attach to every memory write"
|
||||
)]
|
||||
public string OnMemoryWrite(LuaFunction luaf, object address = null, string name = null)
|
||||
public string OnMemoryWrite(LuaFunction luaf, uint? address = null, string name = null)
|
||||
{
|
||||
var nlf = new NamedLuaFunction(luaf, "OnMemoryWrite", LogOutputCallback, CurrentThread, name);
|
||||
_luaFunctions.Add(nlf);
|
||||
Global.CoreComm.MemoryCallbackSystem.AddWrite(nlf.Callback, address != null ? LuaUInt(address) : (uint?)null);
|
||||
Global.CoreComm.MemoryCallbackSystem.AddWrite(nlf.Callback, address);
|
||||
return nlf.Guid.ToString();
|
||||
}
|
||||
|
||||
|
|
|
@ -106,22 +106,20 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"readbyte",
|
||||
"gets the value from the given address as an unsigned byte"
|
||||
"readbyte", "gets the value from the given address as an unsigned byte"
|
||||
)]
|
||||
public uint ReadByte(object addr)
|
||||
public uint ReadByte(int addr)
|
||||
{
|
||||
return ReadUnsignedByte(LuaInt(addr));
|
||||
return ReadUnsignedByte(addr);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"readbyterange",
|
||||
"Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key)."
|
||||
)]
|
||||
public LuaTable ReadByteRange(object address, object length)
|
||||
public LuaTable ReadByteRange(int addr, int length)
|
||||
{
|
||||
var addr = LuaInt(address);
|
||||
var lastAddr = LuaInt(length) + addr;
|
||||
var lastAddr = length + addr;
|
||||
var table = _lua.NewTable();
|
||||
for (var i = addr; i <= lastAddr; i++)
|
||||
{
|
||||
|
@ -138,25 +136,20 @@ namespace BizHawk.Client.Common
|
|||
"readfloat",
|
||||
"Reads the given address as a 32-bit float value from the main memory domain with th e given endian"
|
||||
)]
|
||||
public float ReadFloat(object addr, bool bigendian)
|
||||
public float ReadFloat(int addr, bool bigendian)
|
||||
{
|
||||
var val = Global.Emulator.MemoryDomains.MainMemory.PeekDWord(LuaInt(addr), bigendian);
|
||||
var val = Global.Emulator.MemoryDomains.MainMemory.PeekDWord(addr, bigendian);
|
||||
var bytes = BitConverter.GetBytes(val);
|
||||
var _float = BitConverter.ToSingle(bytes, 0);
|
||||
|
||||
return _float;
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"writebyte",
|
||||
"Writes the given value to the given address as an unsigned byte"
|
||||
)]
|
||||
public void WriteByte(object addr, object value)
|
||||
public void WriteByte(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedByte(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value)
|
||||
);
|
||||
WriteUnsignedByte(addr, value);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
|
@ -178,306 +171,264 @@ namespace BizHawk.Client.Common
|
|||
"writefloat",
|
||||
"Writes the given 32-bit float value to the given address and endian"
|
||||
)]
|
||||
public void WriteFloat(object address, object value, bool bigendian)
|
||||
public void WriteFloat(int address, double value, bool bigendian)
|
||||
{
|
||||
var dv = (float)(double)value;
|
||||
var dv = (float)value;
|
||||
var bytes = BitConverter.GetBytes(dv);
|
||||
var v = BitConverter.ToUInt32(bytes, 0);
|
||||
Global.Emulator.MemoryDomains.MainMemory.PokeDWord(LuaInt(address), v, bigendian);
|
||||
Global.Emulator.MemoryDomains.MainMemory.PokeDWord(address, v, bigendian);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s8",
|
||||
"read signed byte"
|
||||
)]
|
||||
public int ReadS8(object addr)
|
||||
public int ReadS8(int addr)
|
||||
{
|
||||
return (sbyte)ReadUnsignedByte(LuaInt(addr));
|
||||
return (sbyte)ReadUnsignedByte(addr);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u8",
|
||||
"read unsigned byte"
|
||||
)]
|
||||
public uint ReadU8(object addr)
|
||||
public uint ReadU8(int addr)
|
||||
{
|
||||
return ReadUnsignedByte(LuaInt(addr));
|
||||
return ReadUnsignedByte(addr);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s16_le",
|
||||
"read signed 2 byte value, little endian"
|
||||
)]
|
||||
public int ReadS16Little(object addr)
|
||||
public int ReadS16Little(int addr)
|
||||
{
|
||||
return ReadSignedLittleCore(LuaInt(addr), 2);
|
||||
return ReadSignedLittleCore(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s24_le",
|
||||
"read signed 24 bit value, little endian"
|
||||
)]
|
||||
public int ReadS24Little(object addr)
|
||||
public int ReadS24Little(int addr)
|
||||
{
|
||||
return ReadSignedLittleCore(LuaInt(addr), 3);
|
||||
return ReadSignedLittleCore(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s32_le",
|
||||
"read signed 4 byte value, little endian"
|
||||
)]
|
||||
public int ReadS32Little(object addr)
|
||||
public int ReadS32Little(int addr)
|
||||
{
|
||||
return ReadSignedLittleCore(LuaInt(addr), 4);
|
||||
return ReadSignedLittleCore(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u16_le",
|
||||
"read unsigned 2 byte value, little endian"
|
||||
)]
|
||||
public uint ReadU16Little(object addr)
|
||||
public uint ReadU16Little(int addr)
|
||||
{
|
||||
return ReadSignedLittle(LuaInt(addr), 2);
|
||||
return ReadSignedLittle(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u24_le",
|
||||
"read unsigned 24 bit value, little endian"
|
||||
)]
|
||||
public uint ReadU24Little(object addr)
|
||||
public uint ReadU24Little(int addr)
|
||||
{
|
||||
return ReadSignedLittle(LuaInt(addr), 3);
|
||||
return ReadSignedLittle(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u32_le",
|
||||
"read unsigned 4 byte value, little endian"
|
||||
)]
|
||||
public uint ReadU32Little(object addr)
|
||||
public uint ReadU32Little(int addr)
|
||||
{
|
||||
return ReadSignedLittle(LuaInt(addr), 4);
|
||||
return ReadSignedLittle(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s16_be",
|
||||
"read signed 2 byte value, big endian"
|
||||
)]
|
||||
public int ReadS16Big(object addr)
|
||||
public int ReadS16Big(int addr)
|
||||
{
|
||||
return ReadSignedBig(LuaInt(addr), 2);
|
||||
return ReadSignedBig(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s24_be",
|
||||
"read signed 24 bit value, big endian"
|
||||
)]
|
||||
public int ReadS24Big(object addr)
|
||||
public int ReadS24Big(int addr)
|
||||
{
|
||||
return ReadSignedBig(LuaInt(addr), 3);
|
||||
return ReadSignedBig(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s32_be",
|
||||
"read signed 4 byte value, big endian"
|
||||
)]
|
||||
public int ReadS32Big(object addr)
|
||||
public int ReadS32Big(int addr)
|
||||
{
|
||||
return ReadSignedBig(LuaInt(addr), 4);
|
||||
return ReadSignedBig(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u16_be",
|
||||
"read unsigned 2 byte value, big endian"
|
||||
)]
|
||||
public uint ReadU16Big(object addr)
|
||||
public uint ReadU16Big(int addr)
|
||||
{
|
||||
return ReadUnsignedBig(LuaInt(addr), 2);
|
||||
return ReadUnsignedBig(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u24_be",
|
||||
"read unsigned 24 bit value, big endian"
|
||||
)]
|
||||
public uint ReadU24Big(object addr)
|
||||
public uint ReadU24Big(int addr)
|
||||
{
|
||||
return ReadUnsignedBig(LuaInt(addr), 3);
|
||||
return ReadUnsignedBig(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u32_be",
|
||||
"read unsigned 4 byte value, big endian"
|
||||
)]
|
||||
public uint ReadU32Big(object addr)
|
||||
public uint ReadU32Big(int addr)
|
||||
{
|
||||
return ReadUnsignedBig(LuaInt(addr), 4);
|
||||
return ReadUnsignedBig(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s8",
|
||||
"write signed byte"
|
||||
)]
|
||||
public void WriteS8(object addr, object value)
|
||||
public void WriteS8(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedByte(
|
||||
LuaInt(addr),
|
||||
(uint)LuaInt(value)
|
||||
);
|
||||
WriteUnsignedByte(addr, value);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u8",
|
||||
"write unsigned byte"
|
||||
)]
|
||||
public void WriteU8(object addr, object value)
|
||||
public void WriteU8(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedByte(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value)
|
||||
);
|
||||
WriteUnsignedByte(addr, value);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s16_le",
|
||||
"write signed 2 byte value, little endian"
|
||||
)]
|
||||
public void WriteS16Little(object addr, object value)
|
||||
public void WriteS16Little(int addr, int value)
|
||||
{
|
||||
WriteSignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
2);
|
||||
WriteSignedLittle(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s24_le",
|
||||
"write signed 24 bit value, little endian"
|
||||
)]
|
||||
public void WriteS24Little(object addr, object value)
|
||||
public void WriteS24Little(int addr, int value)
|
||||
{
|
||||
WriteSignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
3);
|
||||
WriteSignedLittle(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s32_le",
|
||||
"write signed 4 byte value, little endian"
|
||||
)]
|
||||
public void WriteS32Little(object addr, object value)
|
||||
public void WriteS32Little(int addr, int value)
|
||||
{
|
||||
WriteSignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
4);
|
||||
WriteSignedLittle(addr, value, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u16_le",
|
||||
"write unsigned 2 byte value, little endian"
|
||||
)]
|
||||
public void WriteU16Little(object addr, object value)
|
||||
public void WriteU16Little(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
2);
|
||||
WriteUnsignedLittle(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u24_le",
|
||||
"write unsigned 24 bit value, little endian"
|
||||
)]
|
||||
public void WriteU24Little(object addr, object value)
|
||||
public void WriteU24Little(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
3);
|
||||
WriteUnsignedLittle(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u32_le",
|
||||
"write unsigned 4 byte value, little endian"
|
||||
)]
|
||||
public void WriteU32Little(object addr, object value)
|
||||
public void WriteU32Little(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
4);
|
||||
WriteUnsignedLittle(addr, value, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s16_be",
|
||||
"write signed 2 byte value, big endian"
|
||||
)]
|
||||
public void WriteS16Big(object addr, object value)
|
||||
public void WriteS16Big(int addr, int value)
|
||||
{
|
||||
WriteSignedBig(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
2);
|
||||
WriteSignedBig(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s24_be",
|
||||
"write signed 24 bit value, big endian"
|
||||
)]
|
||||
public void WriteS24Big(object addr, object value)
|
||||
public void WriteS24Big(int addr, int value)
|
||||
{
|
||||
WriteSignedBig(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
3);
|
||||
WriteSignedBig(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s32_be",
|
||||
"write signed 4 byte value, big endian"
|
||||
)]
|
||||
public void WriteS32Big(object addr, object value)
|
||||
public void WriteS32Big(int addr, int value)
|
||||
{
|
||||
WriteSignedBig(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
4);
|
||||
WriteSignedBig(addr, value, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u16_be",
|
||||
"write unsigned 2 byte value, big endian"
|
||||
)]
|
||||
public void WriteU16Big(object addr, object value)
|
||||
public void WriteU16Big(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedBig(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
2);
|
||||
WriteUnsignedBig(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u24_be",
|
||||
"write unsigned 24 bit value, big endian"
|
||||
)]
|
||||
public void WriteU24Big(object addr, object value)
|
||||
public void WriteU24Big(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedBig(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
3);
|
||||
WriteUnsignedBig(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u32_be",
|
||||
"write unsigned 4 byte value, big endian"
|
||||
)]
|
||||
public void WriteU32Big(object addr, object value)
|
||||
public void WriteU32Big(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedBig(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
4);
|
||||
WriteUnsignedBig(addr, value, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,18 +120,18 @@ namespace BizHawk.Client.Common
|
|||
"readbyte",
|
||||
"gets the value from the given address as an unsigned byte"
|
||||
)]
|
||||
public uint ReadByte(object addr)
|
||||
public uint ReadByte(int addr)
|
||||
{
|
||||
return ReadUnsignedByte(LuaInt(addr));
|
||||
return ReadUnsignedByte(addr);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"readfloat",
|
||||
"Reads the given address as a 32-bit float value from the main memory domain with th e given endian"
|
||||
)]
|
||||
public float ReadFloat(object addr, bool bigendian)
|
||||
public float ReadFloat(int addr, bool bigendian)
|
||||
{
|
||||
var val = Global.Emulator.MemoryDomains[_currentMemoryDomain].PeekDWord(LuaInt(addr), bigendian);
|
||||
var val = Global.Emulator.MemoryDomains[_currentMemoryDomain].PeekDWord(addr, bigendian);
|
||||
var bytes = BitConverter.GetBytes(val);
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
@ -140,24 +140,21 @@ namespace BizHawk.Client.Common
|
|||
"writebyte",
|
||||
"Writes the given value to the given address as an unsigned byte"
|
||||
)]
|
||||
public void WriteByte(object addr, object value)
|
||||
public void WriteByte(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedByte(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value)
|
||||
);
|
||||
WriteUnsignedByte(addr, value);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"writefloat",
|
||||
"Writes the given 32-bit float value to the given address and endian"
|
||||
)]
|
||||
public void WriteFloat(object addr, object value, bool bigendian)
|
||||
public void WriteFloat(int addr, double value, bool bigendian)
|
||||
{
|
||||
var dv = (float)(double)value;
|
||||
var dv = (float)value;
|
||||
var bytes = BitConverter.GetBytes(dv);
|
||||
var v = BitConverter.ToUInt32(bytes, 0);
|
||||
Global.Emulator.MemoryDomains[_currentMemoryDomain].PokeDWord(LuaInt(addr), v, bigendian);
|
||||
Global.Emulator.MemoryDomains[_currentMemoryDomain].PokeDWord(addr, v, bigendian);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
|
@ -182,294 +179,252 @@ namespace BizHawk.Client.Common
|
|||
"read_s8",
|
||||
"read signed byte"
|
||||
)]
|
||||
public int ReadS8(object addr)
|
||||
public int ReadS8(int addr)
|
||||
{
|
||||
return (sbyte)ReadUnsignedByte(LuaInt(addr));
|
||||
return (sbyte)ReadUnsignedByte(addr);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u8",
|
||||
"read unsigned byte"
|
||||
)]
|
||||
public uint ReadU8(object addr)
|
||||
public uint ReadU8(int addr)
|
||||
{
|
||||
return ReadUnsignedByte(LuaInt(addr));
|
||||
return ReadUnsignedByte(addr);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s16_le",
|
||||
"read signed 2 byte value, little endian"
|
||||
)]
|
||||
public int ReadS16Little(object addr)
|
||||
public int ReadS16Little(int addr)
|
||||
{
|
||||
return ReadSignedLittleCore(LuaInt(addr), 2);
|
||||
return ReadSignedLittleCore(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s24_le",
|
||||
"read signed 24 bit value, little endian"
|
||||
)]
|
||||
public int ReadS24Little(object addr)
|
||||
public int ReadS24Little(int addr)
|
||||
{
|
||||
return ReadSignedLittleCore(LuaInt(addr), 3);
|
||||
return ReadSignedLittleCore(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s32_le",
|
||||
"read signed 4 byte value, little endian"
|
||||
)]
|
||||
public int ReadS32Little(object addr)
|
||||
public int ReadS32Little(int addr)
|
||||
{
|
||||
return ReadSignedLittleCore(LuaInt(addr), 4);
|
||||
return ReadSignedLittleCore(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u16_le",
|
||||
"read unsigned 2 byte value, little endian"
|
||||
)]
|
||||
public uint ReadU16Little(object addr)
|
||||
public uint ReadU16Little(int addr)
|
||||
{
|
||||
return ReadUnsignedLittle(LuaInt(addr), 2);
|
||||
return ReadUnsignedLittle(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u24_le",
|
||||
"read unsigned 24 bit value, little endian"
|
||||
)]
|
||||
public uint ReadU24Little(object addr)
|
||||
public uint ReadU24Little(int addr)
|
||||
{
|
||||
return ReadUnsignedLittle(LuaInt(addr), 3);
|
||||
return ReadUnsignedLittle(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u32_le",
|
||||
"read unsigned 4 byte value, little endian"
|
||||
)]
|
||||
public uint ReadU32Little(object addr)
|
||||
public uint ReadU32Little(int addr)
|
||||
{
|
||||
return ReadUnsignedLittle(LuaInt(addr), 4);
|
||||
return ReadUnsignedLittle(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s16_be",
|
||||
"read signed 2 byte value, big endian"
|
||||
)]
|
||||
public int ReadS16Big(object addr)
|
||||
public int ReadS16Big(int addr)
|
||||
{
|
||||
return ReadSignedBig(LuaInt(addr), 2);
|
||||
return ReadSignedBig(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s24_be",
|
||||
"read signed 24 bit value, big endian"
|
||||
)]
|
||||
public int ReadS24Big(object addr)
|
||||
public int ReadS24Big(int addr)
|
||||
{
|
||||
return ReadSignedBig(LuaInt(addr), 3);
|
||||
return ReadSignedBig(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_s32_be",
|
||||
"read signed 4 byte value, big endian"
|
||||
)]
|
||||
public int ReadS32Big(object addr)
|
||||
public int ReadS32Big(int addr)
|
||||
{
|
||||
return ReadSignedBig(LuaInt(addr), 4);
|
||||
return ReadSignedBig(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u16_be",
|
||||
"read unsigned 2 byte value, big endian"
|
||||
)]
|
||||
public uint ReadU16Big(object addr)
|
||||
public uint ReadU16Big(int addr)
|
||||
{
|
||||
return ReadUnsignedBig(LuaInt(addr), 2);
|
||||
return ReadUnsignedBig(addr, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"read_u24_be",
|
||||
"read unsigned 24 bit value, big endian"
|
||||
)]
|
||||
public uint ReadU24Big(object addr)
|
||||
public uint ReadU24Big(int addr)
|
||||
{
|
||||
return ReadUnsignedBig(LuaInt(addr), 3);
|
||||
return ReadUnsignedBig(addr, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"u32_be",
|
||||
"read unsigned 4 byte value, big endian"
|
||||
)]
|
||||
public uint ReadU32Big(object addr)
|
||||
public uint ReadU32Big(int addr)
|
||||
{
|
||||
return ReadUnsignedBig(LuaInt(addr), 4);
|
||||
return ReadUnsignedBig(addr, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s8",
|
||||
"write signed byte"
|
||||
)]
|
||||
public void WriteS8(object addr, object value)
|
||||
public void WriteS8(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedByte(
|
||||
LuaInt(addr),
|
||||
(uint)LuaInt(value)
|
||||
);
|
||||
WriteUnsignedByte(addr, value);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s8",
|
||||
"write unsigned byte"
|
||||
)]
|
||||
public void WriteU8(object addr, object value)
|
||||
public void WriteU8(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedByte(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value)
|
||||
);
|
||||
WriteUnsignedByte(addr, value);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s16_le",
|
||||
"write signed 2 byte value, little endian"
|
||||
)]
|
||||
public void WriteS16Little(object addr, object value)
|
||||
public void WriteS16Little(int addr, int value)
|
||||
{
|
||||
WriteSignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
2);
|
||||
WriteSignedLittle(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s24_le",
|
||||
"write signed 24 bit value, little endian"
|
||||
)]
|
||||
public void WriteS24Little(object addr, object value)
|
||||
public void WriteS24Little(int addr, int value)
|
||||
{
|
||||
WriteSignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
3);
|
||||
WriteSignedLittle(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s32_le",
|
||||
"write signed 4 byte value, little endian"
|
||||
)]
|
||||
public void WriteS32Little(object addr, object value)
|
||||
public void WriteS32Little(int addr, int value)
|
||||
{
|
||||
WriteSignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
4);
|
||||
WriteSignedLittle(addr, value, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u16_le",
|
||||
"write unsigned 2 byte value, little endian"
|
||||
)]
|
||||
public void WriteU16Little(object addr, object value)
|
||||
public void WriteU16Little(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
2);
|
||||
WriteUnsignedLittle(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u24_le",
|
||||
"write unsigned 24 bit value, little endian"
|
||||
)]
|
||||
public void WriteU24Little(object addr, object value)
|
||||
public void WriteU24Little(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
3);
|
||||
WriteUnsignedLittle(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u32_le",
|
||||
"write unsigned 4 byte value, little endian"
|
||||
)]
|
||||
public void WriteU32Little(object addr, object value)
|
||||
public void WriteU32Little(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedLittle(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
4);
|
||||
WriteUnsignedLittle(addr, value, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s16_be",
|
||||
"write signed 2 byte value, big endian"
|
||||
)]
|
||||
public void WriteS16Big(object addr, object value)
|
||||
public void WriteS16Big(int addr, int value)
|
||||
{
|
||||
WriteSignedBig(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
2);
|
||||
WriteSignedBig(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s24_be",
|
||||
"write signed 24 bit value, big endian"
|
||||
)]
|
||||
public void WriteS24Big(object addr, object value)
|
||||
public void WriteS24Big(int addr, int value)
|
||||
{
|
||||
WriteSignedBig(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
3);
|
||||
WriteSignedBig(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_s32_be",
|
||||
"write signed 4 byte value, big endian"
|
||||
)]
|
||||
public void WriteS32Big(object addr, object value)
|
||||
public void WriteS32Big(int addr, int value)
|
||||
{
|
||||
WriteSignedBig(
|
||||
LuaInt(addr),
|
||||
LuaInt(value),
|
||||
4);
|
||||
WriteSignedBig(addr, value, 4);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u16_be",
|
||||
"write unsigned 2 byte value, big endian"
|
||||
)]
|
||||
public void WriteU16Big(object addr, object value)
|
||||
public void WriteU16Big(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedBig(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
2);
|
||||
WriteUnsignedBig(addr, value, 2);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u24_be",
|
||||
"write unsigned 24 bit value, big endian"
|
||||
)]
|
||||
public void WriteU24Big(object addr, object value)
|
||||
public void WriteU24Big(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedBig(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
3);
|
||||
WriteUnsignedBig(addr, value, 3);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write_u32_be",
|
||||
"write unsigned 4 byte value, big endian"
|
||||
)]
|
||||
public void WriteU32Big(object addr, object value)
|
||||
public void WriteU32Big(int addr, uint value)
|
||||
{
|
||||
WriteUnsignedBig(
|
||||
LuaInt(addr),
|
||||
LuaUInt(value),
|
||||
4);
|
||||
WriteUnsignedBig(addr, value, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ namespace BizHawk.Client.Common
|
|||
"getinput",
|
||||
"Returns a table of buttons pressed on a given frame of the loaded movie"
|
||||
)]
|
||||
public LuaTable GetInput(object frame)
|
||||
public LuaTable GetInput(int frame)
|
||||
{
|
||||
var input = _lua.NewTable();
|
||||
|
||||
var m = new MovieControllerAdapter { Type = Global.MovieSession.MovieControllerAdapter.Type };
|
||||
m.SetControllersAsMnemonic(
|
||||
Global.MovieSession.Movie.GetInput(LuaInt(frame))
|
||||
Global.MovieSession.Movie.GetInput(frame)
|
||||
);
|
||||
|
||||
foreach (var button in m.Type.BoolButtons)
|
||||
|
|
|
@ -179,41 +179,39 @@ namespace BizHawk.Client.Common
|
|||
"setscanlines",
|
||||
"sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239"
|
||||
)]
|
||||
public static void SetScanlines(object top, object bottom, bool pal = false)
|
||||
public static void SetScanlines(int top, int bottom, bool pal = false)
|
||||
{
|
||||
if (Global.Emulator is NES)
|
||||
{
|
||||
var first = LuaInt(top);
|
||||
var last = LuaInt(bottom);
|
||||
if (first > 127)
|
||||
if (top > 127)
|
||||
{
|
||||
first = 127;
|
||||
top = 127;
|
||||
}
|
||||
else if (first < 0)
|
||||
else if (top < 0)
|
||||
{
|
||||
first = 0;
|
||||
top = 0;
|
||||
}
|
||||
|
||||
if (last > 239)
|
||||
if (bottom > 239)
|
||||
{
|
||||
last = 239;
|
||||
bottom = 239;
|
||||
}
|
||||
else if (last < 128)
|
||||
else if (bottom < 128)
|
||||
{
|
||||
last = 128;
|
||||
bottom = 128;
|
||||
}
|
||||
|
||||
var s = (NES.NESSettings)Global.Emulator.GetSettings();
|
||||
|
||||
if (pal)
|
||||
{
|
||||
s.PAL_TopLine = first;
|
||||
s.PAL_BottomLine = last;
|
||||
s.PAL_TopLine = top;
|
||||
s.PAL_BottomLine = bottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.NTSC_TopLine = first;
|
||||
s.NTSC_BottomLine = last;
|
||||
s.NTSC_TopLine = top;
|
||||
s.NTSC_BottomLine = bottom;
|
||||
}
|
||||
|
||||
Global.Emulator.PutSettings(s);
|
||||
|
|
|
@ -86,18 +86,18 @@ namespace BizHawk.Client.Common
|
|||
"substring",
|
||||
"Returns a string that represents a substring of str starting at position for the specified length"
|
||||
)]
|
||||
public static string SubString(string str, object position, object length)
|
||||
public static string SubString(string str, int position, int length)
|
||||
{
|
||||
return str.Substring((int)position, (int)length);
|
||||
return str.Substring(position, length);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"remove",
|
||||
"Returns a string that represents str with the given position and count removed"
|
||||
)]
|
||||
public static string Remove(string str, object position, object count)
|
||||
public static string Remove(string str, int position, int count)
|
||||
{
|
||||
return str.Remove((int)position, (int)count);
|
||||
return str.Remove(position, count);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
|
|
Loading…
Reference in New Issue