diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs index 64ae7bc911..bf1248d56f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs @@ -30,10 +30,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public string Disassemble(MemoryDomain m, uint addr, out int length) { length = 4; // TODO: is this right? - var instruction = m.PeekWord(addr, true); + var instruction = m.PeekDWord(addr, true); - var result = api.m64p_decode_op((uint)instruction, (int)addr); - var strResult = Marshal.PtrToStringAnsi(result); + //TODO - reserve buffer here for disassembling into. allocating repeatedly will be slower + var result = api.m64p_decode_op(instruction, addr); + string strResult = Marshal.PtrToStringAnsi(result); return strResult; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs index 7a7d64a359..13788635fe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs @@ -265,8 +265,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi delegate m64p_error CoreDoCommandRenderCallback(m64p_command Command, int ParamInt, RenderCallback ParamPtr); CoreDoCommandRenderCallback m64pCoreDoCommandRenderCallback; + //WARNING - RETURNS A STATIC BUFFER [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr biz_r4300_decode_op(uint instr, int counter); + public delegate IntPtr biz_r4300_decode_op(uint instr, uint counter); public biz_r4300_decode_op m64p_decode_op; /// diff --git a/libmupen64plus/mupen64plus-core/src/debugger/dbg_decoder.c b/libmupen64plus/mupen64plus-core/src/debugger/dbg_decoder.c index 7bda6d91b9..59d8340aec 100644 --- a/libmupen64plus/mupen64plus-core/src/debugger/dbg_decoder.c +++ b/libmupen64plus/mupen64plus-core/src/debugger/dbg_decoder.c @@ -799,27 +799,20 @@ r4k_disassemble_split_quick ( uint32_t instruction, #include "api/m64p_types.h" -EXPORT char* CALL biz_r4300_decode_op(uint32 instr, int counter) +//WARNING - RETURNS A STATIC BUFFER +EXPORT char* CALL biz_r4300_decode_op(uint32 instr, uint32 counter) { - char * _final; - char * _op, * _args; - - _op = NULL; - _args = NULL; - _final = NULL; - - r4k_disassemble_split_quick( - instr, - counter, - &_op, - &_args - ); + static char tmp[128]; + static struct r4k_dis_t state; + memset( &state, 0, sizeof(state) ); + r4k_disassemble( + &state, + instr, + counter, + tmp + ); - - //free( _op ); - strcat(_op, " "); - strcat(_op, _args); - return _op; + return tmp; } //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[ DECODE_OP ]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[//