rework mgba callbacks to not be global junks

This commit is contained in:
nattthebear 2020-07-26 15:36:29 -04:00
parent 2f5c947a5c
commit 2cdc978e2f
5 changed files with 11 additions and 11 deletions

2
mgba

@ -1 +1 @@
Subproject commit fc7b04b5f081945099f83ad8fe51539ada4adfe9
Subproject commit 2876df558067b85877cb4bb0241db947a92b7cae

Binary file not shown.

View File

@ -183,18 +183,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
[UnmanagedFunctionPointer(cc)]
public delegate void TraceCallback(string msg);
// [BizImport(cc, Compatibility = true)]
// public abstract void BizSetTraceCallback(TraceCallback cb);
[BizImport(cc, Compatibility = true)]
public abstract void BizSetTraceCallback(IntPtr ctx, TraceCallback cb);
[UnmanagedFunctionPointer(cc)]
public delegate void MemCallback(uint addr, mWatchpointType type, uint oldValue, uint newValue);
// [BizImport(cc, Compatibility = true)]
// public abstract void BizSetMemCallback(MemCallback cb);
[BizImport(cc, Compatibility = true)]
public abstract void BizSetMemCallback(IntPtr ctx, MemCallback cb);
[UnmanagedFunctionPointer(cc)]
public delegate void ExecCallback(uint pc);
// [BizImport(cc, Compatibility = true)]
// public abstract void BizSetExecCallback(ExecCallback cb);
[BizImport(cc, Compatibility = true)]
public abstract void BizSetExecCallback(IntPtr ctx, ExecCallback cb);
[BizImport(cc, Compatibility = true)]
public abstract int BizSetWatchpoint(IntPtr ctx, uint addr, mWatchpointType type);

View File

@ -125,7 +125,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
WireMemoryDomainPointers();
}
// LibmGBA.BizSetTraceCallback(Tracer.Enabled ? _tracecb : null);
LibmGBA.BizSetTraceCallback(Core, Tracer.Enabled ? _tracecb : null);
IsLagFrame = LibmGBA.BizAdvance(
Core,

View File

@ -56,11 +56,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
{
_executeCallback = RunExecCallback;
_execPcs[callback.Address.Value] = callback;
// MGBAHawk.ZZHacky.BizSetExecCallback(_executeCallback);
MGBAHawk.ZZHacky.BizSetExecCallback(_mgba.Core, _executeCallback);
}
else
{
// MGBAHawk.ZZHacky.BizSetMemCallback(container.CallDelegate);
MGBAHawk.ZZHacky.BizSetMemCallback(_mgba.Core, container.CallDelegate);
container.ID = MGBAHawk.ZZHacky.BizSetWatchpoint(_mgba.Core, callback.Address.Value, container.WatchPointType);
}
@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
if (_callbacks.All(cb => cb.Callback.Type != MemoryCallbackType.Execute))
{
_executeCallback = null;
// MGBAHawk.ZZHacky.BizSetExecCallback(null);
MGBAHawk.ZZHacky.BizSetExecCallback(_mgba.Core, null);
}
}
else if (MGBAHawk.ZZHacky.BizClearWatchpoint(_mgba.Core, cbToRemove.ID))