implement memory.readbyterange() and memory.writebyterange(), these were in the mainmemory library but how did they manage to never be implemented in the memory library?
This commit is contained in:
parent
059952f0a4
commit
e1a5123dcf
|
@ -112,6 +112,39 @@ namespace BizHawk.Client.Common
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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(int addr, int length)
|
||||||
|
{
|
||||||
|
var lastAddr = length + addr;
|
||||||
|
var table = _lua.NewTable();
|
||||||
|
for (var i = addr; i <= lastAddr; i++)
|
||||||
|
{
|
||||||
|
var a = string.Format("{0:X2}", i);
|
||||||
|
var v = Global.Emulator.MemoryDomains[_currentMemoryDomain].PeekByte(i);
|
||||||
|
var vs = string.Format("{0:X2}", (int)v);
|
||||||
|
table[a] = vs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
[LuaMethodAttributes(
|
||||||
|
"writebyterange",
|
||||||
|
"Writes the given values to the given addresses as unsigned bytes"
|
||||||
|
)]
|
||||||
|
public void WriteByteRange(LuaTable memoryblock)
|
||||||
|
{
|
||||||
|
foreach (var address in memoryblock.Keys)
|
||||||
|
{
|
||||||
|
Global.Emulator.MemoryDomains[_currentMemoryDomain].PokeByte(
|
||||||
|
LuaInt(address),
|
||||||
|
(byte)LuaInt(memoryblock[address]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
"getcurrentmemorydomain",
|
"getcurrentmemorydomain",
|
||||||
"Returns a string name of the current memory domain selected by Lua. The default is Main memory"
|
"Returns a string name of the current memory domain selected by Lua. The default is Main memory"
|
||||||
|
|
Loading…
Reference in New Issue