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