Emulation.Common cleanups

This commit is contained in:
adelikat 2017-04-27 11:37:26 -05:00
parent b98d428a64
commit a8c15a652b
13 changed files with 49 additions and 41 deletions

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
private void BizBox_Load(object sender, EventArgs e)
{
string mainversion = VersionInfo.MAINVERSION;
string mainversion = VersionInfo.Mainversion;
if (IntPtr.Size == 8)
mainversion += " (x64)";
if (VersionInfo.DeveloperBuild)

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -53,8 +53,8 @@ namespace BizHawk.Client.EmuHawk
{
return AutoCheckEnabled &&
LatestVersion != IgnoreVersion &&
ParseVersion(VersionInfo.MAINVERSION) != 0 && // Avoid notifying if current version string is invalid
ParseVersion(LatestVersion) > ParseVersion(VersionInfo.MAINVERSION);
ParseVersion(VersionInfo.Mainversion) != 0 && // Avoid notifying if current version string is invalid
ParseVersion(LatestVersion) > ParseVersion(VersionInfo.Mainversion);
}
}

View File

@ -30,5 +30,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -311,14 +311,22 @@ namespace BizHawk.Emulation.Common.BizInvoke
var nativeParamTypes = new List<Type>();
var returnType = baseMethod.ReturnType;
if (returnType != typeof(void) && !returnType.IsPrimitive)
{
throw new InvalidOperationException("Only primitive return types are supported");
}
// define a field on the type to hold the entry pointer
var field = type.DefineField("EntryPtrField" + baseMethod.Name, typeof(IntPtr),
var field = type.DefineField(
"EntryPtrField" + baseMethod.Name,
typeof(IntPtr),
FieldAttributes.Public);
var method = type.DefineMethod(baseMethod.Name, MethodAttributes.Virtual | MethodAttributes.Public,
CallingConventions.HasThis, returnType, paramTypes);
var method = type.DefineMethod(
baseMethod.Name,
MethodAttributes.Virtual | MethodAttributes.Public,
CallingConventions.HasThis,
returnType,
paramTypes);
var il = method.GetILGenerator();

View File

@ -8,17 +8,6 @@ using BizHawk.Common.BufferExtensions;
namespace BizHawk.Emulation.Common
{
public class CompactGameInfo
{
public string Name { get; set; }
public string System { get; set; }
public string MetaData { get; set; }
public string Hash { get; set; }
public string Region { get; set; }
public RomStatus Status { get; set; }
public string ForcedCore { get; set; }
}
public static class Database
{
private static readonly Dictionary<string, CompactGameInfo> DB = new Dictionary<string, CompactGameInfo>();
@ -42,8 +31,8 @@ namespace BizHawk.Emulation.Common
public static GameInfo CheckDatabase(string hash)
{
CompactGameInfo cgi;
var hash_notype = RemoveHashType(hash);
DB.TryGetValue(hash_notype, out cgi);
var hashNotype = RemoveHashType(hash);
DB.TryGetValue(hashNotype, out cgi);
if (cgi == null)
{
Console.WriteLine("DB: hash " + hash + " not in game database.");
@ -237,7 +226,7 @@ namespace BizHawk.Emulation.Common
CRC32.Calculate(romData),
System.Security.Cryptography.MD5.Create().ComputeHash(romData).BytesToHexString());
var ext = Path.GetExtension(fileName).ToUpperInvariant();
var ext = Path.GetExtension(fileName)?.ToUpperInvariant();
switch (ext)
{
@ -344,10 +333,10 @@ namespace BizHawk.Emulation.Common
break;
}
game.Name = Path.GetFileNameWithoutExtension(fileName).Replace('_', ' ');
game.Name = Path.GetFileNameWithoutExtension(fileName)?.Replace('_', ' ');
// If filename is all-caps, then attempt to proper-case the title.
if (game.Name == game.Name.ToUpperInvariant())
if (!string.IsNullOrWhiteSpace(game.Name) && game.Name == game.Name.ToUpperInvariant())
{
game.Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(game.Name.ToLower());
}
@ -355,4 +344,15 @@ namespace BizHawk.Emulation.Common
return game;
}
}
public class CompactGameInfo
{
public string Name { get; set; }
public string System { get; set; }
public string MetaData { get; set; }
public string Hash { get; set; }
public string Region { get; set; }
public RomStatus Status { get; set; }
public string ForcedCore { get; set; }
}
}

View File

@ -53,8 +53,8 @@ namespace BizHawk.Emulation.Common
// so, we're going to lay this out carefully so that we choose things in a sensible order, but prefer the correct region
var ss_100_j = File("2B8CB4F87580683EB4D760E4ED210813D667F0A2", 524288, "saturn-1.00-(J).bin", "Bios v1.00 (J)");
var ss_100_ue = File("FAA8EA183A6D7BBE5D4E03BB1332519800D3FBC3", 524288, "saturn-1.00-(U+E).bin", "Bios v1.00 (U+E)");
var ss_100a_ue = File("3BB41FEB82838AB9A35601AC666DE5AACFD17A58", 524288, "saturn-1.00a-(U+E).bin", "Bios v1.00a (U+E)"); //?? is this size correct?
var ss_101_j = File("DF94C5B4D47EB3CC404D88B33A8FDA237EAF4720", 524288, "saturn-1.01-(J).bin", "Bios v1.01 (J)"); //?? is this size correct?
var ss_100a_ue = File("3BB41FEB82838AB9A35601AC666DE5AACFD17A58", 524288, "saturn-1.00a-(U+E).bin", "Bios v1.00a (U+E)"); // ?? is this size correct?
var ss_101_j = File("DF94C5B4D47EB3CC404D88B33A8FDA237EAF4720", 524288, "saturn-1.01-(J).bin", "Bios v1.01 (J)"); // ?? is this size correct?
Firmware("SAT", "J", "Bios (J)");
Option("SAT", "J", ss_100_j);
Option("SAT", "J", ss_101_j);
@ -113,8 +113,8 @@ namespace BizHawk.Emulation.Common
// SMS
var sms_us_13 = File("C315672807D8DDB8D91443729405C766DD95CAE7", 8192, "sms_us_1.3.sms", "SMS BIOS 1.3 (USA, Europe)");
var sms_jp_21 = File("A8C1B39A2E41137835EDA6A5DE6D46DD9FADBAF2", 8192, "sms_jp_2.1.sms", "SMS BIOS 2.1 (Japan)");
var sms_us_1b = File("29091FF60EF4C22B1EE17AA21E0E75BAC6B36474", 8192, "sms_us_1.0b.sms", "SMS BIOS 1.0 (USA) (Proto)"); //?? is this size correct?
var sms_m404 = File("4A06C8E66261611DCE0305217C42138B71331701", 8192, "sms_m404.sms", "SMS BIOS (USA) (M404) (Proto)"); //?? is this size correct?
var sms_us_1b = File("29091FF60EF4C22B1EE17AA21E0E75BAC6B36474", 8192, "sms_us_1.0b.sms", "SMS BIOS 1.0 (USA) (Proto)"); // ?? is this size correct?
var sms_m404 = File("4A06C8E66261611DCE0305217C42138B71331701", 8192, "sms_m404.sms", "SMS BIOS (USA) (M404) (Proto)"); // ?? is this size correct?
Firmware("SMS", "Export", "SMS Bios (USA/Export)");
Firmware("SMS", "Japan", "SMS Bios (Japan)");

View File

@ -341,7 +341,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
// If async is not provided by the implementation this method will throw an exception
// We need to figure out a reliable way to check specifically for a NotImplementedException, then maybe this method will be more useful
// If a method is not marked but all it does is throw an exception, consider it not implemented
//return !info.ThrowsError();
////return !info.ThrowsError();
return true;
}

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]