using System; using System.Runtime.InteropServices; using BizHawk.Emulation.Common; using System.Text; namespace BizHawk.Emulation.Cores.Computers.MSX { /// /// static bindings into MSXHawk.dll /// public static class LibMSX { # region Core /// opaque state pointer [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MSX_create(); /// opaque state pointer [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_destroy(IntPtr core); /// /// Load BIOS and BASIC image. each must be 16K in size /// /// opaque state pointer /// the rom data, can be disposed of once this function returns /// length of romdata in bytes /// 0 on success, negative value on failure. [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int MSX_load_bios(IntPtr core, byte[] bios, byte[] basic); /// /// Load ROM image. /// /// opaque state pointer /// the rom data, can be disposed of once this function returns /// length of romdata in bytes /// Mapper number to load core with /// the rom data, can be disposed of once this function returns /// length of romdata in bytes /// Mapper number to load core with /// 0 on success, negative value on failure. [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int MSX_load(IntPtr core, byte[] romdata_1, uint length_1, int mapper_1, byte[] romdata_2, uint length_2, int mapper_2); /// /// Advance a frame and send controller data. /// /// opaque state pointer /// controller data for player 1 /// controller data for player 2 /// length of romdata in bytes /// Mapper number to load core with /// 0 on success, negative value on failure. [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool MSX_frame_advance(IntPtr core, byte ctrl1, byte ctrl2, byte[] kbrows, bool render, bool sound); /// /// Get Video data /// /// opaque state pointer /// where to send video to [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_get_video(IntPtr core, int[] videobuf); /// /// Get Video data /// /// opaque state pointer /// where to send left audio to /// number of left samples [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern uint MSX_get_audio(IntPtr core, int[] aud_buf, ref uint n_samp); #endregion #region State Save / Load /// /// Save State /// /// opaque state pointer /// save buffer [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_save_state(IntPtr core, byte[] saver); /// /// Load State /// /// opaque state pointer /// load buffer [DllImport("MSXHAWK.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_load_state(IntPtr core, byte[] loader); #endregion #region Memory Domain Functions /// /// Read the system bus /// /// opaque state pointer /// system bus address [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern byte MSX_getsysbus(IntPtr core, int addr); /// /// Read the VRAM /// /// opaque state pointer /// vram address [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern byte MSX_getvram(IntPtr core, int addr); /// /// Read the RAM /// /// opaque state pointer /// ram address [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern byte MSX_getram(IntPtr core, int addr); #endregion #region Tracer /// /// type of the cpu trace callback /// /// type of event [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void TraceCallback(int t); /// /// set a callback for trace logging /// /// opaque state pointer /// null to clear [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_settracecallback(IntPtr core, TraceCallback callback); /// /// get the trace logger header length /// /// opaque state pointer [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int MSX_getheaderlength(IntPtr core); /// /// get the trace logger disassembly length, a constant /// /// opaque state pointer [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int MSX_getdisasmlength(IntPtr core); /// /// get the trace logger register string length, a constant /// /// opaque state pointer [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int MSX_getregstringlength(IntPtr core); /// /// get the trace logger header /// /// opaque state pointer /// pointer to const char * /// null to clear [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_getheader(IntPtr core, StringBuilder h, int l); /// /// get the register state from the cpu /// /// opaque state pointer /// pointer to const char * /// call type /// copy length, must be obtained from appropriate get legnth function [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_getregisterstate(IntPtr core, StringBuilder h, int t, int l); /// /// get the register state from the cpu /// /// opaque state pointer /// pointer to const char * /// call type /// copy length, must be obtained from appropriate get legnth function [DllImport("MSXHawk.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void MSX_getdisassembly(IntPtr core, StringBuilder h, int t, int l); #endregion } }