gba: tracelog
This commit is contained in:
parent
81146fde8e
commit
08d4319ad3
|
@ -462,6 +462,7 @@
|
|||
<Compile Include="CPUs\68000\Memory.cs" />
|
||||
<Compile Include="CPUs\68000\OpcodeTable.cs" />
|
||||
<Compile Include="CPUs\68000\Tables.cs" />
|
||||
<Compile Include="CPUs\ARM\Darm.cs" />
|
||||
<Compile Include="CPUs\CP1610\CP1610.cs" />
|
||||
<Compile Include="CPUs\CP1610\Disassembler.cs" />
|
||||
<Compile Include="CPUs\CP1610\Execute.cs" />
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Components.ARM
|
||||
{
|
||||
public class Darm
|
||||
{
|
||||
public const string dllname = "libdarm.dll";
|
||||
public const CallingConvention cc = CallingConvention.Cdecl;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class Darm_T
|
||||
{
|
||||
public uint w;
|
||||
public uint instr;
|
||||
public uint instr_type;
|
||||
public uint instr_imm_type;
|
||||
public uint instr_flag_type;
|
||||
public uint cond;
|
||||
public uint B;
|
||||
public uint S;
|
||||
public uint E;
|
||||
public uint M;
|
||||
public uint N;
|
||||
public uint option;
|
||||
public uint U;
|
||||
public uint H;
|
||||
public uint P;
|
||||
public uint R;
|
||||
public uint T;
|
||||
public uint W;
|
||||
public uint I;
|
||||
public uint rotate;
|
||||
public uint Rd;
|
||||
public uint Rn;
|
||||
public uint Rm;
|
||||
public uint Ra;
|
||||
public uint Rt;
|
||||
public uint Rt2;
|
||||
public uint RdHi;
|
||||
public uint RdLo;
|
||||
public uint imm;
|
||||
public uint sat_imm;
|
||||
public uint shift_type;
|
||||
public uint Rs;
|
||||
public uint shift;
|
||||
public uint lsb;
|
||||
public uint msb;
|
||||
public uint width;
|
||||
public ushort reglist;
|
||||
public byte coproc;
|
||||
public byte opc1;
|
||||
public byte opc2;
|
||||
public uint CRd;
|
||||
public uint CRn;
|
||||
public uint Crm;
|
||||
public uint D;
|
||||
public uint firstcond;
|
||||
public byte mask;
|
||||
// just in case we got something wrong, padding
|
||||
public uint Pad1;
|
||||
public uint Pad2;
|
||||
public uint Pad3;
|
||||
public uint Pad4;
|
||||
public uint Pad5;
|
||||
public uint Pad6;
|
||||
public uint Pad7;
|
||||
public uint Pad8;
|
||||
public uint Pad9;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class Darm_Str_T
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
||||
public byte[] mnemonic = new byte[12];
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6 * 32)]
|
||||
public byte[,] arg = new byte[6, 32];
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
||||
public byte[] shift = new byte[12];
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
public byte[] total = new byte[64];
|
||||
}
|
||||
|
||||
[DllImport(dllname, CallingConvention = cc, EntryPoint = "darm_disasm")]
|
||||
public static extern bool Disassemble([Out] Darm_T d, ushort w, ushort w2, uint addr);
|
||||
|
||||
[DllImport(dllname, CallingConvention = cc, EntryPoint = "darm_str2")]
|
||||
public static extern bool Str([In] [Out]Darm_T d, [Out]Darm_Str_T s, bool lowercase);
|
||||
|
||||
public static string DisassembleStuff(uint addr, uint opcode)
|
||||
{
|
||||
var d = new Darm_T();
|
||||
var s = new Darm_Str_T();
|
||||
if (!Disassemble(d, (ushort)opcode, (ushort)(opcode >> 16), addr))
|
||||
return null;
|
||||
if (Str(d, s, false))
|
||||
return null;
|
||||
return Encoding.ASCII.GetString(s.total);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -79,7 +79,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
InitCallbacks();
|
||||
|
||||
CoreComm.CpuTraceAvailable = true;
|
||||
CoreComm.TraceHeader = "--ADDR-- ---OP---";
|
||||
|
||||
// todo: hook me up as a setting
|
||||
SetupColors();
|
||||
|
@ -271,13 +270,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
LibVBANext.AddressCallback writecb;
|
||||
LibVBANext.TraceCallback tracecb;
|
||||
|
||||
string Trace(uint addr, uint opcode)
|
||||
{
|
||||
return
|
||||
string.Format("{0:x8} {1}",
|
||||
opcode,
|
||||
Emulation.Cores.Components.ARM.Darm.DisassembleStuff(addr, opcode));
|
||||
}
|
||||
|
||||
void InitCallbacks()
|
||||
{
|
||||
padcb = new LibVBANext.StandardCallback(() => CoreComm.InputCallback.Call());
|
||||
fetchcb = new LibVBANext.AddressCallback((addr) => CoreComm.MemoryCallbackSystem.CallExecute(addr));
|
||||
readcb = new LibVBANext.AddressCallback((addr) => CoreComm.MemoryCallbackSystem.CallRead(addr));
|
||||
writecb = new LibVBANext.AddressCallback((addr) => CoreComm.MemoryCallbackSystem.CallWrite(addr));
|
||||
tracecb = new LibVBANext.TraceCallback((addr, opcode) => CoreComm.Tracer.Put(string.Format("{0:x8} {1:x8}", addr, opcode)));
|
||||
tracecb = new LibVBANext.TraceCallback((addr, opcode) => CoreComm.Tracer.Put(Trace(addr, opcode)));
|
||||
}
|
||||
|
||||
void SyncCallbacks()
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue