diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 2b0cc497d5..ee0c5c4869 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2422,14 +2422,16 @@ namespace BizHawk.Client.EmuHawk { if (MainStatusBar.Visible) { - if (Global.Emulator.CoreComm.UsesDriveLed) + var hasDriveLight = Global.Emulator.HasDriveLight() && Global.Emulator.AsDriveLight().DriveLightEnabled; + + if (hasDriveLight) { if (!LedLightStatusLabel.Visible) { LedLightStatusLabel.Visible = true; } - LedLightStatusLabel.Image = Global.Emulator.CoreComm.DriveLED + LedLightStatusLabel.Image = Global.Emulator.AsDriveLight().DriveLightOn ? StatusBarDiskLightOnImage : StatusBarDiskLightOffImage; } diff --git a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj index 8348590576..99206673d3 100644 --- a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj +++ b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -72,6 +72,7 @@ + diff --git a/BizHawk.Emulation.Common/CoreComms.cs b/BizHawk.Emulation.Common/CoreComms.cs index 1191d41c71..557691c1a1 100644 --- a/BizHawk.Emulation.Common/CoreComms.cs +++ b/BizHawk.Emulation.Common/CoreComms.cs @@ -35,9 +35,6 @@ namespace BizHawk.Emulation.Common public int NominalWidth = 640; public int NominalHeight = 480; - public bool DriveLED = false; - public bool UsesDriveLed = false; - public bool LinkConnected = false; public bool UsesLinkCable = false; diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index 1c72ba65fb..b7ddf5d46f 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -77,6 +77,21 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions return (IInputPollable)core.ServiceProvider.GetService(); } + public static bool HasDriveLight(this IEmulator core) + { + if (core == null) + { + return false; + } + + return core.ServiceProvider.HasService(); + } + + public static IDriveLight AsDriveLight(this IEmulator core) + { + return (IDriveLight)core.ServiceProvider.GetService(); + } + public static bool CanDebug(this IEmulator core) { if (core == null) diff --git a/BizHawk.Emulation.Common/Interfaces/IDriveLight.cs b/BizHawk.Emulation.Common/Interfaces/IDriveLight.cs new file mode 100644 index 0000000000..a5425614ea --- /dev/null +++ b/BizHawk.Emulation.Common/Interfaces/IDriveLight.cs @@ -0,0 +1,18 @@ +namespace BizHawk.Emulation.Common +{ + /// + /// Specifies an interface to returning the state of a LED drive light such as on Disk and CD Drives + /// + public interface IDriveLight : IEmulatorService + { + /// + /// Specifies whether there is currently a Drive light available + /// + bool DriveLightEnabled { get; } + + /// + /// Specifies whether the light is currently lit + /// + bool DriveLightOn { get; } + } +} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 89ead8f7b3..9f42083022 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 isReleased: false )] [ServiceNotApplicable(typeof(ISettable<,>))] - sealed public partial class C64 : IEmulator, IMemoryDomains, IStatable, IInputPollable + sealed public partial class C64 : IEmulator, IMemoryDomains, IStatable, IInputPollable, IDriveLight { // internal variables private bool _islag = true; @@ -84,11 +84,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 CoreComm = comm; Init(Region.PAL); cyclesPerFrame = board.vic.CyclesPerFrame; - CoreComm.UsesDriveLed = true; SetupMemoryDomains(); HardReset(); } + public bool DriveLightEnabled { get { return true; } } + public bool DriveLightOn { get; private set; } + public IEmulatorServiceProvider ServiceProvider { get; private set; } public void Dispose() @@ -169,7 +171,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 //Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4)); int test = board.cpu.LagCycles; - CoreComm.DriveLED = DriveLED; + DriveLightOn = DriveLED; } private void HandleFirmwareError(string file) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index f5352986ec..33f9c09289 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -46,8 +46,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Init(game, rom, fdsbios); if (board is FDS) { - CoreComm.UsesDriveLed = true; - (board as FDS).SetDriveLightCallback((val) => CoreComm.DriveLED = val); + DriveLightEnabled = true; + (board as FDS).SetDriveLightCallback((val) => DriveLightOn = val); } PutSettings((NESSettings)Settings ?? new NESSettings()); } @@ -59,6 +59,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES BootGodDB.Initialize(); } + public bool DriveLightEnabled { get; private set; } + public bool DriveLightOn { get; private set; } + public void WriteLogTimestamp() { if (ppu != null) diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 8be810246d..44200d4d8e 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.PCEngine isReleased: true )] public sealed partial class PCEngine : IEmulator, IMemoryDomains, ISaveRam, IStatable, IInputPollable, - IDebuggable, ISettable + IDebuggable, ISettable, IDriveLight { // ROM public byte[] RomData; @@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.PCEngine CoreComm = comm; Tracer = new TraceBuffer(); MemoryCallbacks = new MemoryCallbackSystem(); - CoreComm.UsesDriveLed = true; + DriveLightEnabled = true; systemid = "PCECD"; Type = NecSystemType.TurboCD; this.disc = disc; @@ -152,6 +152,9 @@ namespace BizHawk.Emulation.Cores.PCEngine SetControllerButtons(); } + public bool DriveLightEnabled { get; private set; } + public bool DriveLightOn { get; internal set; } + void Init(GameInfo game, byte[] rom) { Controller = NullController.GetNullController(); @@ -317,7 +320,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public void FrameAdvance(bool render, bool rendersound) { lagged = true; - CoreComm.DriveLED = false; + DriveLightOn = false; Frame++; CheckSpriteLimit(); PSG.BeginFrame(Cpu.TotalExecutedCycles); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs index 2461431c18..13fa66e042 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs @@ -170,7 +170,7 @@ namespace BizHawk.Emulation.Cores.PCEngine if (DataReadInProgress && pce.Cpu.TotalExecutedCycles > DataReadWaitTimer) { if (SectorsLeftToRead > 0) - pce.CoreComm.DriveLED = true; + pce.DriveLightOn = true; if (DataIn.Count == 0) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 759d072bea..524325c67d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn portedUrl: "http://yabause.org" )] public class Yabause : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, ISaveRam, IStatable, IInputPollable, - ISettable + ISettable, IDriveLight { public static ControllerDefinition SaturnController = new ControllerDefinition { @@ -77,13 +77,16 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn InputCallbackH = new LibYabause.InputCallback(() => InputCallbacks.Call()); LibYabause.libyabause_setinputcallback(InputCallbackH); - CoreComm.UsesDriveLed = true; + DriveLightEnabled = true; DeactivateGL(); } public IEmulatorServiceProvider ServiceProvider { get; private set; } + public bool DriveLightEnabled { get; private set; } + public bool DriveLightOn { get; private set; } + static object glContext; void ActivateGL() @@ -275,7 +278,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn LibYabause.libyabause_setpads(p11, p12, p21, p22); - CoreComm.DriveLED = false; + DriveLightOn = false; IsLagFrame = LibYabause.libyabause_frameadvance(out w, out h, out nsamp); BufferWidth = w; @@ -686,7 +689,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn return 0; // failure } Marshal.Copy(data, 0, dest, 2352); - CoreComm.DriveLED = true; + DriveLightOn = true; return 1; // success } /// diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index b27815de93..a61f5ffa7a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx portedUrl: "https://code.google.com/p/genplus-gx/" )] public class GPGX : IEmulator, ISyncSoundProvider, IVideoProvider, IMemoryDomains, ISaveRam, IStatable, - IInputPollable, IDebuggable, ISettable + IInputPollable, IDebuggable, ISettable, IDriveLight { static GPGX AttachedCore = null; @@ -164,7 +164,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx LibGPGX.gpgx_set_input_callback(InputCallback); if (CD != null) - CoreComm.UsesDriveLed = true; + DriveLightEnabled = true; PutSettings((GPGXSettings)Settings ?? new GPGXSettings()); @@ -180,6 +180,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public IEmulatorServiceProvider ServiceProvider { get; private set; } + public bool DriveLightEnabled { get; private set;} + public bool DriveLightOn { get; private set; } + /// /// core callback for file loading /// @@ -430,7 +433,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx LagCount++; if (CD != null) - CoreComm.DriveLED = drivelight; + DriveLightOn = drivelight; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 96473cf8b7..185f9e8e7b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX isPorted: true, isReleased: false )] - public unsafe class Octoshock : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, ISaveRam + public unsafe class Octoshock : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, ISaveRam, IDriveLight { public string SystemId { get { return "PSX"; } } @@ -174,7 +174,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; - CoreComm.UsesDriveLed = true; + DriveLightEnabled = true; Attach(); @@ -190,7 +190,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX { //if current disc this delegate disc, activity is happening if (disc == this.disc) - CoreComm.DriveLED = true; + DriveLightOn = true; }); //determine region of the provided disc @@ -253,6 +253,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public IEmulatorServiceProvider ServiceProvider { get; private set; } + public bool DriveLightEnabled { get; private set; } + public bool DriveLightOn { get; private set; } + void Attach() { //attach this core as the current @@ -309,7 +312,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public void FrameAdvance(bool render, bool rendersound) { Frame++; - CoreComm.DriveLED = false; + DriveLightOn = false; SetInput();