Quicknes: clean up previous commit

This commit is contained in:
goyuken 2014-07-23 03:02:44 +00:00
parent e87f0ceba7
commit 3218085682
2 changed files with 27 additions and 10 deletions

View File

@ -543,14 +543,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public class BootGodDB
{
static object staticsyncroot = new object();
object syncroot = new object();
bool validate = true;
public static BootGodDB Instance;
public static Func<byte[]> GetDatabaseBytes;
private static BootGodDB _Instance;
public static BootGodDB Instance
{
get { lock (staticsyncroot) { return _Instance; } }
}
private static Func<byte[]> _GetDatabaseBytes;
public static Func<byte[]> GetDatabaseBytes
{
set { lock (staticsyncroot) { _GetDatabaseBytes = value; } }
}
public static void Initialize()
{
if(Instance == null)
Instance = new BootGodDB();
lock (staticsyncroot)
{
if (_Instance == null)
_Instance = new BootGodDB();
}
}
int ParseSize(string str)
{
@ -571,7 +585,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//in anticipation of any slowness annoying people, and just for shits and giggles, i made a super fast parser
int state=0;
var xmlreader = XmlReader.Create(new MemoryStream(GetDatabaseBytes()));
var xmlreader = XmlReader.Create(new MemoryStream(_GetDatabaseBytes()));
CartInfo currCart = null;
string currName = null;
while (xmlreader.Read())
@ -655,16 +669,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break;
}
} //end xmlreader loop
}
Bag<string, CartInfo> sha1_table = new Bag<string, CartInfo>();
public List<CartInfo> Identify(string sha1)
{
if (!sha1_table.ContainsKey(sha1)) return new List<CartInfo>();
return sha1_table[sha1];
lock (syncroot)
{
if (!sha1_table.ContainsKey(sha1))
return new List<CartInfo>();
else
return sha1_table[sha1];
}
}
}
}

View File

@ -57,7 +57,6 @@ 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)
@ -396,6 +395,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
void ComputeBootGod()
{
// inefficient, sloppy, etc etc
Emulation.Cores.Nintendo.NES.NES.BootGodDB.Initialize();
var chrrom = MemoryDomains["CHR VROM"];
var prgrom = MemoryDomains["PRG ROM"];