diff --git a/BizHawk.Client.Common/FirmwareManager.cs b/BizHawk.Client.Common/FirmwareManager.cs
index d6dc3040fa..136c5714c2 100644
--- a/BizHawk.Client.Common/FirmwareManager.cs
+++ b/BizHawk.Client.Common/FirmwareManager.cs
@@ -259,8 +259,13 @@ namespace BizHawk.Client.Common
continue;
}
- // compute its hash
- var rff = reader.Read(fi);
+ // compute its hash
+ RealFirmwareFile rff;
+ // NDS's firmware file contains user settings; these are over-written by sync settings, so we shouldn't allow them to impact the hash
+ if (fr.SystemId == "NDS" && fr.FirmwareId == "firmware")
+ rff = reader.Read(new FileInfo(Emulation.Cores.Consoles.Nintendo.NDS.MelonDS.CreateModifiedFirmware(userSpec)));
+ else
+ rff = reader.Read(fi);
ri.Size = fi.Length;
ri.Hash = rff.Hash;
diff --git a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
index f2f143cb10..d0879103d1 100644
--- a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
+++ b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs
@@ -44,8 +44,7 @@ namespace BizHawk.Emulation.Common
FirmwareAndOption("24F67BDEA115A2C847C8813A262502EE1607B7DF", 16384, "NDS", "bios7", "bios7.bin", "ARM7 BIOS");
FirmwareAndOption("BFAAC75F101C135E32E2AAF541DE6B1BE4C8C62D", 4096, "NDS", "bios9", "bios9.bin", "ARM9 BIOS");
- // NDS firmware dump contains user settings, so hashes are not expected to match
- FirmwareAndOption("0000000000000000000000000000000000000000", 262144, "NDS", "firmware", "firmware.bin", "NDS Firmware");
+ FirmwareAndOption("DDDDA2447AE84A77385497D8889516E8BC090418", 262144, "NDS", "firmware", "firmware.bin", "NDS Firmware (note: given hash is with blank user data)");
FirmwareAndOption("E4ED47FAE31693E016B081C6BDA48DA5B70D7CCB", 512, "Lynx", "Boot", "lynxboot.img", "Boot Rom");
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs
index e425773a91..36874b2c64 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs
@@ -11,7 +11,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
[Core("MelonDS", "Arisotura")]
- unsafe partial class MelonDS : IEmulator
+ unsafe public partial class MelonDS : IEmulator
{
private BasicServiceProvider _serviceProvider;
public IEmulatorServiceProvider ServiceProvider => _serviceProvider;
@@ -139,5 +139,26 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
else
File.Delete("melon/firmware.bin");
}
+
+ ///
+ /// Creates a modified copy of the given firmware file, with the user settings erased.
+ ///
+ /// Returns a path to the new file.
+ public static string CreateModifiedFirmware(string firmwarePath)
+ {
+ const string newPath = "melon/tohash.bin";
+ byte[] bytes = File.ReadAllBytes(firmwarePath);
+
+ // There are two regions for user settings
+ int settingsLength = getUserSettingsLength();
+ for (int i = bytes.Length - 0x200; i < bytes.Length - 0x200 + settingsLength; i++)
+ bytes[i] = 0xFF;
+ for (int i = bytes.Length - 0x100; i < bytes.Length - 0x100 + settingsLength; i++)
+ bytes[i] = 0xFF;
+
+
+ File.WriteAllBytes(newPath, bytes);
+ return newPath;
+ }
}
}