diff --git a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index 82cf241074..45fc28e4a3 100644 --- a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -205,12 +205,7 @@ namespace BizHawk.Emulation.Common } // Hack for things like gameboy/ti-83 as opposed to genesis with no controllers plugged in - if (allNames.Any(b => b.StartsWith("Up"))) - { - return 1; - } - - return 0; + return allNames.Any(b => b.StartsWith("Up")) ? 1 : 0; } } diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs index 4978360a6c..72fe0c5f66 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs @@ -143,7 +143,7 @@ namespace BizHawk.Emulation.Common HasExecutes = _execs.Count > 0; _hasAny = HasReads || HasWrites || HasExecutes; - return (HasReads != hadReads || HasWrites != hadWrites || HasExecutes != hadExecutes); + return HasReads != hadReads || HasWrites != hadWrites || HasExecutes != hadExecutes; } private int RemoveInternal(MemoryCallbackDelegate action) diff --git a/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs b/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs index e46157b6af..45f5af0678 100644 --- a/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs +++ b/BizHawk.Emulation.Common/ControllerDefinitionMerger.cs @@ -8,16 +8,16 @@ namespace BizHawk.Emulation.Common // with it without knowing what else is connected public static class ControllerDefinitionMerger { - private static string Allocate(string input, ref int plr, ref int plrnext) + private static string Allocate(string input, ref int plr, ref int playerNext) { int offset = int.Parse(input.Substring(0, 1)); - int currplr = plr + offset; - if (currplr >= plrnext) + int currentPlayer = plr + offset; + if (currentPlayer >= playerNext) { - plrnext = currplr + 1; + playerNext = currentPlayer + 1; } - return $"P{currplr} {input.Substring(1)}"; + return $"P{currentPlayer} {input.Substring(1)}"; } /// @@ -28,27 +28,27 @@ namespace BizHawk.Emulation.Common ControllerDefinition ret = new ControllerDefinition(); unmergers = new List(); int plr = 1; - int plrnext = 1; + int playerNext = 1; foreach (var def in controllers) { - Dictionary remaps = new Dictionary(); + var remaps = new Dictionary(); foreach (string s in def.BoolButtons) { - string r = Allocate(s, ref plr, ref plrnext); + string r = Allocate(s, ref plr, ref playerNext); ret.BoolButtons.Add(r); remaps[s] = r; } foreach (string s in def.FloatControls) { - string r = Allocate(s, ref plr, ref plrnext); + string r = Allocate(s, ref plr, ref playerNext); ret.FloatControls.Add(r); remaps[s] = r; } ret.FloatRanges.AddRange(def.FloatRanges); - plr = plrnext; + plr = playerNext; unmergers.Add(new ControlDefUnMerger(remaps)); } diff --git a/BizHawk.Emulation.Common/DSKIdentifier.cs b/BizHawk.Emulation.Common/DSKIdentifier.cs index e35a59802f..ce7d818ce4 100644 --- a/BizHawk.Emulation.Common/DSKIdentifier.cs +++ b/BizHawk.Emulation.Common/DSKIdentifier.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Linq; +using System.Text; namespace BizHawk.Emulation.Common { @@ -404,16 +405,7 @@ namespace BizHawk.Emulation.Common public byte[] SectorData { get; set; } public bool ContainsMultipleWeakSectors { get; set; } - public int GetChecksum256() - { - int res = 0; - foreach (var b in SectorData) - { - res += b % 256; - } - - return res; - } + public int GetChecksum256() => SectorData.Sum(b => b % 256); } #endregion diff --git a/BizHawk.Emulation.Common/Database/Database.cs b/BizHawk.Emulation.Common/Database/Database.cs index 76bc0d7f0f..d17fb5e120 100644 --- a/BizHawk.Emulation.Common/Database/Database.cs +++ b/BizHawk.Emulation.Common/Database/Database.cs @@ -136,30 +136,28 @@ namespace BizHawk.Emulation.Common var game = new CompactGameInfo { - Hash = RemoveHashType(items[0].ToUpper()) + Hash = RemoveHashType(items[0].ToUpper()), + // remove a hash type identifier. well don't really need them for indexing (they're just there for human purposes) + Status = items[1].Trim() + switch + { + "B" => RomStatus.BadDump, + "V" => RomStatus.BadDump, + "T" => RomStatus.TranslatedRom, + "O" => RomStatus.Overdump, + "I" => RomStatus.Bios, + "D" => RomStatus.Homebrew, + "H" => RomStatus.Hack, + "U" => RomStatus.Unknown, + _ => RomStatus.GoodDump + }, + Name = items[2], + System = items[3], + MetaData = items.Length >= 6 ? items[5] : null, + Region = items.Length >= 7 ? items[6] : "", + ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : "", }; - // remove a hash type identifier. well don't really need them for indexing (they're just there for human purposes) - game.Status = items[1].Trim() - switch - { - "B" => RomStatus.BadDump, - "V" => RomStatus.BadDump, - "T" => RomStatus.TranslatedRom, - "O" => RomStatus.Overdump, - "I" => RomStatus.Bios, - "D" => RomStatus.Homebrew, - "H" => RomStatus.Hack, - "U" => RomStatus.Unknown, - _ => RomStatus.GoodDump - }; - - game.Name = items[2]; - game.System = items[3]; - game.MetaData = items.Length >= 6 ? items[5] : null; - game.Region = items.Length >= 7 ? items[6] : ""; - game.ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : ""; - if (DB.ContainsKey(game.Hash)) { Console.WriteLine("gamedb: Multiple hash entries {0}, duplicate detected on \"{1}\" and \"{2}\"", game.Hash, game.Name, DB[game.Hash].Name); diff --git a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs index e739fc9cda..a6e660da2f 100644 --- a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs +++ b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs @@ -2,6 +2,8 @@ using System.Linq; using System.Collections.Generic; +// ReSharper disable IdentifierTypo +// ReSharper disable InconsistentNaming // ReSharper disable StringLiteralTypo namespace BizHawk.Emulation.Common { @@ -11,10 +13,10 @@ namespace BizHawk.Emulation.Common { // FDS has two OK variants (http://tcrf.net/Family_Computer_Disk_System) var fdsNintendo = File("57FE1BDEE955BB48D357E463CCBF129496930B62", 8192, "disksys-nintendo.rom", "Bios (Nintendo)"); - var fdsTwinfc = File("E4E41472C454F928E53EB10E0509BF7D1146ECC1", 8192, "disksys-nintendo.rom", "Bios (TwinFC)"); + var fdsTwinFc = File("E4E41472C454F928E53EB10E0509BF7D1146ECC1", 8192, "disksys-nintendo.rom", "Bios (TwinFC)"); Firmware("NES", "Bios_FDS", "Bios"); Option("NES", "Bios_FDS", fdsNintendo); - Option("NES", "Bios_FDS", fdsTwinfc); + Option("NES", "Bios_FDS", fdsTwinFc); FirmwareAndOption("973E10840DB683CF3FAF61BD443090786B3A9F04", 262144, "SNES", "Rom_SGB", "sgb.sfc", "Super GameBoy Rom"); // World (Rev B) ? FirmwareAndOption("A002F4EFBA42775A31185D443F3ED1790B0E949A", 3072, "SNES", "CX4", "cx4.rom", "CX4 Rom"); @@ -57,12 +59,6 @@ namespace BizHawk.Emulation.Common FirmwareAndOption("D3B78C3DBAC55F5199F33F3FE0036439811F7FB3", 16384, "C64", "Drive1541II", "drive-1541ii.bin", "1541-II Disk Drive Rom"); // ZX Spectrum - /* These are now shipped with bizhawk - FirmwareAndOption("5EA7C2B824672E914525D1D5C419D71B84A426A2", 16384, "ZXSpectrum", "48ROM", "48.ROM", "Spectrum 48K ROM"); - FirmwareAndOption("16375D42EA109B47EDDED7A16028DE7FDB3013A1", 32768, "ZXSpectrum", "128ROM", "128.ROM", "Spectrum 128K ROM"); - FirmwareAndOption("8CAFB292AF58617907B9E6B9093D3588A75849B8", 32768, "ZXSpectrum", "PLUS2ROM", "PLUS2.ROM", "Spectrum 128K +2 ROM"); - FirmwareAndOption("929BF1A5E5687EBD8D7245F9B513A596C0EC21A4", 65536, "ZXSpectrum", "PLUS3ROM", "PLUS3.ROM", "Spectrum 128K +3 ROM"); - */ FirmwareAndOption("A584272F21DC82C14B7D4F1ED440E23A976E71F0", 32768, "ZXSpectrum", "PentagonROM", "pentagon.rom", "Russian Pentagon Clone ROM"); FirmwareAndOption("282EB7BC819AAD2A12FD954E76F7838A4E1A7929", 16384, "ZXSpectrum", "TRDOSROM", "trdos.rom", "TRDOS ROM"); @@ -350,7 +346,7 @@ namespace BizHawk.Emulation.Common private static void FirmwareAndOption(string hash, long size, string systemId, string id, string name, string descr) { Firmware(systemId, id, descr); - File(hash, size, name, descr, ""); + File(hash, size, name, descr); _OptionWork(hash, size, systemId, id); } @@ -381,13 +377,13 @@ namespace BizHawk.Emulation.Common public enum FirmwareOptionStatus { - //This is what we want you to use to get checkmarks, and for TASing + // This is what we want you to use to get checkmarks, and for TASing Ideal, - //This will work with our core + // This will work with our core Acceptable, - //This is a good file, but it doesn't work with our core + // This is a good file, but it doesn't work with our core Unacceptable, //I know this is weird, you'd think the file is bad @@ -410,13 +406,8 @@ namespace BizHawk.Emulation.Common public static FirmwareRecord LookupFirmwareRecord(string sysId, string firmwareId) { - var found = - from fr in FirmwareRecords - where fr.FirmwareId == firmwareId - && fr.SystemId == sysId - select fr; - - return found.FirstOrDefault(); + return FirmwareRecords + .FirstOrDefault(fr => fr.FirmwareId == firmwareId && fr.SystemId == sysId); } } // static class FirmwareDatabase } diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index 75bb9da515..d4cbaa5932 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -151,7 +151,7 @@ namespace BizHawk.Emulation.Common public static bool MemoryCallbacksAvailable(this IEmulator core) { // TODO: this is a pretty ugly way to handle this - var debuggable = (IDebuggable) core?.ServiceProvider.GetService(); + var debuggable = core?.ServiceProvider.GetService(); if (debuggable != null) { try diff --git a/BizHawk.Emulation.Common/Interfaces/Services/ISoundProvider.cs b/BizHawk.Emulation.Common/Interfaces/Services/ISoundProvider.cs index 5a4ab1c08e..b83161de34 100644 --- a/BizHawk.Emulation.Common/Interfaces/Services/ISoundProvider.cs +++ b/BizHawk.Emulation.Common/Interfaces/Services/ISoundProvider.cs @@ -1,4 +1,6 @@ -namespace BizHawk.Emulation.Common +using System; + +namespace BizHawk.Emulation.Common { public enum SyncSoundMode { diff --git a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs index 309a9fd8f2..79dc37a6ea 100644 --- a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs +++ b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs @@ -1,6 +1,9 @@ using System; using System.Runtime.InteropServices; +// ReSharper disable UnusedMember.Local +// ReSharper disable UnusedMember.Global +// ReSharper disable IdentifierTypo // ReSharper disable StyleCop.SA1300 // ReSharper disable InconsistentNaming namespace BizHawk.Emulation.Common @@ -22,7 +25,7 @@ namespace BizHawk.Emulation.Common /// /// quality of the resampler. values other than those listed are valid, provided they are between MIN and MAX /// - public enum Quality : int + public enum Quality { QUALITY_MAX = 10, QUALITY_MIN = 0, diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index c58d87999a..07918cba7d 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -231,6 +231,7 @@ True True True + True True True True @@ -327,6 +328,7 @@ True True True + True True True True @@ -404,6 +406,7 @@ True True True + True True True True