BizHawk.Emulation.Common - cleanups -> C#6/7isms, fix some typos, variable naming, spaces to tabs

This commit is contained in:
adelikat 2019-10-29 13:59:08 -05:00
parent c78b6df363
commit 2b7cb1bb7d
28 changed files with 550 additions and 681 deletions

View File

@ -66,8 +66,7 @@ namespace BizHawk.Emulation.Common
public object GetService(Type t)
{
object service;
if (_services.TryGetValue(t, out service))
if (_services.TryGetValue(t, out var service))
{
return service;
}
@ -86,12 +85,6 @@ namespace BizHawk.Emulation.Common
return _services.ContainsKey(t);
}
public IEnumerable<Type> AvailableServices
{
get
{
return _services.Select(d => d.Key);
}
}
public IEnumerable<Type> AvailableServices =>_services.Select(d => d.Key);
}
}

View File

@ -62,9 +62,9 @@ namespace BizHawk.Emulation.Common
/// <summary>
/// Whether the CDL is tracking a block with the given name
/// </summary>
public bool Has(string blockname)
public bool Has(string blockName)
{
return ContainsKey(blockname);
return ContainsKey(blockName);
}
/// <summary>
@ -121,17 +121,17 @@ namespace BizHawk.Emulation.Common
foreach (var kvp in other)
{
byte[] fromdata = kvp.Value;
byte[] todata = this[kvp.Key];
byte[] fromData = kvp.Value;
byte[] toData = this[kvp.Key];
if (fromdata.Length != todata.Length)
if (fromData.Length != toData.Length)
{
throw new InvalidDataException("Memory regions must be the same size!");
}
for (int i = 0; i < todata.Length; i++)
for (int i = 0; i < toData.Length; i++)
{
todata[i] |= fromdata[i];
toData[i] |= fromData[i];
}
}
}
@ -201,7 +201,7 @@ namespace BizHawk.Emulation.Common
}
else
{
throw new InvalidDataException("File is not a Bizhawk CDL file!");
throw new InvalidDataException("File is not a BizHawk CDL file!");
}
int count = br.ReadInt32();

View File

