misc cleanups in Emulation.Common

This commit is contained in:
adelikat 2020-03-01 14:39:24 -06:00
parent 565a319cef
commit 630858cbd4
6 changed files with 20 additions and 85 deletions

View File

@ -192,18 +192,12 @@ namespace BizHawk.Emulation.Common
{
var br = new BinaryReader(s);
string id = br.ReadString();
switch (id)
SubType = id switch
{
case "BIZHAWK-CDL-1":
SubType = "PCE";
break;
case "BIZHAWK-CDL-2":
SubType = br.ReadString().TrimEnd(' ');
break;
default:
throw new InvalidDataException("File is not a BizHawk CDL file!");
}
"BIZHAWK-CDL-1" => "PCE",
"BIZHAWK-CDL-2" => br.ReadString().TrimEnd(' '),
_ => throw new InvalidDataException("File is not a BizHawk CDL file!"),
};
int count = br.ReadInt32();
for (int i = 0; i < count; i++)
{

View File

@ -155,7 +155,7 @@ namespace BizHawk.Emulation.Common
System = items[3],
MetaData = items.Length >= 6 ? items[5] : null,
Region = items.Length >= 7 ? items[6] : "",
ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : "",
ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : ""
};
if (DB.ContainsKey(game.Hash))

View File

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

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace BizHawk.Emulation.Common
{
@ -58,7 +59,7 @@ namespace BizHawk.Emulation.Common
}
else if (bitSize > 64 || bitSize == 0)
{
throw new System.ArgumentOutOfRangeException(nameof(bitSize), $"{nameof(BitSize)} must be in 1..64");
throw new ArgumentOutOfRangeException(nameof(bitSize), $"{nameof(BitSize)} must be in 1..64");
}
else
{
@ -122,49 +123,14 @@ namespace BizHawk.Emulation.Common
BitSize = 64;
}
public static implicit operator RegisterValue(bool val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(byte val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(sbyte val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(ushort val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(short val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(uint val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(int val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(ulong val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(long val)
{
return new RegisterValue(val);
}
public static implicit operator RegisterValue(bool val) => new RegisterValue(val);
public static implicit operator RegisterValue(byte val) => new RegisterValue(val);
public static implicit operator RegisterValue(sbyte val) => new RegisterValue(val);
public static implicit operator RegisterValue(ushort val) => new RegisterValue(val);
public static implicit operator RegisterValue(short val) => new RegisterValue(val);
public static implicit operator RegisterValue(uint val) => new RegisterValue(val);
public static implicit operator RegisterValue(int val) => new RegisterValue(val);
public static implicit operator RegisterValue(ulong val) => new RegisterValue(val);
public static implicit operator RegisterValue(long val) => new RegisterValue(val);
}
}

View File

@ -46,20 +46,6 @@ namespace BizHawk.Emulation.Common
_soundProvider = input;
}
/// <summary>detached mode</summary>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="filterWidth"/> is not in 8..65536</exception>
public DCFilter(int filterWidth)
{
if (filterWidth < 8 || filterWidth > 65536)
{
throw new ArgumentOutOfRangeException();
}
_depth = DepthFromFilterWidth(filterWidth);
_soundProvider = null;
}
/// <summary>
/// pass a set of samples through the filter. should only be used in detached mode
/// </summary>

View File

@ -388,11 +388,6 @@ namespace BizHawk.Emulation.Common
}
_inbufpos = 0;
////Buffer.BlockCopy(inbuf, (int)inal * 2 * sizeof(short), inbuf, 0, inbufpos - (int)inal * 2);
////inbufpos -= (int)inal * 2;
// dispatch outbuf
_drainer(_outbuf, (int)outal);
}