Add an IDriveLight Emulator service, and remove the CoreComm properties, and refactor accordingly
This commit is contained in:
parent
f447ab907b
commit
08fb509a1a
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<Compile Include="Interfaces\IController.cs" />
|
||||
<Compile Include="Interfaces\ICoreFileProvider.cs" />
|
||||
<Compile Include="Interfaces\IDebuggable.cs" />
|
||||
<Compile Include="Interfaces\IDriveLight.cs" />
|
||||
<Compile Include="Interfaces\IEmulator.cs" />
|
||||
<Compile Include="Interfaces\IEmulatorService.cs" />
|
||||
<Compile Include="Interfaces\IInputCallbackSystem.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;
|
||||
|
||||
|
|
|
@ -77,6 +77,21 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
|||
return (IInputPollable)core.ServiceProvider.GetService<IInputPollable>();
|
||||
}
|
||||
|
||||
public static bool HasDriveLight(this IEmulator core)
|
||||
{
|
||||
if (core == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return core.ServiceProvider.HasService<IDriveLight>();
|
||||
}
|
||||
|
||||
public static IDriveLight AsDriveLight(this IEmulator core)
|
||||
{
|
||||
return (IDriveLight)core.ServiceProvider.GetService<IDriveLight>();
|
||||
}
|
||||
|
||||
public static bool CanDebug(this IEmulator core)
|
||||
{
|
||||
if (core == null)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies an interface to returning the state of a LED drive light such as on Disk and CD Drives
|
||||
/// </summary>
|
||||
public interface IDriveLight : IEmulatorService
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies whether there is currently a Drive light available
|
||||
/// </summary>
|
||||
bool DriveLightEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the light is currently lit
|
||||
/// </summary>
|
||||
bool DriveLightOn { get; }
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
isReleased: true
|
||||
)]
|
||||
public sealed partial class PCEngine : IEmulator, IMemoryDomains, ISaveRam, IStatable, IInputPollable,
|
||||
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>
|
||||
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>, 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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<object, Yabause.SaturnSyncSettings>
|
||||
ISettable<object, Yabause.SaturnSyncSettings>, 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
|
||||
}
|
||||
/// <summary>
|
||||
|
|
|
@ -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<GPGX.GPGXSettings, GPGX.GPGXSyncSettings>
|
||||
IInputPollable, IDebuggable, ISettable<GPGX.GPGXSettings, GPGX.GPGXSyncSettings>, 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; }
|
||||
|
||||
/// <summary>
|
||||
/// core callback for file loading
|
||||
/// </summary>
|
||||
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue