C64 - break up services more

This commit is contained in:
adelikat 2017-05-12 14:06:34 -05:00
parent 6cfd112791
commit 59ac3897da
5 changed files with 82 additions and 91 deletions

View File

@ -192,10 +192,15 @@
<Compile Include="Computers\Commodore64\C64.IDebuggable.cs">
<DependentUpon>C64.cs</DependentUpon>
</Compile>
<Compile Include="Computers\Commodore64\C64.IDisassemblable.cs" />
<Compile Include="Computers\Commodore64\C64.IDisassemblable.cs">
<DependentUpon>C64.cs</DependentUpon>
</Compile>
<Compile Include="Computers\Commodore64\C64.IDriveLight.cs">
<DependentUpon>C64.cs</DependentUpon>
</Compile>
<Compile Include="Computers\Commodore64\C64.IEmulator.cs">
<DependentUpon>C64.cs</DependentUpon>
</Compile>
<Compile Include="Computers\Commodore64\C64.IInputPollable.cs">
<DependentUpon>C64.cs</DependentUpon>
</Compile>

View File

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
@ -23,44 +23,47 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
_selectedDebuggable = GetAvailableDebuggables().First();
}
IDictionary<string, RegisterValue> IDebuggable.GetCpuFlagsAndRegisters()
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
{
if (_selectedDebuggable == null)
{
SetDefaultDebuggable();
}
return _selectedDebuggable.GetCpuFlagsAndRegisters();
}
void IDebuggable.SetCpuRegister(string register, int value)
public void SetCpuRegister(string register, int value)
{
if (_selectedDebuggable == null)
{
SetDefaultDebuggable();
}
_selectedDebuggable.SetCpuRegister(register, value);
}
bool IDebuggable.CanStep(StepType type)
public bool CanStep(StepType type)
{
if (_selectedDebuggable == null)
{
SetDefaultDebuggable();
}
return _selectedDebuggable.CanStep(type);
}
void IDebuggable.Step(StepType type)
public void Step(StepType type)
{
if (_selectedDebuggable == null)
{
SetDefaultDebuggable();
}
_selectedDebuggable.Step(type);
}
[FeatureNotImplemented]
public int TotalExecutedCycles
{
get { return _selectedDebuggable.TotalExecutedCycles; }
@ -70,6 +73,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
private readonly IMemoryCallbackSystem _memoryCallbacks;
[SaveState.DoNotSave]
IMemoryCallbackSystem IDebuggable.MemoryCallbacks { get { return _memoryCallbacks; } }
IMemoryCallbackSystem IDebuggable.MemoryCallbacks => _memoryCallbacks;
}
}

View File

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64

View File

@ -0,0 +1,59 @@
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public sealed partial class C64 : IEmulator
{
[SaveState.DoNotSave]
public IEmulatorServiceProvider ServiceProvider { get; private set; }
[SaveState.DoNotSave]
public ControllerDefinition ControllerDefinition => C64ControllerDefinition;
public void FrameAdvance(IController controller, bool render, bool rendersound)
{
_board.Controller = controller;
do
{
DoCycle();
}
while (_frameCycles != 0);
}
[SaveState.DoNotSave]
public int Frame => _frame;
[SaveState.DoNotSave]
public string SystemId { get { return "C64"; } }
[SaveState.SaveWithName("DeterministicEmulation")]
public bool DeterministicEmulation => true;
public void ResetCounters()
{
_frame = 0;
LagCount = 0;
IsLagFrame = false;
_frameCycles = 0;
}
[SaveState.DoNotSave]
public CoreComm CoreComm { get; private set; }
public void Dispose()
{
if (_board != null)
{
if (_board.TapeDrive != null)
{
_board.TapeDrive.RemoveMedia();
}
if (_board.DiskDrive != null)
{
_board.DiskDrive.RemoveMedia();
}
_board = null;
}
}
}
}

View File

@ -15,8 +15,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
[ServiceNotApplicable(typeof(ISettable<,>))]
public sealed partial class C64 : IEmulator, IRegionable
{
#region Ctor
public C64(CoreComm comm, IEnumerable<byte[]> roms, object settings, object syncSettings)
{
PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings());
@ -51,14 +49,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
((BasicServiceProvider)ServiceProvider).Register<ISoundProvider>(_soundProvider);
}
DeterministicEmulation = true;
((BasicServiceProvider)ServiceProvider).Register<IVideoProvider>(_board.Vic);
((BasicServiceProvider)ServiceProvider).Register<IDriveLight>(this);
}
#endregion
#region Internals
[SaveState.DoNotSave]
@ -92,87 +86,17 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
private int _frameCycles;
#endregion
#region IDisposable
public void Dispose()
{
if (_board != null)
{
if (_board.TapeDrive != null)
{
_board.TapeDrive.RemoveMedia();
}
if (_board.DiskDrive != null)
{
_board.DiskDrive.RemoveMedia();
}
_board = null;
}
}
#endregion
#region IRegionable
[SaveState.DoNotSave]
public DisplayType Region
{
get;
private set;
}
#endregion
#region IEmulator
[SaveState.DoNotSave]
public CoreComm CoreComm { get; private set; }
[SaveState.DoNotSave]
public string SystemId { get { return "C64"; } }
[SaveState.SaveWithName("DeterministicEmulation")]
public bool DeterministicEmulation { get; set; }
[SaveState.SaveWithName("Frame")]
private int _frame;
[SaveState.DoNotSave]
public int Frame => _frame;
[SaveState.DoNotSave]
public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } }
[SaveState.DoNotSave]
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public void ResetCounters()
{
_frame = 0;
LagCount = 0;
IsLagFrame = false;
_frameCycles = 0;
}
// process frame
public void FrameAdvance(IController controller, bool render, bool rendersound)
{
_board.Controller = controller;
do
{
DoCycle();
}
while (_frameCycles != 0);
}
#endregion
#region ISoundProvider
// IRegionable
[SaveState.DoNotSave]
public DisplayType Region { get; private set; }
[SaveState.DoNotSave]
public ISoundProvider _soundProvider { get; private set; }
#endregion
private ISoundProvider _soundProvider;
private void DoCycle()
{