Debugger: Lua - Added getPrgRomOffset/getChrRomOffset functions

This commit is contained in:
Sour 2018-07-29 12:08:28 -04:00
parent d65261d990
commit f708b2a2cc
2 changed files with 28 additions and 0 deletions

View File

@ -63,6 +63,8 @@ int LuaApi::GetLibrary(lua_State *lua)
{ "write", LuaApi::WriteMemory },
{ "readWord", LuaApi::ReadMemoryWord },
{ "writeWord", LuaApi::WriteMemoryWord },
{ "getPrgRomOffset", LuaApi::GetPrgRomOffset },
{ "getChrRomOffset", LuaApi::GetChrRomOffset },
{ "revertPrgChrChanges", LuaApi::RevertPrgChrChanges },
{ "addMemoryCallback", LuaApi::RegisterMemoryCallback },
{ "removeMemoryCallback", LuaApi::UnregisterMemoryCallback },
@ -236,6 +238,30 @@ int LuaApi::WriteMemoryWord(lua_State *lua)
return l.ReturnCount();
}
int LuaApi::GetPrgRomOffset(lua_State *lua)
{
LuaCallHelper l(lua);
int address = l.ReadInteger();
checkminparams(1);
errorCond(address < 0 || address > 0xFFFF, "address must be between 0 and $FFFF");
int32_t prgRomOffset = _debugger->GetAbsoluteAddress((uint32_t)address);
l.Return(prgRomOffset);
return l.ReturnCount();
}
int LuaApi::GetChrRomOffset(lua_State *lua)
{
LuaCallHelper l(lua);
int address = l.ReadInteger();
checkminparams(1);
errorCond(address < 0 || address > 0x3FFF, "address must be between 0 and $3FFF");
int32_t chrRomOffset = _debugger->GetAbsoluteChrAddress((uint32_t)address);
l.Return(chrRomOffset);
return l.ReturnCount();
}
int LuaApi::RevertPrgChrChanges(lua_State *lua)
{
LuaCallHelper l(lua);

View File

@ -20,6 +20,8 @@ public:
static int WriteMemory(lua_State *lua);
static int ReadMemoryWord(lua_State *lua);
static int WriteMemoryWord(lua_State *lua);
static int GetPrgRomOffset(lua_State *lua);
static int GetChrRomOffset(lua_State *lua);
static int RevertPrgChrChanges(lua_State *lua);
static int RegisterMemoryCallback(lua_State *lua);