misc cleanups

This commit is contained in:
adelikat 2020-04-08 16:03:35 -05:00
parent 813a2ee935
commit 2b281116ed
45 changed files with 238 additions and 397 deletions

View File

@ -158,12 +158,10 @@ namespace BizHawk.Client.Common
public void SetBigEndian(bool enabled = true) => _isBigEndian = enabled;
public List<string> GetMemoryDomainList()
{
var list = new List<string>();
foreach (var domain in DomainList) list.Add(domain.Name);
return list;
}
public List<string> GetMemoryDomainList() =>
DomainList
.Select(domain => domain.Name)
.ToList();
public uint GetMemoryDomainSize(string name = null) => (uint) NamedDomainOrCurrent(name).Size;

View File

@ -14,9 +14,9 @@ namespace BizHawk.Client.Common
private Stream _output;
private readonly CompressionLevel _level;
private byte[] _localHeader;
private readonly byte[] _localHeader;
private List<byte[]> _endBlobs = new List<byte[]>();
private byte[] _fileHeaderTemplate;
private readonly byte[] _fileHeaderTemplate;
private int _numEntries;
private bool _disposed;
@ -115,17 +115,18 @@ namespace BizHawk.Client.Common
}
}
/// <exception cref="NotImplementedException"><paramref name="compressionlevel"/> is <c>0</c></exception>
public FrameworkFastZipWriter(string path, int compressionlevel)
/// <exception cref="NotImplementedException"><paramref name="compressionLevel"/> is <c>0</c></exception>
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

View File

@ -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();

View File

@ -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();

View File

@ -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<Column>
{
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

View File

@ -1,7 +1,5 @@
#nullable enable
using System;
namespace BizHawk.Client.Common
{
/// <remarks>This is separate from <see cref="PolarRectConversion"/> because its large size slows or prevents design-time code analysis.</remarks>

View File

@ -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

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using NLua;
namespace BizHawk.Client.Common

View File

@ -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);

View File

@ -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
};
}
int getFrame;

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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
{

View File

@ -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;

View File

@ -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);

View File

@ -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)
NameColumn => _cheatList.OrderBy(c => c.Name, reverse)
.ThenBy(c => c.Address ?? 0)
.ToList();
break;
case AddressColumn:
_cheatList = _cheatList
.OrderBy(c => c.Address ?? 0, reverse)
.ToList(),
AddressColumn => _cheatList.OrderBy(c => c.Address ?? 0, reverse)
.ThenBy(c => c.Name)
.ToList();
break;
case ValueColumn:
_cheatList = _cheatList
.OrderBy(c => c.Value ?? 0, reverse)
.ToList(),
ValueColumn => _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)
.ToList(),
CompareColumn => _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)
.ToList(),
OnColumn => _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)
.ToList(),
DomainColumn => _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)
.ToList(),
SizeColumn => _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)
.ToList(),
EndianColumn => _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)
.ToList(),
TypeColumn => _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)
.ToList(),
ComparisonType => _cheatList.OrderBy(c => c.ComparisonType, reverse)
.ThenBy(c => c.Name)
.ThenBy(c => c.Address ?? 0)
.ToList();
break;
}
.ToList(),
_ => _cheatList
};
}
public void SetDefaultFileName(string defaultFileName)

View File

