Remove CoreComm link cable properties and turn it into an ILInkable service instead

This commit is contained in:
adelikat 2016-02-28 13:52:17 -05:00
parent 7a4a210ccc
commit f1f45afd83
5 changed files with 24 additions and 9 deletions

View File

@ -2503,14 +2503,14 @@ namespace BizHawk.Client.EmuHawk
} }
} }
if (Global.Emulator.CoreComm.UsesLinkCable) if (Global.Emulator.UsesLinkCable())
{ {
if (!LinkConnectStatusBarButton.Visible) if (!LinkConnectStatusBarButton.Visible)
{ {
LinkConnectStatusBarButton.Visible = true; LinkConnectStatusBarButton.Visible = true;
} }
LinkConnectStatusBarButton.Image = Global.Emulator.CoreComm.LinkConnected LinkConnectStatusBarButton.Image = Global.Emulator.AsLinkable().LinkConnected
? LinkCableOn ? LinkCableOn
: LinkCableOff; : LinkCableOff;
} }

View File

@ -88,6 +88,7 @@
<Compile Include="Interfaces\IEmulatorService.cs" /> <Compile Include="Interfaces\IEmulatorService.cs" />
<Compile Include="Interfaces\IInputCallbackSystem.cs" /> <Compile Include="Interfaces\IInputCallbackSystem.cs" />
<Compile Include="Interfaces\IInputPollable.cs" /> <Compile Include="Interfaces\IInputPollable.cs" />
<Compile Include="Interfaces\ILinkable.cs" />
<Compile Include="Interfaces\IMemoryCallbackSystem.cs" /> <Compile Include="Interfaces\IMemoryCallbackSystem.cs" />
<Compile Include="Interfaces\IMemoryDomains.cs" /> <Compile Include="Interfaces\IMemoryDomains.cs" />
<Compile Include="Interfaces\IRegionable.cs" /> <Compile Include="Interfaces\IRegionable.cs" />

View File

@ -33,9 +33,6 @@ namespace BizHawk.Emulation.Common
public int NominalWidth = 640; public int NominalWidth = 640;
public int NominalHeight = 480; public int NominalHeight = 480;
public bool LinkConnected = false;
public bool UsesLinkCable = false;
//I know we want to get rid of CoreComm, but while it's still here, I'll use it for this //I know we want to get rid of CoreComm, but while it's still here, I'll use it for this
public string LaunchLibretroCore; public string LaunchLibretroCore;

View File

@ -255,6 +255,21 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
return core.ServiceProvider.GetService<ICodeDataLogger>(); return core.ServiceProvider.GetService<ICodeDataLogger>();
} }
public static ILinkable AsLinkable(this IEmulator core)
{
return core.ServiceProvider.GetService<ILinkable>();
}
public static bool UsesLinkCable(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ILinkable>();
}
// TODO: a better place for these // TODO: a better place for these
public static bool IsImplemented(this MethodInfo info) public static bool IsImplemented(this MethodInfo info)
{ {

View File

@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
isReleased: true isReleased: true
)] )]
[ServiceNotApplicable(typeof(IDriveLight))] [ServiceNotApplicable(typeof(IDriveLight))]
public partial class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider, IInputPollable, ISaveRam, IStatable, public partial class GambatteLink : IEmulator, IVideoProvider, ISyncSoundProvider, IInputPollable, ISaveRam, IStatable, ILinkable,
IDebuggable, ISettable<GambatteLink.GambatteLinkSettings, GambatteLink.GambatteLinkSyncSettings> IDebuggable, ISettable<GambatteLink.GambatteLinkSettings, GambatteLink.GambatteLinkSyncSettings>
{ {
public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, object Settings, object SyncSettings, bool deterministic) public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, object Settings, object SyncSettings, bool deterministic)
@ -48,8 +48,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
comm.RomStatusDetails = "LEFT:\r\n" + L.CoreComm.RomStatusDetails + "RIGHT:\r\n" + R.CoreComm.RomStatusDetails; comm.RomStatusDetails = "LEFT:\r\n" + L.CoreComm.RomStatusDetails + "RIGHT:\r\n" + R.CoreComm.RomStatusDetails;
comm.NominalWidth = L.CoreComm.NominalWidth + R.CoreComm.NominalWidth; comm.NominalWidth = L.CoreComm.NominalWidth + R.CoreComm.NominalWidth;
comm.NominalHeight = L.CoreComm.NominalHeight; comm.NominalHeight = L.CoreComm.NominalHeight;
comm.UsesLinkCable = true;
comm.LinkConnected = true; LinkConnected = true;
Frame = 0; Frame = 0;
LagCount = 0; LagCount = 0;
@ -63,6 +63,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
SetMemoryDomains(); SetMemoryDomains();
} }
public bool LinkConnected { get; private set; }
bool disposed = false; bool disposed = false;
Gameboy L; Gameboy L;
@ -126,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{ {
cableconnected ^= true; cableconnected ^= true;
Console.WriteLine("Cable connect status to {0}", cableconnected); Console.WriteLine("Cable connect status to {0}", cableconnected);
CoreComm.LinkConnected = cableconnected; LinkConnected = cableconnected;
} }
cablediscosignal = cablediscosignal_new; cablediscosignal = cablediscosignal_new;