ColecoVision - break off IEmulator properties to their own file, move Input.cs code to ColecoVision.cs
This commit is contained in:
parent
eafa39456f
commit
44ef1f9568
|
@ -359,7 +359,7 @@
|
||||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Consoles\Atari\7800\Atari7800.IEmulator.cs">
|
<Compile Include="Consoles\Atari\7800\Atari7800.IEmulator.cs">
|
||||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Consoles\Atari\7800\Atari7800.IInputPollable.cs">
|
<Compile Include="Consoles\Atari\7800\Atari7800.IInputPollable.cs">
|
||||||
<DependentUpon>Atari7800.cs</DependentUpon>
|
<DependentUpon>Atari7800.cs</DependentUpon>
|
||||||
|
@ -398,6 +398,9 @@
|
||||||
<Compile Include="Consoles\Coleco\ColecoVision.IDebuggable.cs">
|
<Compile Include="Consoles\Coleco\ColecoVision.IDebuggable.cs">
|
||||||
<DependentUpon>ColecoVision.cs</DependentUpon>
|
<DependentUpon>ColecoVision.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Consoles\Coleco\ColecoVision.IEmulator.cs">
|
||||||
|
<DependentUpon>ColecoVision.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Consoles\Coleco\ColecoVision.IInputPollable.cs">
|
<Compile Include="Consoles\Coleco\ColecoVision.IInputPollable.cs">
|
||||||
<DependentUpon>ColecoVision.cs</DependentUpon>
|
<DependentUpon>ColecoVision.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -413,7 +416,6 @@
|
||||||
<Compile Include="Consoles\Coleco\ColecoVision.ISoundProvider.cs">
|
<Compile Include="Consoles\Coleco\ColecoVision.ISoundProvider.cs">
|
||||||
<DependentUpon>ColecoVision.cs</DependentUpon>
|
<DependentUpon>ColecoVision.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Consoles\Coleco\Input.cs" />
|
|
||||||
<Compile Include="Consoles\Coleco\MemoryMap.cs" />
|
<Compile Include="Consoles\Coleco\MemoryMap.cs" />
|
||||||
<Compile Include="Consoles\Coleco\TMS9918A.cs" />
|
<Compile Include="Consoles\Coleco\TMS9918A.cs" />
|
||||||
<Compile Include="Consoles\Coleco\ColecoControllerDeck.cs" />
|
<Compile Include="Consoles\Coleco\ColecoControllerDeck.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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Cores.Components;
|
using BizHawk.Emulation.Cores.Components;
|
||||||
using BizHawk.Emulation.Cores.Components.Z80;
|
using BizHawk.Emulation.Cores.Components.Z80;
|
||||||
using BizHawk.Common.NumberExtensions;
|
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.ColecoVision
|
namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
{
|
{
|
||||||
|
@ -70,44 +69,12 @@ namespace BizHawk.Emulation.Cores.ColecoVision
|
||||||
private byte[] Ram = new byte[1024];
|
private byte[] Ram = new byte[1024];
|
||||||
private readonly TraceBuffer Tracer = new TraceBuffer();
|
private readonly TraceBuffer Tracer = new TraceBuffer();
|
||||||
|
|
||||||
public IEmulatorServiceProvider ServiceProvider { get; }
|
|
||||||
|
|
||||||
public ControllerDefinition ControllerDefinition => ControllerDeck.Definition;
|
|
||||||
|
|
||||||
public ColecoVisionControllerDeck ControllerDeck { get; private set; }
|
public ColecoVisionControllerDeck ControllerDeck { get; private set; }
|
||||||
|
|
||||||
private const ushort RamSizeMask = 0x03FF;
|
private const ushort RamSizeMask = 0x03FF;
|
||||||
|
|
||||||
private IController _controller;
|
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)
|
private void LoadRom(byte[] rom, bool skipbios)
|
||||||
{
|
{
|
||||||
RomData = new byte[0x8000];
|
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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue