ColecoVision - break off IEmulator properties to their own file, move Input.cs code to ColecoVision.cs

This commit is contained in:
adelikat 2017-05-08 11:29:09 -05:00
parent eafa39456f
commit 44ef1f9568
4 changed files with 104 additions and 103 deletions

View File

@ -359,7 +359,7 @@
<DependentUpon>Atari7800.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Atari\7800\Atari7800.IEmulator.cs">
<DependentUpon>Atari7800.cs</DependentUpon>
<DependentUpon>Atari7800.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Atari\7800\Atari7800.IInputPollable.cs">
<DependentUpon>Atari7800.cs</DependentUpon>
@ -398,6 +398,9 @@
<Compile Include="Consoles\Coleco\ColecoVision.IDebuggable.cs">
<DependentUpon>ColecoVision.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Coleco\ColecoVision.IEmulator.cs">
<DependentUpon>ColecoVision.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Coleco\ColecoVision.IInputPollable.cs">
<DependentUpon>ColecoVision.cs</DependentUpon>
</Compile>
@ -413,7 +416,6 @@
<Compile Include="Consoles\Coleco\ColecoVision.ISoundProvider.cs">
<DependentUpon>ColecoVision.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Coleco\Input.cs" />
<Compile Include="Consoles\Coleco\MemoryMap.cs" />
<Compile Include="Consoles\Coleco\TMS9918A.cs" />
<Compile Include="Consoles\Coleco\ColecoControllerDeck.cs" />

View File

@ -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()
{
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}