quicknes: use bootgod db to display helpful information about roms (except galaxian). no effect on emulation

This commit is contained in:
goyuken 2014-07-23 02:48:55 +00:00
parent 2cb1cfa7df
commit e87f0ceba7
2 changed files with 53 additions and 0 deletions

View File

@ -3091,6 +3091,18 @@ namespace BizHawk.Client.EmuHawk
Global.Game.Status = nes.RomStatus;
}
else if (loader.LoadedEmulator is QuickNES)
{
var qns = loader.LoadedEmulator as QuickNES;
if (!string.IsNullOrWhiteSpace(qns.BootGodName))
{
Global.Game.Name = qns.BootGodName;
}
if (qns.BootGodStatus.HasValue)
{
Global.Game.Status = qns.BootGodStatus.Value;
}
}
SetWindowText();

View File

@ -57,6 +57,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
static QuickNES()
{
LibQuickNES.qn_setup_mappers();
Emulation.Cores.Nintendo.NES.NES.BootGodDB.Initialize();
}
public QuickNES(CoreComm nextComm, byte[] Rom, object Settings)
@ -85,6 +86,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
CoreComm.VsyncNum = 39375000;
CoreComm.VsyncDen = 655171;
PutSettings(Settings ?? new QuickNESSettings());
ComputeBootGod();
}
catch
{
@ -385,6 +388,44 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
#endregion
#region bootgod
public RomStatus? BootGodStatus { get; private set; }
public string BootGodName { get; private set; }
void ComputeBootGod()
{
// inefficient, sloppy, etc etc
var chrrom = MemoryDomains["CHR VROM"];
var prgrom = MemoryDomains["PRG ROM"];
var ms = new System.IO.MemoryStream();
for (int i = 0; i < prgrom.Size; i++)
ms.WriteByte(prgrom.PeekByte(i));
if (chrrom != null)
for (int i = 0; i < chrrom.Size; i++)
ms.WriteByte(chrrom.PeekByte(i));
string sha1 = BizHawk.Common.BufferExtensions.BufferExtensions.HashSHA1(ms.ToArray());
Console.WriteLine("Hash for BootGod: {0}", sha1);
sha1 = "sha1:" + sha1; // huh?
var carts = Emulation.Cores.Nintendo.NES.NES.BootGodDB.Instance.Identify(sha1);
if (carts.Count > 0)
{
Console.WriteLine("BootGod entry found: {0}", carts[0].name);
BootGodStatus = RomStatus.GoodDump;
BootGodName = carts[0].name;
}
else
{
Console.WriteLine("No BootGod entry found.");
BootGodStatus = null;
BootGodName = null;
}
}
#endregion
#region settings
public class QuickNESSettings