@ -82,23 +82,23 @@ namespace BizHawk.Emulation.Common
{
case AxisConstraintType.Circular:
{
string xaxis = constraint.Params[0] as string;
string yaxis = constraint.Params[1] as string;
string xAxis = constraint.Params[0] as string ?? "";
string yAxis = constraint.Params[1] as string ?? "";
float range = (float)constraint.Params[2];
if (!floatButtons.ContainsKey(xaxis)) break;
if (!floatButtons.ContainsKey(yaxis)) break;
double xval = floatButtons[xaxis];
double yval = floatButtons[yaxis];
double length = Math.Sqrt((xval * xval) + (yval * yval));
if (!floatButtons.ContainsKey(xAxis)) break;
if (!floatButtons.ContainsKey(yAxis)) break;
double xVal = floatButtons[xAxis];
double yVal = floatButtons[yAxis];
double length = Math.Sqrt((xVal * xVal) + (yVal * yVal));
if (length > range)
{
double ratio = range / length;
xval *= ratio;
yval *= ratio;
xVal *= ratio;
yVal *= ratio;
}
floatButtons[xaxis] = (float)xval;
floatButtons[yaxis] = (float)yval;
floatButtons[xAxis] = (float)xVal;
floatButtons[yAxis] = (float)yVal;
break;
}
}
@ -167,7 +167,7 @@ namespace BizHawk.Emulation.Common
List<string> list = new List<string>(FloatControls);
list.AddRange(BoolButtons);
// starts with console buttons, then each plasyer's buttons individually
// starts with console buttons, then each player's buttons individually
List<string>[] ret = new List<string>[PlayerCount + 1];
for (int i = 0; i < ret.Length; i++)
{

View File

@ -70,11 +70,11 @@ namespace BizHawk.Emulation.Common
private static void Call(ObservableCollection<IMemoryCallback> cbs, uint addr, uint value, uint flags, string scope)
{
for (int i = 0; i < cbs.Count; i++)
foreach (var cb in cbs)
{
if (!cbs[i].Address.HasValue || (cbs[i].Scope == scope && cbs[i].Address == (addr & cbs[i].AddressMask)))
if (!cb.Address.HasValue || (cb.Scope == scope && cb.Address == (addr & cb.AddressMask)))
{
cbs[i].Callback(addr, value, flags);
cb.Callback(addr, value, flags);
}
}
}
@ -134,17 +134,17 @@ namespace BizHawk.Emulation.Common
public bool HasReadsForScope(string scope)
{
return _reads.Where(e => e.Scope == scope).Any();
return _reads.Any(e => e.Scope == scope);
}
public bool HasWritesForScope(string scope)
{
return _writes.Where(e => e.Scope == scope).Any();
return _writes.Any(e => e.Scope == scope);
}
public bool HasExecutesForScope(string scope)
{
return _execs.Where(e => e.Scope == scope).Any();
return _execs.Any(e => e.Scope == scope);
}
private bool UpdateHasVariables()

View File

@ -5,22 +5,13 @@ namespace BizHawk.Emulation.Common
{
public class MemoryDomainDelegate : MemoryDomain
{
private Func<long, byte> _peek;
private Action<long, byte> _poke;
public Func<long, byte> Peek
{
get { return _peek; }
set { _peek = value; }
}
public Func<long, byte> Peek { get; set; }
public Action<long, byte> Poke
{
get
{
return _poke;
}
get => _poke;
set
{
_poke = value;
@ -30,7 +21,7 @@ namespace BizHawk.Emulation.Common
public override byte PeekByte(long addr)
{
return _peek(addr);
return Peek(addr);
}
public override void PokeByte(long addr, byte val)
@ -43,7 +34,7 @@ namespace BizHawk.Emulation.Common
Name = name;
EndianType = endian;
Size = size;
_peek = peek;
Peek = peek;
_poke = poke;
Writable = poke != null;
WordSize = wordSize;
@ -56,11 +47,7 @@ namespace BizHawk.Emulation.Common
public byte[] Data
{
get
{
return _data;
}
get => _data;
set
{
_data = value;

View File

@ -24,13 +24,7 @@ namespace BizHawk.Emulation.Common
{
}
public MemoryDomain this[string name]
{
get
{
return this.FirstOrDefault(x => x.Name == name);
}
}
public MemoryDomain this[string name] => this.FirstOrDefault(x => x.Name == name);
public MemoryDomain MainMemory
{
@ -44,24 +38,10 @@ namespace BizHawk.Emulation.Common
return this.First();
}
set
{
_mainMemory = value;
}
set => _mainMemory = value;
}
public bool HasSystemBus
{
get
{
if (_systemBus != null)
{
return true;
}
return this.Any(x => x.Name == "System Bus");
}
}
public bool HasSystemBus => _systemBus != null || this.Any(x => x.Name == "System Bus");
public MemoryDomain SystemBus
{
@ -82,10 +62,7 @@ namespace BizHawk.Emulation.Common
return MainMemory;
}
set
{
_systemBus = value;
}
set => _systemBus = value;
}
/// <summary>
@ -96,8 +73,7 @@ namespace BizHawk.Emulation.Common
var domains = this.ToDictionary(m => m.Name);
foreach (var src in other)
{
MemoryDomain dst;
if (domains.TryGetValue(src.Name, out dst))
if (domains.TryGetValue(src.Name, out var dst))
{
TryMerge<MemoryDomainByteArray>(dst, src, (d, s) => d.Data = s.Data);
TryMerge<MemoryDomainIntPtr>(dst, src, (d, s) => d.Data = s.Data);

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Common
public ControllerDefinition ControllerDefinition => NullController.Instance.Definition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
if (render == false)
{
@ -249,7 +249,7 @@ namespace BizHawk.Emulation.Common
var ms = new MemoryStream();
gz.CopyTo(ms);
_data = ms.ToArray();
for (int i = 0; i < 3800; i++) // compenstate for sample start point
for (int i = 0; i < 3800; i++) // compensate for sample start point
{
Next();
}

View File

@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Common
: this()
{
_spfNumerator = spf;
_spfDenominator = 1;
_spfDenominator = 1;
}
/// <summary>

View File

@ -6,12 +6,7 @@
/// <seealso cref="ITraceable" />
public class TraceBuffer : ITraceable
{
public TraceBuffer()
{
Header = "Instructions";
}
public string Header { get; set; }
public string Header { get; set; } = "Instructions";
public ITraceSink Sink { private get; set; }

View File

@ -23,12 +23,12 @@ namespace BizHawk.Emulation.Common
SingleInstance = singleInstance;
}
public string CoreName { get; private set; }
public string Author { get; private set; }
public bool Ported { get; private set; }
public bool Released { get; private set; }
public string PortedVersion { get; private set; }
public string PortedUrl { get; private set; }
public bool SingleInstance { get; private set; }
public string CoreName { get; }
public string Author { get; }
public bool Ported { get; }
public bool Released { get; }
public string PortedVersion { get; }
public string PortedUrl { get; }
public bool SingleInstance { get; }
}
}

View File

@ -36,16 +36,16 @@ namespace BizHawk.Emulation.Common
/// <summary>
/// Gets a message to show. reasonably annoying (dialog box), shouldn't be used most of the time
/// </summary>
public Action<string> ShowMessage { get; private set; }
public Action<string> ShowMessage { get; }
/// <summary>
/// Gets a message to show. less annoying (OSD message). Should be used for ignorable helpful messages
/// </summary>
public Action<string> Notify { get; private set; }
public Action<string> Notify { get; }
public Func<int, int, bool, object> RequestGLContext { get; set; }
public Action<object> ReleaseGLContext { get; set; }
public Action<object> ActivateGLContext { get; set; }
public Action DeactivateGLContext { get; set; } // this shouldnt be necessary.. frontend should be changing context before it does anything.. but for now..
public Action DeactivateGLContext { get; set; } // this shouldn't be necessary.. frontend should be changing context before it does anything.. but for now..
}
}

View File

@ -1,421 +1,417 @@

using System.Linq;
using System.Text;
using System.Text;
namespace BizHawk.Emulation.Common
{
/// <summary>
/// A slightly convoluted way of determining the required System based on a *.dsk file
/// This is here because (for probably good reason) there does not appear to be a route
/// to BizHawk.Emulation.Cores from Bizhawk.Emultion.Common
/// </summary>
public class DSKIdentifier
{
/// <summary>
/// Default fallthrough to AppleII
/// </summary>
public string IdentifiedSystem = "AppleII";
private string PossibleIdent = "";
/// <summary>
/// A slightly convoluted way of determining the required System based on a *.dsk file
/// This is here because (for probably good reason) there does not appear to be a route
/// to BizHawk.Emulation.Cores from BizHawk.Emulation.Common
/// </summary>
public class DSKIdentifier
{
/// <summary>
/// Default fallthrough to AppleII
/// </summary>
public string IdentifiedSystem = "AppleII";
private string PossibleIdent = "";
private byte[] data;
// dsk header
public byte NumberOfTracks { get; set; }
public byte NumberOfSides { get; set; }
public int[] TrackSizes { get; set; }
private readonly byte[] data;
// state
public int CylinderCount;
public int SideCount;
public int BytesPerTrack;
// dsk header
public byte NumberOfTracks { get; set; }
public byte NumberOfSides { get; set; }
public int[] TrackSizes { get; set; }
public Track[] Tracks = null;
// state
public int CylinderCount;
public int SideCount;
public int BytesPerTrack;
public DSKIdentifier(byte[] imageData)
{
data = imageData;
ParseDskImage();
}
public Track[] Tracks = null;
private void ParseDskImage()
{
string ident = Encoding.ASCII.GetString(data, 0, 16).ToUpper();
if (ident.Contains("MV - CPC"))
{
ParseDSK();
}
else if (ident.Contains("EXTENDED CPC DSK"))
{
ParseEDSK();
}
else
{
// fall through
return;
}
public DSKIdentifier(byte[] imageData)
{
data = imageData;
ParseDskImage();
}
CalculateFormat();
}
private void ParseDskImage()
{
string ident = Encoding.ASCII.GetString(data, 0, 16).ToUpper();
if (ident.Contains("MV - CPC"))
{
ParseDSK();
}
else if (ident.Contains("EXTENDED CPC DSK"))
{
ParseEDSK();
}
else
{
// fall through
return;
}
private void CalculateFormat()
{
// uses some of the work done here: https://github.com/damieng/DiskImageManager
var trk = Tracks[0];
CalculateFormat();
}
// look for standard speccy bootstart
if (trk.Sectors[0].SectorData != null && trk.Sectors[0].SectorData.Length > 0)
{
if (trk.Sectors[0].SectorData[0] == 0 && trk.Sectors[0].SectorData[1] == 0
&& trk.Sectors[0].SectorData[2] == 40)
{
PossibleIdent = "ZXSpectrum";
}
}
private void CalculateFormat()
{
// uses some of the work done here: https://github.com/damieng/DiskImageManager
var trk = Tracks[0];
// search for PLUS3DOS string
foreach (var t in Tracks)
{
foreach (var s in t.Sectors)
{
if (s.SectorData == null || s.SectorData.Length == 0)
continue;
// look for standard speccy bootstart
if (trk.Sectors[0].SectorData != null && trk.Sectors[0].SectorData.Length > 0)
{
if (trk.Sectors[0].SectorData[0] == 0 && trk.Sectors[0].SectorData[1] == 0
&& trk.Sectors[0].SectorData[2] == 40)
{
PossibleIdent = "ZXSpectrum";
}
}
string str = Encoding.ASCII.GetString(s.SectorData, 0, s.SectorData.Length).ToUpper();
if (str.Contains("PLUS3DOS"))
{
IdentifiedSystem = "ZXSpectrum";
return;
}
}
}
// search for PLUS3DOS string
foreach (var t in Tracks)
{
foreach (var s in t.Sectors)
{
if (s.SectorData == null || s.SectorData.Length == 0)
continue;
// check for bootable status
if (trk.Sectors[0].SectorData != null && trk.Sectors[0].SectorData.Length > 0)
{
int chksm = trk.Sectors[0].GetChecksum256();
string str = Encoding.ASCII.GetString(s.SectorData, 0, s.SectorData.Length).ToUpper();
if (str.Contains("PLUS3DOS"))
{
IdentifiedSystem = "ZXSpectrum";
return;
}
}
}
switch(chksm)
{
case 3:
IdentifiedSystem = "ZXSpectrum";
return;
case 1:
case 255:
// different Amstrad PCW boot records
// just return CPC for now
IdentifiedSystem = "AmstradCPC";
return;
}
// check for bootable status
if (trk.Sectors[0].SectorData != null && trk.Sectors[0].SectorData.Length > 0)
{
int chksm = trk.Sectors[0].GetChecksum256();
switch(trk.GetLowestSectorID())
{
case 65:
case 193:
IdentifiedSystem = "AmstradCPC";
return;
}
}
switch (chksm)
{
case 3:
IdentifiedSystem = "ZXSpectrum";
return;
case 1:
case 255:
// different Amstrad PCW boot records
// just return CPC for now
IdentifiedSystem = "AmstradCPC";
return;
}
// at this point the disk is not standard bootable
// try format analysis
if (trk.Sectors.Length == 9 && trk.Sectors[0].SectorSize == 2)
{
switch(trk.GetLowestSectorID())
{
case 1:
switch(trk.Sectors[0].GetChecksum256())
{
case 3:
IdentifiedSystem = "ZXSpectrum";
return;
case 1:
case 255:
// different Amstrad PCW checksums
// just return CPC for now
IdentifiedSystem = "AmstradCPC";
return;
}
break;
case 65:
case 193:
IdentifiedSystem = "AmstradCPC";
return;
}
}
switch (trk.GetLowestSectorID())
{
case 65:
case 193:
IdentifiedSystem = "AmstradCPC";
return;
}
}
// could be an odd format disk
switch (trk.GetLowestSectorID())
{
case 1:
if (trk.Sectors.Length == 8)
{
// CPC IBM
IdentifiedSystem = "AmstradCPC";
return;
}
break;
case 65:
case 193:
// possible CPC custom
PossibleIdent = "AmstradCPC";
break;
}
// at this point the disk is not standard bootable
// try format analysis
if (trk.Sectors.Length == 9 && trk.Sectors[0].SectorSize == 2)
{
switch (trk.GetLowestSectorID())
{
case 1:
switch (trk.Sectors[0].GetChecksum256())
{
case 3:
IdentifiedSystem = "ZXSpectrum";
return;
case 1:
case 255:
// different Amstrad PCW checksums
// just return CPC for now
IdentifiedSystem = "AmstradCPC";
return;
}
break;
case 65:
case 193:
IdentifiedSystem = "AmstradCPC";
return;
}
}
// other custom ZX Spectrum formats
if (NumberOfSides == 1 && trk.Sectors.Length == 10)
{
if (trk.Sectors[0].SectorData.Length > 10)
{
if (trk.Sectors[0].SectorData[2] == 42 && trk.Sectors[0].SectorData[8] == 12)
{
switch (trk.Sectors[0].SectorData[5])
{
case 0:
if (trk.Sectors[1].SectorID == 8)
{
switch (Tracks[1].Sectors[0].SectorID)
{
case 7:
IdentifiedSystem = "ZXSpectrum";
return;
default:
PossibleIdent = "ZXSpectrum";
break;
}
}
else
{
PossibleIdent = "ZXSpectrum";
}
break;
case 1:
if (trk.Sectors[1].SectorID == 8)
{
switch (Tracks[1].Sectors[0].SectorID)
{
case 7:
case 1:
IdentifiedSystem = "ZXSpectrum";
return;
}
}
else
{
PossibleIdent = "ZXSpectrum";
}
break;
}
}
// could be an odd format disk
switch (trk.GetLowestSectorID())
{
case 1:
if (trk.Sectors.Length == 8)
{
// CPC IBM
IdentifiedSystem = "AmstradCPC";
return;
}
break;
case 65:
case 193:
// possible CPC custom
PossibleIdent = "AmstradCPC";
break;
}
if (trk.Sectors[0].SectorData[7] == 3 &&
trk.Sectors[0].SectorData[9] == 23 &&
trk.Sectors[0].SectorData[2] == 40)
{
IdentifiedSystem = "ZXSpectrum";
return;
}
}
}
// other custom ZX Spectrum formats
if (NumberOfSides == 1 && trk.Sectors.Length == 10)
{
if (trk.Sectors[0].SectorData.Length > 10)
{
if (trk.Sectors[0].SectorData[2] == 42 && trk.Sectors[0].SectorData[8] == 12)
{
switch (trk.Sectors[0].SectorData[5])
{
case 0:
if (trk.Sectors[1].SectorID == 8)
{
switch (Tracks[1].Sectors[0].SectorID)
{
case 7:
IdentifiedSystem = "ZXSpectrum";
return;
default:
PossibleIdent = "ZXSpectrum";
break;
}
}
else
{
PossibleIdent = "ZXSpectrum";
}
break;
case 1:
if (trk.Sectors[1].SectorID == 8)
{
switch (Tracks[1].Sectors[0].SectorID)
{
case 7:
case 1:
IdentifiedSystem = "ZXSpectrum";
return;
}
}
else
{
PossibleIdent = "ZXSpectrum";
}
break;
}
}
// last chance. use the possible value
if (IdentifiedSystem == "AppleII" && PossibleIdent != "")
{
IdentifiedSystem = "ZXSpectrum";
}
}
if (trk.Sectors[0].SectorData[7] == 3 &&
trk.Sectors[0].SectorData[9] == 23 &&
trk.Sectors[0].SectorData[2] == 40)
{
IdentifiedSystem = "ZXSpectrum";
return;
}
}
}
private void ParseDSK()
{
NumberOfTracks = data[0x30];
NumberOfSides = data[0x31];
TrackSizes = new int[NumberOfTracks * NumberOfSides];
Tracks = new Track[NumberOfTracks * NumberOfSides];
int pos = 0x32;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
TrackSizes[i] = (ushort)(data[pos] | data[pos + 1] << 8);
}
pos = 0x100;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
if (TrackSizes[i] == 0)
{
Tracks[i] = new Track();
Tracks[i].Sectors = new Sector[0];
continue;
}
int p = pos;
Tracks[i] = new Track();
Tracks[i].TrackIdent = Encoding.ASCII.GetString(data, p, 12);
p += 16;
Tracks[i].TrackNumber = data[p++];
Tracks[i].SideNumber = data[p++];
p += 2;
Tracks[i].SectorSize = data[p++];
Tracks[i].NumberOfSectors = data[p++];
Tracks[i].GAP3Length = data[p++];
Tracks[i].FillerByte = data[p++];
int dpos = pos + 0x100;
Tracks[i].Sectors = new Sector[Tracks[i].NumberOfSectors];
for (int s = 0; s < Tracks[i].NumberOfSectors; s++)
{
Tracks[i].Sectors[s] = new Sector();
// last chance. use the possible value
if (IdentifiedSystem == "AppleII" && PossibleIdent != "")
{
IdentifiedSystem = "ZXSpectrum";
}
}
Tracks[i].Sectors[s].TrackNumber = data[p++];
Tracks[i].Sectors[s].SideNumber = data[p++];
Tracks[i].Sectors[s].SectorID = data[p++];
Tracks[i].Sectors[s].SectorSize = data[p++];
Tracks[i].Sectors[s].Status1 = data[p++];
Tracks[i].Sectors[s].Status2 = data[p++];
Tracks[i].Sectors[s].ActualDataByteLength = (ushort)(data[p] | data[p + 1] << 8);
p += 2;
if (Tracks[i].Sectors[s].SectorSize == 0)
{
Tracks[i].Sectors[s].ActualDataByteLength = TrackSizes[i];
}
else if (Tracks[i].Sectors[s].SectorSize > 6)
{
Tracks[i].Sectors[s].ActualDataByteLength = TrackSizes[i];
}
else if (Tracks[i].Sectors[s].SectorSize == 6)
{
Tracks[i].Sectors[s].ActualDataByteLength = 0x1800;
}
else
{
Tracks[i].Sectors[s].ActualDataByteLength = 0x80 << Tracks[i].Sectors[s].SectorSize;
}
Tracks[i].Sectors[s].SectorData = new byte[Tracks[i].Sectors[s].ActualDataByteLength];
for (int b = 0; b < Tracks[i].Sectors[s].ActualDataByteLength; b++)
{
Tracks[i].Sectors[s].SectorData[b] = data[dpos + b];
}
dpos += Tracks[i].Sectors[s].ActualDataByteLength;
}
pos += TrackSizes[i];
}
}
private void ParseDSK()
{
NumberOfTracks = data[0x30];
NumberOfSides = data[0x31];
TrackSizes = new int[NumberOfTracks * NumberOfSides];
Tracks = new Track[NumberOfTracks * NumberOfSides];
int pos = 0x32;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
TrackSizes[i] = (ushort)(data[pos] | data[pos + 1] << 8);
}
pos = 0x100;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
if (TrackSizes[i] == 0)
{
Tracks[i] = new Track();
Tracks[i].Sectors = new Sector[0];
continue;
}
int p = pos;
Tracks[i] = new Track();
Tracks[i].TrackIdent = Encoding.ASCII.GetString(data, p, 12);
p += 16;
Tracks[i].TrackNumber = data[p++];
Tracks[i].SideNumber = data[p++];
p += 2;
Tracks[i].SectorSize = data[p++];
Tracks[i].NumberOfSectors = data[p++];
Tracks[i].GAP3Length = data[p++];
Tracks[i].FillerByte = data[p++];
int dpos = pos + 0x100;
Tracks[i].Sectors = new Sector[Tracks[i].NumberOfSectors];
for (int s = 0; s < Tracks[i].NumberOfSectors; s++)
{
Tracks[i].Sectors[s] = new Sector();
private void ParseEDSK()
{
NumberOfTracks = data[0x30];
NumberOfSides = data[0x31];
TrackSizes = new int[NumberOfTracks * NumberOfSides];
Tracks = new Track[NumberOfTracks * NumberOfSides];
int pos = 0x34;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
TrackSizes[i] = data[pos++] * 256;
}
pos = 0x100;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
if (TrackSizes[i] == 0)
{
Tracks[i] = new Track();
Tracks[i].Sectors = new Sector[0];
continue;
}
int p = pos;
Tracks[i] = new Track();
Tracks[i].TrackIdent = Encoding.ASCII.GetString(data, p, 12);
p += 16;
Tracks[i].TrackNumber = data[p++];
Tracks[i].SideNumber = data[p++];
Tracks[i].DataRate = data[p++];
Tracks[i].RecordingMode = data[p++];
Tracks[i].SectorSize = data[p++];
Tracks[i].NumberOfSectors = data[p++];
Tracks[i].GAP3Length = data[p++];
Tracks[i].FillerByte = data[p++];
int dpos = pos + 0x100;
Tracks[i].Sectors = new Sector[Tracks[i].NumberOfSectors];
for (int s = 0; s < Tracks[i].NumberOfSectors; s++)
{
Tracks[i].Sectors[s] = new Sector();
Tracks[i].Sectors[s].TrackNumber = data[p++];
Tracks[i].Sectors[s].SideNumber = data[p++];
Tracks[i].Sectors[s].SectorID = data[p++];
Tracks[i].Sectors[s].SectorSize = data[p++];
Tracks[i].Sectors[s].Status1 = data[p++];
Tracks[i].Sectors[s].Status2 = data[p++];
Tracks[i].Sectors[s].ActualDataByteLength = (ushort)(data[p] | data[p + 1] << 8);
p += 2;
if (Tracks[i].Sectors[s].SectorSize == 0)
{
Tracks[i].Sectors[s].ActualDataByteLength = TrackSizes[i];
}
else if (Tracks[i].Sectors[s].SectorSize > 6)
{
Tracks[i].Sectors[s].ActualDataByteLength = TrackSizes[i];
}
else if (Tracks[i].Sectors[s].SectorSize == 6)
{
Tracks[i].Sectors[s].ActualDataByteLength = 0x1800;
}
else
{
Tracks[i].Sectors[s].ActualDataByteLength = 0x80 << Tracks[i].Sectors[s].SectorSize;
}
Tracks[i].Sectors[s].SectorData = new byte[Tracks[i].Sectors[s].ActualDataByteLength];
for (int b = 0; b < Tracks[i].Sectors[s].ActualDataByteLength; b++)
{
Tracks[i].Sectors[s].SectorData[b] = data[dpos + b];
}
dpos += Tracks[i].Sectors[s].ActualDataByteLength;
}
pos += TrackSizes[i];
}
}
Tracks[i].Sectors[s].TrackNumber = data[p++];
Tracks[i].Sectors[s].SideNumber = data[p++];
Tracks[i].Sectors[s].SectorID = data[p++];
Tracks[i].Sectors[s].SectorSize = data[p++];
Tracks[i].Sectors[s].Status1 = data[p++];
Tracks[i].Sectors[s].Status2 = data[p++];
Tracks[i].Sectors[s].ActualDataByteLength = (ushort)(data[p] | data[p + 1] << 8);
p += 2;
Tracks[i].Sectors[s].SectorData = new byte[Tracks[i].Sectors[s].ActualDataByteLength];
for (int b = 0; b < Tracks[i].Sectors[s].ActualDataByteLength; b++)
{
Tracks[i].Sectors[s].SectorData[b] = data[dpos + b];
}
if (Tracks[i].Sectors[s].SectorSize <= 7)
{
int specifiedSize = 0x80 << Tracks[i].Sectors[s].SectorSize;
if (specifiedSize < Tracks[i].Sectors[s].ActualDataByteLength)
{
if (Tracks[i].Sectors[s].ActualDataByteLength % specifiedSize != 0)
{
Tracks[i].Sectors[s].ContainsMultipleWeakSectors = true;
}
}
}
dpos += Tracks[i].Sectors[s].ActualDataByteLength;
}
pos += TrackSizes[i];
}
}
private void ParseEDSK()
{
NumberOfTracks = data[0x30];
NumberOfSides = data[0x31];
TrackSizes = new int[NumberOfTracks * NumberOfSides];
Tracks = new Track[NumberOfTracks * NumberOfSides];
int pos = 0x34;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
TrackSizes[i] = data[pos++] * 256;
}
pos = 0x100;
for (int i = 0; i < NumberOfTracks * NumberOfSides; i++)
{
if (TrackSizes[i] == 0)
{
Tracks[i] = new Track();
Tracks[i].Sectors = new Sector[0];
continue;
}
int p = pos;
Tracks[i] = new Track();
Tracks[i].TrackIdent = Encoding.ASCII.GetString(data, p, 12);
p += 16;
Tracks[i].TrackNumber = data[p++];
Tracks[i].SideNumber = data[p++];
Tracks[i].DataRate = data[p++];
Tracks[i].RecordingMode = data[p++];
Tracks[i].SectorSize = data[p++];
Tracks[i].NumberOfSectors = data[p++];
Tracks[i].GAP3Length = data[p++];
Tracks[i].FillerByte = data[p++];
int dpos = pos + 0x100;
Tracks[i].Sectors = new Sector[Tracks[i].NumberOfSectors];
for (int s = 0; s < Tracks[i].NumberOfSectors; s++)
{
Tracks[i].Sectors[s] = new Sector();
#region Internal Classes
Tracks[i].Sectors[s].TrackNumber = data[p++];
Tracks[i].Sectors[s].SideNumber = data[p++];
Tracks[i].Sectors[s].SectorID = data[p++];
Tracks[i].Sectors[s].SectorSize = data[p++];
Tracks[i].Sectors[s].Status1 = data[p++];
Tracks[i].Sectors[s].Status2 = data[p++];
Tracks[i].Sectors[s].ActualDataByteLength = (ushort)(data[p] | data[p + 1] << 8);
p += 2;
Tracks[i].Sectors[s].SectorData = new byte[Tracks[i].Sectors[s].ActualDataByteLength];
for (int b = 0; b < Tracks[i].Sectors[s].ActualDataByteLength; b++)
{
Tracks[i].Sectors[s].SectorData[b] = data[dpos + b];
}
if (Tracks[i].Sectors[s].SectorSize <= 7)
{
int specifiedSize = 0x80 << Tracks[i].Sectors[s].SectorSize;
if (specifiedSize < Tracks[i].Sectors[s].ActualDataByteLength)
{
if (Tracks[i].Sectors[s].ActualDataByteLength % specifiedSize != 0)
{
Tracks[i].Sectors[s].ContainsMultipleWeakSectors = true;
}
}
}
dpos += Tracks[i].Sectors[s].ActualDataByteLength;
}
pos += TrackSizes[i];
}
}
public class Track
{
public string TrackIdent { get; set; }
public byte TrackNumber { get; set; }
public byte SideNumber { get; set; }
public byte DataRate { get; set; }
public byte RecordingMode { get; set; }
public byte SectorSize { get; set; }
public byte NumberOfSectors { get; set; }
public byte GAP3Length { get; set; }
public byte FillerByte { get; set; }
public Sector[] Sectors { get; set; }
#region Internal Classes
public byte GetLowestSectorID()
{
byte res = 0xFF;
foreach (var s in Sectors)
{
if (s.SectorID < res)
res = s.SectorID;
}
return res;
}
}
public class Track
{
public string TrackIdent { get; set; }
public byte TrackNumber { get; set; }
public byte SideNumber { get; set; }
public byte DataRate { get; set; }
public byte RecordingMode { get; set; }
public byte SectorSize { get; set; }
public byte NumberOfSectors { get; set; }
public byte GAP3Length { get; set; }
public byte FillerByte { get; set; }
public Sector[] Sectors { get; set; }
public class Sector
{
public byte TrackNumber { get; set; }
public byte SideNumber { get; set; }
public byte SectorID { get; set; }
public byte SectorSize { get; set; }
public byte Status1 { get; set; }
public byte Status2 { get; set; }
public int ActualDataByteLength { get; set; }
public byte[] SectorData { get; set; }
public bool ContainsMultipleWeakSectors { get; set; }
public byte GetLowestSectorID()
{
byte res = 0xFF;
foreach (var s in Sectors)
{
if (s.SectorID < res)
res = s.SectorID;
}
return res;
}
}
public int GetChecksum256()
{
int res = 0;
for (int i = 0; i < SectorData.Length; i++)
{
res += SectorData[i] % 256;
}
return res;
}
}
public class Sector
{
public byte TrackNumber { get; set; }
public byte SideNumber { get; set; }
public byte SectorID { get; set; }
public byte SectorSize { get; set; }
public byte Status1 { get; set; }
public byte Status2 { get; set; }
public int ActualDataByteLength { get; set; }
public byte[] SectorData { get; set; }
public bool ContainsMultipleWeakSectors { get; set; }
#endregion
public int GetChecksum256()
{
int res = 0;
for (int i = 0; i < SectorData.Length; i++)
{
res += SectorData[i] % 256;
}
return res;
}
}
}
#endregion
}
}

