BizHawk/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.ISaveRam.cs

52 lines
947 B
C#
Raw Normal View History

using System;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Atari.Lynx
{
2017-04-15 20:37:30 +00:00
public partial class Lynx : ISaveRam
{
public byte[] CloneSaveRam()
{
int size;
IntPtr data;
if (!LibLynx.GetSaveRamPtr(Core, out size, out data))
2017-04-24 16:51:59 +00:00
{
2017-04-15 20:37:30 +00:00
return null;
2017-04-24 16:51:59 +00:00
}
2017-04-15 20:37:30 +00:00
byte[] ret = new byte[size];
Marshal.Copy(data, ret, 0, size);
return ret;
}
2017-04-15 20:37:30 +00:00
public void StoreSaveRam(byte[] srcdata)
{
int size;
IntPtr data;
if (!LibLynx.GetSaveRamPtr(Core, out size, out data))
2017-04-24 16:51:59 +00:00
{
2017-04-15 20:37:30 +00:00
throw new InvalidOperationException();
2017-04-24 16:51:59 +00:00
}
2017-04-15 20:37:30 +00:00
if (size != srcdata.Length)
2017-04-24 16:51:59 +00:00
{
2017-04-15 20:37:30 +00:00
throw new ArgumentOutOfRangeException();
2017-04-24 16:51:59 +00:00
}
2017-04-15 20:37:30 +00:00
Marshal.Copy(srcdata, 0, data, size);
}
2017-04-15 20:37:30 +00:00
public bool SaveRamModified
{
get
{
int unused;
IntPtr unused2;
return LibLynx.GetSaveRamPtr(Core, out unused, out unused2);
}
}
}
}