diff --git a/src/BizHawk.Client.EmuHawk/MainForm.VSystem.cs b/src/BizHawk.Client.EmuHawk/MainForm.VSystem.cs index 7d0def6e14..89b2540033 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.VSystem.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.VSystem.cs @@ -885,10 +885,6 @@ namespace BizHawk.Client.EmuHawk snes9X.PutSettings(s); AddOnScreenMessage($"Sprite {layer} Layer {(result ? "On" : "Off")}"); } - else - { - return; - } } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index c717b774a8..69de974475 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -4650,7 +4650,7 @@ namespace BizHawk.Client.EmuHawk if (_singleInstanceServer.IsMessageComplete) break; } - var payloadString = System.Text.Encoding.ASCII.GetString(payloadBytes.GetBuffer(), 0, (int)payloadBytes.Length); + var payloadString = Encoding.ASCII.GetString(payloadBytes.GetBuffer(), 0, (int)payloadBytes.Length); var args = payloadString.Split('|').Select(a => Encoding.UTF8.GetString(a.HexStringToBytes())).ToArray(); Console.WriteLine("RECEIVED SINGLE INSTANCE FORWARDED ARGS:"); diff --git a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index 89cf744d0b..563ac12102 100644 --- a/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/src/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -1242,7 +1242,7 @@ namespace BizHawk.Client.EmuHawk // find the control under the mouse Point m = Cursor.Position; Control top = this; - Control found = null; + Control found; do { found = top.GetChildAtPoint(top.PointToClient(m), GetChildAtPointSkip.Invisible); diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs index 59476f2376..bbf0fe6edb 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs @@ -110,7 +110,7 @@ namespace BizHawk.Client.EmuHawk return; } - _values[PatternList.SelectedIndex] = unchecked((int) ValueNum.Value).ToString(NumberFormatInfo.InvariantInfo); + _values[PatternList.SelectedIndex] = ((int) ValueNum.Value).ToString(NumberFormatInfo.InvariantInfo); UpdatePattern(); UpdateDisplay(); } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs index 51e1b685b4..e8565426b0 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs @@ -2,7 +2,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Common { - public readonly struct AxisSpec + public readonly record struct AxisSpec { /// /// Gets the axis constraints that apply artificial constraints to float values diff --git a/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 0628d67ce4..2f005cfd60 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -85,6 +85,5 @@ namespace BizHawk.Emulation.Common public string Scope { get; } } -#nullable restore } } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs b/src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs index 6486115c72..71a3721250 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs @@ -34,71 +34,59 @@ namespace BizHawk.Emulation.Common public virtual ushort PeekUshort(long addr, bool bigEndian) { - Endian endian = bigEndian ? Endian.Big : Endian.Little; - switch (endian) + if (bigEndian) { - default: - case Endian.Big: - return (ushort)((PeekByte(addr) << 8) | PeekByte(addr + 1)); - case Endian.Little: - return (ushort)(PeekByte(addr) | (PeekByte(addr + 1) << 8)); + return (ushort)((PeekByte(addr) << 8) | PeekByte(addr + 1)); } + + return (ushort)(PeekByte(addr) | (PeekByte(addr + 1) << 8)); } public virtual uint PeekUint(long addr, bool bigEndian) { - Endian endian = bigEndian ? Endian.Big : Endian.Little; - switch (endian) + if (bigEndian) { - default: - case Endian.Big: - return (uint)((PeekByte(addr) << 24) + return (uint)((PeekByte(addr) << 24) | (PeekByte(addr + 1) << 16) | (PeekByte(addr + 2) << 8) | (PeekByte(addr + 3) << 0)); - case Endian.Little: - return (uint)((PeekByte(addr) << 0) - | (PeekByte(addr + 1) << 8) - | (PeekByte(addr + 2) << 16) - | (PeekByte(addr + 3) << 24)); } + + return (uint)((PeekByte(addr) << 0) + | (PeekByte(addr + 1) << 8) + | (PeekByte(addr + 2) << 16) + | (PeekByte(addr + 3) << 24)); } public virtual void PokeUshort(long addr, ushort val, bool bigEndian) { - Endian endian = bigEndian ? Endian.Big : Endian.Little; - switch (endian) + if (bigEndian) { - default: - case Endian.Big: - PokeByte(addr + 0, (byte)(val >> 8)); - PokeByte(addr + 1, (byte)val); - break; - case Endian.Little: - PokeByte(addr + 0, (byte)val); - PokeByte(addr + 1, (byte)(val >> 8)); - break; + PokeByte(addr + 0, (byte)(val >> 8)); + PokeByte(addr + 1, (byte)val); + } + else + { + PokeByte(addr + 0, (byte)val); + PokeByte(addr + 1, (byte)(val >> 8)); } } public virtual void PokeUint(long addr, uint val, bool bigEndian) { - Endian endian = bigEndian ? Endian.Big : Endian.Little; - switch (endian) + if (bigEndian) { - default: - case Endian.Big: - PokeByte(addr + 0, (byte)(val >> 24)); - PokeByte(addr + 1, (byte)(val >> 16)); - PokeByte(addr + 2, (byte)(val >> 8)); - PokeByte(addr + 3, (byte)val); - break; - case Endian.Little: - PokeByte(addr + 0, (byte)val); - PokeByte(addr + 1, (byte)(val >> 8)); - PokeByte(addr + 2, (byte)(val >> 16)); - PokeByte(addr + 3, (byte)(val >> 24)); - break; + PokeByte(addr + 0, (byte)(val >> 24)); + PokeByte(addr + 1, (byte)(val >> 16)); + PokeByte(addr + 2, (byte)(val >> 8)); + PokeByte(addr + 3, (byte)val); + } + else + { + PokeByte(addr + 0, (byte)val); + PokeByte(addr + 1, (byte)(val >> 8)); + PokeByte(addr + 2, (byte)(val >> 16)); + PokeByte(addr + 3, (byte)(val >> 24)); } } @@ -107,7 +95,7 @@ namespace BizHawk.Emulation.Common if (addresses is null) throw new ArgumentNullException(paramName: nameof(addresses)); if (values is null) throw new ArgumentNullException(paramName: nameof(values)); - if ((long) addresses.Count() != values.Length) + if ((long)addresses.Count() != values.Length) { throw new InvalidOperationException("Invalid length of values array"); } @@ -121,17 +109,17 @@ namespace BizHawk.Emulation.Common } } - public virtual void BulkPeekUshort(Range addresses, bool bigEndian, ushort[] values) + public virtual void BulkPeekUshort(Range addresses, bool bigEndian, ushort[] values) { if (addresses is null) throw new ArgumentNullException(paramName: nameof(addresses)); if (values is null) throw new ArgumentNullException(paramName: nameof(values)); var start = addresses.Start; - var end = addresses.EndInclusive + 1; + var end = addresses.EndInclusive + 1; if ((start & 1) != 0 || (end & 1) != 0) throw new InvalidOperationException("The API contract doesn't define what to do for unaligned reads and writes!"); - + if (values.LongLength * 2 != end - start) { // a longer array could be valid, but nothing needs that so don't support it for now @@ -151,11 +139,11 @@ namespace BizHawk.Emulation.Common if (values is null) throw new ArgumentNullException(paramName: nameof(values)); var start = addresses.Start; - var end = addresses.EndInclusive + 1; + var end = addresses.EndInclusive + 1; if ((start & 3) != 0 || (end & 3) != 0) throw new InvalidOperationException("The API contract doesn't define what to do for unaligned reads and writes!"); - + if (values.LongLength * 4 != end - start) { // a longer array could be valid, but nothing needs that so don't support it for now diff --git a/src/BizHawk.Emulation.Common/Database/FirmwareID.cs b/src/BizHawk.Emulation.Common/Database/FirmwareID.cs index 98f5619894..a2c286bd26 100644 --- a/src/BizHawk.Emulation.Common/Database/FirmwareID.cs +++ b/src/BizHawk.Emulation.Common/Database/FirmwareID.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Common Firmware = firmware; } - public override bool Equals(object obj) => obj is FirmwareID other + public override bool Equals(object? obj) => obj is FirmwareID other && other.Firmware == Firmware && other.System == System; public override int GetHashCode() => (System, Firmware).GetHashCode();