diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index ffd41c1f4d..5a989ad135 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -290,6 +290,9 @@ Atari2600.cs + + Atari2600.cs + Atari2600.cs diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs index 8ee9b1f331..06e4261788 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII var domains = new List(); var mainRamDomain = new MemoryDomainDelegate("Main Ram", 0xC000, MemoryDomain.Endian.Little, - (addr) => + addr => { if (addr < 0 || addr >= 0xC000) { @@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII domains.Add(mainRamDomain); var systemBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, - (addr) => + addr => { if (addr < 0 || addr >= 65536) { diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index 38a91b7c74..bfcf0031ab 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -172,7 +172,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII _prevPressed = false; } - _machine.BizFrameAdvance(RealButtons.Where(b => controller.IsPressed(b))); + _machine.BizFrameAdvance(RealButtons.Where(controller.IsPressed)); if (IsLagFrame) { LagCount++; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs index 249468281a..163dc531f7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs @@ -14,6 +14,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private DCFilter _dcfilter; private MapperBase _mapper; + private readonly GameInfo _game; + private int _frame; + internal byte[] Ram; internal byte[] Rom { get; private set; } @@ -31,6 +34,16 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private bool _leftDifficultySwitchHeld = false; private bool _rightDifficultySwitchHeld = false; + private static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition + { + Name = "Atari 2600 Basic Controller", + BoolButtons = + { + "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button", + "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button", + "Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty" + } + }; internal byte BaseReadMemory(ushort addr) { @@ -365,17 +378,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private IController _controller; - public void FrameAdvance(IController controller, bool render, bool rendersound) - { - _controller = controller; - StartFrameCond(); - while (_tia.LineCount < _tia.NominalNumScanlines) - Cycle(); - if (rendersound==false) - _tia._audioClocks = 0; // we need this here since the async sound provider won't check in this case - FinishFrameCond(); - } - private void VFrameAdvance() // advance up to 500 lines looking for end of video frame // after vsync falling edge, continues to end of next line { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs new file mode 100644 index 0000000000..7d203baf8a --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs @@ -0,0 +1,48 @@ +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Atari.Atari2600 +{ + public partial class Atari2600 : IEmulator + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition => Atari2600ControllerDefinition; + + public void FrameAdvance(IController controller, bool render, bool rendersound) + { + _controller = controller; + + StartFrameCond(); + while (_tia.LineCount < _tia.NominalNumScanlines) + { + Cycle(); + } + + if (rendersound == false) + { + _tia._audioClocks = 0; // we need this here since the async sound provider won't check in this case + } + + FinishFrameCond(); + } + + public int Frame => _frame; + + public string SystemId => "A26"; + + public bool DeterministicEmulation => true; + + public CoreComm CoreComm { get; } + + public void ResetCounters() + { + _frame = 0; + _lagcount = 0; + _islag = false; + } + + public void Dispose() + { + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index aae14890ac..78be6ec12f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -9,18 +9,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { [CoreAttributes( "Atari2600Hawk", - "Micro500, adelikat, natt", + "Micro500, Alyosha, adelikat, natt", isPorted: false, isReleased: true)] [ServiceNotApplicable(typeof(ISaveRam), typeof(IDriveLight))] public partial class Atari2600 : IEmulator, IStatable, IDebuggable, IInputPollable, IBoardInfo, IRegionable, ICreateGameDBEntries, ISettable { - private readonly GameInfo _game; - private int _frame; - - private ITraceable Tracer { get; } - [CoreConstructor("A26")] public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { @@ -63,30 +58,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Register(_dcfilter); } - public IEmulatorServiceProvider ServiceProvider { get; } - + // IRegionable public DisplayType Region => _pal ? DisplayType.PAL : DisplayType.NTSC; - public string SystemId => "A26"; - - public CoreComm CoreComm { get; } - - public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } } - - public int Frame { get { return _frame; } set { _frame = value; } } - - public bool DeterministicEmulation { get; set; } - - public static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition - { - Name = "Atari 2600 Basic Controller", - BoolButtons = - { - "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button", - "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button", - "Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty" - } - }; + // ITraceable + private ITraceable Tracer { get; } // ICreateGameDBEntries public CompactGameInfo GenerateGameDbEntry() @@ -105,25 +81,19 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // IBoardInfo public string BoardName => _mapper.GetType().Name; - public void ResetCounters() - { - _frame = 0; - _lagcount = 0; - _islag = false; - } - - public void Dispose() - { - } - private static bool DetectPal(GameInfo game, byte[] rom) { // force NTSC mode for the new core we instantiate var newgame = game.Clone(); if (newgame["PAL"]) + { newgame.RemoveOption("PAL"); + } + if (!newgame["NTSC"]) + { newgame.AddOption("NTSC"); + } // give the emu a minimal of input\output connections so it doesn't crash var comm = new CoreComm(null, null);