2014-08-08 00:55:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Runtime.InteropServices;
|
2014-08-08 20:01:09 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2014-08-08 00:55:33 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// create a new context
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[DllImport(dllname, CallingConvention = cc)]
|
|
|
|
|
public static extern IntPtr Create();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// destroy a context
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="g"></param>
|
|
|
|
|
[DllImport(dllname, CallingConvention = cc)]
|
|
|
|
|
public static extern void Destroy(IntPtr g);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// load a rom
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="g"></param>
|
|
|
|
|
/// <param name="romfile"></param>
|
|
|
|
|
/// <param name="romfilelen"></param>
|
|
|
|
|
/// <param name="biosfile"></param>
|
|
|
|
|
/// <param name="biosfilelen"></param>
|
|
|
|
|
/// <returns>success</returns>
|
|
|
|
|
[DllImport(dllname, CallingConvention = cc)]
|
|
|
|
|
public static extern bool LoadRom(IntPtr g, byte[] romfile, uint romfilelen, byte[] biosfile, uint biosfilelen);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// hard reset
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="g"></param>
|
|
|
|
|
[DllImport(dllname, CallingConvention = cc)]
|
|
|
|
|
public static extern void Reset(IntPtr g);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// frame advance
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="g"></param>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <param name="videobuffer">240x160 packed argb32</param>
|
2014-08-08 04:09:50 +00:00
|
|
|
|
/// <param name="audiobuffer">buffer to recieve stereo audio</param>
|
|
|
|
|
/// <param name="numsamp">number of samples created</param>
|
|
|
|
|
/// <returns>true if lagged</returns>
|
2014-08-08 00:55:33 +00:00
|
|
|
|
[DllImport(dllname, CallingConvention = cc)]
|
2014-08-08 04:09:50 +00:00
|
|
|
|
public static extern bool FrameAdvance(IntPtr g, Buttons input, int[] videobuffer, short[] audiobuffer, out int numsamp);
|
2014-08-08 20:01:09 +00:00
|
|
|
|
|
|
|
|
|
[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);
|
2014-08-08 00:55:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|