1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus-core - m64p_types.h * |
3 | * Mupen64Plus homepage: https://mupen64plus.org/ * |
4 | * Copyright (C) 2012 CasualJames * |
5 | * Copyright (C) 2009 Richard Goedeken * |
6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * |
11 | * * |
12 | * This program is distributed in the hope that it will be useful, * |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 | * GNU General Public License for more details. * |
16 | * * |
17 | * You should have received a copy of the GNU General Public License * |
18 | * along with this program; if not, write to the * |
19 | * Free Software Foundation, Inc., * |
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
21 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
22 | |
23 | #if !defined(M64P_TYPES_H) |
24 | #define M64P_TYPES_H |
25 | |
26 | /* ----------------------------------------- */ |
27 | /* Platform-specific stuff */ |
28 | /* ----------------------------------------- */ |
29 | |
30 | /* necessary headers */ |
31 | #include <stdint.h> |
32 | #if defined(WIN32) |
33 | #include <windows.h> |
34 | #endif |
35 | |
36 | /* DLL handles and function declaration specifiers */ |
37 | #if defined(WIN32) |
38 | #define IMPORT extern "C" __declspec(dllimport) |
39 | #define EXPORT __declspec(dllexport) |
40 | #define CALL __cdecl |
41 | typedef HMODULE m64p_dynlib_handle; |
42 | #else |
43 | #define IMPORT extern "C" |
44 | #define EXPORT __attribute__((visibility("default"))) |
45 | #define CALL |
46 | typedef void * m64p_dynlib_handle; |
47 | #endif |
48 | |
49 | /* ----------------------------------------- */ |
50 | /* Structures and Types for Core library API */ |
51 | /* ----------------------------------------- */ |
52 | |
53 | typedef void * m64p_handle; |
54 | |
55 | /* Generic function pointer returned from osal_dynlib_getproc (and the like) |
56 | * Don't use it directly, cast to proper type before using it. |
57 | */ |
58 | typedef void (*m64p_function)(void); |
59 | |
60 | typedef void (*m64p_frame_callback)(unsigned int FrameIndex); |
61 | typedef void (*m64p_input_callback)(void); |
62 | typedef void (*m64p_audio_callback)(void); |
63 | typedef void (*m64p_vi_callback)(void); |
64 | |
65 | typedef enum { |
66 | M64TYPE_INT = 1, |
67 | M64TYPE_FLOAT, |
68 | M64TYPE_BOOL, |
69 | M64TYPE_STRING |
70 | } m64p_type; |
71 | |
72 | typedef enum { |
73 | M64MSG_ERROR = 1, |
74 | M64MSG_WARNING, |
75 | M64MSG_INFO, |
76 | M64MSG_STATUS, |
77 | M64MSG_VERBOSE |
78 | } m64p_msg_level; |
79 | |
80 | typedef enum { |
81 | M64ERR_SUCCESS = 0, |
82 | M64ERR_NOT_INIT, /* Function is disallowed before InitMupen64Plus() is called */ |
83 | M64ERR_ALREADY_INIT, /* InitMupen64Plus() was called twice */ |
84 | M64ERR_INCOMPATIBLE, /* API versions between components are incompatible */ |
85 | M64ERR_INPUT_ASSERT, /* Invalid parameters for function call, such as ParamValue=NULL for GetCoreParameter() */ |
86 | M64ERR_INPUT_INVALID, /* Invalid input data, such as ParamValue="maybe" for SetCoreParameter() to set a BOOL-type value */ |
87 | M64ERR_INPUT_NOT_FOUND, /* The input parameter(s) specified a particular item which was not found */ |
88 | M64ERR_NO_MEMORY, /* Memory allocation failed */ |
89 | M64ERR_FILES, /* Error opening, creating, reading, or writing to a file */ |
90 | M64ERR_INTERNAL, /* Internal error (bug) */ |
91 | M64ERR_INVALID_STATE, /* Current program state does not allow operation */ |
92 | M64ERR_PLUGIN_FAIL, /* A plugin function returned a fatal error */ |
93 | M64ERR_SYSTEM_FAIL, /* A system function call, such as an SDL or file operation, failed */ |
94 | M64ERR_UNSUPPORTED, /* Function call is not supported (ie, core not built with debugger) */ |
95 | M64ERR_WRONG_TYPE /* A given input type parameter cannot be used for desired operation */ |
96 | } m64p_error; |
97 | |
98 | typedef enum { |
99 | M64CAPS_DYNAREC = 1, |
100 | M64CAPS_DEBUGGER = 2, |
101 | M64CAPS_CORE_COMPARE = 4 |
102 | } m64p_core_caps; |
103 | |
104 | typedef enum { |
105 | M64PLUGIN_NULL = 0, |
106 | M64PLUGIN_RSP = 1, |
107 | M64PLUGIN_GFX, |
108 | M64PLUGIN_AUDIO, |
109 | M64PLUGIN_INPUT, |
110 | M64PLUGIN_CORE |
111 | } m64p_plugin_type; |
112 | |
113 | typedef enum { |
114 | M64EMU_STOPPED = 1, |
115 | M64EMU_RUNNING, |
116 | M64EMU_PAUSED |
117 | } m64p_emu_state; |
118 | |
119 | typedef enum { |
120 | M64VIDEO_NONE = 1, |
121 | M64VIDEO_WINDOWED, |
122 | M64VIDEO_FULLSCREEN |
123 | } m64p_video_mode; |
124 | |
125 | typedef enum { |
126 | M64VIDEOFLAG_SUPPORT_RESIZING = 1 |
127 | } m64p_video_flags; |
128 | |
129 | typedef enum { |
130 | M64CORE_EMU_STATE = 1, |
131 | M64CORE_VIDEO_MODE, |
132 | M64CORE_SAVESTATE_SLOT, |
133 | M64CORE_SPEED_FACTOR, |
134 | M64CORE_SPEED_LIMITER, |
135 | M64CORE_VIDEO_SIZE, |
136 | M64CORE_AUDIO_VOLUME, |
137 | M64CORE_AUDIO_MUTE, |
138 | M64CORE_INPUT_GAMESHARK, |
139 | M64CORE_STATE_LOADCOMPLETE, |
140 | M64CORE_STATE_SAVECOMPLETE |
141 | } m64p_core_param; |
142 | |
143 | typedef enum { |
144 | M64CMD_NOP = 0, |
145 | M64CMD_ROM_OPEN, |
146 | M64CMD_ROM_CLOSE, |
147 | , |
148 | M64CMD_ROM_GET_SETTINGS, |
149 | M64CMD_EXECUTE, |
150 | M64CMD_STOP, |
151 | M64CMD_PAUSE, |
152 | M64CMD_RESUME, |
153 | M64CMD_CORE_STATE_QUERY, |
154 | M64CMD_STATE_LOAD, |
155 | M64CMD_STATE_SAVE, |
156 | M64CMD_STATE_SET_SLOT, |
157 | M64CMD_SEND_SDL_KEYDOWN, |
158 | M64CMD_SEND_SDL_KEYUP, |
159 | M64CMD_SET_FRAME_CALLBACK, |
160 | M64CMD_TAKE_NEXT_SCREENSHOT, |
161 | M64CMD_CORE_STATE_SET, |
162 | M64CMD_READ_SCREEN, |
163 | M64CMD_RESET, |
164 | M64CMD_ADVANCE_FRAME, |
165 | M64CMD_SET_MEDIA_LOADER |
166 | } m64p_command; |
167 | |
168 | typedef struct { |
169 | uint32_t address; |
170 | int value; |
171 | } m64p_cheat_code; |
172 | |
173 | typedef struct { |
174 | /* Frontend-defined callback data. */ |
175 | void* cb_data; |
176 | |
177 | /* Allow the frontend to specify the GB cart ROM file to load |
178 | * cb_data: points to frontend-defined callback data. |
179 | * controller_num: (0-3) tell the frontend which controller is about to load a GB cart |
180 | * Returns a NULL-terminated string owned by the core specifying the GB cart ROM filename to load. |
181 | * Empty or NULL string results in no GB cart being loaded (eg. empty transferpak). |
182 | */ |
183 | char* (*get_gb_cart_rom)(void* cb_data, int controller_num); |
184 | |
185 | /* Allow the frontend to specify the GB cart RAM file to load |
186 | * cb_data: points to frontend-defined callback data. |
187 | * controller_num: (0-3) tell the frontend which controller is about to load a GB cart |
188 | * Returns a NULL-terminated string owned by the core specifying the GB cart RAM filename to load |
189 | * Empty or NULL string results in the core generating a default save file with empty content. |
190 | */ |
191 | char* (*get_gb_cart_ram)(void* cb_data, int controller_num); |
192 | |
193 | /* Allow the frontend to specify the DD IPL ROM file to load |
194 | * cb_data: points to frontend-defined callback data. |
195 | * Returns a NULL-terminated string owned by the core specifying the DD IPL ROM filename to load |
196 | * Empty or NULL string results in disabled 64DD. |
197 | */ |
198 | char* (*get_dd_rom)(void* cb_data); |
199 | |
200 | /* Allow the frontend to specify the DD disk file to load |
201 | * cb_data: points to frontend-defined callback data. |
202 | * Returns a NULL-terminated string owned by the core specifying the DD disk filename to load |
203 | * Empty or NULL string results in no DD disk being loaded (eg. empty disk drive). |
204 | */ |
205 | char* (*get_dd_disk)(void* cb_data); |
206 | } m64p_media_loader; |
207 | |
208 | /* ----------------------------------------- */ |
209 | /* Structures to hold ROM image information */ |
210 | /* ----------------------------------------- */ |
211 | |
212 | typedef enum |
213 | { |
214 | SYSTEM_NTSC = 0, |
215 | SYSTEM_PAL, |
216 | SYSTEM_MPAL |
217 | } m64p_system_type; |
218 | |
219 | typedef struct |
220 | { |
221 | uint8_t init_PI_BSB_DOM1_LAT_REG; /* 0x00 */ |
222 | uint8_t init_PI_BSB_DOM1_PGS_REG; /* 0x01 */ |
223 | uint8_t init_PI_BSB_DOM1_PWD_REG; /* 0x02 */ |
224 | uint8_t init_PI_BSB_DOM1_PGS_REG2; /* 0x03 */ |
225 | uint32_t ClockRate; /* 0x04 */ |
226 | uint32_t PC; /* 0x08 */ |
227 | uint32_t Release; /* 0x0C */ |
228 | uint32_t CRC1; /* 0x10 */ |
229 | uint32_t CRC2; /* 0x14 */ |
230 | uint32_t Unknown[2]; /* 0x18 */ |
231 | uint8_t Name[20]; /* 0x20 */ |
232 | uint32_t unknown; /* 0x34 */ |
233 | uint32_t Manufacturer_ID; /* 0x38 */ |
234 | uint16_t Cartridge_ID; /* 0x3C - Game serial number */ |
235 | uint16_t Country_code; /* 0x3E */ |
236 | } ; |
237 | |
238 | typedef struct |
239 | { |
240 | char goodname[256]; |
241 | char MD5[33]; |
242 | unsigned char savetype; |
243 | unsigned char status; /* Rom status on a scale from 0-5. */ |
244 | unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */ |
245 | unsigned char rumble; /* 0 - No, 1 - Yes boolean for rumble support. */ |
246 | unsigned char transferpak; /* 0 - No, 1 - Yes boolean for transfer pak support. */ |
247 | unsigned char mempak; /* 0 - No, 1 - Yes boolean for memory pak support. */ |
248 | unsigned char biopak; /* 0 - No, 1 - Yes boolean for bio pak support. */ |
249 | } m64p_rom_settings; |
250 | |
251 | /* ----------------------------------------- */ |
252 | /* Structures and Types for the Debugger */ |
253 | /* ----------------------------------------- */ |
254 | |
255 | typedef enum { |
256 | M64P_DBG_RUN_STATE = 1, |
257 | M64P_DBG_PREVIOUS_PC, |
258 | M64P_DBG_NUM_BREAKPOINTS, |
259 | M64P_DBG_CPU_DYNACORE, |
260 | M64P_DBG_CPU_NEXT_INTERRUPT |
261 | } m64p_dbg_state; |
262 | |
263 | typedef enum { |
264 | M64P_DBG_RUNSTATE_PAUSED = 0, |
265 | M64P_DBG_RUNSTATE_STEPPING, |
266 | M64P_DBG_RUNSTATE_RUNNING |
267 | } m64p_dbg_runstate; |
268 | |
269 | typedef enum { |
270 | M64P_DBG_MEM_TYPE = 1, |
271 | M64P_DBG_MEM_FLAGS, |
272 | M64P_DBG_MEM_HAS_RECOMPILED, |
273 | M64P_DBG_MEM_NUM_RECOMPILED, |
274 | M64P_DBG_RECOMP_OPCODE = 16, |
275 | M64P_DBG_RECOMP_ARGS, |
276 | M64P_DBG_RECOMP_ADDR |
277 | } m64p_dbg_mem_info; |
278 | |
279 | typedef enum { |
280 | M64P_MEM_NOMEM = 0, |
281 | M64P_MEM_NOTHING, |
282 | M64P_MEM_RDRAM, |
283 | M64P_MEM_RDRAMREG, |
284 | M64P_MEM_RSPMEM, |
285 | M64P_MEM_RSPREG, |
286 | M64P_MEM_RSP, |
287 | M64P_MEM_DP, |
288 | M64P_MEM_DPS, |
289 | M64P_MEM_VI, |
290 | M64P_MEM_AI, |
291 | M64P_MEM_PI, |
292 | M64P_MEM_RI, |
293 | M64P_MEM_SI, |
294 | M64P_MEM_FLASHRAMSTAT, |
295 | M64P_MEM_ROM, |
296 | M64P_MEM_PIF, |
297 | M64P_MEM_MI, |
298 | M64P_MEM_BREAKPOINT |
299 | } m64p_dbg_mem_type; |
300 | |
301 | typedef enum { |
302 | M64P_MEM_FLAG_READABLE = 0x01, |
303 | M64P_MEM_FLAG_WRITABLE = 0x02, |
304 | M64P_MEM_FLAG_READABLE_EMUONLY = 0x04, /* the EMUONLY flags signify that emulated code can read/write here, but debugger cannot */ |
305 | M64P_MEM_FLAG_WRITABLE_EMUONLY = 0x08 |
306 | } m64p_dbg_mem_flags; |
307 | |
308 | typedef enum { |
309 | M64P_DBG_PTR_RDRAM = 1, |
310 | M64P_DBG_PTR_PI_REG, |
311 | M64P_DBG_PTR_SI_REG, |
312 | M64P_DBG_PTR_VI_REG, |
313 | M64P_DBG_PTR_RI_REG, |
314 | M64P_DBG_PTR_AI_REG |
315 | } m64p_dbg_memptr_type; |
316 | |
317 | typedef enum { |
318 | M64P_CPU_PC = 1, |
319 | M64P_CPU_REG_REG, |
320 | M64P_CPU_REG_HI, |
321 | M64P_CPU_REG_LO, |
322 | M64P_CPU_REG_COP0, |
323 | M64P_CPU_REG_COP1_DOUBLE_PTR, |
324 | M64P_CPU_REG_COP1_SIMPLE_PTR, |
325 | M64P_CPU_REG_COP1_FGR_64, |
326 | M64P_CPU_TLB |
327 | } m64p_dbg_cpu_data; |
328 | |
329 | typedef enum { |
330 | M64P_BKP_CMD_ADD_ADDR = 1, |
331 | M64P_BKP_CMD_ADD_STRUCT, |
332 | M64P_BKP_CMD_REPLACE, |
333 | M64P_BKP_CMD_REMOVE_ADDR, |
334 | M64P_BKP_CMD_REMOVE_IDX, |
335 | M64P_BKP_CMD_ENABLE, |
336 | M64P_BKP_CMD_DISABLE, |
337 | M64P_BKP_CMD_CHECK |
338 | } m64p_dbg_bkp_command; |
339 | |
340 | #define M64P_MEM_INVALID 0xFFFFFFFF /* invalid memory read will return this */ |
341 | |
342 | #define BREAKPOINTS_MAX_NUMBER 128 |
343 | |
344 | typedef enum { |
345 | M64P_BKP_FLAG_ENABLED = 0x01, |
346 | M64P_BKP_FLAG_READ = 0x02, |
347 | M64P_BKP_FLAG_WRITE = 0x04, |
348 | M64P_BKP_FLAG_EXEC = 0x08, |
349 | M64P_BKP_FLAG_LOG = 0x10 /* Log to the console when this breakpoint hits */ |
350 | } m64p_dbg_bkp_flags; |
351 | |
352 | #define BPT_CHECK_FLAG(a, b) ((a.flags & b) == b) |
353 | #define BPT_SET_FLAG(a, b) a.flags = (a.flags | b); |
354 | #define BPT_CLEAR_FLAG(a, b) a.flags = (a.flags & (~b)); |
355 | #define BPT_TOGGLE_FLAG(a, b) a.flags = (a.flags ^ b); |
356 | |
357 | typedef struct { |
358 | uint32_t address; |
359 | uint32_t endaddr; |
360 | unsigned int flags; |
361 | } m64p_breakpoint; |
362 | |
363 | /* ------------------------------------------------- */ |
364 | /* Structures and Types for Core Video Extension API */ |
365 | /* ------------------------------------------------- */ |
366 | |
367 | typedef struct { |
368 | unsigned int uiWidth; |
369 | unsigned int uiHeight; |
370 | } m64p_2d_size; |
371 | |
372 | typedef enum { |
373 | M64P_GL_DOUBLEBUFFER = 1, |
374 | M64P_GL_BUFFER_SIZE, |
375 | M64P_GL_DEPTH_SIZE, |
376 | M64P_GL_RED_SIZE, |
377 | M64P_GL_GREEN_SIZE, |
378 | M64P_GL_BLUE_SIZE, |
379 | M64P_GL_ALPHA_SIZE, |
380 | M64P_GL_SWAP_CONTROL, |
381 | M64P_GL_MULTISAMPLEBUFFERS, |
382 | M64P_GL_MULTISAMPLESAMPLES, |
383 | M64P_GL_CONTEXT_MAJOR_VERSION, |
384 | M64P_GL_CONTEXT_MINOR_VERSION, |
385 | M64P_GL_CONTEXT_PROFILE_MASK |
386 | } m64p_GLattr; |
387 | |
388 | typedef enum { |
389 | M64P_GL_CONTEXT_PROFILE_CORE, |
390 | M64P_GL_CONTEXT_PROFILE_COMPATIBILITY, |
391 | M64P_GL_CONTEXT_PROFILE_ES |
392 | } m64p_GLContextType; |
393 | |
394 | typedef struct { |
395 | unsigned int Functions; |
396 | m64p_error (*VidExtFuncInit)(void); |
397 | m64p_error (*VidExtFuncQuit)(void); |
398 | m64p_error (*VidExtFuncListModes)(m64p_2d_size *, int *); |
399 | m64p_error (*VidExtFuncSetMode)(int, int, int, int, int); |
400 | m64p_function (*VidExtFuncGLGetProc)(const char*); |
401 | m64p_error (*VidExtFuncGLSetAttr)(m64p_GLattr, int); |
402 | m64p_error (*VidExtFuncGLGetAttr)(m64p_GLattr, int *); |
403 | m64p_error (*VidExtFuncGLSwapBuf)(void); |
404 | m64p_error (*VidExtFuncSetCaption)(const char *); |
405 | m64p_error (*VidExtFuncToggleFS)(void); |
406 | m64p_error (*VidExtFuncResizeWindow)(int, int); |
407 | uint32_t (*VidExtFuncGLGetDefaultFramebuffer)(void); |
408 | } m64p_video_extension_functions; |
409 | |
410 | #endif /* define M64P_TYPES_H */ |
411 | |
412 | |