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

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

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

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

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

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

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

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

View File

@ -416,7 +416,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
case 0xFF55:
if (GBC_compat)
{
ppu.WriteReg(addr, value);
ppu.WriteReg(addr, value);
}
break;

View File

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

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

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

View File

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

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

View File

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

View File

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

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

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

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

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

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>