From acff619034198c93e32a8a8ed817cf0085954342 Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Sun, 17 Sep 2023 12:37:37 -0700 Subject: [PATCH] add more mmap heap to melonds, check against 0 sized arrays in roms --- .../Consoles/Nintendo/NDS/MelonDS.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index 3eae020769..a8596b09cc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -47,6 +47,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS _coreFiles.Add(path, file); } + private void AddCoreFile(string path, byte[] file) + { + if (file.Length == 0) + { + throw new InvalidOperationException($"Tried to add 0-sized core file to {path}"); + } + + _coreFiles.Add(path, file); + } + private readonly LibMelonDS.LogCallback _logCallback; private static void LogCallback(LibMelonDS.LogLevel level, string message) @@ -107,7 +117,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS SealedHeapSizeKB = 4, InvisibleHeapSizeKB = 4 * 1024, PlainHeapSizeKB = 4, - MmapHeapSizeKB = 1024 * 1024, + MmapHeapSizeKB = 1152 * 1024, SkipCoreConsistencyCheck = CoreComm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck), SkipMemoryConsistencyCheck = CoreComm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck), }, new Delegate[] @@ -148,15 +158,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS if (IsDSiWare) { - _coreFiles.Add("tmd.rom", GetTMDData(DSiTitleId.Full)); - _coreFiles.Add("dsiware.rom", roms[0]); + AddCoreFile("tmd.rom", GetTMDData(DSiTitleId.Full)); + AddCoreFile("dsiware.rom", roms[0]); } else { - _coreFiles.Add("nds.rom", roms[0]); + AddCoreFile("nds.rom", roms[0]); if (gbacartpresent) { - _coreFiles.Add("gba.rom", roms[1]); + AddCoreFile("gba.rom", roms[1]); } }