fix n64 disasm pinvoke

This commit is contained in:
zeromus 2015-01-23 20:28:47 +00:00
parent 29b056b972
commit 8d340a7c19
3 changed files with 18 additions and 23 deletions

View File

@ -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;
}

View File

@ -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;
/// <summary>

View File

@ -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 ]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=[//