From cb159e9228bd5cdee9db3ece0e37fd5b9a2bcc26 Mon Sep 17 00:00:00 2001 From: SuuperW Date: Fri, 20 Dec 2019 09:43:49 -0600 Subject: [PATCH] MelonDS: Use the bios/firmware files selected in BizHawk's "Firmwares" dialog. --- .../Consoles/Nintendo/NDS/MelonDS.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index ff1dbe7a1e..b787161eba 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; +using System.IO; using BizHawk.Emulation.Common; @@ -70,7 +71,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS private static extern void FrameAdvance(short buttons, byte touchX, byte touchY); [CoreConstructor("NDS")] - public MelonDS(byte[] file) + public MelonDS(byte[] file, CoreComm comm) { _serviceProvider = new BasicServiceProvider(this); ControllerDefinition = new ControllerDefinition(); @@ -96,9 +97,26 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS ControllerDefinition.FloatControls.Add("TouchY"); ControllerDefinition.FloatRanges.Add(new ControllerDefinition.FloatRange(0, 96, 191)); - CoreComm = new CoreComm(null, null); + CoreComm = comm; CoreComm.NominalWidth = 256; CoreComm.NominalHeight = 192; + // MelonDS will look for bios + firmware files at specific locations + byte[] fwBytes; + fwBytes = CoreComm.CoreFileProvider.GetFirmware("NDS", "bios7", false); + if (fwBytes != null) + File.WriteAllBytes("melon/bios7.bin", fwBytes); + else + File.Delete("melon/bios7.bin"); + fwBytes = CoreComm.CoreFileProvider.GetFirmware("NDS", "bios9", false); + if (fwBytes != null) + File.WriteAllBytes("melon/bios9.bin", fwBytes); + else + File.Delete("melon/bios9.bin"); + fwBytes = CoreComm.CoreFileProvider.GetFirmware("NDS", "firmware", false); + if (fwBytes != null) + File.WriteAllBytes("melon/firmware.bin", fwBytes); + else + File.Delete("melon/firmware.bin"); if (!Init()) throw new Exception("Failed to init NDS.");