From 9fa59bad42b22dcf76a4d0c1ab99765b571e34af Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 15 Mar 2020 09:10:13 -0500 Subject: [PATCH] refactor CoreComm usages in Computer cores --- BizHawk.Client.Common/RomLoader.cs | 2 +- BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs | 2 -- BizHawk.Emulation.Cores/Calculator/TI83.cs | 3 +-- .../Computers/AmstradCPC/AmstradCPC.IEmulator.cs | 2 -- BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs | 2 ++ .../Computers/AppleII/AppleII.IEmulator.cs | 2 -- BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs | 1 - .../Computers/Commodore64/C64.IEmulator.cs | 2 -- BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs | 2 ++ BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs | 4 +--- BizHawk.Emulation.Cores/Computers/MSX/MSX.cs | 1 - .../Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs | 2 -- .../Computers/SinclairSpectrum/ZXSpectrum.cs | 2 ++ 13 files changed, 9 insertions(+), 18 deletions(-) diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 2bd6e4b818..21ec221c47 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -954,7 +954,7 @@ namespace BizHawk.Client.Common using (var ti83AsHawkFile = new HawkFile(ti83BiosPath)) { var ti83BiosAsRom = new RomGame(ti83AsHawkFile); - var ti83 = new TI83(nextComm, ti83BiosAsRom.GameInfo, ti83Bios, GetCoreSettings()); + var ti83 = new TI83(ti83BiosAsRom.GameInfo, ti83Bios, GetCoreSettings()); ti83.LinkPort.SendFileToCalc(File.OpenRead(path), false); nextEmulator = ti83; } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs index d064695326..f87becf7b3 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs @@ -80,8 +80,6 @@ namespace BizHawk.Emulation.Cores.Calculators _isLag = false; } - public CoreComm CoreComm { get; } - public void Dispose() { } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs index 7058742f08..4a8f795746 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -14,13 +14,12 @@ namespace BizHawk.Emulation.Cores.Calculators public partial class TI83 : IEmulator, IVideoProvider, IDebuggable, IInputPollable, ISettable { [CoreConstructor("TI83")] - public TI83(CoreComm comm, GameInfo game, byte[] rom, object settings) + public TI83(GameInfo game, byte[] rom, object settings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; PutSettings((TI83Settings)settings ?? new TI83Settings()); - CoreComm = comm; _cpu.FetchMemory = ReadMemory; _cpu.ReadMemory = ReadMemory; _cpu.WriteMemory = WriteMemory; diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs index 419d113678..3a97458b45 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs @@ -59,8 +59,6 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _isLag = false; } - public CoreComm CoreComm { get; } - public void Dispose() { if (_machine != null) diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs index 01de270ddf..2092720394 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs @@ -95,6 +95,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC SetupMemoryDomains(); } + internal CoreComm CoreComm { get; } + public Action HardReset; public Action SoftReset; diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs index 48eed6610b..71bf018a6d 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs @@ -29,8 +29,6 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII IsLagFrame = false; } - public CoreComm CoreComm { get; } - public void Dispose() { } diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index 6ddf214cb7..fa854b11d3 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -32,7 +32,6 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII { var ser = new BasicServiceProvider(this); ServiceProvider = ser; - CoreComm = comm; _tracer = new TraceBuffer { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs index 1c2fc7b140..31c60bbb4d 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs @@ -91,8 +91,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 _frameCycles = 0; } - public CoreComm CoreComm { get; } - public void Dispose() { if (_board != null) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index b7165c30d7..792e468b48 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -70,6 +70,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 SetupMemoryDomains(); } + private CoreComm CoreComm { get; } + public string RomDetails { get; } // Currently we will require at least one rom. If multiple they MUST be all the same media type in the same format diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs index 7a31221548..dbe8449bc0 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX public ControllerDefinition ControllerDefinition => current_controller; public bool FrameAdvance(IController controller, bool render, bool rendersound) - { + { _controller = controller; byte ctrl1_byte = 0xFF; @@ -150,8 +150,6 @@ namespace BizHawk.Emulation.Cores.Computers.MSX _isLag = false; } - public CoreComm CoreComm { get; } - public void Dispose() { if (MSX_Pntr != IntPtr.Zero) diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs index 4aacc44881..c81919ea6e 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs @@ -18,7 +18,6 @@ namespace BizHawk.Emulation.Cores.Computers.MSX ServiceProvider = new BasicServiceProvider(this); Settings = (MSXSettings)settings ?? new MSXSettings(); SyncSettings = (MSXSyncSettings)syncSettings ?? new MSXSyncSettings(); - CoreComm = comm; RomData = rom; int size = RomData.Length; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs index 7b5e4f8ad2..dd5681d042 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs @@ -59,8 +59,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _isLag = false; } - public CoreComm CoreComm { get; } - public void Dispose() { if (_machine != null) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index 1ee21ee831..31e4aa3002 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -180,6 +180,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum }; private int diagIndex = 1; + internal CoreComm CoreComm { get; } + private byte[] GetFirmware(int length, params string[] names) { if (DiagRom & File.Exists(Directory.GetCurrentDirectory() + diagRoms[diagIndex]))