From 2b281116ed3cb9267f0974c418678bb51eb76971 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 8 Apr 2020 16:03:35 -0500 Subject: [PATCH] misc cleanups --- BizHawk.Client.Common/Api/Classes/MemApi.cs | 10 +- BizHawk.Client.Common/FirmwareManager.cs | 18 +-- .../FrameworkFastZipWriter.cs | 21 ++-- BizHawk.Client.Common/XmlGame.cs | 8 +- BizHawk.Client.Common/config/ConfigService.cs | 12 +- .../config/ToolDialogSettings.cs | 20 +--- .../input/PolarRectConversionData.cs | 2 - .../inputAdapters/StickyAdapters.cs | 12 +- BizHawk.Client.Common/lua/LuaHelper.cs | 1 - .../movie/bk2/Bk2Movie.IO.cs | 18 ++- BizHawk.Client.Common/movie/bk2/Bk2Movie.cs | 13 +- .../conversions/MovieConversionExtensions.cs | 1 - .../movie/import/DsmImport.cs | 2 - .../movie/import/LsmvImport.cs | 2 +- .../movie/import/VbmImport.cs | 12 +- .../movie/tasproj/TasMovie.History.cs | 5 - .../rewind/RewindThreader.cs | 5 +- BizHawk.Client.Common/tools/CheatList.cs | 111 +++++++----------- .../CallbackBasedTraceBuffer.cs | 2 +- .../ControllerDefinition.cs | 4 +- .../MemoryCallbackSystem.cs | 5 +- .../Base Implementations/MemoryDomain.cs | 5 +- .../Base Implementations/MemoryDomainImpls.cs | 1 - .../Base Implementations/NullController.cs | 10 +- BizHawk.Emulation.Common/Database/GameInfo.cs | 5 - .../Sound/Utilities/SpeexResampler.cs | 2 +- .../CPUs/HuC6280/CDLOpcodes.cs | 10 +- .../CPUs/HuC6280/HuC6280_CDL.cs | 23 +--- .../Media/Tape/TapeDataBlock.cs | 39 +----- .../Consoles/Nintendo/GBHawk/Audio.cs | 8 +- .../Consoles/Nintendo/GBHawk/HW_Registers.cs | 2 +- .../Nintendo/GBHawk/Mappers/Mapper_MBC1.cs | 18 ++- .../Nintendo/NDS/MelonDS_MemoryDomains.cs | 8 +- .../NES/Boards/MMC3_family/Mapper217.cs | 14 +-- .../Nintendo/NES/Boards/MMC3_family/TVROM.cs | 6 +- .../Consoles/Nintendo/NES/Boards/Mapper183.cs | 53 ++++----- .../Nintendo/NES/Boards/NovelDiamond.cs | 3 +- .../Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs | 65 +++++----- .../Consoles/Nintendo/NES/BootGodDB.cs | 11 +- .../Nintendo/NES/NES.ICodeDataLogger.cs | 16 +-- .../Consoles/Nintendo/NES/NES.ISaveRam.cs | 19 +-- .../Consoles/Sega/SMS/SMS.ICodeDataLogger.cs | 20 ++-- .../Consoles/Sega/gpgx64/GenDbgHlp.cs | 8 +- .../Waterbox/WaterboxCore.cs | 3 +- BizHawk.sln.DotSettings | 2 + 45 files changed, 238 insertions(+), 397 deletions(-) diff --git a/BizHawk.Client.Common/Api/Classes/MemApi.cs b/BizHawk.Client.Common/Api/Classes/MemApi.cs index 702512af95..5dde96ad78 100644 --- a/BizHawk.Client.Common/Api/Classes/MemApi.cs +++ b/BizHawk.Client.Common/Api/Classes/MemApi.cs @@ -158,12 +158,10 @@ namespace BizHawk.Client.Common public void SetBigEndian(bool enabled = true) => _isBigEndian = enabled; - public List GetMemoryDomainList() - { - var list = new List(); - foreach (var domain in DomainList) list.Add(domain.Name); - return list; - } + public List GetMemoryDomainList() => + DomainList + .Select(domain => domain.Name) + .ToList(); public uint GetMemoryDomainSize(string name = null) => (uint) NamedDomainOrCurrent(name).Size; diff --git a/BizHawk.Client.Common/FirmwareManager.cs b/BizHawk.Client.Common/FirmwareManager.cs index 7f9dab4c9b..dec58e6f7b 100644 --- a/BizHawk.Client.Common/FirmwareManager.cs +++ b/BizHawk.Client.Common/FirmwareManager.cs @@ -240,15 +240,15 @@ namespace BizHawk.Client.Common continue; } - // compute its hash - RealFirmwareFile rff; - // NDS's firmware file contains user settings; these are over-written by sync settings, so we shouldn't allow them to impact the hash - if (fr.SystemId == "NDS" && fr.FirmwareId == "firmware") - rff = reader.Read(new FileInfo(Emulation.Cores.Consoles.Nintendo.NDS.MelonDS.CreateModifiedFirmware(userSpec))); - else - rff = reader.Read(fi); - ri.Size = fi.Length; - ri.Hash = rff.Hash; + // compute its hash + RealFirmwareFile rff; + // NDS's firmware file contains user settings; these are over-written by sync settings, so we shouldn't allow them to impact the hash + if (fr.SystemId == "NDS" && fr.FirmwareId == "firmware") + rff = reader.Read(new FileInfo(Emulation.Cores.Consoles.Nintendo.NDS.MelonDS.CreateModifiedFirmware(userSpec))); + else + rff = reader.Read(fi); + ri.Size = fi.Length; + ri.Hash = rff.Hash; // check whether it was a known file anyway, and go ahead and bind to the known file, as a perk (the firmwares config doesn't really use this information right now) if (FirmwareDatabase.FirmwareFilesByHash.TryGetValue(rff.Hash, out var ff)) diff --git a/BizHawk.Client.Common/FrameworkFastZipWriter.cs b/BizHawk.Client.Common/FrameworkFastZipWriter.cs index 316fcceff3..cede032acd 100644 --- a/BizHawk.Client.Common/FrameworkFastZipWriter.cs +++ b/BizHawk.Client.Common/FrameworkFastZipWriter.cs @@ -14,9 +14,9 @@ namespace BizHawk.Client.Common private Stream _output; private readonly CompressionLevel _level; - private byte[] _localHeader; + private readonly byte[] _localHeader; private List _endBlobs = new List(); - private byte[] _fileHeaderTemplate; + private readonly byte[] _fileHeaderTemplate; private int _numEntries; private bool _disposed; @@ -115,17 +115,18 @@ namespace BizHawk.Client.Common } } - /// is 0 - public FrameworkFastZipWriter(string path, int compressionlevel) + /// is 0 + public FrameworkFastZipWriter(string path, int compressionLevel) { _output = new FileStream(path, FileMode.Create, FileAccess.Write); - if (compressionlevel == 0) + if (compressionLevel == 0) + { throw new NotImplementedException(); - //_level = CompressionLevel.NoCompression; - else if (compressionlevel < 5) - _level = CompressionLevel.Fastest; - else - _level = CompressionLevel.Optimal; + } + + _level = compressionLevel < 5 + ? CompressionLevel.Fastest + : CompressionLevel.Optimal; var dt = DateTime.Now; var mtime = dt.Second >> 1 diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index 235972f499..2d49abadb7 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -52,18 +52,14 @@ namespace BizHawk.Client.Common foreach (XmlNode a in n.ChildNodes) { string filename = a.Attributes["FileName"].Value; - byte[] data = new byte[0]; + byte[] data; if (filename[0] == '|') { // in same archive var ai = f.FindArchiveMember(filename.Substring(1)); if (ai != null) { - if (originalIndex == null) - { - originalIndex = f.BoundIndex; - } - + originalIndex ??= f.BoundIndex; f.Unbind(); f.BindArchiveMember(ai.Value); data = f.GetStream().ReadAllBytes(); diff --git a/BizHawk.Client.Common/config/ConfigService.cs b/BizHawk.Client.Common/config/ConfigService.cs index 5b81e54d08..ec27761971 100644 --- a/BizHawk.Client.Common/config/ConfigService.cs +++ b/BizHawk.Client.Common/config/ConfigService.cs @@ -76,9 +76,9 @@ namespace BizHawk.Client.Common public static object LoadWithType(string serialized) { - using TextReader tr = new StringReader(serialized); - using JsonTextReader jr = new JsonTextReader(tr); - TypeNameEncapsulator tne = (TypeNameEncapsulator)Serializer.Deserialize(jr, typeof(TypeNameEncapsulator)); + using var tr = new StringReader(serialized); + using var jr = new JsonTextReader(tr); + var tne = (TypeNameEncapsulator)Serializer.Deserialize(jr, typeof(TypeNameEncapsulator)); // in the case of trying to deserialize nothing, tne will be nothing // we want to return nothing @@ -87,9 +87,9 @@ namespace BizHawk.Client.Common public static string SaveWithType(object o) { - using StringWriter sw = new StringWriter(); - using JsonTextWriter jw = new JsonTextWriter(sw) { Formatting = Formatting.None }; - TypeNameEncapsulator tne = new TypeNameEncapsulator { o = o }; + using var sw = new StringWriter(); + using var jw = new JsonTextWriter(sw) { Formatting = Formatting.None }; + var tne = new TypeNameEncapsulator { o = o }; Serializer.Serialize(jw, tne, typeof(TypeNameEncapsulator)); sw.Flush(); return sw.ToString(); diff --git a/BizHawk.Client.Common/config/ToolDialogSettings.cs b/BizHawk.Client.Common/config/ToolDialogSettings.cs index 5635960e79..4323fe5229 100644 --- a/BizHawk.Client.Common/config/ToolDialogSettings.cs +++ b/BizHawk.Client.Common/config/ToolDialogSettings.cs @@ -33,11 +33,7 @@ namespace BizHawk.Client.Common [JsonIgnore] public int? Wndx { - get - { - return _wndx; - } - + get => _wndx; set { if (value != -32000) @@ -50,11 +46,7 @@ namespace BizHawk.Client.Common [JsonIgnore] public int? Wndy { - get - { - return _wndy; - } - + get => _wndy; set { if (value != -32000) @@ -104,13 +96,7 @@ namespace BizHawk.Client.Common public class ColumnList : List { - public Column this[string name] - { - get - { - return this.FirstOrDefault(c => c.Name == name); - } - } + public Column this[string name] => this.FirstOrDefault(c => c.Name == name); } public class Column diff --git a/BizHawk.Client.Common/input/PolarRectConversionData.cs b/BizHawk.Client.Common/input/PolarRectConversionData.cs index ee2643fce4..53a2b6fd7a 100644 --- a/BizHawk.Client.Common/input/PolarRectConversionData.cs +++ b/BizHawk.Client.Common/input/PolarRectConversionData.cs @@ -1,7 +1,5 @@ #nullable enable -using System; - namespace BizHawk.Client.Common { /// This is separate from because its large size slows or prevents design-time code analysis. diff --git a/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs b/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs index ef9f155fd7..2c7a6c0f09 100644 --- a/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs +++ b/BizHawk.Client.Common/inputAdapters/StickyAdapters.cs @@ -162,11 +162,7 @@ namespace BizHawk.Client.Common { if (value.HasValue) { - if (pattern == null) - { - pattern = new AutoPatternFloat(value.Value, _on, 0, _off); - } - + pattern ??= new AutoPatternFloat(value.Value, _on, 0, _off); _axisPatterns[name] = pattern; } else @@ -179,11 +175,7 @@ namespace BizHawk.Client.Common { if (isSticky) { - if (pattern == null) - { - pattern = new AutoPatternBool(_on, _off); - } - + pattern ??= new AutoPatternBool(_on, _off); _boolPatterns[button] = pattern; } else diff --git a/BizHawk.Client.Common/lua/LuaHelper.cs b/BizHawk.Client.Common/lua/LuaHelper.cs index 1c0aacc08e..802d594e40 100644 --- a/BizHawk.Client.Common/lua/LuaHelper.cs +++ b/BizHawk.Client.Common/lua/LuaHelper.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using BizHawk.Common; -using BizHawk.Emulation.Common; using NLua; namespace BizHawk.Client.Common diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs index 84676f16ea..9e3eef00ad 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs @@ -111,9 +111,8 @@ namespace BizHawk.Client.Common bl.GetLump(BinaryStateLump.Input, true, delegate(TextReader tr) { - string errorMessage; IsCountingRerecords = false; - ExtractInputLog(tr, out errorMessage); + ExtractInputLog(tr, out _); IsCountingRerecords = true; }); @@ -166,20 +165,17 @@ namespace BizHawk.Client.Common protected virtual void Write(string fn, bool backup = false) { - if (Global.Emulator is Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk) + if (Global.Emulator is Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk subNes) { - var _subnes = (Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk)Global.Emulator; - Header[HeaderKeys.VBlankCount] = _subnes.VBL_CNT.ToString(); + Header[HeaderKeys.VBlankCount] = subNes.VBL_CNT.ToString(); } - else if (Global.Emulator is Emulation.Cores.Nintendo.Gameboy.Gameboy) + else if (Global.Emulator is Emulation.Cores.Nintendo.Gameboy.Gameboy gameboy) { - var _gameboy = (Emulation.Cores.Nintendo.Gameboy.Gameboy)Global.Emulator; - Header[HeaderKeys.CycleCount] = _gameboy.CycleCount.ToString(); + Header[HeaderKeys.CycleCount] = gameboy.CycleCount.ToString(); } - else if (Global.Emulator is Emulation.Cores.Nintendo.SubGBHawk.SubGBHawk) + else if (Global.Emulator is Emulation.Cores.Nintendo.SubGBHawk.SubGBHawk subGb) { - var _subgb = (Emulation.Cores.Nintendo.SubGBHawk.SubGBHawk)Global.Emulator; - Header[HeaderKeys.VBlankCount] = _subgb.VBL_CNT.ToString(); + Header[HeaderKeys.VBlankCount] = subGb.VBL_CNT.ToString(); } var file = new FileInfo(fn); diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs index 84a2abce5b..2365d83e7d 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs @@ -78,7 +78,8 @@ namespace BizHawk.Client.Common { return Convert.ToUInt64(Header[HeaderKeys.VBlankCount]); } - else if (Header.ContainsKey(HeaderKeys.CycleCount)) + + if (Header.ContainsKey(HeaderKeys.CycleCount)) { var gambatteName = ((CoreAttribute)Attribute.GetCustomAttribute(typeof(Gameboy), typeof(CoreAttribute))).CoreName; if (Header[HeaderKeys.Core] == gambatteName) @@ -86,6 +87,7 @@ namespace BizHawk.Client.Common return Convert.ToUInt64(Header[HeaderKeys.CycleCount]); } } + return (ulong)Log.Count; } } @@ -135,13 +137,10 @@ namespace BizHawk.Client.Common { if (frame < FrameCount && frame >= 0) { - if (_adapter == null) + _adapter ??= new Bk2ControllerAdapter { - _adapter = new Bk2ControllerAdapter - { - Definition = Global.MovieSession.MovieControllerAdapter.Definition - }; - } + Definition = Global.MovieSession.MovieControllerAdapter.Definition + }; int getFrame; diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index b7d999e6d0..2b2b398446 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -2,7 +2,6 @@ using System.IO; using System.Linq; -using BizHawk.Common.PathExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.GBHawk; diff --git a/BizHawk.Client.Common/movie/import/DsmImport.cs b/BizHawk.Client.Common/movie/import/DsmImport.cs index 667fa0e89c..89895041f4 100644 --- a/BizHawk.Client.Common/movie/import/DsmImport.cs +++ b/BizHawk.Client.Common/movie/import/DsmImport.cs @@ -1,7 +1,5 @@ using System; using System.Linq; -using BizHawk.Common; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Consoles.Nintendo.NDS; diff --git a/BizHawk.Client.Common/movie/import/LsmvImport.cs b/BizHawk.Client.Common/movie/import/LsmvImport.cs index 5859d91230..81c2c02227 100644 --- a/BizHawk.Client.Common/movie/import/LsmvImport.cs +++ b/BizHawk.Client.Common/movie/import/LsmvImport.cs @@ -240,7 +240,7 @@ namespace BizHawk.Client.Common.movie.import hf.BindArchiveMember(item.Index); var stream = hf.GetStream(); string subtitles = Encoding.UTF8.GetString(stream.ReadAllBytes()); - using (StringReader reader = new StringReader(subtitles)) + using (var reader = new StringReader(subtitles)) { string line; while ((line = reader.ReadLine()) != null) diff --git a/BizHawk.Client.Common/movie/import/VbmImport.cs b/BizHawk.Client.Common/movie/import/VbmImport.cs index c80cae49a3..d1eeaa2e63 100644 --- a/BizHawk.Client.Common/movie/import/VbmImport.cs +++ b/BizHawk.Client.Common/movie/import/VbmImport.cs @@ -282,10 +282,10 @@ namespace BizHawk.Client.Common.movie.import { if (Global.Config.GbUseGbHawk || Global.Config.UseSubGBHawk) { - var temp_sync = new GBHawk.GBSyncSettings(); - if (is_GBC) { temp_sync.ConsoleMode = GBHawk.GBSyncSettings.ConsoleModeType.GBC; } - else { temp_sync.ConsoleMode = GBHawk.GBSyncSettings.ConsoleModeType.GB; } - Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(temp_sync); + var tempSync = new GBHawk.GBSyncSettings(); + if (is_GBC) { tempSync.ConsoleMode = GBHawk.GBSyncSettings.ConsoleModeType.GBC; } + else { tempSync.ConsoleMode = GBHawk.GBSyncSettings.ConsoleModeType.GB; } + Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(tempSync); } else { @@ -293,8 +293,8 @@ namespace BizHawk.Client.Common.movie.import if (is_GBC) { temp_sync.ConsoleMode = Gameboy.GambatteSyncSettings.ConsoleModeType.GBC; } else { temp_sync.ConsoleMode = Gameboy.GambatteSyncSettings.ConsoleModeType.GB; } Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(temp_sync); - } - } + } + } } private static SimpleController GbController() diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs index d7c8cc9d3b..35ec22f35d 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -294,11 +294,6 @@ namespace BizHawk.Client.Common return ret; } - public void SetName(string name) - { - Names[Names.Count - 1] = name; - } - // TODO: These probably aren't the best way to handle undo/redo. private int _lastGeneral; diff --git a/BizHawk.Client.Common/rewind/RewindThreader.cs b/BizHawk.Client.Common/rewind/RewindThreader.cs index 7169ce8929..713919e8c7 100644 --- a/BizHawk.Client.Common/rewind/RewindThreader.cs +++ b/BizHawk.Client.Common/rewind/RewindThreader.cs @@ -70,10 +70,7 @@ namespace BizHawk.Client.Common savestateCopy = null; } - if (savestateCopy == null) - { - savestateCopy = new byte[coreSavestate.Length]; - } + savestateCopy ??= new byte[coreSavestate.Length]; Buffer.BlockCopy(coreSavestate, 0, savestateCopy, 0, coreSavestate.Length); diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 91f4e3595a..0bafbc3544 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -497,77 +497,48 @@ namespace BizHawk.Client.Common public void Sort(string column, bool reverse) { - switch (column) + _cheatList = column switch { - case NameColumn: - _cheatList = _cheatList - .OrderBy(c => c.Name, reverse) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case AddressColumn: - _cheatList = _cheatList - .OrderBy(c => c.Address ?? 0, reverse) - .ThenBy(c => c.Name) - .ToList(); - break; - case ValueColumn: - _cheatList = _cheatList - .OrderBy(c => c.Value ?? 0, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case CompareColumn: - _cheatList = _cheatList - .OrderBy(c => c.Compare ?? 0, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case OnColumn: - _cheatList = _cheatList - .OrderBy(c => c.Enabled, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case DomainColumn: - _cheatList = _cheatList - .OrderBy(c => c.Domain, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case SizeColumn: - _cheatList = _cheatList - .OrderBy(c => (int)c.Size, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case EndianColumn: - _cheatList = _cheatList - .OrderBy(c => c.BigEndian, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case TypeColumn: - _cheatList = _cheatList - .OrderBy(c => c.Type, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - case ComparisonType: - _cheatList = _cheatList - .OrderBy(c => c.ComparisonType, reverse) - .ThenBy(c => c.Name) - .ThenBy(c => c.Address ?? 0) - .ToList(); - break; - } + NameColumn => _cheatList.OrderBy(c => c.Name, reverse) + .ThenBy(c => c.Address ?? 0) + .ToList(), + AddressColumn => _cheatList.OrderBy(c => c.Address ?? 0, reverse) + .ThenBy(c => c.Name) + .ToList(), + ValueColumn => _cheatList.OrderBy(c => c.Value ?? 0, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + CompareColumn => _cheatList.OrderBy(c => c.Compare ?? 0, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + OnColumn => _cheatList.OrderBy(c => c.Enabled, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + DomainColumn => _cheatList.OrderBy(c => c.Domain, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + SizeColumn => _cheatList.OrderBy(c => (int) c.Size, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + EndianColumn => _cheatList.OrderBy(c => c.BigEndian, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + TypeColumn => _cheatList.OrderBy(c => c.Type, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + ComparisonType => _cheatList.OrderBy(c => c.ComparisonType, reverse) + .ThenBy(c => c.Name) + .ThenBy(c => c.Address ?? 0) + .ToList(), + _ => _cheatList + }; } public void SetDefaultFileName(string defaultFileName) diff --git a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 077d3444fe..a7b3bf1543 100644 --- a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Common public string Header { get; protected set; } - public class TracingMemoryCallback : IMemoryCallback + private class TracingMemoryCallback : IMemoryCallback { public TracingMemoryCallback(MemoryCallbackDelegate callback, string scope) { diff --git a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs index b19d14b46a..221b635ea3 100644 --- a/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs +++ b/BizHawk.Emulation.Common/Base Implementations/ControllerDefinition.cs @@ -168,11 +168,11 @@ namespace BizHawk.Emulation.Common { get { - List list = new List(AxisControls); + var list = new List(AxisControls); list.AddRange(BoolButtons); // starts with console buttons, then each player's buttons individually - List[] ret = new List[PlayerCount + 1]; + var ret = new List[PlayerCount + 1]; for (int i = 0; i < ret.Length; i++) { ret[i] = new List(); diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs index 72fe0c5f66..2090556165 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs @@ -16,10 +16,7 @@ namespace BizHawk.Emulation.Common { public MemoryCallbackSystem(string[] availableScopes) { - if (availableScopes == null) - { - availableScopes = new[] { "System Bus" }; - } + availableScopes ??= new[] {"System Bus"}; AvailableScopes = availableScopes; ExecuteCallbacksAvailable = true; diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs index f9a5785f4e..29d19bc633 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs @@ -29,10 +29,7 @@ namespace BizHawk.Emulation.Common public abstract void PokeByte(long addr, byte val); - public override string ToString() - { - return Name; - } + public override string ToString() => Name; public virtual ushort PeekUshort(long addr, bool bigEndian) { diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryDomainImpls.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryDomainImpls.cs index c84ed1f408..42c5c5043e 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryDomainImpls.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryDomainImpls.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using System; -using System.Collections.Generic; namespace BizHawk.Emulation.Common { diff --git a/BizHawk.Emulation.Common/Base Implementations/NullController.cs b/BizHawk.Emulation.Common/Base Implementations/NullController.cs index 56ced0cd7f..ef20d3ceb7 100644 --- a/BizHawk.Emulation.Common/Base Implementations/NullController.cs +++ b/BizHawk.Emulation.Common/Base Implementations/NullController.cs @@ -12,15 +12,9 @@ Name = "Null Controller" }; - public bool IsPressed(string button) - { - return false; - } + public bool IsPressed(string button) => false; - public float AxisValue(string name) - { - return 0f; - } + public float AxisValue(string name) => 0f; public static readonly NullController Instance = new NullController(); } diff --git a/BizHawk.Emulation.Common/Database/GameInfo.cs b/BizHawk.Emulation.Common/Database/GameInfo.cs index 8775f286ec..595bdd14aa 100644 --- a/BizHawk.Emulation.Common/Database/GameInfo.cs +++ b/BizHawk.Emulation.Common/Database/GameInfo.cs @@ -139,11 +139,6 @@ namespace BizHawk.Emulation.Common return defaultVal; } - public ICollection GetOptions() - { - return Options.Keys; - } - public IDictionary GetOptionsDict() { return new ReadOnlyDictionary(Options); diff --git a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs index 506ee89dd7..f170ef1704 100644 --- a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs +++ b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs @@ -307,7 +307,7 @@ namespace BizHawk.Emulation.Common throw new ArgumentException($"Can't autofetch without being an {nameof(ISoundProvider)}?"); } - LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS; + var err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS; _st = LibSpeexDSP.speex_resampler_init_frac(2, rationum, ratioden, sratein, srateout, quality, ref err); if (_st == IntPtr.Zero) diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs index 40398ee722..57eff65db0 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs @@ -464,7 +464,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { MarkBTFrom(btFrom); MarkBTTo(btTo); - } + } break; case 0x74: // STZ zp,X MarkCode(PC, 2); @@ -783,7 +783,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { MarkBTFrom(btFrom); MarkBTTo(btTo); - } + } break; case 0xC4: // CPY zp MarkCode(PC, 2); @@ -855,7 +855,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { MarkBTFrom(btFrom); MarkBTTo(btTo); - } + } break; case 0xD4: // CSH MarkCode(PC, 1); @@ -924,7 +924,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { MarkBTFrom(btFrom); MarkBTTo(btTo+btAlternator); - } + } break; case 0xE4: // CPX zp MarkCode(PC, 2); @@ -996,7 +996,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { MarkBTFrom(btFrom+btAlternator); MarkBTTo(btTo); - } + } break; case 0xF4: // SET MarkCode(PC, 1); diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs index 86430df8c2..73ac76951f 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using BizHawk.Emulation.Common; @@ -21,10 +20,10 @@ namespace BizHawk.Emulation.Cores.Components.H6280 for (int i = 0; i < kvp.Value.Length; i++) { - if ((kvp.Value[i] & (byte)HuC6280.CDLUsage.Code) != 0) + if ((kvp.Value[i] & (byte)CDLUsage.Code) != 0) { int unused; - string dis = HuC6280.DisassembleExt( + string dis = DisassembleExt( 0, out unused, delegate(ushort addr) @@ -44,24 +43,6 @@ namespace BizHawk.Emulation.Cores.Components.H6280 w.WriteLine("; EOF"); w.Flush(); } - - private static Dictionary SizesFromHuMap(IEnumerable mm) - { - Dictionary sizes = new Dictionary(); - foreach (var m in mm) - { - if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name]) - sizes[m.Name] = m.MaxOffs; - } - - List keys = new List(sizes.Keys); - foreach (var key in keys) - { - // becase we were looking at offsets, and each bank is 8192 big, we need to add that size - sizes[key] += 8192; - } - return sizes; - } } public partial class HuC6280 diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs index b05036d7ef..9b8d7d1fc6 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs @@ -19,10 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum set { _blockID = value; - - if (MetaData == null) - MetaData = new Dictionary(); - + MetaData ??= new Dictionary(); AddMetaData(BlockDescriptorTitle.Block_ID, value.ToString()); } } @@ -37,8 +34,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum set { _blockType = value; - if (MetaData == null) - MetaData = new Dictionary(); + MetaData ??= new Dictionary(); } } @@ -52,34 +48,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum set => _blockData = value; } - /* - - /// - /// An array of bytearray encoded strings (stored in this format for easy Bizhawk serialization) - /// Its basically tape information - /// - private byte[][] _tapeDescriptionData; - - /// - /// Returns the Tape Description Data in a human readable format - /// - public List TapeDescriptionData - { - get - { - List data = new List(); - - foreach (byte[] b in _tapeDescriptionData) - { - data.Add(Encoding.ASCII.GetString(b)); - } - - return data; - } - } - */ - - #region Block Meta Data /// @@ -108,8 +76,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum #endregion - - /// /// List containing the pulse timing values /// @@ -165,7 +131,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ser.BeginSection("DataBlock" + blockPosition); ser.Sync(nameof(_blockID), ref _blockID); - //ser.SyncFixedString(nameof(_blockDescription), ref _blockDescription, 200); ser.SyncEnum(nameof(_blockType), ref _blockType); ser.Sync(nameof(_blockData), ref _blockData, true); ser.SyncEnum(nameof(_command), ref _command); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs index 25c8bdebcc..2956f2b959 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs @@ -720,14 +720,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (L_final != latched_sample_L) { - _blip_L.AddDelta(master_audio_clock, L_final - latched_sample_L); - latched_sample_L = L_final; + _blip_L.AddDelta(master_audio_clock, L_final - latched_sample_L); + latched_sample_L = L_final; } if (R_final != latched_sample_R) { - _blip_R.AddDelta(master_audio_clock, R_final - latched_sample_R); - latched_sample_R = R_final; + _blip_R.AddDelta(master_audio_clock, R_final - latched_sample_R); + latched_sample_R = R_final; } master_audio_clock++; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs index 4e3f7654f8..a886f86574 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs @@ -416,7 +416,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 0xFF55: if (GBC_compat) { - ppu.WriteReg(addr, value); + ppu.WriteReg(addr, value); } break; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs index 53e739d655..49cb8b2132 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs @@ -30,26 +30,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk RAM_mask = Core.cart_RAM.Length / 0x2000 - 1; if (Core.cart_RAM.Length == 0x800) { RAM_mask = 0; } } - } + } public override byte ReadMemoryLow(ushort addr) { if (addr < 0x4000) { - // lowest bank is fixed, but is still effected by mode + // lowest bank is fixed, but is still effected by mode if (sel_mode) { - return Core._rom[(ROM_bank & 0x60) * 0x4000 + addr]; - } - else - { - return Core._rom[addr]; + return Core._rom[(ROM_bank & 0x60) * 0x4000 + addr]; } + + return Core._rom[addr]; } - else - { - return Core._rom[(addr - 0x4000) + ROM_bank * 0x4000]; - } + + return Core._rom[(addr - 0x4000) + ROM_bank * 0x4000]; } public override byte ReadMemoryHigh(ushort addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS_MemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS_MemoryDomains.cs index 48c8927cd6..af61f9cd3d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS_MemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS_MemoryDomains.cs @@ -16,9 +16,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS MainMemory = new MemoryDomainIntPtr("RAM", MemoryDomain.Endian.Little, (IntPtr)GetMainMemory(), GetMainMemorySize(), true, 4); SystemBus = new MelonSystemBus(); - domains = new SortedList(); - domains.Add("RAM", MainMemory); - domains.Add("System Bus", SystemBus); + domains = new SortedList + { + { "RAM", MainMemory }, + { "System Bus", SystemBus } + }; } public MemoryDomain this[string name] => domains[name]; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs index 3127aece61..9410f9b47e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs @@ -53,15 +53,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int temp = 0; for (int i=0;i<4;i++) { - temp = mmc3.prg_regs_8k[i]; + temp = mmc3.prg_regs_8k[i]; - if ((exRegs[1] & 0x8) > 0) - temp = temp & 0x1F; - else - temp = ((temp & 0x0F) | (exRegs[1] & 0x10)); + if ((exRegs[1] & 0x8) > 0) + temp = temp & 0x1F; + else + temp = ((temp & 0x0F) | (exRegs[1] & 0x10)); - temp |= (exRegs[1] << 5 & 0x60); - prg_regs_8k[i] = (byte)(temp & prg_mask_8k); + temp |= (exRegs[1] << 5 & 0x60); + prg_regs_8k[i] = (byte)(temp & prg_mask_8k); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs index 5abeb7ce00..ba957a5a77 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs @@ -40,10 +40,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //read patterns from mapper controlled area return base.ReadPpu(addr); } - else - { - return Vram[addr & 0xFFF]; - } + + return Vram[addr & 0xFFF]; } public override void WritePpu(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs index 9d797ae38d..964e7c9bbd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs @@ -82,8 +82,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - - public override void WriteWram(int addr, byte value) { WriteReg(addr + 0x6000, value); @@ -100,38 +98,37 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { prg[3] = (byte)(addr & 0x3F); } - else if (((addr & 0xF80C) >= 0xB000) && ((addr & 0xF80C) <= 0xE00C)) + else if ((addr & 0xF80C) >= 0xB000 && (addr & 0xF80C) <= 0xE00C) { int index = (((addr >> 11) - 6) | (addr >> 3)) & 7; chr[index] = (byte)((chr[index] & (0xF0 >> (addr & 4))) | ((value & 0x0F) << (addr & 4))); } else switch (addr & 0xF80C) - { - case 0x8800: prg[0] = value; break; - case 0xA800: prg[1] = value; break; - case 0xA000: prg[2] = value; break; - case 0x9800: SetMirroring(value & 3); break; + { + case 0x8800: prg[0] = value; break; + case 0xA800: prg[1] = value; break; + case 0xA000: prg[2] = value; break; + case 0x9800: SetMirroring(value & 3); break; - // TODO: IRQ - case 0xF000: IRQLatch = ((IRQLatch & 0xF0) | (value & 0xF)); break; - case 0xF004: IRQLatch = ((IRQLatch & 0x0F) | ((value & 0xF) << 4)); break; - case 0xF008: - IRQMode = value.Bit(2); - IRQa = value.Bit(1);//value>0 ? true:false; - IRQr = value.Bit(0); - if (IRQa) - { - IRQPre = 341; - IRQCount = IRQLatch; - } - IrqSignal = false; - break; - case 0xF00C: - IrqSignal = false; - IRQa = IRQr; - break; - - } + // TODO: IRQ + case 0xF000: IRQLatch = ((IRQLatch & 0xF0) | (value & 0xF)); break; + case 0xF004: IRQLatch = ((IRQLatch & 0x0F) | ((value & 0xF) << 4)); break; + case 0xF008: + IRQMode = value.Bit(2); + IRQa = value.Bit(1);//value>0 ? true:false; + IRQr = value.Bit(0); + if (IRQa) + { + IRQPre = 341; + IRQCount = IRQLatch; + } + IrqSignal = false; + break; + case 0xF00C: + IrqSignal = false; + IRQa = IRQr; + break; + } } public override byte ReadPpu(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs index 57c948df28..1875f1c8c1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs @@ -27,8 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vrom[addr | chr << 13]; - else - return base.ReadPpu(addr); + return base.ReadPpu(addr); } public override byte ReadPrg(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs index 6ae6ae5338..f93e602775 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs @@ -196,42 +196,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES UpdateChr_2(); } else switch ((addr+0x8000) & 0xE001) - { - case 0x8000: base.WritePrg(addr,value); UpdatePrg(); UpdateChr(); break; - case 0x8001: + { + case 0x8000: base.WritePrg(addr,value); UpdatePrg(); UpdateChr(); break; + case 0x8001: - if (((exRegs[3] << 2) & (mmc3.cmd & 0x8))>0) - { - exRegs[4 | mmc3.cmd & 0x3] = value; + if (((exRegs[3] << 2) & (mmc3.cmd & 0x8))>0) + { + exRegs[4 | mmc3.cmd & 0x3] = value; - UpdatePrg_2(); - UpdateChr_2(); - } - else - { - base.WritePrg(addr, value); - UpdatePrg(); - UpdateChr(); - } - break; + UpdatePrg_2(); + UpdateChr_2(); + } + else + { + base.WritePrg(addr, value); + UpdatePrg(); + UpdateChr(); + } + break; - case 0xA000: - if (value == 0) - { - SetMirrorType(EMirrorType.Vertical); - } - else - { - SetMirrorType(EMirrorType.Horizontal); - } - break; - case 0xA001: base.WritePrg(addr, value); break; - case 0xC000: base.WritePrg(addr, value); break; - case 0xC001: base.WritePrg(addr, value); break; - case 0xE000: base.WritePrg(addr, value); break; - case 0xE001: base.WritePrg(addr, value); break; - - } + case 0xA000: + if (value == 0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } + break; + case 0xA001: base.WritePrg(addr, value); break; + case 0xC000: base.WritePrg(addr, value); break; + case 0xC001: base.WritePrg(addr, value); break; + case 0xE000: base.WritePrg(addr, value); break; + case 0xE001: base.WritePrg(addr, value); break; + } } public override byte ReadPpu(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs index 069f112b85..7a48401603 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/BootGodDB.cs @@ -32,8 +32,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { lock (staticsyncroot) { - if (_instance == null) - _instance = new BootGodDb(); + _instance ??= new BootGodDb(); } } @@ -41,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { int temp = 0; if(validate) if (!str.EndsWith("k")) throw new Exception(); - int len=str.Length-1; + int len = str.Length - 1; for (int i = 0; i < len; i++) { temp *= 10; @@ -51,10 +50,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } public BootGodDb() { - //notes: there can be multiple each of prg,chr,wram,vram - //we arent tracking the individual hashes yet. + // notes: there can be multiple each of prg,chr,wram,vram + // we aren't tracking the individual hashes yet. - //in anticipation of any slowness annoying people, and just for shits and giggles, i made a super fast parser + // in anticipation of any slowness annoying people, and just for shits and giggles, i made a super fast parser int state=0; var xmlReader = XmlReader.Create(new MemoryStream(_GetDatabaseBytes())); CartInfo currCart = null; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ICodeDataLogger.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ICodeDataLogger.cs index db3c3d445e..a9db3059c0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ICodeDataLogger.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ICodeDataLogger.cs @@ -68,15 +68,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private void RunCDL(ushort address, CDLog_Flags flags) { - if (MapMemory != null) + if (MapMemory != null) + { + CDLog_MapResults results = MapMemory(address, false); + switch (results.Type) { - CDLog_MapResults results = MapMemory(address, false); - switch (results.Type) - { - case CDLog_AddrType.None: break; - case CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break; - case CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break; - } + case CDLog_AddrType.None: break; + case CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break; + case CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break; + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISaveRam.cs index 6637e4c622..e5d0692f4c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISaveRam.cs @@ -18,24 +18,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public byte[] CloneSaveRam() { - if (Board is FDS) - return (Board as FDS).ReadSaveRam(); + if (Board is FDS fds) + { + return fds.ReadSaveRam(); + } - if (Board == null || Board.SaveRam == null) - return null; - return (byte[])Board.SaveRam.Clone(); + return (byte[]) Board?.SaveRam?.Clone(); } public void StoreSaveRam(byte[] data) { - if (Board is FDS) + if (Board is FDS fds) { - (Board as FDS).StoreSaveRam(data); + fds.StoreSaveRam(data); return; } - if (Board == null || Board.SaveRam == null) + if (Board?.SaveRam == null) + { return; + } + Array.Copy(data, Board.SaveRam, data.Length); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs index c8cdbdbd6e..6592bf41b4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs @@ -77,17 +77,17 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public void RunCDL(ushort address, CDLog_Flags flags) { - if (MapMemory != null) + if (MapMemory != null) + { + CDLog_MapResults results = MapMemory(address, false); + switch (results.Type) { - CDLog_MapResults results = MapMemory(address, false); - switch (results.Type) - { - case CDLog_AddrType.None: break; - case CDLog_AddrType.ROM: CDL["ROM"][results.Address] |= (byte)flags; break; - case CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break; - case CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break; - case CDLog_AddrType.CartRAM: CDL["Cart (Volatile) RAM"][results.Address] |= (byte)flags; break; - } + case CDLog_AddrType.None: break; + case CDLog_AddrType.ROM: CDL["ROM"][results.Address] |= (byte)flags; break; + case CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break; + case CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break; + case CDLog_AddrType.CartRAM: CDL["Cart (Volatile) RAM"][results.Address] |= (byte)flags; break; + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs index 64d0180f0c..143533c7a5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs @@ -51,8 +51,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { if (disposed) throw new ObjectDisposedException(this.GetType().ToString()); - if (data[statenum] == null) - data[statenum] = new byte[length]; + data[statenum] ??= new byte[length]; Marshal.Copy(DllBase + start, data[statenum], 0, length); Console.WriteLine("State {0} saved", statenum); @@ -117,8 +116,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx Console.WriteLine("Clean!"); } - - public GenDbgHlp() { using (StreamReader sr = new StreamReader(symbolname)) @@ -159,7 +156,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx return SymbolsByAddr.GetRange(minidx, maxidx - minidx + 1); } - public struct Symbol : IComparable { public IntPtr addr; @@ -189,7 +185,5 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public override string ToString() => $"0x{(int)addr:X8} {name} ({section})"; } - - } } diff --git a/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs b/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs index faa1956f73..61baef0cc8 100644 --- a/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs +++ b/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs @@ -46,8 +46,7 @@ namespace BizHawk.Emulation.Cores.Waterbox protected T PreInit(PeRunnerOptions options) where T : LibWaterboxCore { - if (options.Path == null) - options.Path = CoreComm.CoreFileProvider.DllPath(); + options.Path ??= CoreComm.CoreFileProvider.DllPath(); _exe = new PeRunner(options); using (_exe.EnterExit()) { diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 03f109bb2a..2f2f723973 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -300,6 +300,7 @@ True True True + True True True True @@ -313,6 +314,7 @@ True True True + True True True True