Simplifications and cleanups in Emulation.Common
This commit is contained in:
parent
aced228b43
commit
45a777c983
|
@ -52,14 +52,7 @@ namespace BizHawk.Emulation.Common
|
|||
return _systemBus;
|
||||
}
|
||||
|
||||
var bus = this.FirstOrDefault(x => x.Name == "System Bus");
|
||||
|
||||
if (bus != null)
|
||||
{
|
||||
return bus;
|
||||
}
|
||||
|
||||
return MainMemory;
|
||||
return this.FirstOrDefault(x => x.Name == "System Bus") ?? MainMemory;
|
||||
}
|
||||
|
||||
set => _systemBus = value;
|
||||
|
|
|
@ -76,10 +76,7 @@ namespace BizHawk.Emulation.Common
|
|||
_remaps = remaps;
|
||||
}
|
||||
|
||||
public ControllerDefinition Definition
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
public ControllerDefinition Definition => throw new NotImplementedException();
|
||||
|
||||
public bool IsPressed(string button)
|
||||
{
|
||||
|
|
|
@ -31,9 +31,8 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public static GameInfo CheckDatabase(string hash)
|
||||
{
|
||||
CompactGameInfo cgi;
|
||||
var hashNotype = RemoveHashType(hash);
|
||||
DB.TryGetValue(hashNotype, out cgi);
|
||||
var hashNoType = RemoveHashType(hash);
|
||||
DB.TryGetValue(hashNoType, out var cgi);
|
||||
if (cgi == null)
|
||||
{
|
||||
Console.WriteLine($"DB: hash {hash} not in game database.");
|
||||
|
@ -110,94 +109,91 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public static void LoadDatabase(string path)
|
||||
{
|
||||
using (var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
|
||||
using var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
|
||||
while (reader.EndOfStream == false)
|
||||
{
|
||||
while (reader.EndOfStream == false)
|
||||
var line = reader.ReadLine() ?? "";
|
||||
try
|
||||
{
|
||||
var line = reader.ReadLine() ?? "";
|
||||
try
|
||||
if (line.StartsWith(";"))
|
||||
{
|
||||
if (line.StartsWith(";"))
|
||||
{
|
||||
continue; // comment
|
||||
}
|
||||
|
||||
if (line.StartsWith("#"))
|
||||
{
|
||||
LoadDatabase_Escape(line, Path.GetDirectoryName(path));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.Trim().Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var items = line.Split('\t');
|
||||
|
||||
var game = new CompactGameInfo
|
||||
{
|
||||
Hash = RemoveHashType(items[0].ToUpper())
|
||||
};
|
||||
|
||||
// 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":
|
||||
game.Status = RomStatus.BadDump;
|
||||
break;
|
||||
case "V":
|
||||
game.Status = RomStatus.BadDump;
|
||||
break;
|
||||
case "T":
|
||||
game.Status = RomStatus.TranslatedRom;
|
||||
break;
|
||||
case "O":
|
||||
game.Status = RomStatus.Overdump;
|
||||
break;
|
||||
case "I":
|
||||
game.Status = RomStatus.Bios;
|
||||
break;
|
||||
case "D":
|
||||
game.Status = RomStatus.Homebrew;
|
||||
break;
|
||||
case "H":
|
||||
game.Status = RomStatus.Hack;
|
||||
break;
|
||||
case "U":
|
||||
game.Status = RomStatus.Unknown;
|
||||
break;
|
||||
default:
|
||||
game.Status = RomStatus.GoodDump;
|
||||
break;
|
||||
}
|
||||
|
||||
game.Name = items[2];
|
||||
game.System = items[3];
|
||||
game.MetaData = items.Length >= 6 ? items[5] : null;
|
||||
game.Region = items.Length >= 7 ? items[6] : "";
|
||||
game.ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : "";
|
||||
|
||||
if (DB.ContainsKey(game.Hash))
|
||||
{
|
||||
Console.WriteLine("gamedb: Multiple hash entries {0}, duplicate detected on \"{1}\" and \"{2}\"", game.Hash, game.Name, DB[game.Hash].Name);
|
||||
}
|
||||
|
||||
DB[game.Hash] = game;
|
||||
continue; // comment
|
||||
}
|
||||
catch
|
||||
|
||||
if (line.StartsWith("#"))
|
||||
{
|
||||
Console.WriteLine($"Error parsing database entry: {line}");
|
||||
LoadDatabase_Escape(line, Path.GetDirectoryName(path));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.Trim().Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var items = line.Split('\t');
|
||||
|
||||
var game = new CompactGameInfo
|
||||
{
|
||||
Hash = RemoveHashType(items[0].ToUpper())
|
||||
};
|
||||
|
||||
// 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":
|
||||
game.Status = RomStatus.BadDump;
|
||||
break;
|
||||
case "V":
|
||||
game.Status = RomStatus.BadDump;
|
||||
break;
|
||||
case "T":
|
||||
game.Status = RomStatus.TranslatedRom;
|
||||
break;
|
||||
case "O":
|
||||
game.Status = RomStatus.Overdump;
|
||||
break;
|
||||
case "I":
|
||||
game.Status = RomStatus.Bios;
|
||||
break;
|
||||
case "D":
|
||||
game.Status = RomStatus.Homebrew;
|
||||
break;
|
||||
case "H":
|
||||
game.Status = RomStatus.Hack;
|
||||
break;
|
||||
case "U":
|
||||
game.Status = RomStatus.Unknown;
|
||||
break;
|
||||
default:
|
||||
game.Status = RomStatus.GoodDump;
|
||||
break;
|
||||
}
|
||||
|
||||
game.Name = items[2];
|
||||
game.System = items[3];
|
||||
game.MetaData = items.Length >= 6 ? items[5] : null;
|
||||
game.Region = items.Length >= 7 ? items[6] : "";
|
||||
game.ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : "";
|
||||
|
||||
if (DB.ContainsKey(game.Hash))
|
||||
{
|
||||
Console.WriteLine("gamedb: Multiple hash entries {0}, duplicate detected on \"{1}\" and \"{2}\"", game.Hash, game.Name, DB[game.Hash].Name);
|
||||
}
|
||||
|
||||
DB[game.Hash] = game;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"Error parsing database entry: {line}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GameInfo GetGameInfo(byte[] romData, string fileName)
|
||||
{
|
||||
CompactGameInfo cgi;
|
||||
var hash = $"{CRC32.Calculate(romData):X8}";
|
||||
if (DB.TryGetValue(hash, out cgi))
|
||||
if (DB.TryGetValue(hash, out var cgi))
|
||||
{
|
||||
return new GameInfo(cgi);
|
||||
}
|
||||
|
@ -316,10 +312,9 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
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";
|
||||
game.System = Encoding.Default.GetString(head).Contains("C64-TAPE")
|
||||
? "C64"
|
||||
: "ZXSpectrum";
|
||||
break;
|
||||
|
||||
case ".Z64":
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// ReSharper disable StringLiteralTypo
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public static class FirmwareDatabase
|
||||
|
@ -202,10 +203,10 @@ namespace BizHawk.Emulation.Common
|
|||
Option("PSX", "J", ps_30j);
|
||||
Option("PSX", "E", ps_30e);
|
||||
|
||||
// in general, alternates arent allowed.. their quality isnt known.
|
||||
// in general, alternates aren't allowed.. their quality isn't known.
|
||||
// we have this comment from fobby.net: "SCPH7502 works fine for European games" (TBD)
|
||||
// however, we're sticking with the 3.0 series.
|
||||
// please note: 2.1 or 2.2 would be a better choice, as the dates are the same and the bioses are more likely to matching in terms of entrypoints and such.
|
||||
// please note: 2.1 or 2.2 would be a better choice, as the dates are the same and the bioses are more likely to matching in terms of entry points and such.
|
||||
// but 3.0 is what mednafen used
|
||||
Option("PSX", "J", ps_10j, FirmwareOptionStatus.Unacceptable);
|
||||
Option("PSX", "J", ps_11j, FirmwareOptionStatus.Unacceptable);
|
||||
|
@ -371,13 +372,13 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public enum FirmwareOptionStatus
|
||||
{
|
||||
//This is what we want you to use to get checkmarks, and for tasing
|
||||
//This is what we want you to use to get checkmarks, and for TASing
|
||||
Ideal,
|
||||
|
||||
//This will work with our core
|
||||
Acceptable,
|
||||
|
||||
//This is a good file, but it doesnt work with our core
|
||||
//This is a good file, but it doesn't work with our core
|
||||
Unacceptable,
|
||||
|
||||
//I know this is weird, you'd think the file is bad
|
||||
|
|
|
@ -40,11 +40,6 @@ namespace BizHawk.Emulation.Common
|
|||
: base("Core does not support CGB only games!")
|
||||
{
|
||||
}
|
||||
|
||||
public CGBNotSupportedException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class SavestateSizeMismatchException : InvalidOperationException
|
||||
|
|
|
@ -27,14 +27,14 @@ namespace BizHawk.Emulation.Common
|
|||
/// <summary>
|
||||
/// Runs the emulator core for 1 frame
|
||||
/// note that (some?) cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
|
||||
/// please do this, even when <seealso cref="rendersound"/> = false
|
||||
/// please do this, even when <seealso cref="renderSound"/> = false
|
||||
/// <param name="controller">The <seealso cref="IController"/> instance that the core will use for input.
|
||||
/// The <seealso cref="IController"/> provided by the client must provide the buttons specified by the core through the <seealso cref="ControllerDefinition"/> property
|
||||
/// </param>
|
||||
/// <param name="render">Whether or not to render video, cores will pass false here in cases such as frame skipping</param>
|
||||
/// <param name="rendersound">Whether or not to render audio, cores will pass here false here in cases such as fast forwarding where bypassing sound may improve speed</param>
|
||||
/// <param name="renderSound">Whether or not to render audio, cores will pass here false here in cases such as fast forwarding where bypassing sound may improve speed</param>
|
||||
/// </summary>
|
||||
bool FrameAdvance(IController controller, bool render, bool rendersound = true);
|
||||
bool FrameAdvance(IController controller, bool render, bool renderSound = true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current frame count
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace BizHawk.Emulation.Common
|
|||
/// <summary>
|
||||
/// Whether the CDL is tracking a block with the given name
|
||||
/// </summary>
|
||||
bool Has(string blockname);
|
||||
bool Has(string blockName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the status is active.
|
||||
|
|
|
@ -83,8 +83,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
// works for either save or load, but as a consequence cannot report intelligent
|
||||
// errors about section name mismatches
|
||||
Node next = null;
|
||||
Current.Objects.TryGetValue(name, out next);
|
||||
Current.Objects.TryGetValue(name, out var next);
|
||||
if (next == null)
|
||||
{
|
||||
next = new Node();
|
||||
|
|
|
@ -212,6 +212,7 @@
|
|||
<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/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=fname/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=feos/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -223,6 +224,7 @@
|
|||
<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/=Highscore/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Homebrew/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hotkey/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hotkeys/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -237,6 +239,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=LSNES/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=luases/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mainform/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=mame/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Multidisk/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=multilines/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -274,6 +277,7 @@
|
|||
<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/=Subfile/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=subframe/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Subshell/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Syncless/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
Loading…
Reference in New Issue