MelonDS: IStatable (and add forgotten file MelonDS_InputPollable.cs)
This commit is contained in:
parent
d184c8c2d4
commit
dd993b3c37
|
@ -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_Statable.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NDS\MelonDS_VideoProvider.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\APU.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\AVE-NINA.cs" />
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
{
|
||||
partial class MelonDS : IInputPollable
|
||||
{
|
||||
public int LagCount { get => GetLagFrameCount(); set => throw new NotImplementedException(); }
|
||||
public bool IsLagFrame { get => _IsLagFrame(); set => throw new NotImplementedException(); }
|
||||
|
||||
public IInputCallbackSystem InputCallbacks => throw new NotImplementedException();
|
||||
|
||||
[DllImport(dllPath, EntryPoint = "IsLagFrame")]
|
||||
private static extern bool _IsLagFrame();
|
||||
|
||||
[DllImport(dllPath)]
|
||||
private static extern int GetLagFrameCount();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
|
||||
{
|
||||
unsafe partial class MelonDS : IStatable
|
||||
{
|
||||
public bool BinarySaveStatesPreferred => true;
|
||||
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
MemoryStream mStream = new MemoryStream();
|
||||
reader.BaseStream.CopyTo(mStream);
|
||||
|
||||
LoadStateByteArray(mStream.GetBuffer(), (int)mStream.Length);
|
||||
}
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
string str = reader.ReadToEnd();
|
||||
LoadStateByteArray(Convert.FromBase64String(str));
|
||||
}
|
||||
private void LoadStateByteArray(byte[] data, int length = -1)
|
||||
{
|
||||
if (length == -1) length = data.Length;
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
UseSavestate(ptr, length);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] SaveStateBinary()
|
||||
{
|
||||
int len = GetSavestateSize();
|
||||
byte[] ret = new byte[len];
|
||||
fixed (byte* ptr = ret)
|
||||
{
|
||||
GetSavestateData(ptr, len);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
byte[] data = SaveStateBinary();
|
||||
writer.Write(data);
|
||||
}
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
string str = Convert.ToBase64String(SaveStateBinary());
|
||||
writer.Write(str);
|
||||
}
|
||||
|
||||
[DllImport(dllPath)]
|
||||
private static extern void UseSavestate(byte* data, int len);
|
||||
[DllImport(dllPath)]
|
||||
private static extern int GetSavestateSize();
|
||||
[DllImport(dllPath)]
|
||||
private static extern void GetSavestateData(byte* data, int size);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue