diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index f2b01ceb2d..3790384b99 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -192,10 +192,15 @@ C64.cs - + + C64.cs + C64.cs + + C64.cs + C64.cs diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs index 28390722b6..1daea67206 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs @@ -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 IDebuggable.GetCpuFlagsAndRegisters() + public IDictionary 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; } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs index 12b03b93ac..178002cac2 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs @@ -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 diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs new file mode 100644 index 0000000000..621963da8f --- /dev/null +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs @@ -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; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 7450867e65..8ec470400e 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -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 roms, object settings, object syncSettings) { PutSyncSettings((C64SyncSettings)syncSettings ?? new C64SyncSettings()); @@ -51,14 +49,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 ((BasicServiceProvider)ServiceProvider).Register(_soundProvider); } - DeterministicEmulation = true; - ((BasicServiceProvider)ServiceProvider).Register(_board.Vic); ((BasicServiceProvider)ServiceProvider).Register(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() {