@ -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)
{

View File

@ -168,11 +168,11 @@ namespace BizHawk.Emulation.Common
{
get
{
List<string> list = new List<string>(AxisControls);
var list = new List<string>(AxisControls);
list.AddRange(BoolButtons);
// starts with console buttons, then each player's buttons individually
List<string>[] ret = new List<string>[PlayerCount + 1];
var ret = new List<string>[PlayerCount + 1];
for (int i = 0; i < ret.Length; i++)
{
ret[i] = new List<string>();

View File

@ -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;

View File

@ -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)
{

View File

@ -1,6 +1,5 @@
using BizHawk.Common;
using System;
using System.Collections.Generic;
namespace BizHawk.Emulation.Common
{

View File

@ -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();
}

View File

@ -139,11 +139,6 @@ namespace BizHawk.Emulation.Common
return defaultVal;
}
public ICollection<string> GetOptions()
{
return Options.Keys;
}
public IDictionary<string, string> GetOptionsDict()
{
return new ReadOnlyDictionary<string, string>(Options);

View File

@ -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)

View File

@ -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<string, int> SizesFromHuMap(IEnumerable<HuC6280.MemMapping> mm)
{
Dictionary<string, int> sizes = new Dictionary<string, int>();
foreach (var m in mm)
{
if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name])
sizes[m.Name] = m.MaxOffs;
}
List<string> keys = new List<string>(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

View File

@ -19,10 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
set
{
_blockID = value;
if (MetaData == null)
MetaData = new Dictionary<BlockDescriptorTitle, string>();
MetaData ??= new Dictionary<BlockDescriptorTitle, string>();
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<BlockDescriptorTitle, string>();
MetaData ??= new Dictionary<BlockDescriptorTitle, string>();
}
}
@ -52,34 +48,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
set => _blockData = value;
}
/*
/// <summary>
/// An array of bytearray encoded strings (stored in this format for easy Bizhawk serialization)
/// Its basically tape information
/// </summary>
private byte[][] _tapeDescriptionData;
/// <summary>
/// Returns the Tape Description Data in a human readable format
/// </summary>
public List<string> TapeDescriptionData
{
get
{
List<string> data = new List<string>();
foreach (byte[] b in _tapeDescriptionData)
{
data.Add(Encoding.ASCII.GetString(b));
}
return data;
}
}
*/
#region Block Meta Data
/// <summary>
@ -108,8 +76,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
#endregion
/// <summary>
/// List containing the pulse timing values
/// </summary>
@ -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);

View File

@ -41,16 +41,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
return Core._rom[(ROM_bank & 0x60) * 0x4000 + addr];
}
else
{
return Core._rom[addr];
}
}
else
{
return Core._rom[(addr - 0x4000) + ROM_bank * 0x4000];
}
}
public override byte ReadMemoryHigh(ushort addr)
{

View File

@ -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<string, MemoryDomain>();
domains.Add("RAM", MainMemory);
domains.Add("System Bus", SystemBus);
domains = new SortedList<string, MemoryDomain>
{
{ "RAM", MainMemory },
{ "System Bus", SystemBus }
};
}
public MemoryDomain this[string name] => domains[name];

View File

@ -40,11 +40,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//read patterns from mapper controlled area
return base.ReadPpu(addr);
}
else
{
return Vram[addr & 0xFFF];
}
}
public override void WritePpu(int addr, byte value)
{

View File

@ -82,8 +82,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
public override void WriteWram(int addr, byte value)
{
WriteReg(addr + 0x6000, value);
@ -100,7 +98,7 @@ 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)));
@ -130,7 +128,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
IrqSignal = false;
IRQa = IRQr;
break;
}
}

View File

@ -27,7 +27,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
if (addr < 0x2000)
return Vrom[addr | chr << 13];
else
return base.ReadPpu(addr);
}

View File

@ -230,7 +230,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
case 0xC001: base.WritePrg(addr, value); break;
case 0xE000: base.WritePrg(addr, value); break;
case 0xE001: base.WritePrg(addr, value); break;
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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<Symbol>
{
public IntPtr addr;
@ -189,7 +185,5 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public override string ToString() => $"0x{(int)addr:X8} {name} ({section})";
}
}
}

View File

@ -46,8 +46,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
protected T PreInit<T>(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())
{

View File

@ -300,6 +300,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dupped/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ejin/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=emucore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Encapsulator/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Endian/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=endianess/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=endrift/@EntryIndexedValue">True</s:Boolean>
@ -313,6 +314,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFFF/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFFFFE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFFFFFFF/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFFFFFFFFFFFF/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=filenames/@EntryIndexedValue">True</s:Boolean>