From 2ccf03fd4431487cc3c219927501eb4ec8964c8e Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 18 Feb 2020 10:54:39 -0600 Subject: [PATCH] use property initializers in some cores and some constructor cleanups --- .../Computers/Commodore64/C64.IInputPollable.cs | 2 +- .../Computers/Commodore64/C64.cs | 1 - .../SinclairSpectrum/ZXSpectrum.IDebuggable.cs | 2 +- .../SinclairSpectrum/ZXSpectrum.IInputPollable.cs | 2 +- .../Computers/SinclairSpectrum/ZXSpectrum.cs | 3 --- .../Consoles/PC Engine/PCEngine.IDebuggable.cs | 12 +++--------- .../Consoles/PC Engine/PCEngine.IDriveLight.cs | 2 +- .../Consoles/PC Engine/PCEngine.cs | 14 +++++--------- 8 files changed, 12 insertions(+), 26 deletions(-) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs index 32590f0a7b..994b12771d 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 set => _lagCount = value; } - public IInputCallbackSystem InputCallbacks { get; } + public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); private bool _isLagFrame; private int _lagCount; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index ad941abfdb..3606a3a81d 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -23,7 +23,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 var ser = new BasicServiceProvider(this); ServiceProvider = ser; - InputCallbacks = new InputCallbackSystem(); CoreComm = comm; _roms = roms?.ToList() ?? new List(); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IDebuggable.cs index 76ffe90e97..9d51419996 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IDebuggable.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SetCpuRegister(string register, int value) => _cpu.SetCpuRegister(register, value); - public IMemoryCallbackSystem MemoryCallbacks { get; } + public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); public bool CanStep(StepType type) => false; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IInputPollable.cs index ebc8fe737f..ebc7a86445 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IInputPollable.cs @@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum set => _isLag = value; } - public IInputCallbackSystem InputCallbacks { get; } + public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); private int _lagCount = 0; private bool _isLag = false; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index 5c471f32eb..8d74c87845 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -25,9 +25,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { var ser = new BasicServiceProvider(this); ServiceProvider = ser; - InputCallbacks = new InputCallbackSystem(); - MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); - CoreComm = comm; _gameInfo = game; diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs index 5b74440545..8a24cfbc0f 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs @@ -33,18 +33,12 @@ namespace BizHawk.Emulation.Cores.PCEngine throw new NotImplementedException(); } - public IMemoryCallbackSystem MemoryCallbacks { get; } + public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); public long TotalExecutedCycles => Cpu.TotalExecutedCycles; } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDriveLight.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDriveLight.cs index 8503a8a11a..fb9a2ec739 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDriveLight.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDriveLight.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.PCEngine { public sealed partial class PCEngine : IDriveLight { - public bool DriveLightEnabled { get; } + public bool DriveLightEnabled { get; } = true; public bool DriveLightOn { get; internal set; } } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 3baef09b5e..d113d7fa3c 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -22,7 +22,6 @@ namespace BizHawk.Emulation.Cores.PCEngine [CoreConstructor("PCE", "SGX")] public PCEngine(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { - MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); CoreComm = comm; switch (game.System) @@ -50,19 +49,16 @@ namespace BizHawk.Emulation.Cores.PCEngine _syncSettings.Port5); } - public PCEngine(CoreComm comm, GameInfo game, Disc disc, object Settings, object syncSettings) + public PCEngine(CoreComm comm, GameInfo game, Disc disc, object settings, object syncSettings) { CoreComm = comm; - MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); - DriveLightEnabled = true; SystemId = "PCECD"; Type = NecSystemType.TurboCD; this.disc = disc; - this.Settings = (PCESettings)Settings ?? new PCESettings(); + Settings = (PCESettings)settings ?? new PCESettings(); _syncSettings = (PCESyncSettings)syncSettings ?? new PCESyncSettings(); - GameInfo biosInfo; - byte[] rom = CoreComm.CoreFileProvider.GetFirmwareWithGameInfo("PCECD", "Bios", true, out biosInfo, + byte[] rom = CoreComm.CoreFileProvider.GetFirmwareWithGameInfo("PCECD", "Bios", true, out var biosInfo, "PCE-CD System Card not found. Please check the BIOS settings in Config->Firmwares."); if (biosInfo.Status == RomStatus.BadDump) @@ -101,7 +97,7 @@ namespace BizHawk.Emulation.Cores.PCEngine Init(game, rom); // the default RomStatusDetails don't do anything with Disc - CoreComm.RomStatusDetails = $"{game.Name}\r\nDisk partial hash:{new DiscSystem.DiscHasher(disc).OldHash()}"; + CoreComm.RomStatusDetails = $"{game.Name}\r\nDisk partial hash:{new DiscHasher(disc).OldHash()}"; _controllerDeck = new PceControllerDeck( _syncSettings.Port1, @@ -220,7 +216,7 @@ namespace BizHawk.Emulation.Cores.PCEngine RomLength = RomData.Length; // user request: current value of the SF2MapperLatch on the tracelogger - Cpu.Logger = (s) => Tracer.Put(new TraceInfo + Cpu.Logger = s => Tracer.Put(new TraceInfo { Disassembly = $"{SF2MapperLatch:X1}:{s}", RegisterInfo = ""