From 4456e84bf00c91afb5f9aa2ed7d61c4b80d70b82 Mon Sep 17 00:00:00 2001 From: RetroEdit <30182911+RetroEdit@users.noreply.github.com> Date: Sat, 29 Aug 2020 18:38:02 +0000 Subject: [PATCH] mGBA: Update SaveRAM mem domain to a hardcoded size. (#2311) * Revert "mgba - try resetting sram memdomain after frame advance, so sram autodetection can progress and feed into frontend. addresses #1620, maybe not in the best way" This reverts commit 25327b510dce917566c8b4cb28125b19f12fd9f9. We decided exposing the whole buffer would be better than dealing with a variable size memory domain. * mGBA: Update SaveRAM mem domain to a hardcoded size. --- .../Consoles/Nintendo/GBA/LibmGBA.cs | 1 - .../Nintendo/GBA/MGBAHawk.IMemoryDomains.cs | 17 ++++------------- .../Consoles/Nintendo/GBA/MGBAHawk.cs | 4 ---- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs index e32c533484..4e2bb265f4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs @@ -111,7 +111,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA public IntPtr oam; public IntPtr rom; public IntPtr sram; - public int sram_size; } [BizImport(cc, Compatibility = true)] diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IMemoryDomains.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IMemoryDomains.cs index 3286646d78..2d646a45f9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IMemoryDomains.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IMemoryDomains.cs @@ -31,7 +31,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA mm.Add(_vram = new MemoryDomainIntPtr("VRAM", le, IntPtr.Zero, 96 * 1024, true, 4)); mm.Add(_oam = new MemoryDomainIntPtr("OAM", le, IntPtr.Zero, 1024, true, 4)); mm.Add(_rom = new MemoryDomainIntPtr("ROM", le, IntPtr.Zero, romsize, true, 4)); - mm.Add(_sram = new MemoryDomainIntPtr("SRAM", le, IntPtr.Zero, 0, true, 4)); // size will be fixed in wireup + // 128 KB is the max size for GBA savedata + // mGBA does not know a game's save type (and as a result actual savedata size) on startup. + // Instead, BizHawk's savedata buffer will be accessed directly for a consistent interface. + mm.Add(_sram = new MemoryDomainIntPtr("SRAM", le, IntPtr.Zero, 128 * 1024, true, 4)); mm.Add(_cwram = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, le, null, null, 4)); mm.Add(new MemoryDomainDelegate("System Bus", 0x10000000, le, @@ -60,16 +63,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA WireMemoryDomainPointers(); } - private void WireMemoryDomainPointers_SaveRam() - { - var s = new LibmGBA.MemoryAreas(); - LibmGBA.BizGetMemoryAreas(Core, s); - - _sram.Data = s.sram; - if (s.sram == IntPtr.Zero) s.sram_size = 0; - _sram.SetSize(s.sram_size); - } - private void WireMemoryDomainPointers() { var s = new LibmGBA.MemoryAreas(); @@ -83,8 +76,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA _oam.Data = s.oam; _rom.Data = s.rom; _sram.Data = s.sram; - if (s.sram == IntPtr.Zero) s.sram_size = 0; - _sram.SetSize(s.sram_size); // special combined ram memory domain _cwram.Peek = diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index d7dc7d2783..65ce72e702 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -139,10 +139,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA (short)controller.AxisValue("Tilt Z"), (byte)(255 - controller.AxisValue("Light Sensor"))); - //autodetection may have progressed. - //this isn't a great time to do it, but we have to do it some time. maybe it's the best time. - WireMemoryDomainPointers_SaveRam(); - if (IsLagFrame) { LagCount++;