NES: Fix battery backup in certain bootgod identified games

If the wram with the battery backup on it is internal to the mapper asic, and not a separate ram chip, bootgod will have <chip battery=1> and not <wram battery=1>.  Fixes #2570.
This commit is contained in:
nattthebear 2021-01-17 09:06:33 -05:00
parent b8a0720121
commit 070cc59dbf
1 changed files with 15 additions and 13 deletions

View File

@ -1,7 +1,7 @@
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Xml;
using System.Threading;
using BizHawk.Common;
@ -9,7 +9,7 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
public class BootGodDb
{
{
/// <summary>
/// blocks until the DB is done loading
/// </summary>
@ -27,8 +27,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
acquire = new EventWaitHandle(false, EventResetMode.ManualReset);
var stopwatch = Stopwatch.StartNew();
ThreadPool.QueueUserWorkItem(_ =>
{
ThreadPool.QueueUserWorkItem(_ =>
{
instance = new BootGodDb(basePath);
Util.DebugWriteLine("Bootgod DB load: " + stopwatch.Elapsed + " sec");
acquire.Set();
@ -55,15 +55,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// notes: there can be multiple each of prg,chr,wram,vram
// we aren't tracking the individual hashes yet.
string xmlPath = Path.Combine(basePath, "NesCarts.xml");
string x7zPath = Path.Combine(basePath, "NesCarts.7z");
bool loadXml = File.Exists(xmlPath);
using var nesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath);
if (!loadXml)
{
nesCartFile.BindFirst();
}
string xmlPath = Path.Combine(basePath, "NesCarts.xml");
string x7zPath = Path.Combine(basePath, "NesCarts.7z");
bool loadXml = File.Exists(xmlPath);
using var nesCartFile = new HawkFile(loadXml ? xmlPath : x7zPath);
if (!loadXml)
{
nesCartFile.BindFirst();
}
var stream = nesCartFile.GetStream();
// in anticipation of any slowness annoying people, and just for shits and giggles, i made a super fast parser
@ -118,6 +118,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break;
case "chip":
currCart.Chips.Add(xmlReader.GetAttribute("type"));
if (xmlReader.GetAttribute("battery") != null)
currCart.WramBattery = true;
break;
}
} else