using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.GBA
{
public class LibVBANext
{
const string dllname = "libvbanext.dll";
const CallingConvention cc = CallingConvention.Cdecl;
[Flags]
public enum Buttons : int
{
A = 1,
B = 2,
Select = 4,
Start = 8,
Right = 16,
Left = 32,
Up = 64,
Down = 128,
R = 256,
L = 512
}
[StructLayout(LayoutKind.Sequential)]
public class FrontEndSettings
{
public enum SaveType : int
{
auto = 0,
eeprom = 1,
sram = 2,
flash = 3,
eeprom_sensor = 4,
none = 5
}
public enum FlashSize : int
{
small = 0x10000,
big = 0x20000
}
public SaveType saveType;
public FlashSize flashSize = FlashSize.big;
public bool enableRtc;
public bool mirroringEnable;
public bool skipBios;
public bool RTCUseRealTime = true;
public int RTCyear; // 00..99
public int RTCmonth; // 00..11
public int RTCmday; // 01..31
public int RTCwday; // 00..06
public int RTChour; // 00..23
public int RTCmin; // 00..59
public int RTCsec; // 00..59
}
///
/// create a new context
///
///
[DllImport(dllname, CallingConvention = cc)]
public static extern IntPtr Create();
///
/// destroy a context
///
///
[DllImport(dllname, CallingConvention = cc)]
public static extern void Destroy(IntPtr g);
///
/// load a rom
///
///
///
///
///
///
/// success
[DllImport(dllname, CallingConvention = cc)]
public static extern bool LoadRom(IntPtr g, byte[] romfile, uint romfilelen, byte[] biosfile, uint biosfilelen, [In]FrontEndSettings settings);
///
/// hard reset
///
///
[DllImport(dllname, CallingConvention = cc)]
public static extern void Reset(IntPtr g);
///
/// frame advance
///
///
///
/// 240x160 packed argb32
/// buffer to recieve stereo audio
/// number of samples created
/// true if lagged
[DllImport(dllname, CallingConvention = cc)]
public static extern bool FrameAdvance(IntPtr g, Buttons input, int[] videobuffer, short[] audiobuffer, out int numsamp);
[DllImport(dllname, CallingConvention = cc)]
public static extern int BinStateSize(IntPtr g);
[DllImport(dllname, CallingConvention = cc)]
public static extern bool BinStateSave(IntPtr g, byte[] data, int length);
[DllImport(dllname, CallingConvention = cc)]
public static extern bool BinStateLoad(IntPtr g, byte[] data, int length);
[DllImport(dllname, CallingConvention = cc)]
public static extern void TxtStateSave(IntPtr g, [In]ref TextStateFPtrs ff);
[DllImport(dllname, CallingConvention = cc)]
public static extern void TxtStateLoad(IntPtr g, [In]ref TextStateFPtrs ff);
[DllImport(dllname, CallingConvention = cc)]
public static extern int SaveRamSize(IntPtr g);
[DllImport(dllname, CallingConvention = cc)]
public static extern bool SaveRamSave(IntPtr g, byte[] data, int length);
[DllImport(dllname, CallingConvention = cc)]
public static extern bool SaveRamLoad(IntPtr g, byte[] data, int length);
}
}