MelonDS: ISaveRam

This commit is contained in:
SuuperW 2019-10-18 14:37:58 -05:00
parent 69aee123bf
commit 66542312a4
2 changed files with 46 additions and 0 deletions

View File

@ -988,6 +988,7 @@
<Compile Include="Consoles\Nintendo\N64\NativeApi\mupen64plusVideoApi.cs" />
<Compile Include="Consoles\Nintendo\NDS\MelonDS.cs" />
<Compile Include="Consoles\Nintendo\NDS\MelonDS_InputPollable.cs" />
<Compile Include="Consoles\Nintendo\NDS\MelonDS_SaveRam.cs" />
<Compile Include="Consoles\Nintendo\NDS\MelonDS_SoundProvider.cs" />
<Compile Include="Consoles\Nintendo\NDS\MelonDS_Statable.cs" />
<Compile Include="Consoles\Nintendo\NDS\MelonDS_VideoProvider.cs" />

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{
unsafe partial class MelonDS : ISaveRam
{
public bool SaveRamModified => IsSRAMModified();
public byte[] CloneSaveRam()
{
int length = GetSRAMLength();
byte[] data = new byte[length];
fixed (byte* dst = data)
{
GetSRAM(dst, length);
}
return data;
}
public void StoreSaveRam(byte[] data)
{
fixed (byte* src = data)
{
SetSRAM(src, data.Length);
}
}
[DllImport(dllPath)]
private static extern int GetSRAMLength();
[DllImport(dllPath)]
private static extern bool IsSRAMModified();
[DllImport(dllPath)]
private static extern void GetSRAM(byte* dst, int length);
[DllImport(dllPath)]
private static extern void SetSRAM(byte* src, int length);
}
}