From f0c8bd384260f9b6ffbabd00762aa0cee4cbd6cd Mon Sep 17 00:00:00 2001 From: goyuken Date: Wed, 13 Aug 2014 17:52:13 +0000 Subject: [PATCH] IEmulator: clarify naming and implementations so it's clear that CloneSaveRam() always returns a clone that you can do whatever you want with (but won't modify the underlying) --- BizHawk.Client.EmuHawk/MainForm.cs | 4 ++-- .../Interfaces/Base Implementations/NullEmulator.cs | 2 +- BizHawk.Emulation.Common/Interfaces/IEmulator.cs | 2 +- BizHawk.Emulation.Cores/Calculator/TI83.cs | 2 +- .../Computers/Commodore64/C64.Savestate.cs | 2 +- .../Consoles/Atari/2600/Atari2600.cs | 2 +- .../Consoles/Atari/7800/Atari7800.cs | 2 +- .../Consoles/Coleco/ColecoVision.cs | 2 +- .../Consoles/Intellivision/Intellivision.cs | 2 +- .../Consoles/Nintendo/GBA/Meteor.cs | 2 +- .../Consoles/Nintendo/GBA/VBANext.cs | 2 +- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 2 +- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 10 +++++----- .../Consoles/Nintendo/N64/N64.cs | 2 +- .../Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs | 2 +- .../Consoles/Nintendo/NES/NES.cs | 2 +- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 4 ++-- .../Consoles/Nintendo/SNES/LibsnesCore.cs | 2 +- .../Consoles/Nintendo/SNES9X/Snes9x.cs | 2 +- .../Consoles/PC Engine/PCEngine.cs | 2 +- .../Consoles/Sega/Genesis/Cart/SaveRAM.cs | 2 +- BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs | 2 +- .../Consoles/Sega/Saturn/Yabause.cs | 13 ++++++++++--- BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs | 13 ++++++++++--- BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs | 2 +- .../Consoles/Sony/PSX/Octoshock.cs | 2 +- .../Consoles/WonderSwan/WonderSwan.cs | 4 ++-- BizHawk.Emulation.Cores/LibRetroEmulator.cs | 4 ++-- 28 files changed, 54 insertions(+), 40 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 10efe46701..921d9cbd0e 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1354,7 +1354,7 @@ namespace BizHawk.Client.EmuHawk } else { - var oldram = Global.Emulator.ReadSaveRam(); + var oldram = Global.Emulator.CloneSaveRam(); if (oldram == null) { // we're eating this one now. the possible negative consequence is that a user could lose @@ -1401,7 +1401,7 @@ namespace BizHawk.Client.EmuHawk } var writer = new BinaryWriter(new FileStream(path, FileMode.Create, FileAccess.Write)); - var saveram = Global.Emulator.ReadSaveRam(); + var saveram = Global.Emulator.CloneSaveRam(); writer.Write(saveram, 0, saveram.Length); writer.Close(); diff --git a/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs index 1eb1919b80..323b7c82d9 100644 --- a/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/Base Implementations/NullEmulator.cs @@ -72,7 +72,7 @@ namespace BizHawk.Emulation.Common public int LagCount { get { return 0; } set { return; } } public bool IsLagFrame { get { return false; } } - public byte[] ReadSaveRam() { return null; } + public byte[] CloneSaveRam() { return null; } public void StoreSaveRam(byte[] data) { } public void ClearSaveRam() { } public bool DeterministicEmulation { get { return true; } } diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs index c19bed4cca..c8cf194262 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs @@ -81,7 +81,7 @@ namespace BizHawk.Emulation.Common /// /// return a copy of the saveram. editing it won't do you any good unless you later call StoreSaveRam() /// - byte[] ReadSaveRam(); + byte[] CloneSaveRam(); /// /// store new saveram to the emu core. the data should be the same size as the return from ReadSaveRam() diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs index f02f0a8b50..ed43b2451f 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -523,7 +523,7 @@ namespace BizHawk.Emulation.Cores.Calculators public bool DeterministicEmulation { get { return true; } } - public byte[] ReadSaveRam() { return null; } + public byte[] CloneSaveRam() { return null; } public void StoreSaveRam(byte[] data) { } public void ClearSaveRam() { } public bool SaveRamModified diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Savestate.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Savestate.cs index 23ca60d9ce..56ff285325 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Savestate.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Savestate.cs @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 SyncState(new Serializer(reader)); } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return null; } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index 930ea763a1..ede75061c8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -249,7 +249,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.EndSection(); } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return null; } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs index 57469f89c4..2aeebeee42 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs @@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 private int _frame = 0; #region saveram - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return (byte[])hsram.Clone(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index bb08b4d8e0..1fc11ce9d2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -169,7 +169,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision } } - public byte[] ReadSaveRam() { return null; } + public byte[] CloneSaveRam() { return null; } public void StoreSaveRam(byte[] data) { } public void ClearSaveRam() { } public bool SaveRamModified { get; set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 8efc68f663..05415ecb1f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -161,7 +161,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public bool DeterministicEmulation { get { return true; } } - public byte[] ReadSaveRam() { return null; } + public byte[] CloneSaveRam() { return null; } public void StoreSaveRam(byte[] data) { } public void ClearSaveRam() { } public bool SaveRamModified diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs index f1b2f5153d..1d29dd04bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs @@ -105,7 +105,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA #region saveram - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (disposed) throw new ObjectDisposedException(this.GetType().ToString()); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 7898b2d6df..df1afe83de 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -106,7 +106,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA #region SaveRam - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return new byte[16]; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 389c0c3786..c576863f5c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -453,7 +453,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy #region saveram - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { int length = LibGambatte.gambatte_savesavedatalength(GambatteState); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index a0c39617ab..a2bee3d221 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -231,10 +231,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy #region saveram - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { - byte[] lb = L.ReadSaveRam(); - byte[] rb = R.ReadSaveRam(); + byte[] lb = L.CloneSaveRam(); + byte[] rb = R.CloneSaveRam(); byte[] ret = new byte[lb.Length + rb.Length]; Buffer.BlockCopy(lb, 0, ret, 0, lb.Length); Buffer.BlockCopy(rb, 0, ret, lb.Length, rb.Length); @@ -243,8 +243,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public void StoreSaveRam(byte[] data) { - byte[] lb = new byte[L.ReadSaveRam().Length]; - byte[] rb = new byte[R.ReadSaveRam().Length]; + byte[] lb = new byte[L.CloneSaveRam().Length]; + byte[] rb = new byte[R.CloneSaveRam().Length]; Buffer.BlockCopy(data, 0, lb, 0, lb.Length); Buffer.BlockCopy(data, lb.Length, rb, 0, rb.Length); L.StoreSaveRam(lb); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 565dd143fa..558704668e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -276,7 +276,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public bool DeterministicEmulation { get { return false; } } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return api.SaveSaveram(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs index 8a288ca70d..c6506ccc10 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusCoreApi.cs @@ -577,7 +577,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi { if (saveram_backup != null) { - return saveram_backup; + return (byte[])saveram_backup.Clone(); } else { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index d8338adfc6..f43b7b45a9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -323,7 +323,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (board is FDS) return (board as FDS).ReadSaveRam(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 8f8fedcf5e..656f9fa666 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -190,10 +190,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES SaveRamBuff = new byte[size]; } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { LibQuickNES.ThrowStringError(LibQuickNES.qn_battery_ram_save(Context, SaveRamBuff, SaveRamBuff.Length)); - return SaveRamBuff; + return (byte[])SaveRamBuff.Clone(); } public void StoreSaveRam(byte[] data) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 774f34214f..cb698d4c98 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -737,7 +737,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES } } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { byte* buf = api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM); var size = api.QUERY_get_memory_size(LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index 8b5946fc72..e24844aa6a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -62,7 +62,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X #region saveram - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return new byte[0]; } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 441090145b..089f9af9e4 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -357,7 +357,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public string Region { get; set; } public bool DeterministicEmulation { get { return true; } } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (BRAM != null) return (byte[])BRAM.Clone(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Cart/SaveRAM.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Cart/SaveRAM.cs index c5c8244f28..c0ba470fed 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Cart/SaveRAM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Cart/SaveRAM.cs @@ -41,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis Console.WriteLine("SaveRAM enabled. Start: ${0:X6} End: ${1:X6} Length: ${2:X} Mode: {3}", SaveRamStartOffset, SaveRamEndOffset, SaveRamLength, RH_SRamInterpretation()); } - public byte[] ReadSaveRam() { return (byte[])SaveRAM.Clone(); } + public byte[] CloneSaveRam() { return (byte[])SaveRAM.Clone(); } public void StoreSaveRam(byte[] data) { Array.Copy(data, SaveRAM, data.Length); } public void ClearSaveRam() { SaveRAM = new byte[SaveRAM.Length]; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index 7e5c2996b9..d9cfa2f7b6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public byte[] BiosRom; - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (SaveRAM != null) return (byte[])SaveRAM.Clone(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 9e9cea4c4b..4dedb9da58 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -308,11 +308,18 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn #region saveram - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (Disposed) { - return DisposedSaveRam ?? new byte[0]; + if (DisposedSaveRam != null) + { + return (byte[])DisposedSaveRam.Clone(); + } + else + { + return new byte[0]; + } } else { @@ -554,7 +561,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn { ActivateGL(); if (SaveRamModified) - DisposedSaveRam = ReadSaveRam(); + DisposedSaveRam = CloneSaveRam(); LibYabause.libyabause_setvidbuff(IntPtr.Zero); LibYabause.libyabause_setsndbuff(IntPtr.Zero); LibYabause.libyabause_deinit(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index a77d572f2e..c4213e13f3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -412,11 +412,18 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx byte[] DisposedSaveRam = null; - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (disposed) { - return DisposedSaveRam ?? new byte[0]; + if (DisposedSaveRam != null) + { + return (byte[])DisposedSaveRam.Clone(); + } + else + { + return new byte[0]; + } } else { @@ -652,7 +659,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx if (AttachedCore != this) throw new Exception(); if (SaveRamModified) - DisposedSaveRam = ReadSaveRam(); + DisposedSaveRam = CloneSaveRam(); KillMemCallbacks(); AttachedCore = null; disposed = true; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index 15b285d973..d6800bc4a7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP get { return true; } } - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { return new byte[0]; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 2b59f01eb3..9ee273b3c0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -271,7 +271,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public int LagCount { get { return 0; } set { return; } } public bool IsLagFrame { get { return false; } } - public byte[] ReadSaveRam() { return null; } + public byte[] CloneSaveRam() { return null; } public void StoreSaveRam(byte[] data) { } public void ClearSaveRam() { } public bool DeterministicEmulation { get { return true; } } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index affbba05ef..f63bf09adc 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -185,11 +185,11 @@ namespace BizHawk.Emulation.Cores.WonderSwan byte[] saverambuff; - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { if (!BizSwan.bizswan_saveramsave(Core, saverambuff, saverambuff.Length)) throw new InvalidOperationException("bizswan_saveramsave() returned false!"); - return saverambuff; + return (byte[])saverambuff.Clone(); } public void StoreSaveRam(byte[] data) diff --git a/BizHawk.Emulation.Cores/LibRetroEmulator.cs b/BizHawk.Emulation.Cores/LibRetroEmulator.cs index b4d219c6b5..9c1bbc1c67 100644 --- a/BizHawk.Emulation.Cores/LibRetroEmulator.cs +++ b/BizHawk.Emulation.Cores/LibRetroEmulator.cs @@ -243,7 +243,7 @@ namespace BizHawk.Emulation.Cores byte[] saverambuff = new byte[0]; - public byte[] ReadSaveRam() + public byte[] CloneSaveRam() { int size = (int)retro.retro_get_memory_size(LibRetro.RETRO_MEMORY.SAVE_RAM); if (saverambuff.Length != size) @@ -254,7 +254,7 @@ namespace BizHawk.Emulation.Cores throw new Exception("retro_get_memory_data(RETRO_MEMORY_SAVE_RAM) returned NULL"); Marshal.Copy(src, saverambuff, 0, size); - return saverambuff; + return (byte[])saverambuff.Clone(); } public void StoreSaveRam(byte[] data)