From 5f770e46967df0a31ffd5d843d5d0e90aed58eec Mon Sep 17 00:00:00 2001 From: goyuken Date: Thu, 4 Dec 2014 01:46:59 +0000 Subject: [PATCH] update pad callback infrastructure in vbanext core, remove unused stub in lynx core, disable in dual gb core until i get around to it, better comment in gb core --- .../Consoles/Atari/lynx/Lynx.cs | 7 +++---- .../Consoles/Nintendo/GBA/VBANext.cs | 14 +++++++++++++- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 6 +++--- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 12 ++---------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index a405422192..f9ed72380b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -139,12 +139,11 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public int LagCount { get; set; } public bool IsLagFrame { get; private set; } - private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); - - // TODO: optimize managed to unmanaged using the ActiveChanged event + // TODO public IInputCallbackSystem InputCallbacks { - [FeatureNotImplemented]get { return _inputCallbacks; } + [FeatureNotImplemented] + get { throw new NotImplementedException(); } } public string SystemId { get { return "Lynx"; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index b6dd6a530a..0c8eb6d079 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -282,11 +282,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA 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(Trace(addr, opcode))); + _inputCallbacks.ActiveChanged += SyncPadCallback; + } + + bool _inputcbactive = false; + void SyncPadCallback() + { + bool _inputcbactive_new = InputCallbacks.Any(); + if (_inputcbactive != _inputcbactive_new) + { + _inputcbactive = _inputcbactive_new; + LibVBANext.SetPadCallback(Core, _inputcbactive ? padcb : null); + } } void SyncCallbacks() { - LibVBANext.SetPadCallback(Core, InputCallbacks.Any() ? padcb : null); + //LibVBANext.SetPadCallback(Core, InputCallbacks.Any() ? padcb : null); LibVBANext.SetFetchCallback(Core, CoreComm.MemoryCallbackSystem.HasExecutes ? fetchcb : null); LibVBANext.SetReadCallback(Core, CoreComm.MemoryCallbackSystem.HasReads ? readcb : null); LibVBANext.SetWriteCallback(Core, CoreComm.MemoryCallbackSystem.HasWrites ? writecb : null); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 5f70243a26..bf764b8154 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -37,9 +37,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public bool IsLagFrame { get; private set; } private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); - - // TODO: optimize managed to unmanaged using the ActiveChanged event - public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get { return _inputCallbacks; } } + // low priority TODO: due to certain aspects of the core implementation, + // we don't smartly use the ActiveChanged event here. + public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } // all cycle counts are relative to a 2*1024*1024 mhz refclock diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index 956ca4f150..c871a4b272 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -78,18 +78,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy blip_right.SetRates(2097152 * 2, 44100); SetMemoryDomains(); - - foreach (var callback in InputCallbacks) - { - L.InputCallbacks.Add(callback); - R.InputCallbacks.Add(callback); - } } - private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); - - // TODO: optimize managed to unmanaged using the ActiveChanged event - public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get { return _inputCallbacks; } } + // TODO: how to best work this under the new system? IInputCallbackSystem is far too unwieldly to actually implement + public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get { throw new NotImplementedException(); } } public IVideoProvider VideoProvider { get { return this; } } public ISoundProvider SoundProvider { get { return null; } }