2016-08-09 17:03:23 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
2017-07-09 14:21:03 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
2016-08-09 17:03:23 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class GPGX : IDebuggable
|
|
|
|
|
{
|
|
|
|
|
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
|
|
|
|
{
|
2016-08-10 19:27:46 +00:00
|
|
|
|
LibGPGX.RegisterInfo[] regs = new LibGPGX.RegisterInfo[Core.gpgx_getmaxnumregs()];
|
2016-08-09 17:03:23 +00:00
|
|
|
|
|
2016-08-10 19:27:46 +00:00
|
|
|
|
int n = Core.gpgx_getregs(regs);
|
2016-08-09 17:03:23 +00:00
|
|
|
|
if (n > regs.Length)
|
|
|
|
|
throw new InvalidOperationException("A buffer overrun has occured!");
|
|
|
|
|
var ret = new Dictionary<string, RegisterValue>();
|
|
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
|
{
|
|
|
|
|
// el hacko
|
|
|
|
|
string name = Marshal.PtrToStringAnsi(regs[i].Name);
|
|
|
|
|
byte size = 32;
|
|
|
|
|
if (name.Contains("68K SR") || name.StartsWith("Z80"))
|
|
|
|
|
size = 16;
|
|
|
|
|
|
|
|
|
|
ret[name] = new RegisterValue((ulong)regs[i].Value, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[FeatureNotImplemented]
|
|
|
|
|
public void SetCpuRegister(string register, int value)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IMemoryCallbackSystem MemoryCallbacks
|
|
|
|
|
{
|
|
|
|
|
get { return _memoryCallbacks; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanStep(StepType type) { return false; }
|
|
|
|
|
|
|
|
|
|
[FeatureNotImplemented]
|
|
|
|
|
public void Step(StepType type) { throw new NotImplementedException(); }
|
|
|
|
|
|
2017-01-10 01:23:05 +00:00
|
|
|
|
[FeatureNotImplemented]
|
2018-05-12 16:55:42 +00:00
|
|
|
|
public long TotalExecutedCycles
|
2017-01-10 01:23:05 +00:00
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-30 03:33:26 +00:00
|
|
|
|
private readonly MemoryCallbackSystem _memoryCallbacks = new MemoryCallbackSystem(new[] { "M68K BUS", "" });
|
2016-08-09 17:03:23 +00:00
|
|
|
|
|
|
|
|
|
private LibGPGX.mem_cb ExecCallback;
|
|
|
|
|
private LibGPGX.mem_cb ReadCallback;
|
|
|
|
|
private LibGPGX.mem_cb WriteCallback;
|
|
|
|
|
private LibGPGX.CDCallback CDCallback;
|
|
|
|
|
|
|
|
|
|
private void InitMemCallbacks()
|
|
|
|
|
{
|
2019-06-06 09:04:47 +00:00
|
|
|
|
ExecCallback = new LibGPGX.mem_cb(a =>
|
|
|
|
|
{
|
|
|
|
|
uint flags = (uint)(MemoryCallbackFlags.AccessExecute);
|
|
|
|
|
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
|
|
|
|
|
});
|
|
|
|
|
ReadCallback = new LibGPGX.mem_cb(a =>
|
|
|
|
|
{
|
|
|
|
|
uint flags = (uint)(MemoryCallbackFlags.AccessRead);
|
|
|
|
|
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
|
|
|
|
|
});
|
|
|
|
|
WriteCallback = new LibGPGX.mem_cb(a =>
|
|
|
|
|
{
|
|
|
|
|
uint flags = (uint)(MemoryCallbackFlags.AccessWrite);
|
|
|
|
|
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
|
|
|
|
|
});
|
2016-08-09 17:03:23 +00:00
|
|
|
|
_memoryCallbacks.ActiveChanged += RefreshMemCallbacks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshMemCallbacks()
|
|
|
|
|
{
|
2016-08-10 19:27:46 +00:00
|
|
|
|
Core.gpgx_set_mem_callback(
|
2016-08-09 17:03:23 +00:00
|
|
|
|
MemoryCallbacks.HasReads ? ReadCallback : null,
|
|
|
|
|
MemoryCallbacks.HasWrites ? WriteCallback : null,
|
|
|
|
|
MemoryCallbacks.HasExecutes ? ExecCallback : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void KillMemCallbacks()
|
|
|
|
|
{
|
2016-08-10 19:27:46 +00:00
|
|
|
|
Core.gpgx_set_mem_callback(null, null, null);
|
2016-08-09 17:03:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|