2012-09-08 20:22:07 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
2013-11-13 03:32:25 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
2012-09-08 20:22:07 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// static bindings into libgambatte.dll
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class LibGambatte
|
|
|
|
|
{
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>opaque state pointer</returns>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern IntPtr gambatte_create();
|
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_destroy(IntPtr core);
|
|
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
|
public enum LoadFlags : uint
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Treat the ROM as not having CGB support regardless of what its header advertises</summary>
|
|
|
|
|
FORCE_DMG = 1,
|
|
|
|
|
/// <summary>Use GBA intial CPU register values when in CGB mode.</summary>
|
|
|
|
|
GBA_CGB = 2,
|
|
|
|
|
/// <summary>Use heuristics to detect and support some multicart MBCs disguised as MBC1.</summary>
|
2014-05-03 03:05:34 +00:00
|
|
|
|
MULTICART_COMPAT = 4
|
2012-09-08 20:22:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Load ROM image.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2012-09-09 21:15:54 +00:00
|
|
|
|
/// <param name="romdata">the rom data, can be disposed of once this function returns</param>
|
|
|
|
|
/// <param name="length">length of romdata in bytes</param>
|
2013-05-09 23:15:59 +00:00
|
|
|
|
/// <param name="now">RTC time when the rom is loaded</param>
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <param name="flags">ORed combination of LoadFlags.</param>
|
2012-09-08 21:36:04 +00:00
|
|
|
|
/// <returns>0 on success, negative value on failure.</returns>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2013-05-09 23:15:59 +00:00
|
|
|
|
public static extern int gambatte_load(IntPtr core, byte[] romdata, uint length, long now, LoadFlags flags);
|
2012-09-08 20:22:07 +00:00
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Emulates until at least 'samples' stereo sound samples are produced in the supplied buffer,
|
|
|
|
|
/// or until a video frame has been drawn.
|
|
|
|
|
///
|
|
|
|
|
/// There are 35112 stereo sound samples in a video frame.
|
|
|
|
|
/// May run for up to 2064 stereo samples too long.
|
|
|
|
|
/// A stereo sample consists of two native endian 2s complement 16-bit PCM samples,
|
|
|
|
|
/// with the left sample preceding the right one.
|
|
|
|
|
///
|
|
|
|
|
/// Returns early when a new video frame has finished drawing in the video buffer,
|
|
|
|
|
/// such that the caller may update the video output before the frame is overwritten.
|
|
|
|
|
/// The return value indicates whether a new video frame has been drawn, and the
|
|
|
|
|
/// exact time (in number of samples) at which it was drawn.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="soundbuf">buffer with space >= samples + 2064</param>
|
|
|
|
|
/// <param name="samples">in: number of stereo samples to produce, out: actual number of samples produced</param>
|
|
|
|
|
/// <returns>sample number at which the video frame was produced. -1 means no frame was produced.</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2014-05-03 03:05:34 +00:00
|
|
|
|
public static extern int gambatte_runfor(IntPtr core, short[] soundbuf, ref uint samples);
|
2012-12-29 15:48:30 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2014-05-03 03:05:34 +00:00
|
|
|
|
unsafe public static extern int gambatte_runfor(IntPtr core, short* soundbuf, ref uint samples);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// blit from internal framebuffer to provided framebuffer
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="videobuf"></param>
|
|
|
|
|
/// <param name="pitch">in pixels</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
unsafe public static extern void gambatte_blitto(IntPtr core, int* videobuf, int pitch);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// blit from internal framebuffer to provided framebuffer
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="videobuf"></param>
|
|
|
|
|
/// <param name="pitch">in pixels</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_blitto(IntPtr core, int[] videobuf, int pitch);
|
2012-09-08 20:46:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reset to initial state.
|
|
|
|
|
/// Equivalent to reloading a ROM image, or turning a Game Boy Color off and on again.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2013-05-09 23:15:59 +00:00
|
|
|
|
/// <param name="now">RTC time when the reset occurs</param>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2013-05-09 23:15:59 +00:00
|
|
|
|
public static extern void gambatte_reset(IntPtr core, long now);
|
2012-09-08 20:22:07 +00:00
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// palette type for gambatte_setdmgpalettecolor
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum PalType : uint
|
|
|
|
|
{
|
|
|
|
|
BG_PALETTE = 0,
|
|
|
|
|
SP1_PALETTE = 1,
|
|
|
|
|
SP2_PALETTE = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2012-09-12 22:18:51 +00:00
|
|
|
|
/// <param name="palnum">in [0, 2]: One of BG_PALETTE, SP1_PALETTE and SP2_PALETTE.</param>
|
|
|
|
|
/// <param name="colornum">in [0, 3]</param>
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <param name="rgb32"></param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_setdmgpalettecolor(IntPtr core, PalType palnum, uint colornum, uint rgb32);
|
|
|
|
|
|
2012-11-18 17:02:55 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// set cgb palette lookup
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2013-12-23 02:51:41 +00:00
|
|
|
|
/// <param name="lut">uint32[32768], input color (r,g,b) is at lut[r | g << 5 | b << 10]</param>
|
2012-11-18 17:02:55 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2012-11-19 17:59:57 +00:00
|
|
|
|
public static extern void gambatte_setcgbpalette(IntPtr core, int[] lut);
|
2012-11-18 17:02:55 +00:00
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// combination of button flags used by the input callback
|
|
|
|
|
/// </summary>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[Flags]
|
|
|
|
|
public enum Buttons
|
2014-05-03 03:05:34 +00:00
|
|
|
|
{
|
2012-09-08 20:22:07 +00:00
|
|
|
|
A = 0x01,
|
|
|
|
|
B = 0x02,
|
|
|
|
|
SELECT = 0x04,
|
|
|
|
|
START = 0x08,
|
|
|
|
|
RIGHT = 0x10,
|
|
|
|
|
LEFT = 0x20,
|
|
|
|
|
UP = 0x40,
|
|
|
|
|
DOWN = 0x80
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 14:17:57 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// type of the callback for input state
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>bitfield combination of pressed buttons</returns>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
public delegate Buttons InputGetter();
|
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the callback used for getting input state.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="getinput"></param>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2012-09-09 14:17:57 +00:00
|
|
|
|
public static extern void gambatte_setinputgetter(IntPtr core, InputGetter getinput);
|
2012-09-08 20:22:07 +00:00
|
|
|
|
|
2012-10-14 15:10:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// type of the read\write memory callbacks
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="address">the address which the cpu is read\writing</param>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
public delegate void MemoryCallback(uint address);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-11-13 17:08:52 +00:00
|
|
|
|
/// set a callback to occur immediately BEFORE EVERY cpu read, except for opcode first byte fetches
|
2012-10-14 15:10:33 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="callback">null to clear</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_setreadcallback(IntPtr core, MemoryCallback callback);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// set a callback to occur immediately AFTER EVERY cpu write
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="callback">null to clear</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_setwritecallback(IntPtr core, MemoryCallback callback);
|
|
|
|
|
|
2013-11-13 17:08:52 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// set a callback to occur immediately BEFORE EVERY cpu opcode (first byte) fetch
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="callback">null to clear</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_setexeccallback(IntPtr core, MemoryCallback callback);
|
|
|
|
|
|
2012-11-02 19:44:31 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// type of the cpu trace callback
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="data">cpu state</param>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
public delegate void TraceCallback(IntPtr state);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// set a callback to occur immediately BEFORE each opcode is executed
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="callback">null to clear</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_settracecallback(IntPtr core, TraceCallback callback);
|
|
|
|
|
|
2012-11-05 20:15:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// type of the scanline callback
|
|
|
|
|
/// </summary>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
public delegate void ScanlineCallback();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// set a callback to occur when ly reaches a particular scanline (so at the beginning of the scanline).
|
|
|
|
|
/// when the LCD is active, typically 145 will be the first callback after the beginning of frame advance,
|
|
|
|
|
/// and 144 will be the last callback right before frame advance returns
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="callback">null to clear</param>
|
|
|
|
|
/// <param name="sl">0-153 inclusive</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_setscanlinecallback(IntPtr core, ScanlineCallback callback, int sl);
|
|
|
|
|
|
2013-05-09 23:15:59 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// type of the RTC callback
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>what time is it, unixy</returns>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2013-11-24 17:32:46 +00:00
|
|
|
|
public delegate uint RTCCallback();
|
2013-05-09 23:15:59 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// sets RTC callback. probably mandatory.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="callback">the callback</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_setrtccallback(IntPtr core, RTCCallback callback);
|
|
|
|
|
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if the currently loaded ROM image is treated as having CGB support.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern bool gambatte_iscgb(IntPtr core);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if a ROM image is loaded.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern bool gambatte_isloaded(IntPtr core);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-09-10 23:40:53 +00:00
|
|
|
|
/// Get persistant cart memory.
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2012-09-10 23:40:53 +00:00
|
|
|
|
/// <param name="dest">byte buffer to write into. gambatte_savesavedatalength() bytes will be written</param>
|
2012-09-08 20:46:54 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2012-09-10 23:40:53 +00:00
|
|
|
|
public static extern void gambatte_savesavedata(IntPtr core, byte[] dest);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// restore persistant cart memory.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="data">byte buffer to read from. gambatte_savesavedatalength() bytes will be read</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_loadsavedata(IntPtr core, byte[] data);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get the size of the persistant cart memory block. this value DEPENDS ON THE PARTICULAR CART LOADED
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <returns>length in bytes. 0 means no internal persistant cart memory</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern int gambatte_savesavedatalength(IntPtr core);
|
2012-09-08 20:46:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-11-21 13:43:58 +00:00
|
|
|
|
/// Saves emulator state to a byte array
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2012-09-09 18:47:00 +00:00
|
|
|
|
/// <param name="data">private savestate data returned by the core</param>
|
|
|
|
|
/// <param name="len">the length of the data in bytes</param>
|
|
|
|
|
/// <returns>success</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2014-05-03 03:05:34 +00:00
|
|
|
|
public static extern bool gambatte_savestate(IntPtr core, ref IntPtr data, ref uint len);
|
2012-09-09 18:47:00 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// destroy data returned by gambatte_savestate() to avoid memory leaks
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="data">pointer from gambatte_savestate()</param>
|
2012-09-08 20:46:54 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2012-09-09 18:47:00 +00:00
|
|
|
|
public static extern void gambatte_savestate_destroy(IntPtr data);
|
2012-09-08 20:46:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-11-21 13:43:58 +00:00
|
|
|
|
/// Loads emulator state from a byte array
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
2012-09-09 18:47:00 +00:00
|
|
|
|
/// <param name="data">savestate data</param>
|
|
|
|
|
/// <param name="len">length of the savestate data in bytes</param>
|
2012-09-08 20:46:54 +00:00
|
|
|
|
/// <returns>success</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
2012-09-09 18:47:00 +00:00
|
|
|
|
public static extern bool gambatte_loadstate(IntPtr core, byte[] data, uint len);
|
2012-09-08 20:46:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ROM header title of currently loaded ROM image.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <returns></returns>
|
2012-09-08 20:22:07 +00:00
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern string gambatte_romtitle(IntPtr core);
|
|
|
|
|
|
2012-09-11 15:28:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// memory areas that gambatte_getmemoryarea() can return
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum MemoryAreas : int
|
|
|
|
|
{
|
|
|
|
|
vram = 0,
|
|
|
|
|
rom = 1,
|
|
|
|
|
wram = 2,
|
2012-09-11 19:05:44 +00:00
|
|
|
|
cartram = 3,
|
|
|
|
|
oam = 4,
|
2012-11-05 04:09:04 +00:00
|
|
|
|
hram = 5,
|
2012-11-05 15:58:51 +00:00
|
|
|
|
// these last two aren't returning native memory area data, but instead converted RGB32 colors
|
2012-11-05 04:09:04 +00:00
|
|
|
|
bgpal = 6,
|
|
|
|
|
sppal = 7
|
2012-09-11 15:28:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get pointer to internal memory areas, for debugging purposes
|
2012-09-13 21:03:34 +00:00
|
|
|
|
/// so long as you don't write to it, you should be completely sync-safe
|
2012-09-11 15:28:38 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="which">which memory area to access</param>
|
|
|
|
|
/// <param name="data">pointer to the start of the area</param>
|
|
|
|
|
/// <param name="length">valid length of the area, in bytes</param>
|
|
|
|
|
/// <returns>success</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern bool gambatte_getmemoryarea(IntPtr core, MemoryAreas which, ref IntPtr data, ref int length);
|
2012-09-13 21:03:34 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// read a single byte from the cpu bus. this includes all ram, rom, mmio, etc, as it is visible to the cpu (including mappers).
|
|
|
|
|
/// while there is no cycle cost to these reads, there may be other side effects! use at your own risk.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="addr">system bus address</param>
|
|
|
|
|
/// <returns>byte read</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern byte gambatte_cpuread(IntPtr core, ushort addr);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// write a single byte to the cpu bus. while there is no cycle cost to these writes, there can be quite a few side effects.
|
|
|
|
|
/// use at your own risk.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointe</param>
|
|
|
|
|
/// <param name="addr">system bus address</param>
|
|
|
|
|
/// <param name="val">byte to write</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_cpuwrite(IntPtr core, ushort addr, byte val);
|
2012-12-29 01:25:06 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// link cable stuff; never touch for normal operation
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointe</param>
|
|
|
|
|
/// <param name="which">todo</param>
|
|
|
|
|
/// <returns>todo</returns>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern int gambatte_linkstatus(IntPtr core, int which);
|
2013-11-11 18:05:29 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// get reg and flag values
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="core">opaque state pointer</param>
|
|
|
|
|
/// <param name="dest">length of at least 10, please</param>
|
|
|
|
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
public static extern void gambatte_getregs(IntPtr core, int[] dest);
|
|
|
|
|
|
|
|
|
|
public enum RegIndicies : int
|
|
|
|
|
{
|
|
|
|
|
PC, SP, A, B, C, D, E, F, H, L
|
|
|
|
|
}
|
2012-09-08 20:22:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|