From f83261c116ae5ba24a573ad2332434abe8e61ddf Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 11 Jan 2020 13:19:12 -0600 Subject: [PATCH] misc cleanups in emulator core service logic --- .../Calculator/TI83.IDebuggable.cs | 2 - .../Calculator/TI83.IEmulator.cs | 8 +- .../Calculator/TI83.IInputPollable.cs | 8 +- .../Calculator/TI83.IMemoryDomains.cs | 10 +- .../Calculator/TI83.ISettable.cs | 15 +- .../Calculator/TI83.IStatable.cs | 3 +- .../Calculator/TI83.IVideoProvider.cs | 10 +- .../AppleII/AppleII.IDisassembler.cs | 6 +- .../Computers/AppleII/AppleII.IEmulator.cs | 4 +- .../AppleII/AppleII.IInputPollable.cs | 4 +- .../AppleII/AppleII.IMemoryDomains.cs | 2 +- .../Computers/AppleII/AppleII.IStatable.cs | 2 - .../AppleII/AppleII.IVideoProvider.cs | 15 +- .../Commodore64/C64.IDisassemblable.cs | 4 +- .../Computers/Commodore64/C64.IEmulator.cs | 2 +- .../Commodore64/C64.IInputPollable.cs | 8 +- .../Computers/Commodore64/C64.ISettable.cs | 2 +- .../Consoles/Atari/2600/Atari2600.Core.cs | 2 +- .../Atari/2600/Atari2600.IEmulator.cs | 10 +- .../Atari/2600/Atari2600.IInputPollable.cs | 10 +- .../Atari/2600/Atari2600.IMemoryDomains.cs | 8 +- .../Atari/2600/Atari2600.ISettable.cs | 16 +- .../Atari/2600/Atari2600.IStatable.cs | 2 +- .../Atari/2600/Atari2600.RomHeuristics.cs | 4 +- .../Atari/A7800Hawk/A7800Hawk.IDebuggable.cs | 5 +- .../Atari/A7800Hawk/A7800Hawk.IEmulator.cs | 12 +- .../A7800Hawk/A7800Hawk.IInputPollable.cs | 12 +- .../A7800Hawk/A7800Hawk.IMemoryDomains.cs | 11 +- .../Atari/A7800Hawk/A7800Hawk.ISaveRam.cs | 8 +- .../Atari/A7800Hawk/A7800Hawk.ISettable.cs | 11 +- .../Atari/A7800Hawk/A7800Hawk.IStatable.cs | 4 +- .../Consoles/Atari/A7800Hawk/M6532.cs | 4 +- .../Consoles/Atari/A7800Hawk/MemoryMap.cs | 48 +++--- .../Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs | 12 +- .../Atari/lynx/Lynx.IInputPollable.cs | 2 +- .../Atari/lynx/Lynx.IMemoryDomains.cs | 10 +- .../Consoles/Atari/lynx/Lynx.ISaveRam.cs | 24 +-- .../Atari/lynx/Lynx.ISoundProvider.cs | 8 +- .../Consoles/Atari/lynx/Lynx.IStatable.cs | 22 +-- .../Atari/lynx/Lynx.IVideoProvider.cs | 7 +- .../Consoles/Atari/lynx/Lynx.cs | 10 +- .../Consoles/Belogic/Uzem.cs | 4 - .../Coleco/ColecoVision.IDebuggable.cs | 2 - .../Consoles/Coleco/ColecoVision.IEmulator.cs | 24 +-- .../Coleco/ColecoVision.IInputPollable.cs | 10 +- .../Coleco/ColecoVision.IMemoryDomains.cs | 6 +- .../Consoles/Coleco/ColecoVision.ISettable.cs | 12 +- .../Coleco/ColecoVision.ISoundProvider.cs | 6 +- .../Consoles/Coleco/ColecoVision.IStatable.cs | 2 +- .../Intellivision.IDisassemblable.cs | 7 +- .../Intellivision/Intellivision.IEmulator.cs | 10 +- .../Intellivision.IInputPollable.cs | 26 +--- .../Intellivision.IMemoryDomains.cs | 4 +- .../Intellivision/Intellivision.ISettable.cs | 4 +- .../Intellivision/Intellivision.IStatable.cs | 4 +- .../Intellivision/Intellivision.MemoryMap.cs | 4 +- .../Nintendo/QuickNES/QuickNES.IDebuggable.cs | 7 +- .../QuickNES/QuickNES.IDisassembler.cs | 15 +- .../QuickNES/QuickNES.IInputPollable.cs | 2 +- .../QuickNES/QuickNES.IMemoryDomains.cs | 2 +- .../QuickNES/QuickNES.INESPPUViewable.cs | 50 ++----- .../Nintendo/QuickNES/QuickNES.ISaveRam.cs | 16 +- .../Nintendo/QuickNES/QuickNES.ISettable.cs | 23 ++- .../QuickNES/QuickNES.ISoundProvider.cs | 26 ++-- .../Nintendo/QuickNES/QuickNES.IStatable.cs | 48 +++--- .../Nintendo/QuickNES/QuickNES.ITraceable.cs | 11 +- .../QuickNES/QuickNES.IVideoProvider.cs | 38 ++--- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 6 +- .../Nintendo/SNES/LibsnesCore.IDebuggable.cs | 8 +- .../Nintendo/SNES/LibsnesCore.IEmulator.cs | 10 +- .../SNES/LibsnesCore.IMemoryDomains.cs | 16 +- .../Nintendo/SNES/LibsnesCore.IRegionable.cs | 15 +- .../Nintendo/SNES/LibsnesCore.ISettable.cs | 4 +- .../Nintendo/SNES/LibsnesCore.IStatable.cs | 4 +- .../SNES/LibsnesCore.IVideoProvider.cs | 5 +- .../Consoles/Nintendo/SNES9X/Snes9x.cs | 3 - .../SubNESHawk/SubNESHawk.IDebuggable.cs | 5 +- .../SubNESHawk/SubNESHawk.IEmulator.cs | 16 +- .../SubNESHawk/SubNESHawk.IInputPollable.cs | 12 +- .../SubNESHawk/SubNESHawk.IMemoryDomains.cs | 5 +- .../SubNESHawk/SubNESHawk.ISaveRam.cs | 19 ++- .../SubNESHawk/SubNESHawk.IStatable.cs | 9 +- .../PC Engine/PCEngine.ICodeDataLogger.cs | 4 +- .../Consoles/PC Engine/PCEngine.IEmulator.cs | 6 +- .../PC Engine/PCEngine.IInputPollable.cs | 13 +- .../PC Engine/PCEngine.IMemoryDomains.cs | 22 +-- .../Consoles/PC Engine/PCEngine.ISaveRam.cs | 9 +- .../Consoles/SNK/NeoGeoPort.cs | 7 - .../GGHawkLink/GGHawkLink.ICodeDataLog.cs | 12 +- .../Sega/GGHawkLink/GGHawkLink.IDebuggable.cs | 5 +- .../Sega/GGHawkLink/GGHawkLink.IEmulator.cs | 24 +-- .../GGHawkLink/GGHawkLink.IInputPollable.cs | 12 +- .../GGHawkLink/GGHawkLink.IMemoryDomains.cs | 14 +- .../Sega/GGHawkLink/GGHawkLink.ISaveRam.cs | 30 ++-- .../Sega/GGHawkLink/GGHawkLink.IStatable.cs | 4 +- .../Consoles/Sega/GGHawkLink/GGHawkLink.cs | 9 +- .../Consoles/Sega/PicoDrive/LibPicoDrive.cs | 4 - .../Consoles/Sega/Saturn/Saturnus.cs | 11 +- .../Sega/gpgx64/GPGX.ICodeDataLogger.cs | 10 +- .../Sega/gpgx64/GPGX.IDisassembler.cs | 12 +- .../Consoles/Sega/gpgx64/GPGX.IDriveLight.cs | 4 +- .../Consoles/Sega/gpgx64/GPGX.IEmulator.cs | 30 ++-- .../Sega/gpgx64/GPGX.IInputPollable.cs | 4 +- .../Sega/gpgx64/GPGX.IMemoryDomains.cs | 14 +- .../Consoles/Sega/gpgx64/GPGX.ISaveRam.cs | 7 +- .../Consoles/Sega/gpgx64/GPGX.ISettable.cs | 60 ++------ .../Sega/gpgx64/GPGX.ISoundProvider.cs | 26 ++-- .../Consoles/Sega/gpgx64/GPGX.IStatable.cs | 5 +- .../Sega/gpgx64/GPGX.IVideoProvider.cs | 51 +++---- .../Consoles/Sega/gpgx64/GPGX.cs | 8 +- .../Sega/gpgx64/GPGXControlConverter.cs | 137 +++++++++--------- .../WonderSwan/WonderSwan.Controller.cs | 8 +- .../WonderSwan/WonderSwan.IMemoryDomains.cs | 14 +- .../WonderSwan/WonderSwan.ISaveRam.cs | 25 ++-- .../WonderSwan/WonderSwan.ISettable.cs | 3 - .../WonderSwan/WonderSwan.ISoundProvider.cs | 12 +- .../WonderSwan/WonderSwan.IStatable.cs | 2 +- BizHawk.sln.DotSettings | 11 ++ 118 files changed, 621 insertions(+), 875 deletions(-) diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs index e6477b56fd..f183cf273a 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; - -using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Calculators diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs index c76e33f2c9..d064695326 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Calculators public ControllerDefinition ControllerDefinition => TI83Controller; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; _lagged = true; @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Calculators TIM_1_int = true; _cpu.FlagI = true; } - } + } } Frame++; @@ -65,8 +65,8 @@ namespace BizHawk.Emulation.Cores.Calculators public int Frame { - get { return _frame; } - private set { _frame = value; } + get => _frame; + private set => _frame = value; } public string SystemId => "TI83"; diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs index ca3e882fc9..a31df55395 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IInputPollable.cs @@ -10,16 +10,16 @@ namespace BizHawk.Emulation.Cores.Calculators public int LagCount { - get { return _lagCount; } - set { _lagCount = value; } + get => _lagCount; + set => _lagCount = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); public bool IsLagFrame { - get { return _isLag; } - set { _isLag = value; } + get => _isLag; + set => _isLag = value; } } } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs index a1bd4aa083..a41f923225 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IMemoryDomains.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Calculators { private readonly Dictionary _byteArrayDomains = new Dictionary(); private IMemoryDomains _memoryDomains; - private bool _memoryDomainsInit = false; + private bool _memoryDomainsInit; private void SetupMemoryDomains() { @@ -20,13 +20,19 @@ namespace BizHawk.Emulation.Cores.Calculators (addr) => { if (addr < 0 || addr >= 65536) + { throw new ArgumentOutOfRangeException(); + } + return _cpu.ReadMemory((ushort)addr); }, (addr, value) => { if (addr < 0 || addr >= 65536) + { throw new ArgumentOutOfRangeException(); + } + _cpu.WriteMemory((ushort)addr, value); }, 1); @@ -35,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Calculators SyncAllByteArrayDomains(); _memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); - (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); _memoryDomainsInit = true; } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs index c3d84b355e..c637365861 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.ISettable.cs @@ -4,16 +4,16 @@ namespace BizHawk.Emulation.Cores.Calculators { public partial class TI83 : ISettable { - private TI83Settings Settings; + private TI83Settings _settings; public TI83Settings GetSettings() { - return Settings.Clone(); + return _settings.Clone(); } public bool PutSettings(TI83Settings o) { - Settings = o; + _settings = o; return false; } @@ -29,13 +29,8 @@ namespace BizHawk.Emulation.Cores.Calculators public class TI83Settings { - public uint BGColor = 0x889778; - public uint ForeColor = 0x36412D; - - public TI83Settings() - { - - } + public uint BGColor { get; set; } = 0x889778; + public uint ForeColor { get; set; } = 0x36412D; public TI83Settings Clone() { diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs index e0a7286fa3..536e1b6cf9 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs @@ -40,12 +40,11 @@ namespace BizHawk.Emulation.Cores.Calculators private void SyncState(Serializer ser) { - byte[] core = null; if (ser.IsWriter) { var ms = new MemoryStream(); ms.Close(); - core = ms.ToArray(); + ms.ToArray(); } _cpu.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IVideoProvider.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IVideoProvider.cs index ea4c4f85b6..1ea0a88ed6 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IVideoProvider.cs @@ -22,19 +22,19 @@ namespace BizHawk.Emulation.Cores.Calculators for (int x = 0; x < 96; x++) { int offset = (y * 96) + x; - int bufbyte = offset >> 3; - int bufbit = offset & 7; - int bit = (_vram[bufbyte] >> (7 - bufbit)) & 1; + int buffByte = offset >> 3; + int buffBit = offset & 7; + int bit = (_vram[buffByte] >> (7 - buffBit)) & 1; if (bit == 0) { unchecked { - pixels[i++] = (int)Settings.BGColor; + pixels[i++] = (int)_settings.BGColor; } } else { - pixels[i++] = (int)Settings.ForeColor; + pixels[i++] = (int)_settings.ForeColor; } } } diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs index b7184d053f..4ae4f1a107 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDisassembler.cs @@ -9,11 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII { public string Cpu { - get - { - return "6502"; - } - + get => "6502"; set { } diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs index 903fc365bd..82c5cda2c4 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs @@ -14,9 +14,9 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII public bool DeterministicEmulation => true; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { - FrameAdv(controller, render, rendersound); + FrameAdv(controller, render, renderSound); return true; } diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs index 51f471dab3..f0ff0e291c 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs @@ -8,8 +8,8 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII public bool IsLagFrame { - get { return _machine.Lagged; } - set { _machine.Lagged = value; } + get => _machine.Lagged; + set => _machine.Lagged = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs index 06e4261788..4efccf5c36 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IMemoryDomains.cs @@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII domains.Add(systemBusDomain); _memoryDomains = new MemoryDomainList(domains); - (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } private IMemoryDomains _memoryDomains; diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs index e7b748e46c..0da80cbc35 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs @@ -5,8 +5,6 @@ using BizHawk.Emulation.Common; using Jellyfish.Virtu; using Newtonsoft.Json; -using Newtonsoft.Json.Bson; -using Newtonsoft.Json.Linq; namespace BizHawk.Emulation.Cores.Computers.AppleII { diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs index 29e17983af..2b2ed9d145 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IVideoProvider.cs @@ -4,10 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII { public partial class AppleII : IVideoProvider { - public int[] GetVideoBuffer() - { - return _machine.Video.VideoService.fb; - } + public int[] GetVideoBuffer() => _machine.Video.VideoService.fb; // put together, these describe a metric on the screen // they should define the smallest size that the buffer can be placed inside such that: @@ -22,19 +19,13 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII public int VsyncNumerator { [FeatureNotImplemented] // TODO: precise numbers or confirm the default is okay - get - { - return NullVideo.DefaultVsyncNum; - } + get => NullVideo.DefaultVsyncNum; } public int VsyncDenominator { [FeatureNotImplemented] // TODO: precise numbers or confirm the default is okay - get - { - return NullVideo.DefaultVsyncDen; - } + get => NullVideo.DefaultVsyncDen; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs index a37204c755..944c24bcb9 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDisassemblable.cs @@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { var currentSelectedDisassemblable = _selectedDisassemblable; _selectedDisassemblable = GetAvailableDisassemblables().FirstOrDefault(d => d.Cpu == value) ?? currentSelectedDisassemblable; - if (_selectedDisassemblable is IDebuggable) + if (_selectedDisassemblable is IDebuggable debuggable) { - _selectedDebuggable = _selectedDisassemblable as IDebuggable; + _selectedDebuggable = debuggable; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs index b0f5b1a55c..1c2fc7b140 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public ControllerDefinition ControllerDefinition => C64ControllerDefinition; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _board.Controller = controller; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs index ca419faa8c..32590f0a7b 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IInputPollable.cs @@ -6,14 +6,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public bool IsLagFrame { - get { return _isLagFrame; } - set { _isLagFrame = value; } + get => _isLagFrame; + set => _isLagFrame = value; } public int LagCount { - get { return _lagCount; } - set { _lagCount = value; } + get => _lagCount; + set => _lagCount = value; } public IInputCallbackSystem InputCallbacks { get; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs index d58347d4d0..c62b885bbd 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.ISettable.cs @@ -3,7 +3,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Computers.Commodore64 { - // adelikat: changing settings to default object until there are actually settings, as the ui depends on it to know if there are any settings avaialable + // adelikat: changing settings to default object until there are actually settings, as the ui depends on it to know if there are any settings available public partial class C64 : ISettable { public C64Settings GetSettings() diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs index 3c479b2647..ccb90651e9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs @@ -317,7 +317,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _mapper.Core = this; - _lagcount = 0; + _lagCount = 0; Cpu = new MOS6502X(new CpuLink(this)); if (_game["PAL"]) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs index 23585fb39f..705cef1f2e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; @@ -58,20 +58,20 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else { throw new Exception("ERROR: Unable to resolve Frame. Please Report."); - } + } } } _tia.New_Frame = false; - if (rendersound == false) + if (renderSound == false) { _tia.AudioClocks = 0; // we need this here since the async sound provider won't check in this case } if (_islag) { - _lagcount++; + _lagCount++; } _tia.LineCount = 0; @@ -90,7 +90,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public void ResetCounters() { _frame = 0; - _lagcount = 0; + _lagCount = 0; _islag = false; } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs index 2a9044428d..2eb1f4e032 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IInputPollable.cs @@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { public int LagCount { - get { return _lagcount; } - set { _lagcount = value; } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get { return _islag; } - set { _islag = value; } + get => _islag; + set => _islag = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); private bool _islag = true; - private int _lagcount; + private int _lagCount; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs index b034755ae3..1899121854 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { internal IMemoryDomains MemoryDomains; private readonly Dictionary _byteArrayDomains = new Dictionary(); - private bool _memoryDomainsInit = false; + private bool _memoryDomainsInit; private void SetupMemoryDomains() { @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 SyncAllByteArrayDomains(); MemoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); - (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + ((BasicServiceProvider)ServiceProvider).Register(MemoryDomains); _memoryDomainsInit = true; } @@ -57,9 +57,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { SyncByteArrayDomain("Main RAM", _ram); - if (_mapper is mDPC) + if (_mapper is mDPC dpc) { - SyncByteArrayDomain("DPC", (_mapper as mDPC).DspData); + SyncByteArrayDomain("DPC", dpc.DspData); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.ISettable.cs index 92eaeee755..c1f6aa0011 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.ISettable.cs @@ -101,8 +101,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 [DefaultValue(24)] public int NTSCTopLine { - get { return _ntscTopLine; } - set { _ntscTopLine = Math.Min(64, Math.Max(value, 0)); } + get => _ntscTopLine; + set => _ntscTopLine = Math.Min(64, Math.Max(value, 0)); } [DisplayName("NTSC Bottom Line")] @@ -110,8 +110,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 [DefaultValue(248)] public int NTSCBottomLine { - get { return _ntscBottomLine; } - set { _ntscBottomLine = Math.Min(260, Math.Max(value, 192)); } + get => _ntscBottomLine; + set => _ntscBottomLine = Math.Min(260, Math.Max(value, 192)); } [DisplayName("PAL Top Line")] @@ -119,8 +119,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 [DefaultValue(24)] public int PALTopLine { - get { return _palTopLine; } - set { _palTopLine = Math.Min(64, Math.Max(value, 0)); } + get => _palTopLine; + set => _palTopLine = Math.Min(64, Math.Max(value, 0)); } [DisplayName("PAL Bottom Line")] @@ -128,8 +128,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 [DefaultValue(296)] public int PALBottomLine { - get { return _palBottomLine; } - set { _palBottomLine = Math.Min(310, Math.Max(value, 192)); } + get => _palBottomLine; + set => _palBottomLine = Math.Min(310, Math.Max(value, 192)); } [DisplayName("Background Color")] diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs index 8ab93398d9..bbc8c721cd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs @@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.BeginSection("A2600"); Cpu.SyncState(ser); ser.Sync("ram", ref _ram, false); - ser.Sync("Lag", ref _lagcount); + ser.Sync("Lag", ref _lagCount); ser.Sync("Frame", ref _frame); ser.Sync("IsLag", ref _islag); ser.Sync(nameof(cyc_counter), ref cyc_counter); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs index 54a53da195..928596d20b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.RomHeuristics.cs @@ -443,12 +443,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private static bool ContainsAny(byte[] rom, IEnumerable signatures) { - return signatures.Any(signature => rom.FindBytes(signature)); + return signatures.Any(rom.FindBytes); } private static bool ContainsAll(byte[] rom, IEnumerable signatures) { - return signatures.All(signature => rom.FindBytes(signature)); + return signatures.All(rom.FindBytes); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IDebuggable.cs index 343f831e5e..00cfe7e28a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IDebuggable.cs @@ -67,9 +67,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk throw new NotImplementedException(); } - public long TotalExecutedCycles - { - get { return cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs index 667ee16c13..4c27b32215 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs @@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public bool slow_access = false; public int slow_countdown; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { if (_tracer.Enabled) { @@ -77,16 +77,16 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk HardReset(); } - _islag = true; + _isLag = true; GetControllerState(controller); GetConsoleState(controller); maria.RunFrame(); - if (_islag) + if (_isLag) { - _lagcount++; + _lagCount++; } return true; @@ -322,8 +322,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public void ResetCounters() { _frame = 0; - _lagcount = 0; - _islag = false; + _lagCount = 0; + _isLag = false; } public CoreComm CoreComm { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IInputPollable.cs index 349ab3b549..547b0513a3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IInputPollable.cs @@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { public int LagCount { - get { return _lagcount; } - set { _lagcount = value; } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get { return _islag; } - set { _islag = value; } + get => _isLag; + set => _isLag = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); - public bool _islag = true; - private int _lagcount; + public bool _isLag = true; + private int _lagCount; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IMemoryDomains.cs index ce29d7ba3f..42369d2cc8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IMemoryDomains.cs @@ -1,14 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { public partial class A7800Hawk { - private IMemoryDomains MemoryDomains; + private IMemoryDomains _memoryDomains; public void SetupMemoryDomains() { @@ -65,8 +62,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk 1) }; - MemoryDomains = new MemoryDomainList(domains); - (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + _memoryDomains = new MemoryDomainList(domains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } private byte PeekSystemBus(long addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISaveRam.cs index 6f8004fd45..875dbcf8d3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISaveRam.cs @@ -15,12 +15,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk Buffer.BlockCopy(data, 0, _hsram, 0, data.Length); } - public bool SaveRamModified - { - get - { - return (_hsbios != null); - } - } + public bool SaveRamModified => (_hsbios != null); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs index 88e9a55297..165e6ae5b1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.ISettable.cs @@ -56,17 +56,14 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk [JsonIgnore] public string Filter { - get { return _Filter; } - set - { - _Filter = value; - } + get => _Filter; + set => _Filter = value; } [JsonIgnore] public string Port1 { - get { return _port1; } + get => _port1; set { if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value)) @@ -81,7 +78,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk [JsonIgnore] public string Port2 { - get { return _port2; } + get => _port2; set { if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value)) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs index d6bf7f09a0..e417f03e99 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs @@ -48,9 +48,9 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk pokey.SyncState(ser); ser.BeginSection("Atari7800"); - ser.Sync("Lag", ref _lagcount); + ser.Sync("Lag", ref _lagCount); ser.Sync("Frame", ref _frame); - ser.Sync("IsLag", ref _islag); + ser.Sync("IsLag", ref _isLag); _controllerDeck.SyncState(ser); ser.Sync(nameof(A7800_control_register), ref A7800_control_register); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs index 29385c0e75..43b773dfe7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs @@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk var registerAddr = (ushort)(addr & 0x0007); if (registerAddr == 0x00) { - Core._islag = false; + Core._isLag = false; // Read Output reg A // Combine readings from player 1 and player 2 @@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (registerAddr == 0x02) { - Core._islag = false; + Core._isLag = false; // Read Output reg B byte temp = Core.con_state; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs index 7f871dc7a4..a28e1b3939 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/MemoryMap.cs @@ -1,6 +1,4 @@ -using System; - -// X = don't care +// X = don't care /* 1. TIA 0000 00XX 0000 0000 - 0000 00XX 0001 1111 2. MARIA 0000 00XX 0010 0000 - 0000 00XX 0011 1111 @@ -30,13 +28,12 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { return 0xFF; // TODO: what to return here? } - else - { - slow_access = true; - return tia.ReadMemory((ushort)(addr & 0x1F), false); - } + + slow_access = true; + return tia.ReadMemory((ushort)(addr & 0x1F), false); } - else if ((addr & 0xFCE0) == 0x20) + + if ((addr & 0xFCE0) == 0x20) { if ((A7800_control_register & 0x2) > 0) { @@ -47,54 +44,61 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk return 0x80; // TODO: What if Maria is off? } } - else if ((addr & 0xFF80) == 0x280) + + if ((addr & 0xFF80) == 0x280) { slow_access = true; return m6532.ReadMemory(addr, false); } - else if ((addr & 0xFE80) == 0x480) + + if ((addr & 0xFE80) == 0x480) { slow_access = true; return RAM_6532[addr & 0x7F]; } - else if ((addr >= 0x1800) && (addr < 0x2800)) + + if ((addr >= 0x1800) && (addr < 0x2800)) { return RAM[addr -0x1800]; } - else if ((addr >= 0x40) && (addr < 0x100)) + + if ((addr >= 0x40) && (addr < 0x100)) { // RAM block 0 return RAM[addr - 0x40 + 0x840]; } - else if ((addr >= 0x140) && (addr < 0x200)) + + if ((addr >= 0x140) && (addr < 0x200)) { // RAM block 1 return RAM[addr - 0x140 + 0x940]; } - else if ((addr >= 0x2800) && (addr < 0x3000)) + + if ((addr >= 0x2800) && (addr < 0x3000)) { // this mirror evidently does not exist on hardware despite being in the documentation return 0xFF;// RAM[(addr & 0x7FF) + 0x800]; } - else if ((addr >= 0x3000) && (addr < 0x4000)) + + if ((addr >= 0x3000) && (addr < 0x4000)) { // could be either RAM mirror or ROM return mapper.ReadMemory(addr); } - else if ((addr >= 0x400) && (addr < 0x480)) + + if ((addr >= 0x400) && (addr < 0x480)) { // cartridge space available return mapper.ReadMemory(addr); } - else if ((addr >= 0x500) && (addr < 0x1800)) + + if ((addr >= 0x500) && (addr < 0x1800)) { // cartridge space available return mapper.ReadMemory(addr); } - else - { - return mapper.ReadMemory(addr); - } + + return mapper.ReadMemory(addr); } public void WriteMemory(ushort addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs index 3509efe335..15363fdaff 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs @@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { if ((Core.m6532._outputB & 0x04) == 0 && (Core.m6532._ddRb & 0x04) == 0x04) { - Core._islag = false; + Core._isLag = false; return (byte)(Core.p1_fire_2x & 0x80); } else @@ -106,7 +106,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { if ((Core.m6532._outputB & 0x04) == 0 && (Core.m6532._ddRb & 0x04) == 0x04) { - Core._islag = false; + Core._isLag = false; return (byte)((Core.p1_fire_2x & 0x40)<<1); } else @@ -119,7 +119,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { if ((Core.m6532._outputB & 0x10) == 0 && (Core.m6532._ddRb & 0x10) == 0x10) { - Core._islag = false; + Core._isLag = false; return (byte)(Core.p2_fire_2x & 0x80); } else @@ -132,7 +132,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { if ((Core.m6532._outputB & 0x10) == 0 && (Core.m6532._ddRb & 0x10) == 0x10) { - Core._islag = false; + Core._isLag = false; return (byte)((Core.p2_fire_2x & 0x40)<<1); } else @@ -143,7 +143,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (maskedAddr == 0x0C) // INPT4 { - Core._islag = false; + Core._isLag = false; if (!Core.p1_is_2button) { @@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk if (maskedAddr == 0x0D) // INPT5 { - Core._islag = false; + Core._isLag = false; if (!Core.p2_is_2button) { if (!Core.p2_is_lightgun) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs index be6b17fe03..7c081b73e4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IInputPollable.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] - get { throw new NotImplementedException(); } + get => throw new NotImplementedException(); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IMemoryDomains.cs index de6af23d3a..4a090fe8fb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IMemoryDomains.cs @@ -14,16 +14,12 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx new MemoryDomainIntPtr("RAM", MemoryDomain.Endian.Little, LibLynx.GetRamPointer(Core), 65536, true, 2) }; - IntPtr p; - int s; - if (LibLynx.GetSaveRamPtr(Core, out s, out p)) + if (LibLynx.GetSaveRamPtr(Core, out var s, out var p)) { mms.Add(new MemoryDomainIntPtr("Save RAM", MemoryDomain.Endian.Little, p, s, true, 2)); } - IntPtr p0, p1; - int s0, s1; - LibLynx.GetReadOnlyCartPtrs(Core, out s0, out p0, out s1, out p1); + LibLynx.GetReadOnlyCartPtrs(Core, out var s0, out var p0, out var s1, out var p1); if (s0 > 0 && p0 != IntPtr.Zero) { mms.Add(new MemoryDomainIntPtr("Cart A", MemoryDomain.Endian.Little, p0, s0, false, 2)); @@ -35,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx } _memoryDomains = new MemoryDomainList(mms); - (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } private IMemoryDomains _memoryDomains; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISaveRam.cs index 7bd5e7572f..1d0c573615 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISaveRam.cs @@ -9,9 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx { public byte[] CloneSaveRam() { - int size; - IntPtr data; - if (!LibLynx.GetSaveRamPtr(Core, out size, out data)) + if (!LibLynx.GetSaveRamPtr(Core, out var size, out var data)) { return null; } @@ -21,31 +19,21 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx return ret; } - public void StoreSaveRam(byte[] srcdata) + public void StoreSaveRam(byte[] srcData) { - int size; - IntPtr data; - if (!LibLynx.GetSaveRamPtr(Core, out size, out data)) + if (!LibLynx.GetSaveRamPtr(Core, out var size, out var data)) { throw new InvalidOperationException(); } - if (size != srcdata.Length) + if (size != srcData.Length) { throw new ArgumentOutOfRangeException(); } - Marshal.Copy(srcdata, 0, data, size); + Marshal.Copy(srcData, 0, data, size); } - public bool SaveRamModified - { - get - { - int unused; - IntPtr unused2; - return LibLynx.GetSaveRamPtr(Core, out unused, out unused2); - } - } + public bool SaveRamModified => LibLynx.GetSaveRamPtr(Core, out int unused, out IntPtr unused2); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISoundProvider.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISoundProvider.cs index 216b1e1656..dcae3ea27f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISoundProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISoundProvider.cs @@ -5,15 +5,15 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx { public partial class Lynx : ISoundProvider { - private readonly short[] _soundbuff = new short[2048]; - private int _numsamp; + private readonly short[] _soundBuff = new short[2048]; + private int _numSamp; public bool CanProvideAsync => false; public void GetSamplesSync(out short[] samples, out int nsamp) { - samples = _soundbuff; - nsamp = _numsamp; + samples = _soundBuff; + nsamp = _numSamp; } public void DiscardSamples() diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs index e30efd4873..2f869099c9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs @@ -38,13 +38,13 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public void SaveStateBinary(BinaryWriter writer) { - if (!LibLynx.BinStateSave(Core, _savebuff, _savebuff.Length)) + if (!LibLynx.BinStateSave(Core, _saveBuff, _saveBuff.Length)) { throw new InvalidOperationException($"Core's {nameof(LibLynx.BinStateSave)}() returned false!"); } - writer.Write(_savebuff.Length); - writer.Write(_savebuff); + writer.Write(_saveBuff.Length); + writer.Write(_saveBuff); // other variables writer.Write(IsLagFrame); @@ -55,13 +55,13 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public void LoadStateBinary(BinaryReader reader) { int length = reader.ReadInt32(); - if (length != _savebuff.Length) + if (length != _saveBuff.Length) { throw new InvalidOperationException("Save buffer size mismatch!"); } - reader.Read(_savebuff, 0, length); - if (!LibLynx.BinStateLoad(Core, _savebuff, _savebuff.Length)) + reader.Read(_saveBuff, 0, length); + if (!LibLynx.BinStateLoad(Core, _saveBuff, _saveBuff.Length)) { throw new InvalidOperationException($"Core's {nameof(LibLynx.BinStateLoad)}() returned false!"); } @@ -74,22 +74,22 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public byte[] SaveStateBinary() { - using var ms = new MemoryStream(_savebuff2, true); + using var ms = new MemoryStream(_saveBuff2, true); using var bw = new BinaryWriter(ms); SaveStateBinary(bw); bw.Flush(); - if (ms.Position != _savebuff2.Length) + if (ms.Position != _saveBuff2.Length) { throw new InvalidOperationException(); } ms.Close(); - return _savebuff2; + return _saveBuff2; } private readonly JsonSerializer _ser = new JsonSerializer { Formatting = Formatting.Indented }; - private readonly byte[] _savebuff; - private readonly byte[] _savebuff2; + private readonly byte[] _saveBuff; + private readonly byte[] _saveBuff2; private class TextStateData { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IVideoProvider.cs index 2ee563fc5a..78091753f5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IVideoProvider.cs @@ -7,12 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx private const int Width = 160; private const int Height = 102; - private readonly int[] _videobuff = new int[Width * Height]; + private readonly int[] _videoBuff = new int[Width * Height]; - public int[] GetVideoBuffer() - { - return _videobuff; - } + public int[] GetVideoBuffer() => _videoBuff; public int VirtualWidth => BufferWidth; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index 72f42f4f66..4cb018b774 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -92,8 +92,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx Core = LibLynx.Create(realfile, realfile.Length, bios, bios.Length, pagesize0, pagesize1, false); try { - _savebuff = new byte[LibLynx.BinStateSize(Core)]; - _savebuff2 = new byte[_savebuff.Length + 13]; + _saveBuff = new byte[LibLynx.BinStateSize(Core)]; + _saveBuff2 = new byte[_saveBuff.Length + 13]; int rot = game.OptionPresent("rotate") ? int.Parse(game.OptionValue("rotate")) : 0; LibLynx.SetRotation(Core, rot); @@ -128,9 +128,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx LibLynx.Reset(Core); } - int samples = _soundbuff.Length; - IsLagFrame = LibLynx.Advance(Core, GetButtons(controller), _videobuff, _soundbuff, ref samples); - _numsamp = samples / 2; // sound provider wants number of sample pairs + int samples = _soundBuff.Length; + IsLagFrame = LibLynx.Advance(Core, GetButtons(controller), _videoBuff, _soundBuff, ref samples); + _numSamp = samples / 2; // sound provider wants number of sample pairs if (IsLagFrame) { LagCount++; diff --git a/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs b/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs index ea5cafe733..b82d2d494b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Belogic/Uzem.cs @@ -1,10 +1,6 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Belogic { diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs index 73ca2c072e..8427d8c478 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; - -using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.ColecoVision diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs index 8d8c7b8b48..a2bcdd88bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs @@ -70,8 +70,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision change2 = -(float)((ControllerDeck.temp_wheel2 + (360 - ControllerDeck.wheel2)) / 1.25); } - int changes_1 = change1 > 0 ? (int)Math.Floor(change1) : (int)Math.Ceiling(change1); - int changes_2 = change2 > 0 ? (int)Math.Floor(change2) : (int)Math.Ceiling(change2); + int changes1 = change1 > 0 ? (int)Math.Floor(change1) : (int)Math.Ceiling(change1); + int changes2 = change2 > 0 ? (int)Math.Floor(change2) : (int)Math.Ceiling(change2); for (int scanLine = 0; scanLine < 262; scanLine++) { @@ -88,10 +88,10 @@ namespace BizHawk.Emulation.Cores.ColecoVision for (int i = 0; i < 228; i++) { PSG.generate_sound(1); - if (use_SGM) { SGM_sound.generate_sound(1); } + if (use_SGM) { SGM_sound.generate_sound(1); } _cpu.ExecuteOne(); - // pick out sound samples from the sound devies twice per scanline + // pick out sound samples from the sound devices twice per scanline int v = PSG.Sample(); if (use_SGM) @@ -111,31 +111,31 @@ namespace BizHawk.Emulation.Cores.ColecoVision // starting from scanline 20, changes to the wheel are added once per scanline (up to 144) if (scanLine > 20) { - if (changes_1 != 0) + if (changes1 != 0) { - if (changes_1 > 0) + if (changes1 > 0) { ControllerDeck.temp_wheel1 = (float)((ControllerDeck.temp_wheel1 + 1.25) % 360); - changes_1--; + changes1--; } else { ControllerDeck.temp_wheel1 = (float)((ControllerDeck.temp_wheel1 - 1.25) % 360); - changes_1++; + changes1++; } } - if (changes_2 != 0) + if (changes2 != 0) { - if (changes_2 > 0) + if (changes2 > 0) { ControllerDeck.temp_wheel2 = (float)((ControllerDeck.temp_wheel2 + 1.25) % 360); - changes_2--; + changes2--; } else { ControllerDeck.temp_wheel2 = (float)((ControllerDeck.temp_wheel2 - 1.25) % 360); - changes_2++; + changes2++; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs index 3c9708667b..bace4830d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IInputPollable.cs @@ -7,20 +7,20 @@ namespace BizHawk.Emulation.Cores.ColecoVision { public int LagCount { - get { return _lagCount; } - set { _lagCount = value; } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get { return _isLag; } - set { _isLag = value; } + get => _isLag; + set => _isLag = value; } public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] - get { throw new NotImplementedException(); } + get => throw new NotImplementedException(); } private int _lagCount = 0; diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs index dc5501642d..2dd95c12be 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision { public partial class ColecoVision { - private MemoryDomainList memoryDomains; + private MemoryDomainList _memoryDomains; private readonly Dictionary _byteArrayDomains = new Dictionary(); private bool _memoryDomainsInit = false; @@ -48,8 +48,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision SyncAllByteArrayDomains(); - memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); - (ServiceProvider as BasicServiceProvider).Register(memoryDomains); + _memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); + ((BasicServiceProvider)ServiceProvider).Register(_memoryDomains); _memoryDomainsInit = true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISettable.cs index 5dfee99534..e083d0eb0d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISettable.cs @@ -54,11 +54,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision [JsonIgnore] public string Port1 { - get - { - return _port1; - } - + get => _port1; set { if (!ColecoVisionControllerDeck.ValidControllerTypes.ContainsKey(value)) @@ -73,11 +69,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision [JsonIgnore] public string Port2 { - get - { - return _port2; - } - + get => _port2; set { if (!ColecoVisionControllerDeck.ValidControllerTypes.ContainsKey(value)) diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISoundProvider.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISoundProvider.cs index ccb6ba44f3..9d906296a2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISoundProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.ISoundProvider.cs @@ -6,8 +6,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision { public partial class ColecoVision : ISoundProvider { - private SN76489col PSG; - private AY_3_8910_SGM SGM_sound; + private readonly SN76489col PSG; + private readonly AY_3_8910_SGM SGM_sound; private readonly BlipBuffer _blip = new BlipBuffer(4096); @@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision for (int i = 0; i < nsamp * 2; i += 2) { samples[i + 1] = samples[i]; - } + } } public void GetSamples(short[] samples) diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs index 8770d66919..599f40ebea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs @@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision } _cpu.SyncState(ser); - ser.BeginSection("Coleco"); + ser.BeginSection("Coleco"); _vdp.SyncState(ser); ControllerDeck.SyncState(ser); PSG.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs index 5494aa548e..df00bdc290 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDisassemblable.cs @@ -7,14 +7,11 @@ namespace BizHawk.Emulation.Cores.Intellivision { public string Cpu { - get { return "CP1610"; } + get => "CP1610"; set { } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public IEnumerable AvailableCpus { diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs index 0d0dd5dee2..c25aedc167 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { if (_tracer.Enabled) { @@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Intellivision _cpu.PendingCycles = 14934 - 3791 + _cpu.GetPendingCycles(); _stic.Sr1 = true; - _islag = true; + _isLag = true; bool activeDisplay = _stic.active_display; @@ -110,9 +110,9 @@ namespace BizHawk.Emulation.Cores.Intellivision _stic.in_vb_2 = false; - if (_islag) + if (_isLag) { - _lagcount++; + _lagCount++; } if (controller.IsPressed("Power")) @@ -137,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public void ResetCounters() { _frame = 0; - _lagcount = 0; + _lagCount = 0; } public CoreComm CoreComm { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs index acf63f850c..2b4214f217 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IInputPollable.cs @@ -6,33 +6,19 @@ namespace BizHawk.Emulation.Cores.Intellivision { public int LagCount { - get - { - return _lagcount; - } - - set - { - _lagcount = value; - } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get - { - return _islag; - } - - set - { - _islag = value; - } + get => _isLag; + set => _isLag = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); - private bool _islag; - private int _lagcount; + private bool _isLag; + private int _lagCount; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IMemoryDomains.cs index 85cd7669f2..8668bca6f6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IMemoryDomains.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.Linq; - using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Intellivision @@ -63,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Intellivision }; MemoryDomains = new MemoryDomainList(domains); - (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + ((BasicServiceProvider) ServiceProvider).Register(MemoryDomains); } private byte PeekSystemBus(long addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs index 2097ac67e8..f6a63569d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.ISettable.cs @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Intellivision [JsonIgnore] public string Port1 { - get { return _port1; } + get => _port1; set { if (!IntellivisionControllerDeck.ValidControllerTypes.ContainsKey(value)) @@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Intellivision [JsonIgnore] public string Port2 { - get { return _port2; } + get => _port2; set { if (!IntellivisionControllerDeck.ValidControllerTypes.ContainsKey(value)) diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs index 79d6c0c4e0..36285ad7df 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs @@ -53,8 +53,8 @@ namespace BizHawk.Emulation.Cores.Intellivision ser.Sync(nameof(ExecutiveRom), ref ExecutiveRom, false); ser.Sync(nameof(GraphicsRom), ref GraphicsRom, false); ser.Sync(nameof(GraphicsRam), ref GraphicsRam, false); - ser.Sync("islag", ref _islag); - ser.Sync("lagcount", ref _lagcount); + ser.Sync("islag", ref _isLag); + ser.Sync("lagcount", ref _lagCount); _cpu.SyncState(ser); _stic.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs index 4b70a918d5..fed35f0f0e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.MemoryMap.cs @@ -42,14 +42,14 @@ if (addr==0x01FE) { if (!peek) - _islag = false; + _isLag = false; return _psg.Register[14]; } if (addr == 0x01FF) { if (!peek) - _islag = false; + _isLag = false; return _psg.Register[15]; } break; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs index d2bb1f5212..c102a3b114 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs @@ -35,13 +35,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public IMemoryCallbackSystem MemoryCallbacks { [FeatureNotImplemented] - get { throw new NotImplementedException(); } + get => throw new NotImplementedException(); } [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDisassembler.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDisassembler.cs index 1a202fee25..5599675375 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDisassembler.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDisassembler.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.M6502; @@ -11,19 +8,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public string Cpu { - get - { - return "6502"; - } + get => "6502"; set { } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public IEnumerable AvailableCpus { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs index a83c9d6bc9..290dc0463d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IInputPollable.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] - get { throw new NotImplementedException(); } + get => throw new NotImplementedException(); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs index 248e1565f9..1a6fe975b9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs @@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES }, 1)); _memoryDomains = new MemoryDomainList(mm); - (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } private IMemoryDomains _memoryDomains; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.INESPPUViewable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.INESPPUViewable.cs index 40251ec9be..f81083570f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.INESPPUViewable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.INESPPUViewable.cs @@ -1,56 +1,41 @@ using System; -using System.Collections.Generic; -using System.Linq; - +using System.Runtime.InteropServices; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.NES; -using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public partial class QuickNES : INESPPUViewable { // todo: don't just call the callbacks at the end of frame; use the scanline info - private Action CB1; - private Action CB2; + private Action _callBack1; + private Action _callBack2; - public int[] GetPalette() - { - return VideoPalette; - } + public int[] GetPalette() => _videoPalette; - private byte R2000 { get { return QN.qn_get_reg2000(Context); } } + private byte R2000 => QN.qn_get_reg2000(Context); - public bool BGBaseHigh - { - get { return (R2000 & 0x10) != 0; } - } + public bool BGBaseHigh => (R2000 & 0x10) != 0; - public bool SPBaseHigh - { - get { return (R2000 & 0x08) != 0; } - } + public bool SPBaseHigh => (R2000 & 0x08) != 0; - public bool SPTall - { - get { return (R2000 & 0x20) != 0; } - } + public bool SPTall => (R2000 & 0x20) != 0; - private byte[] ppubusbuf = new byte[0x3000]; + private readonly byte[] ppubusbuf = new byte[0x3000]; public byte[] GetPPUBus() { QN.qn_peek_ppubus(Context, ppubusbuf); return ppubusbuf; } - private byte[] palrambuf = new byte[0x20]; + private readonly byte[] palrambuf = new byte[0x20]; public byte[] GetPalRam() { Marshal.Copy(QN.qn_get_palmem(Context), palrambuf, 0, 0x20); return palrambuf; } - byte[] oambuf = new byte[0x100]; + private readonly byte[] oambuf = new byte[0x100]; public byte[] GetOam() { Marshal.Copy(QN.qn_get_oammem(Context), oambuf, 0, 0x100); @@ -68,10 +53,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES throw new InvalidOperationException(); } - public bool ExActive - { - get { return false; } - } + public bool ExActive => false; public byte[] GetExRam() { @@ -85,22 +67,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public void InstallCallback1(Action cb, int sl) { - CB1 = cb; + _callBack1 = cb; } public void InstallCallback2(Action cb, int sl) { - CB2 = cb; + _callBack2 = cb; } public void RemoveCallback1() { - CB1 = null; + _callBack1 = null; } public void RemoveCallback2() { - CB2 = null; + _callBack2 = null; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISaveRam.cs index 3c58707f43..d312ca8456 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISaveRam.cs @@ -6,8 +6,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public byte[] CloneSaveRam() { - LibQuickNES.ThrowStringError(QN.qn_battery_ram_save(Context, SaveRamBuff, SaveRamBuff.Length)); - return (byte[])SaveRamBuff.Clone(); + LibQuickNES.ThrowStringError(QN.qn_battery_ram_save(Context, _saveRamBuff, _saveRamBuff.Length)); + return (byte[])_saveRamBuff.Clone(); } public void StoreSaveRam(byte[] data) @@ -15,21 +15,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES LibQuickNES.ThrowStringError(QN.qn_battery_ram_load(Context, data, data.Length)); } - public bool SaveRamModified - { - get - { - return QN.qn_has_battery_ram(Context); - } - } + public bool SaveRamModified => QN.qn_has_battery_ram(Context); - private byte[] SaveRamBuff; + private byte[] _saveRamBuff; private void InitSaveRamBuff() { int size = 0; LibQuickNES.ThrowStringError(QN.qn_battery_ram_size(Context, ref size)); - SaveRamBuff = new byte[size]; + _saveRamBuff = new byte[size]; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISettable.cs index 0d50e5ae0a..a2bee06de7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISettable.cs @@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES /// /// the syncsettings that this run of emulation is using (was passed to ctor) /// - private QuickNESSyncSettings _syncSettings; + private readonly QuickNESSyncSettings _syncSettings; /// /// the syncsettings that were requested but won't be used yet @@ -60,8 +60,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES [DisplayName("Visible Sprites")] public int NumSprites { - get { return _NumSprites; } - set { _NumSprites = Math.Min(64, Math.Max(0, value)); } + get => _NumSprites; + set => _NumSprites = Math.Min(64, Math.Max(0, value)); } [JsonIgnore] @@ -80,15 +80,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES [Browsable(false)] public byte[] Palette { - get { return _Palette; } + get => _Palette; set { if (value == null) + { throw new ArgumentNullException(); - else if (value.Length == 64 * 8 * 3) + } + + if (value.Length == 64 * 8 * 3) + { _Palette = value; + } else + { throw new ArgumentOutOfRangeException(); + } } } @@ -120,7 +127,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES if (nColors == 512) { - //just copy the palette directly + // just copy the palette directly for (int c = 0; c < nColors; c++) { _Palette[c * 3 + 0] = pal[c, 0]; @@ -130,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES } else { - //use quickNES's deemph calculator + // use quickNES's deemph calculator for (int c = 0; c < 64; c++) { int a = c & 63; @@ -183,7 +190,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public static bool NeedsReboot(QuickNESSyncSettings x, QuickNESSyncSettings y) { // the core can handle dynamic plugging and unplugging, but that changes - // the controllerdefinition, and we're not ready for that + // the ControllerDefinition, and we're not ready for that return !DeepEquality.DeepEquals(x, y); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISoundProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISoundProvider.cs index 1aa0f14568..643fe0e7c6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISoundProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ISoundProvider.cs @@ -5,19 +5,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public partial class QuickNES : ISoundProvider { - private short[] MonoBuff = new short[1024]; - private short[] StereoBuff = new short[2048]; - private int NumSamples = 0; + private readonly short[] _monoBuff = new short[1024]; + private readonly short[] _stereoBuff = new short[2048]; + private int _numSamples; - public bool CanProvideAsync - { - get { return false; } - } + public bool CanProvideAsync => false; public void GetSamplesSync(out short[] samples, out int nsamp) { - samples = StereoBuff; - nsamp = NumSamples; + samples = _stereoBuff; + nsamp = _numSamples; } public void DiscardSamples() @@ -33,10 +30,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES } } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesAsync(short[] samples) { @@ -50,14 +44,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES private void DrainAudio() { - NumSamples = QN.qn_read_audio(Context, MonoBuff, MonoBuff.Length); + _numSamples = QN.qn_read_audio(Context, _monoBuff, _monoBuff.Length); unsafe { - fixed (short* _src = &MonoBuff[0], _dst = &StereoBuff[0]) + fixed (short* _src = &_monoBuff[0], _dst = &_stereoBuff[0]) { short* src = _src; short* dst = _dst; - for (int i = 0; i < NumSamples; i++) + for (int i = 0; i < _numSamples; i++) { *dst++ = *src; *dst++ = *src++; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IStatable.cs index b2f38791ad..58e9a137c9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IStatable.cs @@ -1,6 +1,5 @@ using System; using System.IO; - using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; @@ -8,44 +7,48 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public partial class QuickNES : IStatable { - public bool BinarySaveStatesPreferred { get { return true; } } + public bool BinarySaveStatesPreferred => true; - public void SaveStateText(System.IO.TextWriter writer) + public void SaveStateText(TextWriter writer) { CheckDisposed(); var temp = SaveStateBinary(); temp.SaveAsHexFast(writer); } - public void LoadStateText(System.IO.TextReader reader) + public void LoadStateText(TextReader reader) { CheckDisposed(); string hex = reader.ReadLine(); byte[] state = new byte[hex.Length / 2]; state.ReadFromHexFast(hex); - LoadStateBinary(new System.IO.BinaryReader(new System.IO.MemoryStream(state))); + LoadStateBinary(new BinaryReader(new MemoryStream(state))); } - public void SaveStateBinary(System.IO.BinaryWriter writer) + public void SaveStateBinary(BinaryWriter writer) { CheckDisposed(); - LibQuickNES.ThrowStringError(QN.qn_state_save(Context, SaveStateBuff, SaveStateBuff.Length)); - writer.Write(SaveStateBuff.Length); - writer.Write(SaveStateBuff); + LibQuickNES.ThrowStringError(QN.qn_state_save(Context, _saveStateBuff, _saveStateBuff.Length)); + writer.Write(_saveStateBuff.Length); + writer.Write(_saveStateBuff); + // other variables writer.Write(IsLagFrame); writer.Write(LagCount); writer.Write(Frame); } - public void LoadStateBinary(System.IO.BinaryReader reader) + public void LoadStateBinary(BinaryReader reader) { CheckDisposed(); int len = reader.ReadInt32(); - if (len != SaveStateBuff.Length) + if (len != _saveStateBuff.Length) + { throw new InvalidOperationException("Unexpected savestate buffer length!"); - reader.Read(SaveStateBuff, 0, SaveStateBuff.Length); - LibQuickNES.ThrowStringError(QN.qn_state_load(Context, SaveStateBuff, SaveStateBuff.Length)); + } + + reader.Read(_saveStateBuff, 0, _saveStateBuff.Length); + LibQuickNES.ThrowStringError(QN.qn_state_load(Context, _saveStateBuff, _saveStateBuff.Length)); // other variables IsLagFrame = reader.ReadBoolean(); LagCount = reader.ReadInt32(); @@ -55,25 +58,28 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public byte[] SaveStateBinary() { CheckDisposed(); - var ms = new System.IO.MemoryStream(SaveStateBuff2, true); - var bw = new System.IO.BinaryWriter(ms); + var ms = new MemoryStream(_saveStateBuff2, true); + var bw = new BinaryWriter(ms); SaveStateBinary(bw); bw.Flush(); - if (ms.Position != SaveStateBuff2.Length) + if (ms.Position != _saveStateBuff2.Length) + { throw new InvalidOperationException("Unexpected savestate length!"); + } + bw.Close(); - return SaveStateBuff2; + return _saveStateBuff2; } - private byte[] SaveStateBuff; - private byte[] SaveStateBuff2; + private byte[] _saveStateBuff; + private byte[] _saveStateBuff2; private void InitSaveStateBuff() { int size = 0; LibQuickNES.ThrowStringError(QN.qn_state_size(Context, ref size)); - SaveStateBuff = new byte[size]; - SaveStateBuff2 = new byte[size + 13]; + _saveStateBuff = new byte[size]; + _saveStateBuff2 = new byte[size + 13]; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs index 409540ec4e..7f79c764df 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public TraceBuffer Tracer { get; private set; } - private LibQuickNES.TraceCallback _tracecb; + private LibQuickNES.TraceCallback _traceCb; private const string TraceHeader = "6502: PC, mnemonic, operands, registers (A, X, Y, P, SP)"; @@ -26,10 +26,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES ushort pc = (ushort)s[4]; byte p = (byte)s[5]; - byte opcode = (byte)s[6]; - - int notused = 0; - string opcodeStr = MOS6502X.Disassemble(pc, out notused, (address) => _memoryDomains.SystemBus.PeekByte(address)); + string opcodeStr = MOS6502X.Disassemble(pc, out _, address => _memoryDomains.SystemBus.PeekByte(address)); Tracer.Put(new TraceInfo { @@ -46,8 +43,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES private void ConnectTracer() { Tracer = new TraceBuffer { Header = TraceHeader }; - (ServiceProvider as BasicServiceProvider).Register(Tracer); - _tracecb = new LibQuickNES.TraceCallback(MakeTrace); + ((BasicServiceProvider) ServiceProvider).Register(Tracer); + _traceCb = MakeTrace; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IVideoProvider.cs index 5f5b1d02eb..768011802d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IVideoProvider.cs @@ -6,47 +6,35 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { public int BufferWidth { get; private set; } public int BufferHeight { get; private set; } - public int BackgroundColor { get { return unchecked((int)0xff000000); } } + public int BackgroundColor => unchecked((int)0xff000000); public int VsyncNumerator => 39375000; public int VsyncDenominator => 655171; - public int[] GetVideoBuffer() - { - return VideoOutput; - } + public int[] GetVideoBuffer() =>_videoOutput; - public int VirtualWidth - { - get { return (int)(BufferWidth * 1.146); } - } + public int VirtualWidth => (int)(BufferWidth * 1.146); - public int VirtualHeight - { - get { return BufferHeight; } - } + public int VirtualHeight => BufferHeight; - private int[] VideoOutput = new int[256 * 240]; - private int[] VideoPalette = new int[512]; + private readonly int[] _videoOutput = new int[256 * 240]; + private readonly int[] _videoPalette = new int[512]; - private int cropleft = 0; - private int cropright = 0; - private int croptop = 0; - private int cropbottom = 0; + private int _cropLeft, _cropRight, _cropTop, _cropBottom; private void RecalculateCrops() { - cropright = cropleft = _settings.ClipLeftAndRight ? 8 : 0; - cropbottom = croptop = _settings.ClipTopAndBottom ? 8 : 0; - BufferWidth = 256 - cropleft - cropright; - BufferHeight = 240 - croptop - cropbottom; + _cropRight = _cropLeft = _settings.ClipLeftAndRight ? 8 : 0; + _cropBottom = _cropTop = _settings.ClipTopAndBottom ? 8 : 0; + BufferWidth = 256 - _cropLeft - _cropRight; + BufferHeight = 240 - _cropTop - _cropBottom; } private void CalculatePalette() { for (int i = 0; i < 512; i++) { - VideoPalette[i] = + _videoPalette[i] = _settings.Palette[i * 3] << 16 | _settings.Palette[i * 3 + 1] << 8 | _settings.Palette[i * 3 + 2] | @@ -56,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES private void Blit() { - QN.qn_blit(Context, VideoOutput, VideoPalette, cropleft, croptop, cropright, cropbottom); + QN.qn_blit(Context, _videoOutput, _videoPalette, _cropLeft, _cropTop, _cropRight, _cropBottom); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index c7540be6b7..3241355b9b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -206,7 +206,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES SetPads(controller, out j1, out j2); if (Tracer.Enabled) - QN.qn_set_tracecb(Context, _tracecb); + QN.qn_set_tracecb(Context, _traceCb); else QN.qn_set_tracecb(Context, null); @@ -221,8 +221,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES if (rendersound) DrainAudio(); - if (CB1 != null) CB1(); - if (CB2 != null) CB2(); + if (_callBack1 != null) _callBack1(); + if (_callBack2 != null) _callBack2(); return true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs index 7736c32b70..6aae8aa449 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IDebuggable.cs @@ -9,8 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { public IDictionary GetCpuFlagsAndRegisters() { - LibsnesApi.CPURegs regs; - Api.QUERY_peek_cpu_regs(out regs); + Api.QUERY_peek_cpu_regs(out var regs); bool fn = (regs.p & 0x80) != 0; bool fv = (regs.p & 0x40) != 0; @@ -71,9 +70,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES } [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs index e16511cbaa..ba053cb0be 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; @@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES } // speedup when sound rendering is not needed - Api.QUERY_set_audio_sample(rendersound ? _soundcb : null); + Api.QUERY_set_audio_sample(renderSound ? _soundcb : null); bool resetSignal = controller.IsPressed("Reset"); if (resetSignal) @@ -75,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES _timeFrameCounter++; Api.CMD_run(); - // once upon a time we forwarded messages frmo bsnes here, by checking for queued text messages, but I don't think it's needed any longer + // once upon a time we forwarded messages from bsnes here, by checking for queued text messages, but I don't think it's needed any longer if (IsLagFrame) { LagCount++; @@ -86,8 +86,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public int Frame { - get { return _timeFrameCounter; } - private set { _timeFrameCounter = value; } + get => _timeFrameCounter; + private set => _timeFrameCounter = value; } public string SystemId { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IMemoryDomains.cs index 874a443f03..dc2eb0ee52 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IMemoryDomains.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { private readonly List _memoryDomainList = new List(); private IMemoryDomains _memoryDomains; - private LibsnesApi.SNES_MAPPER? _mapper = null; + private LibsnesApi.SNES_MAPPER? _mapper; // works for WRAM, garbage for anything else private static int? FakeBusMap(int addr) @@ -76,22 +76,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES _memoryDomains = new MemoryDomainList(_memoryDomainList); - (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } private unsafe void MakeMemoryDomain(string name, LibsnesApi.SNES_MEMORY id, MemoryDomain.Endian endian, int byteSize = 1) { int size = Api.QUERY_get_memory_size(id); - // if this type of memory isnt available, dont make the memory domain (most commonly save ram) + // if this type of memory isn't available, don't make the memory domain (most commonly save ram) if (size == 0) { return; } - byte* blockptr = Api.QUERY_get_memory_data(id); + byte* blockPtr = Api.QUERY_get_memory_data(id); - var md = new MemoryDomainIntPtrMonitor(name, MemoryDomain.Endian.Little, (IntPtr)blockptr, size, + var md = new MemoryDomainIntPtrMonitor(name, MemoryDomain.Endian.Little, (IntPtr)blockPtr, size, id != LibsnesApi.SNES_MEMORY.CARTRIDGE_ROM, // hack: for just this one memory area, it will be readonly byteSize, Api); @@ -106,7 +106,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES throw new InvalidOperationException(); } - byte* blockptr = Api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.WRAM); + byte* blockPtr = Api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.WRAM); var md = new MemoryDomainDelegate("System Bus", 0x1000000, MemoryDomain.Endian.Little, addr => @@ -116,7 +116,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES var a = FakeBusMap((int)addr); if (a.HasValue) { - return blockptr[a.Value]; + return blockPtr[a.Value]; } return FakeBusRead((int)addr); @@ -128,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { var a = FakeBusMap((int)addr); if (a.HasValue) - blockptr[a.Value] = val; + blockPtr[a.Value] = val; } }, wordSize: 2); _memoryDomainList.Add(md); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IRegionable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IRegionable.cs index d61a01296a..807e671d72 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IRegionable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IRegionable.cs @@ -4,17 +4,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { public partial class LibsnesCore : IRegionable { - public DisplayType Region - { - get - { - if (Api.Region == LibsnesApi.SNES_REGION.NTSC) - { - return DisplayType.NTSC; - } - - return DisplayType.PAL; - } - } + public DisplayType Region => Api.Region == LibsnesApi.SNES_REGION.NTSC + ? DisplayType.NTSC + : DisplayType.PAL; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.ISettable.cs index f2a271904d..983e124d70 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.ISettable.cs @@ -16,9 +16,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public bool PutSettings(SnesSettings o) { - bool refreshneeded = o.Palette != _settings.Palette; + bool refreshNeeded = o.Palette != _settings.Palette; _settings = o; - if (refreshneeded) + if (refreshNeeded) { RefreshPalette(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs index ffb3fedfd7..50a080a048 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; - +using System.IO; using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IVideoProvider.cs index 67876f698b..f5be5617de 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IVideoProvider.cs @@ -14,10 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public int BackgroundColor => 0; - public int[] GetVideoBuffer() - { - return _videoBuffer; - } + public int[] GetVideoBuffer() => _videoBuffer; public int VsyncNumerator { get; } public int VsyncDenominator { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index 27169b6337..5254036531 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -1,10 +1,7 @@ using System; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Waterbox; -using BizHawk.Common.BizInvoke; -using System.Runtime.InteropServices; using System.IO; -using BizHawk.Common.BufferExtensions; using System.ComponentModel; using BizHawk.Common; using System.Collections.Generic; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs index dd36a64441..d833c87b41 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs @@ -64,9 +64,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } - public long TotalExecutedCycles - { - get { return subnes.cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => subnes.cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs index ba5b1c0638..5d083b1f52 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs @@ -1,7 +1,5 @@ using System; - using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { @@ -11,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk public ControllerDefinition ControllerDefinition => subnes.ControllerDefinition; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { //Console.WriteLine("-----------------------FRAME-----------------------"); if (_tracer.Enabled) @@ -39,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk reset_cycle = controller.GetFloat("Reset Cycle"); reset_cycle_int = (int)Math.Floor(reset_cycle); - _islag = true; + _isLag = true; subnes.alt_lag = true; InputCallbacks.Call(); @@ -55,11 +53,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk subnes.cpu.ext_ppu_cycle = current_cycle; } - _islag = subnes.alt_lag; + _isLag = subnes.alt_lag; - if (_islag) + if (_isLag) { - _lagcount++; + _lagCount++; VBL_CNT++; } @@ -102,8 +100,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk public void ResetCounters() { _frame = 0; - _lagcount = 0; - _islag = false; + _lagCount = 0; + _isLag = false; } public CoreComm CoreComm { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs index 04c6faea5c..e731613c95 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs @@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { public int LagCount { - get { return _lagcount; } - set { _lagcount = value; } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get { return _islag; } - set { _islag = value; } + get => _isLag; + set => _isLag = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); - public bool _islag = true; - private int _lagcount; + public bool _isLag = true; + private int _lagCount; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs index b1aafedaf7..6d011b3910 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs index 1d61877e5b..0450a03167 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs @@ -18,24 +18,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk public byte[] CloneSaveRam() { - if (subnes.Board is NES.FDS) - return (subnes.Board as NES.FDS).ReadSaveRam(); + if (subnes.Board is NES.FDS fds) + { + return fds.ReadSaveRam(); + } - if (subnes.Board == null || subnes.Board.SaveRam == null) - return null; - return (byte[])subnes.Board.SaveRam.Clone(); + return (byte[]) subnes.Board?.SaveRam?.Clone(); } public void StoreSaveRam(byte[] data) { - if (subnes.Board is NES.FDS) + if (subnes.Board is NES.FDS fds) { - (subnes.Board as NES.FDS).StoreSaveRam(data); + fds.StoreSaveRam(data); return; } - if (subnes.Board == null || subnes.Board.SaveRam == null) + if (subnes.Board?.SaveRam == null) + { return; + } + Array.Copy(data, subnes.Board.SaveRam, data.Length); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs index 6ded0e50d8..a8b098dfa9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs @@ -2,7 +2,6 @@ using BizHawk.Common; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { @@ -38,8 +37,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk public byte[] SaveStateBinary() { - MemoryStream ms = new MemoryStream(); - BinaryWriter bw = new BinaryWriter(ms); + using var ms = new MemoryStream(); + using var bw = new BinaryWriter(ms); SaveStateBinary(bw); bw.Flush(); return ms.ToArray(); @@ -49,9 +48,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk private void SyncState(Serializer ser) { - ser.Sync("Lag", ref _lagcount); + ser.Sync("Lag", ref _lagCount); ser.Sync("Frame", ref _frame); - ser.Sync("IsLag", ref _islag); + ser.Sync("IsLag", ref _isLag); ser.Sync(nameof(pass_a_frame), ref pass_a_frame); ser.Sync(nameof(reset_frame), ref reset_frame); ser.Sync(nameof(pass_new_input), ref pass_new_input); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ICodeDataLogger.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ICodeDataLogger.cs index 7b1063fc2b..b30f8490d7 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ICodeDataLogger.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ICodeDataLogger.cs @@ -102,8 +102,8 @@ namespace BizHawk.Emulation.Cores.PCEngine CDLMappingApplyRange(mm, "Battery RAM", 0xf7, BRAM.Length); } - var rammirrors = new HuC6280.MemMapping { Name = "Main Memory", Offs = 0 }; - mm[0xf9] = mm[0xfa] = mm[0xfb] = rammirrors; + var ramMirrors = new HuC6280.MemMapping { Name = "Main Memory", Offs = 0 }; + mm[0xf9] = mm[0xfa] = mm[0xfb] = ramMirrors; CDLMappingApplyRange(mm, "Main Memory", 0xf8, Ram.Length); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs index 6b46010327..aee12e7136 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; _lagged = true; @@ -45,8 +45,8 @@ namespace BizHawk.Emulation.Cores.PCEngine public int Frame { - get { return _frame; } - set { _frame = value; } + get => _frame; + set => _frame = value; } public string SystemId { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IInputPollable.cs index 2f61e011b8..bb22491ee7 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IInputPollable.cs @@ -6,20 +6,17 @@ namespace BizHawk.Emulation.Cores.PCEngine { public int LagCount { - get { return _lagCount; } - set { _lagCount = value; } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get { return _isLag; } - set { _isLag = value; } + get => _isLag; + set => _isLag = value; } - public IInputCallbackSystem InputCallbacks - { - get { return _inputCallbacks; } - } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); private int _lagCount; diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IMemoryDomains.cs index 00247ab409..665c101ad5 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IMemoryDomains.cs @@ -8,15 +8,15 @@ namespace BizHawk.Emulation.Cores.PCEngine { public sealed partial class PCEngine { - private Dictionary _byteArrayDomains = new Dictionary(); - private bool _memoryDomainsInit = false; + private readonly Dictionary _byteArrayDomains = new Dictionary(); + private bool _memoryDomainsInit; private MemoryDomainList _memoryDomains; private void SetupMemoryDomains() { var domains = new List(2); - var SystemBusDomain = new MemoryDomainDelegate("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little, + var systemBusDomain = new MemoryDomainDelegate("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 0x200000) @@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.PCEngine Cpu.WriteMemory21((int)addr, value); }, wordSize: 2); - domains.Add(SystemBusDomain); + domains.Add(systemBusDomain); - var CpuBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, + var cpuBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 0x10000) @@ -46,14 +46,16 @@ namespace BizHawk.Emulation.Cores.PCEngine Cpu.WriteMemory((ushort)addr, value); }, wordSize: 2); - domains.Add(CpuBusDomain); + domains.Add(cpuBusDomain); SyncAllByteArrayDomains(); - _memoryDomains = new MemoryDomainList(domains.Concat(_byteArrayDomains.Values).ToList()); - _memoryDomains.SystemBus = CpuBusDomain; - _memoryDomains.MainMemory = _byteArrayDomains["Main Memory"]; - (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + _memoryDomains = new MemoryDomainList(domains.Concat(_byteArrayDomains.Values).ToList()) + { + SystemBus = cpuBusDomain, MainMemory = _byteArrayDomains["Main Memory"] + }; + + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); _memoryDomainsInit = true; } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISaveRam.cs index e6ac027c1f..0a4b50e697 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ISaveRam.cs @@ -9,14 +9,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public byte[] CloneSaveRam() { - if (BRAM != null) - { - return (byte[])BRAM.Clone(); - } - else - { - return null; - } + return (byte[]) BRAM?.Clone(); } public void StoreSaveRam(byte[] data) diff --git a/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs b/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs index d34f5f24aa..442ac82358 100644 --- a/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs @@ -1,18 +1,11 @@ using BizHawk.Common; -using BizHawk.Common.BizInvoke; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; -using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.SNK { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs index 14bdaaa32d..9e179fe513 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs @@ -27,17 +27,17 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink public void NewCDL(ICodeDataLog cdl) { - cdl["ROM"] = new byte[MemoryDomains["ROM"].Size]; - cdl["Main RAM"] = new byte[MemoryDomains["Main RAM"].Size]; + cdl["ROM"] = new byte[_memoryDomains["ROM"].Size]; + cdl["Main RAM"] = new byte[_memoryDomains["Main RAM"].Size]; - if (MemoryDomains.Has("Save RAM")) + if (_memoryDomains.Has("Save RAM")) { - cdl["Save RAM"] = new byte[MemoryDomains["Save RAM"].Size]; + cdl["Save RAM"] = new byte[_memoryDomains["Save RAM"].Size]; } - if (MemoryDomains.Has("Cart (Volatile) RAM")) + if (_memoryDomains.Has("Cart (Volatile) RAM")) { - cdl["Cart (Volatile) RAM"] = new byte[MemoryDomains["Cart (Volatile) RAM"].Size]; + cdl["Cart (Volatile) RAM"] = new byte[_memoryDomains["Cart (Volatile) RAM"].Size]; } cdl.SubType = "SMS"; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs index 559381bead..d6a2348f82 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs @@ -144,9 +144,6 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink throw new NotImplementedException(); } - public long TotalExecutedCycles - { - get { return (long)L.Cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => L.Cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs index 19c04a4312..185d4f81f6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink public int L_NMI_CD, R_NMI_CD; - public bool FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { //Console.WriteLine("-----------------------FRAME-----------------------"); if (_tracer.Enabled) @@ -31,32 +31,32 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink HardReset(); } - bool cablediscosignalNew = controller.IsPressed("Toggle Cable"); - if (cablediscosignalNew && !_cablediscosignal) + bool cableDiscoSignalNew = controller.IsPressed("Toggle Cable"); + if (cableDiscoSignalNew && !_cablediscosignal) { _cableconnected ^= true; Console.WriteLine("Cable connect status to {0}", _cableconnected); } - _cablediscosignal = cablediscosignalNew; + _cablediscosignal = cableDiscoSignalNew; - _islag = true; + _isLag = true; GetControllerState(controller); - do_frame(controller, render, rendersound); + DoFrame(controller, render, renderSound); - _islag = L._isLag; + _isLag = L._isLag; - if (_islag) + if (_isLag) { - _lagcount++; + _lagCount++; } return true; } - public void do_frame(IController controller, bool render, bool rendersound) + private void DoFrame(IController controller, bool render, bool renderSound) { L.start_pressed = controller.IsPressed("P1 Start"); R.start_pressed = controller.IsPressed("P2 Start"); @@ -280,8 +280,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink public void ResetCounters() { _frame = 0; - _lagcount = 0; - _islag = false; + _lagCount = 0; + _isLag = false; } public CoreComm CoreComm { get; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs index 3a180561c8..d926a3f7b2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs @@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink { public int LagCount { - get { return _lagcount; } - set { _lagcount = value; } + get => _lagCount; + set => _lagCount = value; } public bool IsLagFrame { - get { return _islag; } - set { _islag = value; } + get => _isLag; + set => _isLag = value; } public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); - public bool _islag = true; - private int _lagcount; + public bool _isLag = true; + private int _lagCount; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs index 9c2f9977c8..1ea4505014 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink { public partial class GGHawkLink { - private IMemoryDomains MemoryDomains; + private IMemoryDomains _memoryDomains; public void SetupMemoryDomains() { @@ -73,18 +73,18 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink if (L.SaveRAM != null) { - var CartRamL = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, L.SaveRAM, true, 1); - domains.Add(CartRamL); + var cartRamL = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, L.SaveRAM, true, 1); + domains.Add(cartRamL); } if (R.SaveRAM != null) { - var CartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.SaveRAM, true, 1); - domains.Add(CartRamR); + var cartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.SaveRAM, true, 1); + domains.Add(cartRamR); } - MemoryDomains = new MemoryDomainList(domains); - (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + _memoryDomains = new MemoryDomainList(domains); + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } private byte PeekSystemBusL(long addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs index 335b273e86..c8657cbc79 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs @@ -9,21 +9,21 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink { if ((L.SaveRAM != null) || (R.SaveRAM != null)) { - int Len1 = 0; - int Len2 = 0; + int len1 = 0; + int len2 = 0; int index = 0; if (L.SaveRAM != null) { - Len1 = L.SaveRAM.Length; + len1 = L.SaveRAM.Length; } if (R.SaveRAM != null) { - Len2 = R.SaveRAM.Length; + len2 = R.SaveRAM.Length; } - byte[] temp = new byte[Len1 + Len2]; + byte[] temp = new byte[len1 + len2]; if (L.SaveRAM != null) { @@ -45,23 +45,21 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink return temp; } - else - { - return null; - } + + return null; } public void StoreSaveRam(byte[] data) { - if ((L.SaveRAM != null) && (R.SaveRAM == null)) + if (L.SaveRAM != null && R.SaveRAM == null) { Buffer.BlockCopy(data, 0, L.SaveRAM, 0, L.SaveRAM.Length); } - else if ((R.SaveRAM != null) && (L.SaveRAM == null)) + else if (R.SaveRAM != null && L.SaveRAM == null) { Buffer.BlockCopy(data, 0, R.SaveRAM, 0, R.SaveRAM.Length); } - else if ((R.SaveRAM != null) && (L.SaveRAM != null)) + else if (R.SaveRAM != null && L.SaveRAM != null) { Buffer.BlockCopy(data, 0, L.SaveRAM, 0, L.SaveRAM.Length); Buffer.BlockCopy(data, L.SaveRAM.Length, R.SaveRAM, 0, R.SaveRAM.Length); @@ -70,12 +68,6 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink Console.WriteLine("loading SRAM here"); } - public bool SaveRamModified - { - get - { - return linkSyncSettings.Use_SRAM; - } - } + public bool SaveRamModified => linkSyncSettings.Use_SRAM; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs index 920fa985f6..f91074025a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs @@ -53,9 +53,9 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink private void SyncState(Serializer ser) { - ser.Sync("Lag", ref _lagcount); + ser.Sync("Lag", ref _lagCount); ser.Sync("Frame", ref _frame); - ser.Sync("IsLag", ref _islag); + ser.Sync("IsLag", ref _isLag); ser.Sync(nameof(_cableconnected), ref _cableconnected); ser.Sync(nameof(_cablediscosignal), ref _cablediscosignal); ser.Sync(nameof(do_r_next), ref do_r_next); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs index 401bebf97d..fa0b679944 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs @@ -1,7 +1,4 @@ -using System; - -using BizHawk.Emulation.Common; - +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Sega.MasterSystem; namespace BizHawk.Emulation.Cores.Sega.GGHawkLink @@ -81,8 +78,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink public bool LinkConnected { - get { return _cableconnected; } - set { _cableconnected = value; } + get => _cableconnected; + set => _cableconnected = value; } private void ExecFetch(ushort addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/LibPicoDrive.cs b/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/LibPicoDrive.cs index 096a6f6173..f63cc1466d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/LibPicoDrive.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/LibPicoDrive.cs @@ -1,11 +1,7 @@ using BizHawk.Common.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs index 60cbd0787d..5320c39603 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs @@ -13,7 +13,6 @@ using System.Linq; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn { @@ -51,12 +50,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn if (Encoding.ASCII.GetString(buff, 0, 16) != "SEGA SEGASATURN ") return false; - using (var sha256 = SHA256.Create()) - { - sha256.ComputeHash(buff, 0x100, 0xd00); - if (sha256.Hash.BytesToHexString() != "96B8EA48819CFA589F24C40AA149C224C420DCCF38B730F00156EFE25C9BBC8F") - return false; - } + using var sha256 = SHA256.Create(); + sha256.ComputeHash(buff, 0x100, 0xd00); + if (sha256.Hash.BytesToHexString() != "96B8EA48819CFA589F24C40AA149C224C420DCCF38B730F00156EFE25C9BBC8F") + return false; } return true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ICodeDataLogger.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ICodeDataLogger.cs index 9883a26b1f..f3a29eab94 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ICodeDataLogger.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ICodeDataLogger.cs @@ -16,12 +16,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public void NewCDL(ICodeDataLog cdl) { - cdl["MD CART"] = new byte[MemoryDomains["MD CART"].Size]; - cdl["68K RAM"] = new byte[MemoryDomains["68K RAM"].Size]; - cdl["Z80 RAM"] = new byte[MemoryDomains["Z80 RAM"].Size]; + cdl["MD CART"] = new byte[_memoryDomains["MD CART"].Size]; + cdl["68K RAM"] = new byte[_memoryDomains["68K RAM"].Size]; + cdl["Z80 RAM"] = new byte[_memoryDomains["Z80 RAM"].Size]; - if (MemoryDomains.Has("SRAM")) - cdl["SRAM"] = new byte[MemoryDomains["SRAM"].Size]; + if (_memoryDomains.Has("SRAM")) + cdl["SRAM"] = new byte[_memoryDomains["SRAM"].Size]; cdl.SubType = "GEN"; cdl.SubVer = 0; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs index dd7c1a7d44..ebf7916018 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs @@ -8,19 +8,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public string Cpu { - get - { - return "M68000"; - } + get => "M68000"; set { } } - public string PCRegisterName - { - get { return "M68K PC"; } - } + public string PCRegisterName => "M68K PC"; public IEnumerable AvailableCpus { @@ -40,6 +34,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } // TODO: refactor MC6800's disassembler to be a static call - private MC68000 _disassemblerInstance = new MC68000(); + private readonly MC68000 _disassemblerInstance = new MC68000(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDriveLight.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDriveLight.cs index bc2cefba4d..ed2b66b178 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDriveLight.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDriveLight.cs @@ -4,9 +4,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public partial class GPGX : IDriveLight { - public bool DriveLightEnabled { get; private set; } + public bool DriveLightEnabled { get; } public bool DriveLightOn { get; private set; } - private bool _drivelight; + private bool _driveLight; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs index 7ec674a0a1..8e2415cf73 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs @@ -5,12 +5,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public partial class GPGX : IEmulator, ISoundProvider { - public IEmulatorServiceProvider ServiceProvider { get; private set; } + public IEmulatorServiceProvider ServiceProvider { get; } public ControllerDefinition ControllerDefinition { get; private set; } - // TODO: use render and rendersound - public bool FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool renderSound = true) { if (controller.IsPressed("Reset")) Core.gpgx_reset(false); @@ -46,8 +45,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx // if (!Core.gpgx_get_control(input, inputsize)) // throw new Exception("gpgx_get_control() failed!"); - ControlConverter.ScreenWidth = vwidth; - ControlConverter.ScreenHeight = vheight; + ControlConverter.ScreenWidth = _vwidth; + ControlConverter.ScreenHeight = _vheight; ControlConverter.Convert(controller, input); if (!Core.gpgx_put_control(input, inputsize)) @@ -55,36 +54,30 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx IsLagFrame = true; Frame++; - _drivelight = false; + _driveLight = false; Core.gpgx_advance(); if (render) UpdateVideo(); - if (rendersound) + if (renderSound) update_audio(); if (IsLagFrame) LagCount++; if (_cds != null) - DriveLightOn = _drivelight; + DriveLightOn = _driveLight; return true; } public int Frame { get; private set; } - public string SystemId - { - get { return "GEN"; } - } + public string SystemId => "GEN"; - public bool DeterministicEmulation - { - get { return true; } - } + public bool DeterministicEmulation => true; public void ResetCounters() { @@ -93,14 +86,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx LagCount = 0; } - public CoreComm CoreComm { get; private set; } + public CoreComm CoreComm { get; } public void Dispose() { if (!_disposed) { - if (_elf != null) - _elf.Dispose(); + _elf?.Dispose(); if (_cds != null) foreach (var cd in _cds) cd.Dispose(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IInputPollable.cs index f899a8698c..008b1ab06a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IInputPollable.cs @@ -8,9 +8,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public bool IsLagFrame { get; set; } - public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; - private LibGPGX.input_cb InputCallback = null; + private readonly LibGPGX.input_cb _inputCallback; private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IMemoryDomains.cs index 5be260f3cc..4a48ab6edd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IMemoryDomains.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public partial class GPGX { - private IMemoryDomains MemoryDomains; + private IMemoryDomains _memoryDomains; private unsafe void SetMemoryDomains() { @@ -20,10 +20,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { IntPtr area = IntPtr.Zero; int size = 0; - IntPtr pname = Core.gpgx_get_memdom(i, ref area, ref size); - if (area == IntPtr.Zero || pname == IntPtr.Zero || size == 0) + IntPtr pName = Core.gpgx_get_memdom(i, ref area, ref size); + if (area == IntPtr.Zero || pName == IntPtr.Zero || size == 0) continue; - string name = Marshal.PtrToStringAnsi(pname); + string name = Marshal.PtrToStringAnsi(pName); var endian = name == "Z80 RAM" ? MemoryDomain.Endian.Little @@ -95,10 +95,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx mm.Add(s68Bus); } - MemoryDomains = new MemoryDomainList(mm); - MemoryDomains.SystemBus = m68Bus; - - (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + _memoryDomains = new MemoryDomainList(mm) { SystemBus = m68Bus }; + ((BasicServiceProvider) ServiceProvider).Register(_memoryDomains); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs index add922edc3..55bab54129 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISaveRam.cs @@ -1,10 +1,7 @@ using System; -using System.IO; - -using BizHawk.Common.BufferExtensions; -using BizHawk.Emulation.Common; using System.Runtime.InteropServices; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { @@ -26,7 +23,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public void StoreSaveRam(byte[] data) { if (!Core.gpgx_put_sram(data, data.Length)) + { throw new Exception("Core rejected saveram"); + } } public bool SaveRamModified diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs index 2fb22f0e7b..687653f7e8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs @@ -40,26 +40,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { - if (sourceType == typeof(string)) - { - return true; - } - else - { - return base.CanConvertFrom(context, sourceType); - } + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { - if (destinationType == typeof(string)) - { - return true; - } - else - { - return base.CanConvertTo(context, destinationType); - } + return destinationType == typeof(string) || base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) @@ -68,10 +54,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { return $"0x{value:x8}"; } - else - { - return base.ConvertTo(context, culture, value, destinationType); - } + + return base.ConvertTo(context, culture, value, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) @@ -85,10 +69,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } return uint.Parse(input, NumberStyles.HexNumber, culture); } - else - { - return base.ConvertFrom(context, culture, value); - } + + return base.ConvertFrom(context, culture, value); } } @@ -96,26 +78,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { - if (sourceType == typeof(string)) - { - return true; - } - else - { - return base.CanConvertFrom(context, sourceType); - } + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { - if (destinationType == typeof(string)) - { - return true; - } - else - { - return base.CanConvertTo(context, destinationType); - } + return destinationType == typeof(string) || base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) @@ -124,10 +92,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { return $"0x{value:x4}"; } - else - { - return base.ConvertTo(context, culture, value, destinationType); - } + + return base.ConvertTo(context, culture, value, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) @@ -141,10 +107,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } return ushort.Parse(input, NumberStyles.HexNumber, culture); } - else - { - return base.ConvertFrom(context, culture, value); - } + + return base.ConvertFrom(context, culture, value); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISoundProvider.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISoundProvider.cs index de9bce6a56..7e66fd11a7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISoundProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISoundProvider.cs @@ -7,24 +7,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public partial class GPGX : ISoundProvider { - private short[] samples = new short[4096]; - private int nsamp = 0; + private readonly short[] _samples = new short[4096]; + private int _nsamp; - public bool CanProvideAsync - { - get { return false; } - } + public bool CanProvideAsync => false; public void GetSamplesSync(out short[] samples, out int nsamp) { - nsamp = this.nsamp; - samples = this.samples; - this.nsamp = 0; + nsamp = _nsamp; + samples = _samples; + _nsamp = 0; } public void DiscardSamples() { - this.nsamp = 0; + _nsamp = 0; } public void SetSyncMode(SyncSoundMode mode) @@ -35,10 +32,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesAsync(short[] samples) { @@ -48,11 +42,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx private void update_audio() { IntPtr src = IntPtr.Zero; - Core.gpgx_get_audio(ref nsamp, ref src); + Core.gpgx_get_audio(ref _nsamp, ref src); if (src != IntPtr.Zero) { using (_elf.EnterExit()) - Marshal.Copy(src, samples, 0, nsamp * 2); + Marshal.Copy(src, _samples, 0, _nsamp * 2); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IStatable.cs index 3cdd5cebca..4fddc76c06 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IStatable.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; @@ -35,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx _prevDiskPressed = reader.ReadBoolean(); _nextDiskPressed = reader.ReadBoolean(); // any managed pointers that we sent to the core need to be resent now! - Core.gpgx_set_input_callback(InputCallback); + Core.gpgx_set_input_callback(_inputCallback); RefreshMemCallbacks(); Core.gpgx_set_cdd_callback(cd_callback_handle); Core.gpgx_invalidate_pattern_cache(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs index 69f2250c13..1ce55c98ee 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs @@ -6,25 +6,25 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public partial class GPGX : IVideoProvider { - public int[] GetVideoBuffer() { return vidbuff; } + public int[] GetVideoBuffer() => _vidBuff; - public int VirtualWidth { get { return 320; } } + public int VirtualWidth => 320; - public int VirtualHeight { get { return 224; } } + public int VirtualHeight => 224; - public int BufferWidth { get { return vwidth; } } + public int BufferWidth => _vwidth; - public int BufferHeight { get { return vheight; } } + public int BufferHeight => _vheight; - public int BackgroundColor { get { return unchecked((int)0xff000000); } } + public int BackgroundColor => unchecked((int)0xff000000); public int VsyncNumerator { get; } public int VsyncDenominator { get; } - private int[] vidbuff = new int[0]; - private int vwidth; - private int vheight; + private int[] _vidBuff = new int[0]; + private int _vwidth; + private int _vheight; private void UpdateVideoInitial() { @@ -33,11 +33,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx // so instead, just assume a 320x224 size now; if that happens to be wrong, it'll be fixed soon enough. - vwidth = 320; - vheight = 224; - vidbuff = new int[vwidth * vheight]; - for (int i = 0; i < vidbuff.Length; i++) - vidbuff[i] = unchecked((int)0xff000000); + _vwidth = 320; + _vheight = 224; + _vidBuff = new int[_vwidth * _vheight]; + for (int i = 0; i < _vidBuff.Length; i++) + { + _vidBuff[i] = unchecked((int)0xff000000); + } } private unsafe void UpdateVideo() @@ -50,25 +52,24 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx using (_elf.EnterExit()) { - int gppitch, gpwidth, gpheight; IntPtr src = IntPtr.Zero; - Core.gpgx_get_video(out gpwidth, out gpheight, out gppitch, ref src); + Core.gpgx_get_video(out var gpwidth, out var gpheight, out var gppitch, ref src); - vwidth = gpwidth; - vheight = gpheight; + _vwidth = gpwidth; + _vheight = gpheight; - if (_settings.PadScreen320 && vwidth == 256) - vwidth = 320; + if (_settings.PadScreen320 && _vwidth == 256) + _vwidth = 320; - int xpad = (vwidth - gpwidth) / 2; - int xpad2 = vwidth - gpwidth - xpad; + int xpad = (_vwidth - gpwidth) / 2; + int xpad2 = _vwidth - gpwidth - xpad; - if (vidbuff.Length < vwidth * vheight) - vidbuff = new int[vwidth * vheight]; + if (_vidBuff.Length < _vwidth * _vheight) + _vidBuff = new int[_vwidth * _vheight]; int rinc = (gppitch / 4) - gpwidth; - fixed (int* pdst_ = vidbuff) + fixed (int* pdst_ = _vidBuff) { int* pdst = pdst_; int* psrc = (int*)src; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs index d47ac6f60a..50c6757ed6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs @@ -139,8 +139,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx SetMemoryDomains(); - InputCallback = new LibGPGX.input_cb(input_callback); - Core.gpgx_set_input_callback(InputCallback); + _inputCallback = new LibGPGX.input_cb(input_callback); + Core.gpgx_set_input_callback(_inputCallback); // process the non-init settings now PutSettings(_settings); @@ -151,7 +151,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx InitMemCallbacks(); KillMemCallbacks(); - _tracer = new GPGXTraceBuffer(this, MemoryDomains, this); + _tracer = new GPGXTraceBuffer(this, _memoryDomains, this); (ServiceProvider as BasicServiceProvider).Register(_tracer); } @@ -311,7 +311,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx byte[] data = new byte[2048]; _cdReaders[_discIndex].ReadLBA_2048(lba, data, 0); Marshal.Copy(data, 0, dest, 2048); - _drivelight = true; + _driveLight = true; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs index cf49ad8d4a..5b7cde8d0a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs @@ -1,9 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx @@ -14,16 +10,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx struct CName { - public string Name; - public LibGPGX.INPUT_KEYS Key; - public CName(string Name, LibGPGX.INPUT_KEYS Key) + public readonly string Name; + public readonly LibGPGX.INPUT_KEYS Key; + public CName(string name, LibGPGX.INPUT_KEYS key) { - this.Name = Name; - this.Key = Key; + Name = name; + Key = key; } } - static CName[] Genesis3 = + private static readonly CName[] Genesis3 = { new CName("Up", LibGPGX.INPUT_KEYS.INPUT_UP), new CName("Down", LibGPGX.INPUT_KEYS.INPUT_DOWN), @@ -35,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx new CName("Start", LibGPGX.INPUT_KEYS.INPUT_START), }; - static CName[] Genesis6 = + private static readonly CName[] Genesis6 = { new CName("Up", LibGPGX.INPUT_KEYS.INPUT_UP), new CName("Down", LibGPGX.INPUT_KEYS.INPUT_DOWN), @@ -51,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx new CName("Mode", LibGPGX.INPUT_KEYS.INPUT_MODE), }; - static CName[] Mouse = + private static readonly CName[] Mouse = { new CName("Mouse Left", LibGPGX.INPUT_KEYS.INPUT_MOUSE_LEFT), new CName("Mouse Center", LibGPGX.INPUT_KEYS.INPUT_MOUSE_CENTER), @@ -59,13 +55,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx new CName("Mouse Start", LibGPGX.INPUT_KEYS.INPUT_MOUSE_START), }; - static CName[] Lightgun = + private static readonly CName[] Lightgun = { new CName("Lightgun Trigger", LibGPGX.INPUT_KEYS.INPUT_MENACER_TRIGGER), new CName("Lightgun Start", LibGPGX.INPUT_KEYS.INPUT_MENACER_START), }; - static CName[] Activator = + private static readonly CName[] Activator = { new CName("1L", LibGPGX.INPUT_KEYS.INPUT_ACTIVATOR_1L), new CName("1U", LibGPGX.INPUT_KEYS.INPUT_ACTIVATOR_1U), @@ -85,7 +81,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx new CName("8U", LibGPGX.INPUT_KEYS.INPUT_ACTIVATOR_8U), }; - static CName[] XEA1P = + private static readonly CName[] Xea1P = { new CName("XE A", LibGPGX.INPUT_KEYS.INPUT_XE_A), new CName("XE B", LibGPGX.INPUT_KEYS.INPUT_XE_B), @@ -97,81 +93,85 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx new CName("XE E2", LibGPGX.INPUT_KEYS.INPUT_XE_E2), }; - static ControllerDefinition.FloatRange MouseRange = new ControllerDefinition.FloatRange(-256, 0, 255); + private static readonly ControllerDefinition.FloatRange MouseRange = new ControllerDefinition.FloatRange(-256, 0, 255); + // lightgun needs to be transformed to match the current screen resolution - static ControllerDefinition.FloatRange LightgunRange = new ControllerDefinition.FloatRange(0, 5000, 10000); + private static readonly ControllerDefinition.FloatRange LightgunRange = new ControllerDefinition.FloatRange(0, 5000, 10000); - static ControllerDefinition.FloatRange XEA1PRange = new ControllerDefinition.FloatRange(-128, 0, 127); + private static readonly ControllerDefinition.FloatRange Xea1PRange = new ControllerDefinition.FloatRange(-128, 0, 127); - LibGPGX.InputData target = null; - IController source = null; + private LibGPGX.InputData _target; + private IController _source; - List Converts = new List(); + private readonly List _converts = new List(); - public ControllerDefinition ControllerDef { get; private set; } + public ControllerDefinition ControllerDef { get; } - void AddToController(int idx, int player, IEnumerable Buttons) + void AddToController(int idx, int player, IEnumerable buttons) { - foreach (var Button in Buttons) + foreach (var button in buttons) { - string Name = $"P{player} {Button.Name}"; - ControllerDef.BoolButtons.Add(Name); - var ButtonFlag = Button.Key; - Converts.Add(delegate() + string name = $"P{player} {button.Name}"; + ControllerDef.BoolButtons.Add(name); + var buttonFlag = button.Key; + _converts.Add(delegate { - if (source.IsPressed(Name)) - target.pad[idx] |= ButtonFlag; + if (_source.IsPressed(name)) + { + _target.pad[idx] |= buttonFlag; + } }); } } - void DoMouseAnalog(int idx, int player) + private void DoMouseAnalog(int idx, int player) { - string NX = $"P{player} Mouse X"; - string NY = $"P{player} Mouse Y"; - ControllerDef.FloatControls.Add(NX); - ControllerDef.FloatControls.Add(NY); + string nx = $"P{player} Mouse X"; + string ny = $"P{player} Mouse Y"; + ControllerDef.FloatControls.Add(nx); + ControllerDef.FloatControls.Add(ny); ControllerDef.FloatRanges.Add(MouseRange); ControllerDef.FloatRanges.Add(MouseRange); - Converts.Add(delegate() + _converts.Add(delegate { - target.analog[(2 * idx) + 0] = (short)source.GetFloat(NX); - target.analog[(2 * idx) + 1] = (short)source.GetFloat(NY); + _target.analog[(2 * idx) + 0] = (short)_source.GetFloat(nx); + _target.analog[(2 * idx) + 1] = (short)_source.GetFloat(ny); }); } - void DoLightgunAnalog(int idx, int player) + private void DoLightgunAnalog(int idx, int player) { - string NX = $"P{player} Lightgun X"; - string NY = $"P{player} Lightgun Y"; - ControllerDef.FloatControls.Add(NX); - ControllerDef.FloatControls.Add(NY); + string nx = $"P{player} Lightgun X"; + string ny = $"P{player} Lightgun Y"; + ControllerDef.FloatControls.Add(nx); + ControllerDef.FloatControls.Add(ny); ControllerDef.FloatRanges.Add(LightgunRange); ControllerDef.FloatRanges.Add(LightgunRange); - Converts.Add(delegate() + _converts.Add(delegate { - target.analog[(2 * idx) + 0] = (short)(source.GetFloat(NX) / 10000.0f * (ScreenWidth - 1)); - target.analog[(2 * idx) + 1] = (short)(source.GetFloat(NY) / 10000.0f * (ScreenHeight - 1)); + _target.analog[(2 * idx) + 0] = (short)(_source.GetFloat(nx) / 10000.0f * (ScreenWidth - 1)); + _target.analog[(2 * idx) + 1] = (short)(_source.GetFloat(ny) / 10000.0f * (ScreenHeight - 1)); }); } - void DoXEA1PAnalog(int idx, int player) + private void DoXea1PAnalog(int idx, int player) { - string NX = $"P{player} Stick X"; - string NY = $"P{player} Stick Y"; - string NZ = $"P{player} Stick Z"; - ControllerDef.FloatControls.Add(NX); - ControllerDef.FloatControls.Add(NY); - ControllerDef.FloatControls.Add(NZ); - ControllerDef.FloatRanges.Add(XEA1PRange); - ControllerDef.FloatRanges.Add(XEA1PRange); - ControllerDef.FloatRanges.Add(XEA1PRange); - Converts.Add(delegate() + string nx = $"P{player} Stick X"; + string ny = $"P{player} Stick Y"; + string nz = $"P{player} Stick Z"; + ControllerDef.FloatControls.Add(nx); + ControllerDef.FloatControls.Add(ny); + ControllerDef.FloatControls.Add(nz); + ControllerDef.FloatRanges.Add(Xea1PRange); + ControllerDef.FloatRanges.Add(Xea1PRange); + ControllerDef.FloatRanges.Add(Xea1PRange); + _converts.Add(delegate { - target.analog[(2 * idx) + 0] = (short)(source.GetFloat(NX)); - target.analog[(2 * idx) + 1] = (short)(source.GetFloat(NY)); + _target.analog[(2 * idx) + 0] = (short)_source.GetFloat(nx); + _target.analog[(2 * idx) + 1] = (short)_source.GetFloat(ny); + // +2 is correct in how gpgx internally does this - target.analog[(2 * idx) + 2] = (short)(source.GetFloat(NZ)); + _target.analog[(2 * idx) + 2] = (short)(_source.GetFloat(nz)); }); } @@ -230,8 +230,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx player++; break; case LibGPGX.INPUT_DEVICE.DEVICE_XE_A1P: - AddToController(i, player, XEA1P); - DoXEA1PAnalog(i, player); + AddToController(i, player, Xea1P); + DoXea1PAnalog(i, player); player++; break; case LibGPGX.INPUT_DEVICE.DEVICE_PICO: @@ -247,13 +247,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public void Convert(IController source, LibGPGX.InputData target) { - this.source = source; - this.target = target; + _source = source; + _target = target; target.ClearAllBools(); - foreach (var f in Converts) + foreach (var f in _converts) + { f(); - this.source = null; - this.target = null; + } + _source = null; + _target = null; } /// @@ -264,6 +266,5 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx /// must be set for proper lightgun operation /// public int ScreenHeight { get; set; } - } } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs index 286eac3b04..feeb4710a8 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.WonderSwan { @@ -41,7 +37,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan "Rotate" } }; - public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } } + public ControllerDefinition ControllerDefinition => WonderSwanController; BizSwan.Buttons GetButtons(IController controller) { diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IMemoryDomains.cs index bbdfcecb5a..c888bd3bcc 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IMemoryDomains.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.InteropServices; using BizHawk.Emulation.Common; @@ -13,10 +12,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan var mmd = new List(); for (int i = 0;; i++) { - IntPtr name; - int size; - IntPtr data; - if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data)) + if (!BizSwan.bizswan_getmemoryarea(Core, i, out var name, out var size, out var data)) { break; } @@ -26,11 +22,11 @@ namespace BizHawk.Emulation.Cores.WonderSwan continue; } - string sname = Marshal.PtrToStringAnsi(name); - mmd.Add(new MemoryDomainIntPtr(sname, MemoryDomain.Endian.Little, data, size, true, 1)); + string sName = Marshal.PtrToStringAnsi(name); + mmd.Add(new MemoryDomainIntPtr(sName, MemoryDomain.Endian.Little, data, size, true, 1)); } - (ServiceProvider as BasicServiceProvider).Register(new MemoryDomainList(mmd)); + ((BasicServiceProvider) ServiceProvider).Register(new MemoryDomainList(mmd)); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs index 6ff43e6c6c..cb775adc3a 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs @@ -1,38 +1,35 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - using BizHawk.Emulation.Common; - namespace BizHawk.Emulation.Cores.WonderSwan { partial class WonderSwan : ISaveRam { - byte[] saverambuff; + private byte[] _saveramBuff; - void InitISaveRam() + private void InitISaveRam() { - saverambuff = new byte[BizSwan.bizswan_saveramsize(Core)]; + _saveramBuff = new byte[BizSwan.bizswan_saveramsize(Core)]; } public byte[] CloneSaveRam() { - if (!BizSwan.bizswan_saveramsave(Core, saverambuff, saverambuff.Length)) + if (!BizSwan.bizswan_saveramsave(Core, _saveramBuff, _saveramBuff.Length)) + { throw new InvalidOperationException($"{nameof(BizSwan.bizswan_saveramsave)}() returned false!"); - return (byte[])saverambuff.Clone(); + } + + return (byte[])_saveramBuff.Clone(); } public void StoreSaveRam(byte[] data) { if (!BizSwan.bizswan_saveramload(Core, data, data.Length)) + { throw new InvalidOperationException($"{nameof(BizSwan.bizswan_saveramload)}() returned false!"); + } } - public bool SaveRamModified - { - get { return BizSwan.bizswan_saveramsize(Core) > 0; } - } + public bool SaveRamModified => BizSwan.bizswan_saveramsize(Core) > 0; } } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs index 024db5612c..ebdd4a1d0f 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISettable.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Emulation.Common; using System.ComponentModel; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISoundProvider.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISoundProvider.cs index fdefe2af5f..fe8983b1c9 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISoundProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISoundProvider.cs @@ -5,13 +5,10 @@ namespace BizHawk.Emulation.Cores.WonderSwan { public partial class WonderSwan : ISoundProvider { - private short[] sbuff = new short[1536]; + private readonly short[] sbuff = new short[1536]; private int sbuffcontains = 0; - public bool CanProvideAsync - { - get { return false; } - } + public bool CanProvideAsync => false; public void GetSamplesSync(out short[] samples, out int nsamp) { @@ -32,10 +29,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan } } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesAsync(short[] samples) { diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs index 0abf83c15c..7160d76c2a 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan { partial class WonderSwan: IStatable { - void InitIStatable() + private void InitIStatable() { savebuff = new byte[BizSwan.bizswan_binstatesize(Core)]; savebuff2 = new byte[savebuff.Length + 13]; diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index bfea204500..2401ac5a34 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -182,6 +182,7 @@ True True True + True True True True @@ -195,14 +196,17 @@ True True True + True True True True True + True True True True True + True True True True @@ -283,6 +287,7 @@ True True True + True True True True @@ -300,6 +305,7 @@ True True True + True True True True @@ -347,6 +353,7 @@ True True True + True True True True @@ -368,6 +375,7 @@ True True True + True True True True @@ -391,6 +399,7 @@ True True True + True True True True @@ -404,6 +413,7 @@ True True True + True True True True @@ -412,6 +422,7 @@ True True True + True True True True