View File

@ -117,7 +117,7 @@ namespace BizHawk.Emulation.Common
var line = reader.ReadLine() ?? "";
try
{
if (line.StartsWith(";"))
if (line.StartsWith(";"))
{
continue; // comment
}
@ -140,7 +140,7 @@ namespace BizHawk.Emulation.Common
Hash = RemoveHashType(items[0].ToUpper())
};
// remove a hash type identifier. well don't really need them for indexing (theyre just there for human purposes)
// remove a hash type identifier. well don't really need them for indexing (they're just there for human purposes)
switch (items[1].Trim())
{
case "B":
@ -238,8 +238,8 @@ namespace BizHawk.Emulation.Common
break;
case ".SFC":
case ".SMC":
game.System = "SNES";
case ".SMC":
game.System = "SNES";
break;
case ".GB":
@ -299,30 +299,30 @@ namespace BizHawk.Emulation.Common
case ".D64":
case ".T64":
case ".G64":
case ".CRT":
case ".CRT":
game.System = "C64";
break;
case ".TZX":
case ".PZX":
case ".CSW":
case ".WAV":
game.System = "ZXSpectrum";
break;
case ".TZX":
case ".PZX":
case ".CSW":
case ".WAV":
game.System = "ZXSpectrum";
break;
case ".CDT":
game.System = "AmstradCPC";
break;
case ".CDT":
game.System = "AmstradCPC";
break;
case ".TAP":
byte[] head = romData.Take(8).ToArray();
if (System.Text.Encoding.Default.GetString(head).Contains("C64-TAPE"))
game.System = "C64";
else
game.System = "ZXSpectrum";
break;
case ".TAP":
byte[] head = romData.Take(8).ToArray();
if (System.Text.Encoding.Default.GetString(head).Contains("C64-TAPE"))
game.System = "C64";
else
game.System = "ZXSpectrum";
break;
case ".Z64":
case ".Z64":
case ".V64":
case ".N64":
game.System = "N64";
@ -346,9 +346,9 @@ namespace BizHawk.Emulation.Common
break;
case ".DSK":
var dId = new DSKIdentifier(romData);
game.System = dId.IdentifiedSystem;
break;
var dId = new DSKIdentifier(romData);
game.System = dId.IdentifiedSystem;
break;
case ".PO":
case ".DO":

View File

@ -20,19 +20,19 @@ namespace BizHawk.Emulation.Common
}
}
public class NoAvailableCoreException : Exception
{
public NoAvailableCoreException()
: base("System is currently NOT emulated")
{
}
public class NoAvailableCoreException : Exception
{
public NoAvailableCoreException()
: base("System is currently NOT emulated")
{
}
public NoAvailableCoreException(string message)
: base ($"System is currently NOT emulated: {message}")
{
public NoAvailableCoreException(string message)
: base($"System is currently NOT emulated: {message}")
{
}
}
}
}
public class CGBNotSupportedException : Exception
{

View File

@ -44,12 +44,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool HasSoundProvider(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ISoundProvider>();
return core != null && core.ServiceProvider.HasService<ISoundProvider>();
}
public static ISoundProvider AsSoundProvider(this IEmulator core)
@ -70,12 +65,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool HasMemoryDomains(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<IMemoryDomains>();
return core != null && core.ServiceProvider.HasService<IMemoryDomains>();
}
public static IMemoryDomains AsMemoryDomains(this IEmulator core)
@ -85,12 +75,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool HasSaveRam(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ISaveRam>();
return core != null && core.ServiceProvider.HasService<ISaveRam>();
}
public static ISaveRam AsSaveRam(this IEmulator core)
@ -100,12 +85,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool HasSavestates(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<IStatable>();
return core != null && core.ServiceProvider.HasService<IStatable>();
}
public static IStatable AsStatable(this IEmulator core)
@ -115,12 +95,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool CanPollInput(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<IInputPollable>();
return core != null && core.ServiceProvider.HasService<IInputPollable>();
}
public static IInputPollable AsInputPollable(this IEmulator core)
@ -130,13 +105,8 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool InputCallbacksAvailable(this IEmulator core)
{
if (core == null)
{
return false;
}
// TODO: this is a pretty ugly way to handle this
var pollable = core.ServiceProvider.GetService<IInputPollable>();
var pollable = core?.ServiceProvider.GetService<IInputPollable>();
if (pollable != null)
{
try
@ -155,12 +125,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool HasDriveLight(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<IDriveLight>();
return core != null && core.ServiceProvider.HasService<IDriveLight>();
}
public static IDriveLight AsDriveLight(this IEmulator core)
@ -170,12 +135,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool CanDebug(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<IDebuggable>();
return core != null && core.ServiceProvider.HasService<IDebuggable>();
}
public static IDebuggable AsDebuggable(this IEmulator core)
@ -185,12 +145,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool CpuTraceAvailable(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ITraceable>();
return core != null && core.ServiceProvider.HasService<ITraceable>();
}
public static ITraceable AsTracer(this IEmulator core)
@ -200,13 +155,8 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool MemoryCallbacksAvailable(this IEmulator core)
{
if (core == null)
{
return false;
}
// TODO: this is a pretty ugly way to handle this
var debuggable = (IDebuggable)core.ServiceProvider.GetService<IDebuggable>();
var debuggable = (IDebuggable) core?.ServiceProvider.GetService<IDebuggable>();
if (debuggable != null)
{
try
@ -251,7 +201,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
return core.ServiceProvider.HasService<IDisassemblable>();
}
public static IDisassemblable AsDissassembler(this IEmulator core)
public static IDisassemblable AsDisassembler(this IEmulator core)
{
return core.ServiceProvider.GetService<IDisassemblable>();
}
@ -284,12 +234,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool CanCDLog(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ICodeDataLogger>();
return core != null && core.ServiceProvider.HasService<ICodeDataLogger>();
}
public static ICodeDataLogger AsCodeDataLogger(this IEmulator core)
@ -304,22 +249,12 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool UsesLinkCable(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ILinkable>();
return core != null && core.ServiceProvider.HasService<ILinkable>();
}
public static bool CanGenerateGameDBEntries(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<ICreateGameDBEntries>();
return core != null && core.ServiceProvider.HasService<ICreateGameDBEntries>();
}
public static ICreateGameDBEntries AsGameDBEntryGenerator(this IEmulator core)
@ -329,12 +264,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
public static bool HasBoardInfo(this IEmulator core)
{
if (core == null)
{
return false;
}
return core.ServiceProvider.HasService<IBoardInfo>();
return core != null && core.ServiceProvider.HasService<IBoardInfo>();
}
public static IBoardInfo AsBoardInfo(this IEmulator core)

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Common
namespace BizHawk.Emulation.Common
{
public interface ICycleTiming
{
@ -12,6 +6,7 @@ namespace BizHawk.Emulation.Common
/// Total elapsed emulation time relative to <see cref="ClockRate"/>
/// </summary>
long CycleCount { get; }
/// <summary>
/// Clock Rate in hz for <see cref="CycleCount"/>
/// </summary>

View File

@ -46,8 +46,8 @@ namespace BizHawk.Emulation.Common
public class RegisterValue
{
public ulong Value { get; private set; }
public byte BitSize { get; private set; }
public ulong Value { get; }
public byte BitSize { get; }
public RegisterValue(ulong val, byte bitSize)
{

View File

@ -42,11 +42,7 @@ namespace BizHawk.Emulation.Common
public virtual string Cpu
{
get
{
return _cpu;
}
get => _cpu;
set
{
if (!AvailableCpus.Contains(value))

View File

@ -22,9 +22,9 @@
/// <summary>
/// Gets a value indicating whether or not SaveRAM has been modified since the last save
/// TODO: This is not the best interface. What defines a "save"? I suppose a Clone(), right? at least specify that here.
/// Clone() should probably take an optionthat says whether to clear the dirty flag.
/// Clone() should probably take an option that says whether to clear the dirty flag.
/// And anyway, cores might not know if they can even track a functional dirty flag -- we should convey that fact somehow
/// (reminder: do that with flags, so we dont have to change the interface 10000 times)
/// (reminder: do that with flags, so we don't have to change the interface 10000 times)
/// Dirty SaveRAM can in principle be determined by the frontend in that case, but it could possibly be too slow for the file menu dropdown or other things
/// </summary>
bool SaveRamModified { get; }

View File

@ -71,10 +71,10 @@ namespace BizHawk.Emulation.Common
else
{
var tt = impl.GetGenericArguments();
var settingtype = tt[0];
var synctype = tt[1];
HasSettings = settingtype != typeof(object); // object is used for a placeholder where an emu doesn't have both s and ss
HasSyncSettings = synctype != typeof(object);
var settingType = tt[0];
var syncType = tt[1];
HasSettings = settingType != typeof(object); // object is used for a placeholder where an emu doesn't have both s and ss
HasSyncSettings = syncType != typeof(object);
if (HasSettings)
{

View File

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

View File

@ -45,8 +45,8 @@ namespace BizHawk.Emulation.Common
public void DeSerialize(BinaryReader b)
{
_buttons.Clear();
int numbuttons = b.ReadInt32();
for (int i = 0; i < numbuttons; i++)
int numButtons = b.ReadInt32();
for (int i = 0; i < numButtons; i++)
{
string k = b.ReadString();
float v = b.ReadSingle();

View File

@ -28,6 +28,6 @@ namespace BizHawk.Emulation.Common
NotApplicableTypes = types?.AsEnumerable() ?? Enumerable.Empty<Type>();
}
public IEnumerable<Type> NotApplicableTypes { get; private set; }
public IEnumerable<Type> NotApplicableTypes { get; }
}
}

View File

@ -18,11 +18,11 @@ namespace BizHawk.Emulation.Common
Type targetType = target.GetType();
object[] tmp = new object[1];
foreach (var propinfo in
foreach (var propInfo in
targetType.GetPropertiesWithAttrib(typeof(RequiredServiceAttribute))
.Concat(targetType.GetPropertiesWithAttrib(typeof(OptionalServiceAttribute))))
{
propinfo.GetSetMethod(true).Invoke(target, tmp);
propInfo.GetSetMethod(true).Invoke(target, tmp);
}
}
@ -35,21 +35,21 @@ namespace BizHawk.Emulation.Common
Type targetType = target.GetType();
object[] tmp = new object[1];
foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(RequiredServiceAttribute)))
foreach (var propInfo in targetType.GetPropertiesWithAttrib(typeof(RequiredServiceAttribute)))
{
tmp[0] = source.GetService(propinfo.PropertyType);
tmp[0] = source.GetService(propInfo.PropertyType);
if (tmp[0] == null)
{
return false;
}
propinfo.GetSetMethod(true).Invoke(target, tmp);
propInfo.GetSetMethod(true).Invoke(target, tmp);
}
foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(OptionalServiceAttribute)))
foreach (var propInfo in targetType.GetPropertiesWithAttrib(typeof(OptionalServiceAttribute)))
{
tmp[0] = source.GetService(propinfo.PropertyType);
propinfo.GetSetMethod(true).Invoke(target, tmp);
tmp[0] = source.GetService(propInfo.PropertyType);
propInfo.GetSetMethod(true).Invoke(target, tmp);
}
return true;

View File

@ -15,44 +15,44 @@ namespace BizHawk.Emulation.Common
private int _accumL;
private int _accumR;
private static int DepthFromFilterwidth(int filterwidth)
private static int DepthFromFilterWidth(int filterWidth)
{
int ret = -2;
while (filterwidth > 0)
while (filterWidth > 0)
{
filterwidth >>= 1;
filterWidth >>= 1;
ret++;
}
return ret;
}
public DCFilter(ISoundProvider input, int filterwidth)
public DCFilter(ISoundProvider input, int filterWidth)
{
if (input == null)
{
throw new ArgumentNullException();
}
if (filterwidth < 8 || filterwidth > 65536)
if (filterWidth < 8 || filterWidth > 65536)
{
throw new ArgumentOutOfRangeException();
}
_depth = DepthFromFilterwidth(filterwidth);
_depth = DepthFromFilterWidth(filterWidth);
_soundProvider = input;
}
// Detached mode
public DCFilter(int filterwidth)
public DCFilter(int filterWidth)
{
if (filterwidth < 8 || filterwidth > 65536)
if (filterWidth < 8 || filterWidth > 65536)
{
throw new ArgumentOutOfRangeException();
}
_depth = DepthFromFilterwidth(filterwidth);
_depth = DepthFromFilterWidth(filterWidth);
_soundProvider = null;
}
@ -67,12 +67,12 @@ namespace BizHawk.Emulation.Common
PushThroughSamples(samples, samples, length);
}
private void PushThroughSamples(short[] samplesin, short[] samplesout, int length)
private void PushThroughSamples(short[] samplesIn, short[] samplesOut, int length)
{
for (int i = 0; i < length; i += 2)
{
int l = samplesin[i] << 12;
int r = samplesin[i + 1] << 12;
int l = samplesIn[i] << 12;
int r = samplesIn[i + 1] << 12;
_accumL -= _accumL >> _depth;
_accumR -= _accumR >> _depth;
_accumL += l - _latchL;
@ -86,28 +86,28 @@ namespace BizHawk.Emulation.Common
// check for clipping
if (bigL > 32767)
{
samplesout[i] = 32767;
samplesOut[i] = 32767;
}
else if (bigL < -32768)
{
samplesout[i] = -32768;
samplesOut[i] = -32768;
}
else
{
samplesout[i] = (short)bigL;
samplesOut[i] = (short)bigL;
}
if (bigR > 32767)
{
samplesout[i + 1] = 32767;
samplesOut[i + 1] = 32767;
}
else if (bigR < -32768)
{
samplesout[i + 1] = -32768;
samplesOut[i + 1] = -32768;
}
else
{
samplesout[i + 1] = (short)bigR;
samplesOut[i + 1] = (short)bigR;
}
}
}
@ -125,15 +125,12 @@ namespace BizHawk.Emulation.Common
public void GetSamplesSync(out short[] samples, out int nsamp)
{
short[] sampin;
int nsampin;
_soundProvider.GetSamplesSync(out var sampIn, out var nsampIn);
_soundProvider.GetSamplesSync(out sampin, out nsampin);
short[] ret = new short[nsampin * 2];
PushThroughSamples(sampin, ret, nsampin * 2);
short[] ret = new short[nsampIn * 2];
PushThroughSamples(sampIn, ret, nsampIn * 2);
samples = ret;
nsamp = nsampin;
nsamp = nsampIn;
}
public SyncSoundMode SyncMode => _soundProvider.SyncMode;

View File

@ -75,8 +75,7 @@ namespace BizHawk.Emulation.Common
}
done++;
short left, right;
_adjustobuf.Dequeue(out left, out right);
_adjustobuf.Dequeue(out var left, out var right);
buf[ctr++] = left;
buf[ctr++] = right;
}

View File

@ -22,19 +22,19 @@ namespace BizHawk.Emulation.Common
new SystemInfo { SystemId = "PSX", FullName = "Playstation" },
new SystemInfo { SystemId = "SMS", FullName = "Sega Master System" },
new SystemInfo { SystemId = "GEN", FullName = "Sega Genesis/Megadrive" },
new SystemInfo { SystemId = "GEN", FullName = "Sega Genesis/Mega Drive" },
new SystemInfo { SystemId = "SAT", FullName = "Sega Saturn" },
new SystemInfo { SystemId = "PCE", FullName = "PC Engine/TurboGrafx 16" },
new SystemInfo { SystemId = "Coleco", FullName = "Colecovision" },
new SystemInfo { SystemId = "Coleco", FullName = "ColecoVision" },
new SystemInfo { SystemId = "TI83", FullName = "TI-83 Calculator" },
new SystemInfo { SystemId = "WSWAN", FullName = "WonderSwan" },
new SystemInfo { SystemId = "C64", FullName = "Commodore 64" },
new SystemInfo { SystemId = "AppleII", FullName = "Apple II" },
new SystemInfo { SystemId = "INTV", FullName = "Intellivision" },
new SystemInfo { SystemId = "ZXSpectrum", FullName = "Sinclair ZX Spectrum" },
new SystemInfo { SystemId = "AmstradCPC", FullName = "Amstrad CPC" },
new SystemInfo { SystemId = "INTV", FullName = "IntelliVision" },
new SystemInfo { SystemId = "ZXSpectrum", FullName = "Sinclair ZX Spectrum" },
new SystemInfo { SystemId = "AmstradCPC", FullName = "Amstrad CPC" },
new SystemInfo { SystemId = "ChannelF", FullName = "Fairchild Channel F"},
};
@ -43,13 +43,7 @@ namespace BizHawk.Emulation.Common
get
{
var system = _systems.FirstOrDefault(s => s.SystemId == systemId);
if (system != null)
{
return system;
}
return new SystemInfo { SystemId = "Unknown", FullName = "Unknown" };
return system ?? new SystemInfo { SystemId = "Unknown", FullName = "Unknown" };
}
}

View File

@ -183,6 +183,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=autoflushing/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autohold/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autoload/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=automagically/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=autorestore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=backcolor/@EntryIndexedValue">True</s:Boolean>
@ -194,14 +195,18 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coalescer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coleco/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=colesced/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cpus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=curr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=dearchive/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Disasm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Disassemblable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=disassembly/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dontfire/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ejin/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Endian/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fairchild/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Famtasia/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEU/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean>
@ -212,6 +217,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Frameskipping/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gameboy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gamedb/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Grafx/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzone/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzoned/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Homebrew/@EntryIndexedValue">True</s:Boolean>
@ -232,6 +238,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nametable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nametables/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nintendulator/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=nsamp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Numerics/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=nvidia/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=opengl/@EntryIndexedValue">True</s:Boolean>
@ -241,6 +248,9 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=PCSX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Phaser/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pollable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Regionable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=resizer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=samp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=saveram/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=savestate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=savestates/@EntryIndexedValue">True</s:Boolean>
@ -251,11 +261,13 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Sram/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=sSeeki/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Statable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stateable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Syncless/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=taseditor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasproj/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tastudio/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Turboing/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unmerge/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unpause/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unpaused/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unpausing/@EntryIndexedValue">True</s:Boolean>