diff --git a/Assets/dll/bsnes.wbx.gz b/Assets/dll/bsnes.wbx.gz index cf02e454ef..9fc7feb00c 100644 Binary files a/Assets/dll/bsnes.wbx.gz and b/Assets/dll/bsnes.wbx.gz differ diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs index 4764a9e4f6..6ed3d30313 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesApi.cs @@ -115,10 +115,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES { Filename = "bsnes.wbx", Path = dllPath, - SbrkHeapSizeKB = 14 * 1024, - InvisibleHeapSizeKB = 4, - MmapHeapSizeKB = 110 * 1024, // TODO: check whether this needs to be larger; it depends on the rom size - PlainHeapSizeKB = 0, + SbrkHeapSizeKB = 12 * 1024, + InvisibleHeapSizeKB = 136 * 1024, // TODO: Roms get saved here and in mmap, consider consolidating? + MmapHeapSizeKB = 33 * 1024, // TODO: check whether this needs to be larger; it depends on the rom size + PlainHeapSizeKB = 1 * 1024, SealedHeapSizeKB = 0, SkipCoreConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck), SkipMemoryConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck), diff --git a/waterbox/bsnescore/bsnes/sfc/memory/memory.cpp b/waterbox/bsnescore/bsnes/sfc/memory/memory.cpp index 4b76009681..144e0d6566 100644 --- a/waterbox/bsnescore/bsnes/sfc/memory/memory.cpp +++ b/waterbox/bsnescore/bsnes/sfc/memory/memory.cpp @@ -6,8 +6,9 @@ bool Memory::GlobalWriteEnable = false; Bus bus; Bus::~Bus() { - if(lookup) delete[] lookup; - if(target) delete[] target; + //if(lookup) delete[] lookup; + //if(target) delete[] target; + abort(); } auto Bus::reset() -> void { @@ -17,11 +18,14 @@ auto Bus::reset() -> void { counter[id] = 0; } - if(lookup) delete[] lookup; - if(target) delete[] target; + //if(lookup) delete[] lookup; + //if(target) delete[] target; - lookup = new uint8 [16 * 1024 * 1024](); - target = new uint32[16 * 1024 * 1024](); + //lookup = new uint8 [16 * 1024 * 1024](); + //target = new uint32[16 * 1024 * 1024](); + + if (!lookup) lookup = alloc_invisible (16 * 1024 * 1024); + if (!target) target = alloc_invisible(16 * 1024 * 1024); reader[0] = [](uint, uint8 data) -> uint8 { return data; }; writer[0] = [](uint, uint8) -> void {}; diff --git a/waterbox/bsnescore/bsnes/sfc/memory/protectable.hpp b/waterbox/bsnescore/bsnes/sfc/memory/protectable.hpp index a6f8a5b384..c2afc9fb2e 100644 --- a/waterbox/bsnescore/bsnes/sfc/memory/protectable.hpp +++ b/waterbox/bsnescore/bsnes/sfc/memory/protectable.hpp @@ -1,14 +1,18 @@ struct ProtectableMemory : Memory { inline auto reset() -> void override { - delete[] self.data; - self.data = nullptr; - self.size = 0; + //delete[] self.data; + //self.data = nullptr; + //self.size = 0; } inline auto allocate(uint size, uint8 fill = 0xff) -> void override { + if (!self.data) { + self.data = alloc_plain(self.size = size); + } if(self.size != size) { - delete[] self.data; - self.data = new uint8[self.size = size]; + //delete[] self.data; + //self.data = new uint8[self.size = size]; + abort(); } for(uint address : range(size)) { self.data[address] = fill; diff --git a/waterbox/bsnescore/bsnes/sfc/memory/readable.hpp b/waterbox/bsnescore/bsnes/sfc/memory/readable.hpp index fcaf14b334..ad1a83b7a6 100644 --- a/waterbox/bsnescore/bsnes/sfc/memory/readable.hpp +++ b/waterbox/bsnescore/bsnes/sfc/memory/readable.hpp @@ -1,14 +1,18 @@ struct ReadableMemory : Memory { inline auto reset() -> void override { - delete[] self.data; - self.data = nullptr; - self.size = 0; + //delete[] self.data; + //self.data = nullptr; + //self.size = 0; } inline auto allocate(uint size, uint8 fill = 0xff) -> void override { + if (!self.data) { + self.data = alloc_invisible(self.size = size); + } if(self.size != size) { - delete[] self.data; - self.data = new uint8[self.size = size]; + //delete[] self.data; + //self.data = new uint8[self.size = size]; + abort(); } for(uint address : range(size)) { self.data[address] = fill; diff --git a/waterbox/bsnescore/bsnes/sfc/memory/writable.hpp b/waterbox/bsnescore/bsnes/sfc/memory/writable.hpp index 7d51303fc5..f68cff0e2e 100644 --- a/waterbox/bsnescore/bsnes/sfc/memory/writable.hpp +++ b/waterbox/bsnescore/bsnes/sfc/memory/writable.hpp @@ -1,14 +1,18 @@ struct WritableMemory : Memory { inline auto reset() -> void override { - delete[] self.data; - self.data = nullptr; - self.size = 0; + //delete[] self.data; + //self.data = nullptr; + //self.size = 0; } inline auto allocate(uint size, uint8 fill = 0xff) -> void override { + if (!self.data) { + self.data = alloc_plain(self.size = size); + } if(self.size != size) { - delete[] self.data; - self.data = new uint8[self.size = size]; + //delete[] self.data; + //self.data = new uint8[self.size = size]; + abort(); } for(uint address : range(size)) { self.data[address] = fill; diff --git a/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.cpp b/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.cpp index 53d1212d78..18f84d2702 100644 --- a/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.cpp +++ b/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.cpp @@ -34,10 +34,12 @@ auto PPU::noVRAMBlocking() const -> bool { return configuration.hacks.ppu.noVRAM #define ppu ppufast PPU::PPU() { - output = new uint16_t[2304 * 2160](); + //output = new uint16_t[2304 * 2160](); + output = alloc_invisible(2304 * 2160); for(uint l : range(16)) { - lightTable[l] = new uint16_t[32768]; + //lightTable[l] = new uint16_t[32768]; + lightTable[l] = alloc_invisible(32768); for(uint r : range(32)) { for(uint g : range(32)) { for(uint b : range(32)) { @@ -51,14 +53,17 @@ PPU::PPU() { } } + lines = alloc_invisible(240); + for(uint y : range(240)) { lines[y].y = y; } } PPU::~PPU() { - delete[] output; - for(uint l : range(16)) delete[] lightTable[l]; + //delete[] output; + //for(uint l : range(16)) delete[] lightTable[l]; + abort(); } auto PPU::synchronizeCPU() -> void { diff --git a/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.hpp b/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.hpp index 3a076083cc..b4857ebb75 100644 --- a/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.hpp +++ b/waterbox/bsnescore/bsnes/sfc/ppu-fast/ppu.hpp @@ -351,7 +351,8 @@ public: }; //unserialized: - Line lines[240]; + //Line lines[240]; + Line* lines; //used to help detect when the video output size changes between frames to clear overscan area. struct Frame { diff --git a/waterbox/bsnescore/bsnes/sfc/sfc.hpp b/waterbox/bsnescore/bsnes/sfc/sfc.hpp index eae1eb5407..51b9d218e5 100644 --- a/waterbox/bsnescore/bsnes/sfc/sfc.hpp +++ b/waterbox/bsnescore/bsnes/sfc/sfc.hpp @@ -3,6 +3,8 @@ //license: GPLv3 //started: 2004-10-14 +#include + #include #include #include