mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
Lua: Add Teak disassembler
This commit is contained in:
parent
eab1a12b07
commit
27828b1351
1 changed files with 13 additions and 0 deletions
13
src/lua.cpp
13
src/lua.cpp
|
@ -1,4 +1,6 @@
|
||||||
#ifdef PANDA3DS_ENABLE_LUA
|
#ifdef PANDA3DS_ENABLE_LUA
|
||||||
|
#include <teakra/disassembler.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "capstone.hpp"
|
#include "capstone.hpp"
|
||||||
|
@ -227,6 +229,15 @@ static int disassembleARMThunk(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int disassembleTeakThunk(lua_State* L) {
|
||||||
|
const u16 instruction = u16(lua_tonumber(L, 1));
|
||||||
|
const u16 expansion = u16(lua_tonumber(L, 2));
|
||||||
|
|
||||||
|
std::string disassembly = Teakra::Disassembler::Do(instruction, expansion);
|
||||||
|
lua_pushstring(L, disassembly.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static constexpr luaL_Reg functions[] = {
|
static constexpr luaL_Reg functions[] = {
|
||||||
{ "__read8", read8Thunk },
|
{ "__read8", read8Thunk },
|
||||||
|
@ -246,6 +257,7 @@ static constexpr luaL_Reg functions[] = {
|
||||||
{ "__getCirclepad", getCirclepadThunk },
|
{ "__getCirclepad", getCirclepadThunk },
|
||||||
{ "__getButton", getButtonThunk },
|
{ "__getButton", getButtonThunk },
|
||||||
{ "__disassembleARM", disassembleARMThunk },
|
{ "__disassembleARM", disassembleARMThunk },
|
||||||
|
{ "__disassembleTeak", disassembleTeakThunk },
|
||||||
{ nullptr, nullptr },
|
{ nullptr, nullptr },
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -280,6 +292,7 @@ void LuaManager::initializeThunks() {
|
||||||
getCirclepad = function() return GLOBALS.__getCirclepad() end,
|
getCirclepad = function() return GLOBALS.__getCirclepad() end,
|
||||||
|
|
||||||
disassembleARM = function(pc, instruction) return GLOBALS.__disassembleARM(pc, instruction) end,
|
disassembleARM = function(pc, instruction) return GLOBALS.__disassembleARM(pc, instruction) end,
|
||||||
|
disassembleTeak = function(opcode, exp) return GLOBALS.__disassembleTeak(opcode, exp or 0) end,
|
||||||
|
|
||||||
Frame = __Frame,
|
Frame = __Frame,
|
||||||
ButtonA = __ButtonA,
|
ButtonA = __ButtonA,
|
||||||
|
|
Loading…
Add table
Reference in a new issue