wondersaw'n: update trace callback internal infrastructure

This commit is contained in:
goyuken 2014-12-04 01:22:34 +00:00
parent ccb8cce788
commit 802dadcd64
1 changed files with 15 additions and 7 deletions

View File

@ -143,7 +143,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan
Frame++; Frame++;
IsLagFrame = true; IsLagFrame = true;
SetDebugCallbacks(); SetMemoryCallbacks();
if (Controller["Power"]) if (Controller["Power"])
BizSwan.bizswan_reset(Core); BizSwan.bizswan_reset(Core);
@ -176,9 +176,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan
public bool IsLagFrame { get; private set; } public bool IsLagFrame { get; private set; }
private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem();
public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } }
// TODO: optimize managed to unmanaged using the ActiveChanged event
public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get { return _inputCallbacks; } }
public string SystemId { get { return "WSWAN"; } } public string SystemId { get { return "WSWAN"; } }
public bool DeterministicEmulation { get; private set; } public bool DeterministicEmulation { get; private set; }
@ -364,16 +362,26 @@ namespace BizHawk.Emulation.Cores.WonderSwan
WriteCallbackD = new BizSwan.MemoryCallback(WriteCallback); WriteCallbackD = new BizSwan.MemoryCallback(WriteCallback);
ExecCallbackD = new BizSwan.MemoryCallback(ExecCallback); ExecCallbackD = new BizSwan.MemoryCallback(ExecCallback);
ButtonCallbackD = new BizSwan.ButtonCallback(ButtonCallback); ButtonCallbackD = new BizSwan.ButtonCallback(ButtonCallback);
_inputCallbacks.ActiveChanged += SetInputCallback;
} }
void SetDebugCallbacks() bool _inputcbactive = false;
void SetInputCallback()
{
bool _inputcbactive_new = InputCallbacks.Any();
if (_inputcbactive != _inputcbactive_new)
{
_inputcbactive = _inputcbactive_new;
BizSwan.bizswan_setbuttoncallback(Core, _inputcbactive ? ButtonCallbackD : null);
}
}
void SetMemoryCallbacks()
{ {
BizSwan.bizswan_setmemorycallbacks(Core, BizSwan.bizswan_setmemorycallbacks(Core,
CoreComm.MemoryCallbackSystem.HasReads ? ReadCallbackD : null, CoreComm.MemoryCallbackSystem.HasReads ? ReadCallbackD : null,
CoreComm.MemoryCallbackSystem.HasWrites ? WriteCallbackD : null, CoreComm.MemoryCallbackSystem.HasWrites ? WriteCallbackD : null,
CoreComm.MemoryCallbackSystem.HasExecutes ? ExecCallbackD : null); CoreComm.MemoryCallbackSystem.HasExecutes ? ExecCallbackD : null);
BizSwan.bizswan_setbuttoncallback(Core,
InputCallbacks.Any() ? ButtonCallbackD : null);
} }
#endregion #endregion