From 44ef1f9568e64fbd4ca3f898347052a6509f08c7 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 8 May 2017 11:29:09 -0500 Subject: [PATCH] ColecoVision - break off IEmulator properties to their own file, move Input.cs code to ColecoVision.cs --- .../BizHawk.Emulation.Cores.csproj | 6 +- .../Consoles/Coleco/ColecoVision.IEmulator.cs | 59 ++++++++++++ .../Consoles/Coleco/ColecoVision.cs | 90 +++++++++---------- .../Consoles/Coleco/Input.cs | 52 ----------- 4 files changed, 104 insertions(+), 103 deletions(-) create mode 100644 BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs delete mode 100644 BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 3555e005c5..b9fecadc73 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -359,7 +359,7 @@ Atari7800.cs - Atari7800.cs + Atari7800.cs Atari7800.cs @@ -398,6 +398,9 @@ ColecoVision.cs + + ColecoVision.cs + ColecoVision.cs @@ -413,7 +416,6 @@ ColecoVision.cs - diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs new file mode 100644 index 0000000000..83998168f0 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs @@ -0,0 +1,59 @@ +using BizHawk.Emulation.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.ColecoVision +{ + public partial class ColecoVision : IEmulator + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition => ControllerDeck.Definition; + + public void FrameAdvance(IController controller, bool render, bool renderSound) + { + _controller = controller; + Cpu.Debug = Tracer.Enabled; + frame++; + _isLag = true; + PSG.BeginFrame(Cpu.TotalExecutedCycles); + + if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first + { + Cpu.Logger = (s) => Tracer.Put(s); + } + + byte tempRet1 = ControllerDeck.ReadPort1(controller, true, true); + byte tempRet2 = ControllerDeck.ReadPort2(controller, true, true); + + bool intPending = (!tempRet1.Bit(4)) | (!tempRet2.Bit(4)); + + VDP.ExecuteFrame(intPending); + + PSG.EndFrame(Cpu.TotalExecutedCycles); + + if (_isLag) + { + _lagCount++; + } + } + + public int Frame => frame; + + public string SystemId => "Coleco"; + + public bool DeterministicEmulation => true; + + public void ResetCounters() + { + frame = 0; + _lagCount = 0; + _isLag = false; + } + + public CoreComm CoreComm { get; } + + public void Dispose() + { + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 1dc3124251..0f1fc55057 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -1,7 +1,6 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components; using BizHawk.Emulation.Cores.Components.Z80; -using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.ColecoVision { @@ -70,44 +69,12 @@ namespace BizHawk.Emulation.Cores.ColecoVision private byte[] Ram = new byte[1024]; private readonly TraceBuffer Tracer = new TraceBuffer(); - public IEmulatorServiceProvider ServiceProvider { get; } - - public ControllerDefinition ControllerDefinition => ControllerDeck.Definition; - public ColecoVisionControllerDeck ControllerDeck { get; private set; } private const ushort RamSizeMask = 0x03FF; private IController _controller; - public void FrameAdvance(IController controller, bool render, bool renderSound) - { - _controller = controller; - Cpu.Debug = Tracer.Enabled; - Frame++; - _isLag = true; - PSG.BeginFrame(Cpu.TotalExecutedCycles); - - if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first - { - Cpu.Logger = (s) => Tracer.Put(s); - } - - byte tempRet1 = ControllerDeck.ReadPort1(controller, true, true); - byte tempRet2 = ControllerDeck.ReadPort2(controller, true, true); - - bool intPending = (!tempRet1.Bit(4)) | (!tempRet2.Bit(4)); - - VDP.ExecuteFrame(intPending); - - PSG.EndFrame(Cpu.TotalExecutedCycles); - - if (_isLag) - { - _lagCount++; - } - } - private void LoadRom(byte[] rom, bool skipbios) { RomData = new byte[0x8000]; @@ -188,22 +155,47 @@ namespace BizHawk.Emulation.Cores.ColecoVision } } - public bool DeterministicEmulation => true; - - public void Dispose() - { - } - - public void ResetCounters() - { - Frame = 0; - _lagCount = 0; - _isLag = false; - } - - public string SystemId => "Coleco"; - private GameInfo _game; - public CoreComm CoreComm { get; } + + public enum InputPortMode { Left, Right } + private InputPortMode InputPortSelection; + + private byte ReadController1() + { + _isLag = false; + byte retval; + if (InputPortSelection == InputPortMode.Left) + { + retval = ControllerDeck.ReadPort1(_controller, true, false); + return retval; + } + + if (InputPortSelection == InputPortMode.Right) + { + retval = ControllerDeck.ReadPort1(_controller, false, false); + return retval; + } + return 0x7F; + } + + private byte ReadController2() + { + _isLag = false; + byte retval; + if (InputPortSelection == InputPortMode.Left) + { + retval = ControllerDeck.ReadPort2(_controller, true, false); + return retval; + } + + if (InputPortSelection == InputPortMode.Right) + { + retval = ControllerDeck.ReadPort2(_controller, false, false); + return retval; + } + return 0x7F; + } + + private int frame; } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs deleted file mode 100644 index f3479971e5..0000000000 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace BizHawk.Emulation.Cores.ColecoVision -{ - public partial class ColecoVision - { - public enum InputPortMode { Left, Right } - private InputPortMode InputPortSelection; - - private byte ReadController1() - { - _isLag = false; - byte retval; - if (InputPortSelection == InputPortMode.Left) - { - retval = ControllerDeck.ReadPort1(_controller, true, false); - return retval; - } - - if (InputPortSelection == InputPortMode.Right) - { - retval = ControllerDeck.ReadPort1(_controller, false, false); - return retval; - } - return 0x7F; - } - - private byte ReadController2() - { - _isLag = false; - byte retval; - if (InputPortSelection == InputPortMode.Left) - { - retval = ControllerDeck.ReadPort2(_controller, true, false); - return retval; - } - - if (InputPortSelection == InputPortMode.Right) - { - retval = ControllerDeck.ReadPort2(_controller, false, false); - return retval; - } - return 0x7F; - } - - public int Frame - { - get { return frame; } - private set { frame = value; } - } - - private int frame; - } -}