diff --git a/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs b/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs
index 9cc0587be9..062dd992ad 100644
--- a/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs
+++ b/src/BizHawk.Client.Common/Api/Classes/EmulationApi.cs
@@ -73,25 +73,23 @@ namespace BizHawk.Client.Common
public int FrameCount()
=> Emulator!.Frame;
- public object? Disassemble(uint pc, string? name = null)
+ public (string Disasm, int Length) Disassemble(uint pc, string? name = null)
{
try
{
if (DisassemblableCore != null)
{
- return new {
- disasm = DisassemblableCore.Disassemble(
- string.IsNullOrEmpty(name) ? MemoryDomains!.SystemBus : MemoryDomains![name!]!,
- pc,
- out var l
- ),
- length = l
- };
+ var disasm = DisassemblableCore.Disassemble(
+ string.IsNullOrEmpty(name) ? MemoryDomains!.SystemBus : MemoryDomains![name!]!,
+ pc,
+ out var l
+ );
+ return (disasm, l);
}
}
catch (NotImplementedException) {}
LogCallback($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDisassemblable.Disassemble)}()");
- return null;
+ return (string.Empty, 0);
}
public ulong? GetRegister(string name)
diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs
index 177c73223a..885706661e 100644
--- a/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs
+++ b/src/BizHawk.Client.Common/Api/Interfaces/IEmulationApi.cs
@@ -10,7 +10,10 @@ namespace BizHawk.Client.Common
{
void DisplayVsync(bool enabled);
int FrameCount();
- object? Disassemble(uint pc, string? name = null);
+
+ /// disassembly and opcode width, or (string.Empty, 0) on failure
+ (string Disasm, int Length) Disassemble(uint pc, string? name = null);
+
ulong? GetRegister(string name);
IReadOnlyDictionary GetRegisters();
void SetRegister(string register, int value);
diff --git a/src/BizHawk.Client.Common/lua/CommonLibs/EmulationLuaLibrary.cs b/src/BizHawk.Client.Common/lua/CommonLibs/EmulationLuaLibrary.cs
index 898970d1af..dfa3b314cd 100644
--- a/src/BizHawk.Client.Common/lua/CommonLibs/EmulationLuaLibrary.cs
+++ b/src/BizHawk.Client.Common/lua/CommonLibs/EmulationLuaLibrary.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.ComponentModel;
using NLua;
@@ -38,8 +39,15 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local obemudis = emu.disassemble( 0x8000 );")]
[LuaMethod("disassemble", "Returns the disassembly object (disasm string and length int) for the given PC address. Uses System Bus domain if no domain name provided")]
[return: LuaASCIIStringParam]
- public object Disassemble(uint pc, [LuaASCIIStringParam] string name = "")
- => APIs.Emulation.Disassemble(pc, name);
+ public LuaTable Disassemble(uint pc, [LuaASCIIStringParam] string name = "")
+ {
+ var (disasm, length) = APIs.Emulation.Disassemble(pc, name);
+ if (length is 0) return null;
+ var table = _th.CreateTable();
+ table["disasm"] = disasm;
+ table["length"] = length;
+ return table;
+ }
// TODO: what about 64 bit registers?
[LuaMethodExample("local inemuget = emu.getregister( emu.getregisters( )[ 0 ] );")]