using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace BizHawk.Emulation.Consoles.Nintendo.GBA { /// /// bindings into libmeteor.dll /// public static class LibMeteor { /// /// reset the emulation core /// [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_reset(); /// /// signal that you are removing data from the sound buffer. /// the next time frameadvance() is called, writing will start from the beginning /// /// the valid length of the buffer, in bytes [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern uint libmeteor_emptysound(); /// /// set up buffers for libmeteor to dump data to. these must be valid before every frameadvance /// /// buffer to hold video data as BGRA32 /// length in bytes. must be at least 240 * 160 * 4 /// buffer to hold audio data as stereo s16le /// length in bytes. must be 0 mod 4 (hold a full stereo sample set) /// false if some problem. buffers will not be valid in this case [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool libmeteor_setbuffers(IntPtr vid, uint vidlen, IntPtr aud, uint audlen); /// /// initialize the library /// [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_init(); /// /// run emulation for one frame, updating sound and video along the way /// [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_frameadvance(); /// /// load a rom image /// /// raw rom data. need not persist past this call /// length of data in bytes [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_loadrom(byte[] data, uint datalen); /// /// load a bios image /// /// raw bios data. need not persist past this call /// length of data in bytes [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_loadbios(byte[] data, uint datalen); /// /// core callback to print meaningful (or meaningless) log messages /// /// message to be printed /// true if emulation should be aborted [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void MessageCallback(string msg, bool abort); /// /// set callback for log messages. this can (and should) be called first /// /// [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_setmessagecallback(MessageCallback cb); /// /// combination of button flags used by the key callback /// [Flags] public enum Buttons : ushort { BTN_A = 0x001, BTN_B = 0x002, BTN_SELECT = 0x004, BTN_START = 0x008, BTN_RIGHT = 0x010, BTN_LEFT = 0x020, BTN_UP = 0x040, BTN_DOWN = 0x080, BTN_R = 0x100, BTN_L = 0x200 } /// /// core callback to get input state /// /// buttons pressed bitfield [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate Buttons InputCallback(); /// /// set callback for whenever input is requested /// /// [DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void libmeteor_setkeycallback(InputCallback callback); } }