LUA: update documentation of readbyterange to reflect what it actually does. Add readbyterangetable which allows the user to select the starting index to any desired value. Resolves #2844
This commit is contained in:
parent
21b2d40832
commit
d784e9c00c
|
@ -47,9 +47,13 @@ namespace BizHawk.Client.Common
|
||||||
public void WriteByte(long addr, uint value, string domain = null) => APIs.Memory.WriteByte(addr, value, domain);
|
public void WriteByte(long addr, uint value, string domain = null) => APIs.Memory.WriteByte(addr, value, domain);
|
||||||
|
|
||||||
[LuaMethodExample("local nlmemrea = memory.readbyterange( 0x100, 30, mainmemory.getname( ) );")]
|
[LuaMethodExample("local nlmemrea = memory.readbyterange( 0x100, 30, mainmemory.getname( ) );")]
|
||||||
[LuaMethod("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).")]
|
[LuaMethod("readbyterange", "Reads the address range that starts from address, and is length long. Returns a zero-indexed table containing the read values (an array of bytes.)")]
|
||||||
public LuaTable ReadByteRange(long addr, int length, string domain = null) => _th.ListToTable(APIs.Memory.ReadByteRange(addr, length, domain));
|
public LuaTable ReadByteRange(long addr, int length, string domain = null) => _th.ListToTable(APIs.Memory.ReadByteRange(addr, length, domain));
|
||||||
|
|
||||||
|
[LuaMethodExample("local nlmemrea = memory.readbyterangetable( 0x100, 30, mainmemory.getname( ) );")]
|
||||||
|
[LuaMethod("readbyterangetable", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the index is the first key.)")]
|
||||||
|
public LuaTable ReadByteRangeTable(long addr, int length, long index, string domain = null) => _th.ListToTable(APIs.Memory.ReadByteRange(addr, length, domain), index);
|
||||||
|
|
||||||
/// <remarks>TODO C# version requires a contiguous address range</remarks>
|
/// <remarks>TODO C# version requires a contiguous address range</remarks>
|
||||||
[LuaMethodExample("")]
|
[LuaMethodExample("")]
|
||||||
[LuaMethod("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
|
[LuaMethod("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
|
||||||
|
|
|
@ -44,9 +44,13 @@ namespace BizHawk.Client.Common
|
||||||
public void WriteByte(long addr, uint value) => APIs.Memory.WriteByte(addr, value, MainMemName);
|
public void WriteByte(long addr, uint value) => APIs.Memory.WriteByte(addr, value, MainMemName);
|
||||||
|
|
||||||
[LuaMethodExample("local nlmairea = mainmemory.readbyterange( 0x100, 64 );")]
|
[LuaMethodExample("local nlmairea = mainmemory.readbyterange( 0x100, 64 );")]
|
||||||
[LuaMethod("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).")]
|
[LuaMethod("readbyterange", "Reads the address range that starts from address, and is length long. Returns a zero-indexed table containing the read values (an array of bytes.)")]
|
||||||
public LuaTable ReadByteRange(long addr, int length) => _th.ListToTable(APIs.Memory.ReadByteRange(addr, length, MainMemName));
|
public LuaTable ReadByteRange(long addr, int length) => _th.ListToTable(APIs.Memory.ReadByteRange(addr, length, MainMemName));
|
||||||
|
|
||||||
|
[LuaMethodExample("local nlmairea = mainmemory.readbyterangetable( 0x100, 0x100, 64 );")]
|
||||||
|
[LuaMethod("readbyterangetable", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the index is the first key.)")]
|
||||||
|
public LuaTable ReadByteRangeTable(long addr, int length, long index) => _th.ListToTable(APIs.Memory.ReadByteRange(addr, length), index);
|
||||||
|
|
||||||
/// <remarks>TODO C# version requires a contiguous address range</remarks>
|
/// <remarks>TODO C# version requires a contiguous address range</remarks>
|
||||||
[LuaMethodExample("")]
|
[LuaMethodExample("")]
|
||||||
[LuaMethod("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
|
[LuaMethod("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public IEnumerable<T> EnumerateValues<T>(LuaTable table) => table.Values.Cast<T>();
|
public IEnumerable<T> EnumerateValues<T>(LuaTable table) => table.Values.Cast<T>();
|
||||||
|
|
||||||
public LuaTable ListToTable<T>(IList<T> list, int indexFrom = 0)
|
public LuaTable ListToTable<T>(IList<T> list, long indexFrom = 0)
|
||||||
{
|
{
|
||||||
var table = _lua.NewTable();
|
var table = _lua.NewTable();
|
||||||
for (int i = 0, l = list.Count; i != l; i++) table[indexFrom + i] = list[i];
|
for (int i = 0, l = list.Count; i != l; i++) table[indexFrom + i] = list[i];
|
||||||
|
|
Loading…
Reference in New Issue