Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / doc / emuwiki-api-doc / Mupen64Plus_v2.0_headers.txt
1 [http://mupen64plus.retrouprising.com Project page]
2
3 == m64p_types.h ==
4  /* ----------------------------------------- */
5  /* Platform-specific stuff                   */
6  /* ----------------------------------------- */
7  
8  /* necessary headers */
9  #if defined(WIN32)
10    #include <windows.h>
11  #endif
12  
13  /* DLL handles and function declaration specifiers */
14  #if defined(WIN32)
15    #define IMPORT extern "C" __declspec(dllimport)
16    #define EXPORT __declspec(dllexport)
17    #define CALL   __cdecl
18    typedef HMODULE m64p_dynlib_handle;
19  #else
20    #define IMPORT extern "C"
21    #define EXPORT __attribute__((visibility("default")))
22    #define CALL
23    typedef void * m64p_dynlib_handle;
24  #endif
25  
26  /* ----------------------------------------- */
27  /* Structures and Types for Core library API */
28  /* ----------------------------------------- */
29  
30  typedef void * m64p_handle;
31  
32  typedef void (*m64p_frame_callback)(unsigned int FrameIndex);
33  typedef void (*m64p_input_callback)(void);
34  typedef void (*m64p_audio_callback)(void);
35  typedef void (*m64p_vi_callback)(void);
36  
37  typedef enum {
38    M64TYPE_INT = 1,
39    M64TYPE_FLOAT,
40    M64TYPE_BOOL,
41    M64TYPE_STRING
42  } m64p_type;
43  
44  typedef enum {
45    M64MSG_ERROR = 1,
46    M64MSG_WARNING,
47    M64MSG_INFO,
48    M64MSG_STATUS,
49    M64MSG_VERBOSE
50  } m64p_msg_level;
51  
52  typedef enum {
53    M64ERR_SUCCESS = 0,
54    M64ERR_NOT_INIT,        /* Function is disallowed before InitMupen64Plus() is called */
55    M64ERR_ALREADY_INIT,    /* InitMupen64Plus() was called twice */
56    M64ERR_INCOMPATIBLE,    /* API versions between components are incompatible */
57    M64ERR_INPUT_ASSERT,    /* Invalid parameters for function call, such as ParamValue=NULL for GetCoreParameter() */
58    M64ERR_INPUT_INVALID,   /* Invalid input data, such as ParamValue="maybe" for SetCoreParameter() to set a BOOL-type value */
59    M64ERR_INPUT_NOT_FOUND, /* The input parameter(s) specified a particular item which was not found */
60    M64ERR_NO_MEMORY,       /* Memory allocation failed */
61    M64ERR_FILES,           /* Error opening, creating, reading, or writing to a file */
62    M64ERR_INTERNAL,        /* Internal error (bug) */
63    M64ERR_INVALID_STATE,   /* Current program state does not allow operation */
64    M64ERR_PLUGIN_FAIL,     /* A plugin function returned a fatal error */
65    M64ERR_SYSTEM_FAIL,     /* A system function call, such as an SDL or file operation, failed */
66    M64ERR_UNSUPPORTED,     /* Function call is not supported (ie, core not built with debugger) */
67    M64ERR_WRONG_TYPE       /* A given input type parameter cannot be used for desired operation */
68  } m64p_error;
69  
70  typedef enum {
71    M64CAPS_DYNAREC = 1,
72    M64CAPS_DEBUGGER = 2,
73    M64CAPS_CORE_COMPARE = 4
74  } m64p_core_caps;
75  
76  typedef enum {
77    M64PLUGIN_NULL = 0,
78    M64PLUGIN_RSP = 1,
79    M64PLUGIN_GFX,
80    M64PLUGIN_AUDIO,
81    M64PLUGIN_INPUT,
82    M64PLUGIN_CORE
83  } m64p_plugin_type;
84  
85  typedef enum {
86    M64EMU_STOPPED = 1,
87    M64EMU_RUNNING,
88    M64EMU_PAUSED
89  } m64p_emu_state;
90  
91  typedef enum {
92    M64VIDEO_NONE = 1,
93    M64VIDEO_WINDOWED,
94    M64VIDEO_FULLSCREEN
95  } m64p_video_mode;
96  
97  typedef enum {
98    M64VIDEOFLAG_SUPPORT_RESIZING = 1
99  } m64p_video_flags;
100  
101  typedef enum {
102    M64CORE_EMU_STATE = 1,
103    M64CORE_VIDEO_MODE,
104    M64CORE_SAVESTATE_SLOT,
105    M64CORE_SPEED_FACTOR,
106    M64CORE_SPEED_LIMITER,
107    M64CORE_VIDEO_SIZE,
108    M64CORE_AUDIO_VOLUME,
109    M64CORE_AUDIO_MUTE,
110    M64CORE_INPUT_GAMESHARK,
111    M64CORE_STATE_LOADCOMPLETE,
112    M64CORE_STATE_SAVECOMPLETE
113  } m64p_core_param;
114  
115  typedef enum {
116    M64CMD_NOP = 0,
117    M64CMD_ROM_OPEN,
118    M64CMD_ROM_CLOSE,
119    M64CMD_ROM_GET_HEADER,
120    M64CMD_ROM_GET_SETTINGS,
121    M64CMD_EXECUTE,
122    M64CMD_STOP,
123    M64CMD_PAUSE,
124    M64CMD_RESUME,
125    M64CMD_CORE_STATE_QUERY,
126    M64CMD_STATE_LOAD,
127    M64CMD_STATE_SAVE,
128    M64CMD_STATE_SET_SLOT,
129    M64CMD_SEND_SDL_KEYDOWN,
130    M64CMD_SEND_SDL_KEYUP,
131    M64CMD_SET_FRAME_CALLBACK,
132    M64CMD_TAKE_NEXT_SCREENSHOT,
133    M64CMD_CORE_STATE_SET,
134    M64CMD_READ_SCREEN,
135    M64CMD_RESET,
136    M64CMD_ADVANCE_FRAME
137  } m64p_command;
138  
139  typedef struct {
140    unsigned int address;
141    int          value;
142  } m64p_cheat_code;
143  
144  /* ----------------------------------------- */
145  /* Structures to hold ROM image information  */
146  /* ----------------------------------------- */
147  
148  typedef enum
149  {
150      SYSTEM_NTSC = 0,
151      SYSTEM_PAL,
152      SYSTEM_MPAL
153  } m64p_system_type;
154  
155  typedef struct
156  {
157     unsigned char init_PI_BSB_DOM1_LAT_REG;  /* 0x00 */
158     unsigned char init_PI_BSB_DOM1_PGS_REG;  /* 0x01 */
159     unsigned char init_PI_BSB_DOM1_PWD_REG;  /* 0x02 */
160     unsigned char init_PI_BSB_DOM1_PGS_REG2; /* 0x03 */
161     unsigned int ClockRate;                  /* 0x04 */
162     unsigned int PC;                         /* 0x08 */
163     unsigned int Release;                    /* 0x0C */
164     unsigned int CRC1;                       /* 0x10 */
165     unsigned int CRC2;                       /* 0x14 */
166     unsigned int Unknown[2];                 /* 0x18 */
167     unsigned char Name[20];                  /* 0x20 */
168     unsigned int unknown;                    /* 0x34 */
169     unsigned int Manufacturer_ID;            /* 0x38 */
170     unsigned short Cartridge_ID;             /* 0x3C - Game serial number  */
171     unsigned short Country_code;             /* 0x3E */
172  } m64p_rom_header;
173  
174  typedef struct
175  {
176     char goodname[256];
177     char MD5[33];
178     unsigned char savetype;
179     unsigned char status;  /* Rom status on a scale from 0-5. */
180     unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */
181     unsigned char rumble;  /* 0 - No, 1 - Yes boolean for rumble support. */
182  } m64p_rom_settings;
183  
184  /* ----------------------------------------- */
185  /* Structures and Types for the Debugger     */
186  /* ----------------------------------------- */
187  
188  typedef enum {
189    M64P_DBG_RUN_STATE = 1,
190    M64P_DBG_PREVIOUS_PC,
191    M64P_DBG_NUM_BREAKPOINTS,
192    M64P_DBG_CPU_DYNACORE,
193    M64P_DBG_CPU_NEXT_INTERRUPT
194  } m64p_dbg_state;
195  
196  typedef enum {
197    M64P_DBG_MEM_TYPE = 1,
198    M64P_DBG_MEM_FLAGS,
199    M64P_DBG_MEM_HAS_RECOMPILED,
200    M64P_DBG_MEM_NUM_RECOMPILED,
201    M64P_DBG_RECOMP_OPCODE = 16,
202    M64P_DBG_RECOMP_ARGS,
203    M64P_DBG_RECOMP_ADDR
204  } m64p_dbg_mem_info;
205  
206  typedef enum {
207    M64P_MEM_NOMEM = 0,
208    M64P_MEM_NOTHING,
209    M64P_MEM_RDRAM,
210    M64P_MEM_RDRAMREG,
211    M64P_MEM_RSPMEM,
212    M64P_MEM_RSPREG,
213    M64P_MEM_RSP,
214    M64P_MEM_DP,
215    M64P_MEM_DPS,
216    M64P_MEM_VI,
217    M64P_MEM_AI,
218    M64P_MEM_PI,
219    M64P_MEM_RI,
220    M64P_MEM_SI,
221    M64P_MEM_FLASHRAMSTAT,
222    M64P_MEM_ROM,
223    M64P_MEM_PIF,
224    M64P_MEM_MI,
225    M64P_MEM_BREAKPOINT
226  } m64p_dbg_mem_type;
227  
228  typedef enum {
229    M64P_MEM_FLAG_READABLE = 0x01,
230    M64P_MEM_FLAG_WRITABLE = 0x02,
231    M64P_MEM_FLAG_READABLE_EMUONLY = 0x04,  // the EMUONLY flags signify that emulated code can read/write here, but debugger cannot
232    M64P_MEM_FLAG_WRITABLE_EMUONLY = 0x08
233  } m64p_dbg_mem_flags;
234  
235  typedef enum {
236    M64P_DBG_PTR_RDRAM = 1,
237    M64P_DBG_PTR_PI_REG,
238    M64P_DBG_PTR_SI_REG,
239    M64P_DBG_PTR_VI_REG,
240    M64P_DBG_PTR_RI_REG,
241    M64P_DBG_PTR_AI_REG
242  } m64p_dbg_memptr_type;
243  
244  typedef enum {
245    M64P_CPU_PC = 1,
246    M64P_CPU_REG_REG,
247    M64P_CPU_REG_HI,
248    M64P_CPU_REG_LO,
249    M64P_CPU_REG_COP0,
250    M64P_CPU_REG_COP1_DOUBLE_PTR,
251    M64P_CPU_REG_COP1_SIMPLE_PTR,
252    M64P_CPU_REG_COP1_FGR_64,
253    M64P_CPU_TLB
254  } m64p_dbg_cpu_data;
255  
256  typedef enum {
257    M64P_BKP_CMD_ADD_ADDR = 1,
258    M64P_BKP_CMD_ADD_STRUCT,
259    M64P_BKP_CMD_REPLACE,
260    M64P_BKP_CMD_REMOVE_ADDR,
261    M64P_BKP_CMD_REMOVE_IDX,
262    M64P_BKP_CMD_ENABLE,
263    M64P_BKP_CMD_DISABLE,
264    M64P_BKP_CMD_CHECK
265  } m64p_dbg_bkp_command;
266  
267  #define M64P_MEM_INVALID        0xFFFFFFFF  // invalid memory read will return this
268  
269  #define BREAKPOINTS_MAX_NUMBER  128
270  
271  #define BPT_FLAG_ENABLED        0x01
272  #define BPT_FLAG_CONDITIONAL    0x02
273  #define BPT_FLAG_COUNTER        0x04
274  #define BPT_FLAG_READ           0x08
275  #define BPT_FLAG_WRITE          0x10
276  #define BPT_FLAG_EXEC           0x20
277  #define BPT_FLAG_LOG            0x40 //Log to the console when this breakpoint hits.
278  
279  #define BPT_CHECK_FLAG(a, b)  ((a.flags & b) == b)
280  #define BPT_SET_FLAG(a, b)    a.flags = (a.flags | b);
281  #define BPT_CLEAR_FLAG(a, b)  a.flags = (a.flags & (~b));
282  #define BPT_TOGGLE_FLAG(a, b) a.flags = (a.flags ^ b);
283  
284  typedef struct _breakpoint {
285      unsigned int address; 
286      unsigned int endaddr;
287      unsigned int flags;
288      //unsigned int condition;  //Placeholder for breakpoint condition
289      } breakpoint;
290  
291  /* ------------------------------------------------- */
292  /* Structures and Types for Core Video Extension API */
293  /* ------------------------------------------------- */
294  
295  typedef struct {
296    unsigned int uiWidth;
297    unsigned int uiHeight;
298  } m64p_2d_size;
299  
300  typedef enum {
301    M64P_GL_DOUBLEBUFFER = 1,
302    M64P_GL_BUFFER_SIZE,
303    M64P_GL_DEPTH_SIZE,
304    M64P_GL_RED_SIZE,
305    M64P_GL_GREEN_SIZE,
306    M64P_GL_BLUE_SIZE,
307    M64P_GL_ALPHA_SIZE,
308    M64P_GL_SWAP_CONTROL,
309    M64P_GL_MULTISAMPLEBUFFERS,
310    M64P_GL_MULTISAMPLESAMPLES
311  } m64p_GLattr;
312  
313  typedef struct {
314    unsigned int Functions;
315    m64p_error (*VidExtFuncInit)(void);
316    m64p_error (*VidExtFuncQuit)(void);
317    m64p_error (*VidExtFuncListModes)(m64p_2d_size *, int *);
318    m64p_error (*VidExtFuncSetMode)(int, int, int, int, int);
319    void *     (*VidExtFuncGLGetProc)(const char*);
320    m64p_error (*VidExtFuncGLSetAttr)(m64p_GLattr, int);
321    m64p_error (*VidExtFuncGLGetAttr)(m64p_GLattr, int *);
322    m64p_error (*VidExtFuncGLSwapBuf)(void);
323    m64p_error (*VidExtFuncSetCaption)(const char *);
324    m64p_error (*VidExtFuncToggleFS)(void);
325    m64p_error (*VidExtFuncResizeWindow)(int, int);
326  } m64p_video_extension_functions;
327