SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
libretro/libretro.h
1 /* Copyright (C) 2010-2020 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this libretro API header (libretro.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef LIBRETRO_H__
24 #define LIBRETRO_H__
25
26 #include <stdint.h>
27 #include <stddef.h>
28 #include <limits.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #ifndef __cplusplus
35 #if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
36 /* Hack applied for MSVC when compiling in C89 mode
37 * as it isn't C99-compliant. */
38 #define bool unsigned char
39 #define true 1
40 #define false 0
41 #else
42 #include <stdbool.h>
43 #endif
44 #endif
45
46 #ifndef RETRO_CALLCONV
47 # if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)
48 # define RETRO_CALLCONV __attribute__((cdecl))
49 # elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)
50 # define RETRO_CALLCONV __cdecl
51 # else
52 # define RETRO_CALLCONV /* all other platforms only have one calling convention each */
53 # endif
54 #endif
55
56 #ifndef RETRO_API
57 # if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
58 # ifdef RETRO_IMPORT_SYMBOLS
59 # ifdef __GNUC__
60 # define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))
61 # else
62 # define RETRO_API RETRO_CALLCONV __declspec(dllimport)
63 # endif
64 # else
65 # ifdef __GNUC__
66 # define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))
67 # else
68 # define RETRO_API RETRO_CALLCONV __declspec(dllexport)
69 # endif
70 # endif
71 # else
72 # if defined(__GNUC__) && __GNUC__ >= 4
73 # define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
74 # else
75 # define RETRO_API RETRO_CALLCONV
76 # endif
77 # endif
78 #endif
79
80 /* Used for checking API/ABI mismatches that can break libretro
81 * implementations.
82 * It is not incremented for compatible changes to the API.
83 */
84 #define RETRO_API_VERSION 1
85
86 /*
87 * Libretro's fundamental device abstractions.
88 *
89 * Libretro's input system consists of some standardized device types,
90 * such as a joypad (with/without analog), mouse, keyboard, lightgun
91 * and a pointer.
92 *
93 * The functionality of these devices are fixed, and individual cores
94 * map their own concept of a controller to libretro's abstractions.
95 * This makes it possible for frontends to map the abstract types to a
96 * real input device, and not having to worry about binding input
97 * correctly to arbitrary controller layouts.
98 */
99
100 #define RETRO_DEVICE_TYPE_SHIFT 8
101 #define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1)
102 #define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base)
103
104 /* Input disabled. */
105 #define RETRO_DEVICE_NONE 0
106
107 /* The JOYPAD is called RetroPad. It is essentially a Super Nintendo
108 * controller, but with additional L2/R2/L3/R3 buttons, similar to a
109 * PS1 DualShock. */
110 #define RETRO_DEVICE_JOYPAD 1
111
112 /* The mouse is a simple mouse, similar to Super Nintendo's mouse.
113 * X and Y coordinates are reported relatively to last poll (poll callback).
114 * It is up to the libretro implementation to keep track of where the mouse
115 * pointer is supposed to be on the screen.
116 * The frontend must make sure not to interfere with its own hardware
117 * mouse pointer.
118 */
119 #define RETRO_DEVICE_MOUSE 2
120
121 /* KEYBOARD device lets one poll for raw key pressed.
122 * It is poll based, so input callback will return with the current
123 * pressed state.
124 * For event/text based keyboard input, see
125 * RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
126 */
127 #define RETRO_DEVICE_KEYBOARD 3
128
129 /* LIGHTGUN device is similar to Guncon-2 for PlayStation 2.
130 * It reports X/Y coordinates in screen space (similar to the pointer)
131 * in the range [-0x8000, 0x7fff] in both axes, with zero being center and
132 * -0x8000 being out of bounds.
133 * As well as reporting on/off screen state. It features a trigger,
134 * start/select buttons, auxiliary action buttons and a
135 * directional pad. A forced off-screen shot can be requested for
136 * auto-reloading function in some games.
137 */
138 #define RETRO_DEVICE_LIGHTGUN 4
139
140 /* The ANALOG device is an extension to JOYPAD (RetroPad).
141 * Similar to DualShock2 it adds two analog sticks and all buttons can
142 * be analog. This is treated as a separate device type as it returns
143 * axis values in the full analog range of [-0x7fff, 0x7fff],
144 * although some devices may return -0x8000.
145 * Positive X axis is right. Positive Y axis is down.
146 * Buttons are returned in the range [0, 0x7fff].
147 * Only use ANALOG type when polling for analog values.
148 */
149 #define RETRO_DEVICE_ANALOG 5
150
151 /* Abstracts the concept of a pointing mechanism, e.g. touch.
152 * This allows libretro to query in absolute coordinates where on the
153 * screen a mouse (or something similar) is being placed.
154 * For a touch centric device, coordinates reported are the coordinates
155 * of the press.
156 *
157 * Coordinates in X and Y are reported as:
158 * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
159 * and 0x7fff corresponds to the far right/bottom of the screen.
160 * The "screen" is here defined as area that is passed to the frontend and
161 * later displayed on the monitor.
162 *
163 * The frontend is free to scale/resize this screen as it sees fit, however,
164 * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
165 * game image, etc.
166 *
167 * To check if the pointer coordinates are valid (e.g. a touch display
168 * actually being touched), PRESSED returns 1 or 0.
169 *
170 * If using a mouse on a desktop, PRESSED will usually correspond to the
171 * left mouse button, but this is a frontend decision.
172 * PRESSED will only return 1 if the pointer is inside the game screen.
173 *
174 * For multi-touch, the index variable can be used to successively query
175 * more presses.
176 * If index = 0 returns true for _PRESSED, coordinates can be extracted
177 * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with
178 * index = 1, and so on.
179 * Eventually _PRESSED will return false for an index. No further presses
180 * are registered at this point. */
181 #define RETRO_DEVICE_POINTER 6
182
183 /* Buttons for the RetroPad (JOYPAD).
184 * The placement of these is equivalent to placements on the
185 * Super Nintendo controller.
186 * L2/R2/L3/R3 buttons correspond to the PS1 DualShock.
187 * Also used as id values for RETRO_DEVICE_INDEX_ANALOG_BUTTON */
188 #define RETRO_DEVICE_ID_JOYPAD_B 0
189 #define RETRO_DEVICE_ID_JOYPAD_Y 1
190 #define RETRO_DEVICE_ID_JOYPAD_SELECT 2
191 #define RETRO_DEVICE_ID_JOYPAD_START 3
192 #define RETRO_DEVICE_ID_JOYPAD_UP 4
193 #define RETRO_DEVICE_ID_JOYPAD_DOWN 5
194 #define RETRO_DEVICE_ID_JOYPAD_LEFT 6
195 #define RETRO_DEVICE_ID_JOYPAD_RIGHT 7
196 #define RETRO_DEVICE_ID_JOYPAD_A 8
197 #define RETRO_DEVICE_ID_JOYPAD_X 9
198 #define RETRO_DEVICE_ID_JOYPAD_L 10
199 #define RETRO_DEVICE_ID_JOYPAD_R 11
200 #define RETRO_DEVICE_ID_JOYPAD_L2 12
201 #define RETRO_DEVICE_ID_JOYPAD_R2 13
202 #define RETRO_DEVICE_ID_JOYPAD_L3 14
203 #define RETRO_DEVICE_ID_JOYPAD_R3 15
204
205 #define RETRO_DEVICE_ID_JOYPAD_MASK 256
206
207 /* Index / Id values for ANALOG device. */
208 #define RETRO_DEVICE_INDEX_ANALOG_LEFT 0
209 #define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1
210 #define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2
211 #define RETRO_DEVICE_ID_ANALOG_X 0
212 #define RETRO_DEVICE_ID_ANALOG_Y 1
213
214 /* Id values for MOUSE. */
215 #define RETRO_DEVICE_ID_MOUSE_X 0
216 #define RETRO_DEVICE_ID_MOUSE_Y 1
217 #define RETRO_DEVICE_ID_MOUSE_LEFT 2
218 #define RETRO_DEVICE_ID_MOUSE_RIGHT 3
219 #define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
220 #define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
221 #define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
222 #define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7
223 #define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8
224 #define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9
225 #define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10
226
227 /* Id values for LIGHTGUN. */
228 #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/
229 #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/
230 #define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/
231 #define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2
232 #define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/
233 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3
234 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4
235 #define RETRO_DEVICE_ID_LIGHTGUN_START 6
236 #define RETRO_DEVICE_ID_LIGHTGUN_SELECT 7
237 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_C 8
238 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP 9
239 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10
240 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11
241 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12
242 /* deprecated */
243 #define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/
244 #define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/
245 #define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/
246 #define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/
247 #define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/
248
249 /* Id values for POINTER. */
250 #define RETRO_DEVICE_ID_POINTER_X 0
251 #define RETRO_DEVICE_ID_POINTER_Y 1
252 #define RETRO_DEVICE_ID_POINTER_PRESSED 2
253 #define RETRO_DEVICE_ID_POINTER_COUNT 3
254
255 /* Returned from retro_get_region(). */
256 #define RETRO_REGION_NTSC 0
257 #define RETRO_REGION_PAL 1
258
259 /* Id values for LANGUAGE */
260 enum retro_language
261 {
262 RETRO_LANGUAGE_ENGLISH = 0,
263 RETRO_LANGUAGE_JAPANESE = 1,
264 RETRO_LANGUAGE_FRENCH = 2,
265 RETRO_LANGUAGE_SPANISH = 3,
266 RETRO_LANGUAGE_GERMAN = 4,
267 RETRO_LANGUAGE_ITALIAN = 5,
268 RETRO_LANGUAGE_DUTCH = 6,
269 RETRO_LANGUAGE_PORTUGUESE_BRAZIL = 7,
270 RETRO_LANGUAGE_PORTUGUESE_PORTUGAL = 8,
271 RETRO_LANGUAGE_RUSSIAN = 9,
272 RETRO_LANGUAGE_KOREAN = 10,
273 RETRO_LANGUAGE_CHINESE_TRADITIONAL = 11,
274 RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12,
275 RETRO_LANGUAGE_ESPERANTO = 13,
276 RETRO_LANGUAGE_POLISH = 14,
277 RETRO_LANGUAGE_VIETNAMESE = 15,
278 RETRO_LANGUAGE_ARABIC = 16,
279 RETRO_LANGUAGE_GREEK = 17,
280 RETRO_LANGUAGE_TURKISH = 18,
281 RETRO_LANGUAGE_SLOVAK = 19,
282 RETRO_LANGUAGE_PERSIAN = 20,
283 RETRO_LANGUAGE_HEBREW = 21,
284 RETRO_LANGUAGE_ASTURIAN = 22,
285 RETRO_LANGUAGE_FINNISH = 23,
286 RETRO_LANGUAGE_LAST,
287
288 /* Ensure sizeof(enum) == sizeof(int) */
289 RETRO_LANGUAGE_DUMMY = INT_MAX
290 };
291
292 /* Passed to retro_get_memory_data/size().
293 * If the memory type doesn't apply to the
294 * implementation NULL/0 can be returned.
295 */
296 #define RETRO_MEMORY_MASK 0xff
297
298 /* Regular save RAM. This RAM is usually found on a game cartridge,
299 * backed up by a battery.
300 * If save game data is too complex for a single memory buffer,
301 * the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment
302 * callback can be used. */
303 #define RETRO_MEMORY_SAVE_RAM 0
304
305 /* Some games have a built-in clock to keep track of time.
306 * This memory is usually just a couple of bytes to keep track of time.
307 */
308 #define RETRO_MEMORY_RTC 1
309
310 /* System ram lets a frontend peek into a game systems main RAM. */
311 #define RETRO_MEMORY_SYSTEM_RAM 2
312
313 /* Video ram lets a frontend peek into a game systems video RAM (VRAM). */
314 #define RETRO_MEMORY_VIDEO_RAM 3
315
316 /* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */
317 enum retro_key
318 {
319 RETROK_UNKNOWN = 0,
320 RETROK_FIRST = 0,
321 RETROK_BACKSPACE = 8,
322 RETROK_TAB = 9,
323 RETROK_CLEAR = 12,
324 RETROK_RETURN = 13,
325 RETROK_PAUSE = 19,
326 RETROK_ESCAPE = 27,
327 RETROK_SPACE = 32,
328 RETROK_EXCLAIM = 33,
329 RETROK_QUOTEDBL = 34,
330 RETROK_HASH = 35,
331 RETROK_DOLLAR = 36,
332 RETROK_AMPERSAND = 38,
333 RETROK_QUOTE = 39,
334 RETROK_LEFTPAREN = 40,
335 RETROK_RIGHTPAREN = 41,
336 RETROK_ASTERISK = 42,
337 RETROK_PLUS = 43,
338 RETROK_COMMA = 44,
339 RETROK_MINUS = 45,
340 RETROK_PERIOD = 46,
341 RETROK_SLASH = 47,
342 RETROK_0 = 48,
343 RETROK_1 = 49,
344 RETROK_2 = 50,
345 RETROK_3 = 51,
346 RETROK_4 = 52,
347 RETROK_5 = 53,
348 RETROK_6 = 54,
349 RETROK_7 = 55,
350 RETROK_8 = 56,
351 RETROK_9 = 57,
352 RETROK_COLON = 58,
353 RETROK_SEMICOLON = 59,
354 RETROK_LESS = 60,
355 RETROK_EQUALS = 61,
356 RETROK_GREATER = 62,
357 RETROK_QUESTION = 63,
358 RETROK_AT = 64,
359 RETROK_LEFTBRACKET = 91,
360 RETROK_BACKSLASH = 92,
361 RETROK_RIGHTBRACKET = 93,
362 RETROK_CARET = 94,
363 RETROK_UNDERSCORE = 95,
364 RETROK_BACKQUOTE = 96,
365 RETROK_a = 97,
366 RETROK_b = 98,
367 RETROK_c = 99,
368 RETROK_d = 100,
369 RETROK_e = 101,
370 RETROK_f = 102,
371 RETROK_g = 103,
372 RETROK_h = 104,
373 RETROK_i = 105,
374 RETROK_j = 106,
375 RETROK_k = 107,
376 RETROK_l = 108,
377 RETROK_m = 109,
378 RETROK_n = 110,
379 RETROK_o = 111,
380 RETROK_p = 112,
381 RETROK_q = 113,
382 RETROK_r = 114,
383 RETROK_s = 115,
384 RETROK_t = 116,
385 RETROK_u = 117,
386 RETROK_v = 118,
387 RETROK_w = 119,
388 RETROK_x = 120,
389 RETROK_y = 121,
390 RETROK_z = 122,
391 RETROK_LEFTBRACE = 123,
392 RETROK_BAR = 124,
393 RETROK_RIGHTBRACE = 125,
394 RETROK_TILDE = 126,
395 RETROK_DELETE = 127,
396
397 RETROK_KP0 = 256,
398 RETROK_KP1 = 257,
399 RETROK_KP2 = 258,
400 RETROK_KP3 = 259,
401 RETROK_KP4 = 260,
402 RETROK_KP5 = 261,
403 RETROK_KP6 = 262,
404 RETROK_KP7 = 263,
405 RETROK_KP8 = 264,
406 RETROK_KP9 = 265,
407 RETROK_KP_PERIOD = 266,
408 RETROK_KP_DIVIDE = 267,
409 RETROK_KP_MULTIPLY = 268,
410 RETROK_KP_MINUS = 269,
411 RETROK_KP_PLUS = 270,
412 RETROK_KP_ENTER = 271,
413 RETROK_KP_EQUALS = 272,
414
415 RETROK_UP = 273,
416 RETROK_DOWN = 274,
417 RETROK_RIGHT = 275,
418 RETROK_LEFT = 276,
419 RETROK_INSERT = 277,
420 RETROK_HOME = 278,
421 RETROK_END = 279,
422 RETROK_PAGEUP = 280,
423 RETROK_PAGEDOWN = 281,
424
425 RETROK_F1 = 282,
426 RETROK_F2 = 283,
427 RETROK_F3 = 284,
428 RETROK_F4 = 285,
429 RETROK_F5 = 286,
430 RETROK_F6 = 287,
431 RETROK_F7 = 288,
432 RETROK_F8 = 289,
433 RETROK_F9 = 290,
434 RETROK_F10 = 291,
435 RETROK_F11 = 292,
436 RETROK_F12 = 293,
437 RETROK_F13 = 294,
438 RETROK_F14 = 295,
439 RETROK_F15 = 296,
440
441 RETROK_NUMLOCK = 300,
442 RETROK_CAPSLOCK = 301,
443 RETROK_SCROLLOCK = 302,
444 RETROK_RSHIFT = 303,
445 RETROK_LSHIFT = 304,
446 RETROK_RCTRL = 305,
447 RETROK_LCTRL = 306,
448 RETROK_RALT = 307,
449 RETROK_LALT = 308,
450 RETROK_RMETA = 309,
451 RETROK_LMETA = 310,
452 RETROK_LSUPER = 311,
453 RETROK_RSUPER = 312,
454 RETROK_MODE = 313,
455 RETROK_COMPOSE = 314,
456
457 RETROK_HELP = 315,
458 RETROK_PRINT = 316,
459 RETROK_SYSREQ = 317,
460 RETROK_BREAK = 318,
461 RETROK_MENU = 319,
462 RETROK_POWER = 320,
463 RETROK_EURO = 321,
464 RETROK_UNDO = 322,
465 RETROK_OEM_102 = 323,
466
467 RETROK_LAST,
468
469 RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
470 };
471
472 enum retro_mod
473 {
474 RETROKMOD_NONE = 0x0000,
475
476 RETROKMOD_SHIFT = 0x01,
477 RETROKMOD_CTRL = 0x02,
478 RETROKMOD_ALT = 0x04,
479 RETROKMOD_META = 0x08,
480
481 RETROKMOD_NUMLOCK = 0x10,
482 RETROKMOD_CAPSLOCK = 0x20,
483 RETROKMOD_SCROLLOCK = 0x40,
484
485 RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
486 };
487
488 /* If set, this call is not part of the public libretro API yet. It can
489 * change or be removed at any time. */
490 #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000
491 /* Environment callback to be used internally in frontend. */
492 #define RETRO_ENVIRONMENT_PRIVATE 0x20000
493
494 /* Environment commands. */
495 #define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * --
496 * Sets screen rotation of graphics.
497 * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180,
498 * 270 degrees counter-clockwise respectively.
499 */
500 #define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * --
501 * NOTE: As of 2019 this callback is considered deprecated in favor of
502 * using core options to manage overscan in a more nuanced, core-specific way.
503 *
504 * Boolean value whether or not the implementation should use overscan,
505 * or crop away overscan.
506 */
507 #define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * --
508 * Boolean value whether or not frontend supports frame duping,
509 * passing NULL to video frame callback.
510 */
511
512 /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),
513 * and reserved to avoid possible ABI clash.
514 */
515
516 #define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * --
517 * Sets a message to be displayed in implementation-specific manner
518 * for a certain amount of 'frames'.
519 * Should not be used for trivial messages, which should simply be
520 * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
521 * fallback, stderr).
522 */
523 #define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) --
524 * Requests the frontend to shutdown.
525 * Should only be used if game has a specific
526 * way to shutdown the game from a menu item or similar.
527 */
528 #define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8
529 /* const unsigned * --
530 * Gives a hint to the frontend how demanding this implementation
531 * is on a system. E.g. reporting a level of 2 means
532 * this implementation should run decently on all frontends
533 * of level 2 and up.
534 *
535 * It can be used by the frontend to potentially warn
536 * about too demanding implementations.
537 *
538 * The levels are "floating".
539 *
540 * This function can be called on a per-game basis,
541 * as certain games an implementation can play might be
542 * particularly demanding.
543 * If called, it should be called in retro_load_game().
544 */
545 #define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9
546 /* const char ** --
547 * Returns the "system" directory of the frontend.
548 * This directory can be used to store system specific
549 * content such as BIOSes, configuration data, etc.
550 * The returned value can be NULL.
551 * If so, no such directory is defined,
552 * and it's up to the implementation to find a suitable directory.
553 *
554 * NOTE: Some cores used this folder also for "save" data such as
555 * memory cards, etc, for lack of a better place to put it.
556 * This is now discouraged, and if possible, cores should try to
557 * use the new GET_SAVE_DIRECTORY.
558 */
559 #define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
560 /* const enum retro_pixel_format * --
561 * Sets the internal pixel format used by the implementation.
562 * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.
563 * This pixel format however, is deprecated (see enum retro_pixel_format).
564 * If the call returns false, the frontend does not support this pixel
565 * format.
566 *
567 * This function should be called inside retro_load_game() or
568 * retro_get_system_av_info().
569 */
570 #define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11
571 /* const struct retro_input_descriptor * --
572 * Sets an array of retro_input_descriptors.
573 * It is up to the frontend to present this in a usable way.
574 * The array is terminated by retro_input_descriptor::description
575 * being set to NULL.
576 * This function can be called at any time, but it is recommended
577 * to call it as early as possible.
578 */
579 #define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12
580 /* const struct retro_keyboard_callback * --
581 * Sets a callback function used to notify core about keyboard events.
582 */
583 #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13
584 /* const struct retro_disk_control_callback * --
585 * Sets an interface which frontend can use to eject and insert
586 * disk images.
587 * This is used for games which consist of multiple images and
588 * must be manually swapped out by the user (e.g. PSX).
589 */
590 #define RETRO_ENVIRONMENT_SET_HW_RENDER 14
591 /* struct retro_hw_render_callback * --
592 * Sets an interface to let a libretro core render with
593 * hardware acceleration.
594 * Should be called in retro_load_game().
595 * If successful, libretro cores will be able to render to a
596 * frontend-provided framebuffer.
597 * The size of this framebuffer will be at least as large as
598 * max_width/max_height provided in get_av_info().
599 * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or
600 * NULL to retro_video_refresh_t.
601 */
602 #define RETRO_ENVIRONMENT_GET_VARIABLE 15
603 /* struct retro_variable * --
604 * Interface to acquire user-defined information from environment
605 * that cannot feasibly be supported in a multi-system way.
606 * 'key' should be set to a key which has already been set by
607 * SET_VARIABLES.
608 * 'data' will be set to a value or NULL.
609 */
610 #define RETRO_ENVIRONMENT_SET_VARIABLES 16
611 /* const struct retro_variable * --
612 * Allows an implementation to signal the environment
613 * which variables it might want to check for later using
614 * GET_VARIABLE.
615 * This allows the frontend to present these variables to
616 * a user dynamically.
617 * This should be called the first time as early as
618 * possible (ideally in retro_set_environment).
619 * Afterward it may be called again for the core to communicate
620 * updated options to the frontend, but the number of core
621 * options must not change from the number in the initial call.
622 *
623 * 'data' points to an array of retro_variable structs
624 * terminated by a { NULL, NULL } element.
625 * retro_variable::key should be namespaced to not collide
626 * with other implementations' keys. E.g. A core called
627 * 'foo' should use keys named as 'foo_option'.
628 * retro_variable::value should contain a human readable
629 * description of the key as well as a '|' delimited list
630 * of expected values.
631 *
632 * The number of possible options should be very limited,
633 * i.e. it should be feasible to cycle through options
634 * without a keyboard.
635 *
636 * First entry should be treated as a default.
637 *
638 * Example entry:
639 * { "foo_option", "Speed hack coprocessor X; false|true" }
640 *
641 * Text before first ';' is description. This ';' must be
642 * followed by a space, and followed by a list of possible
643 * values split up with '|'.
644 *
645 * Only strings are operated on. The possible values will
646 * generally be displayed and stored as-is by the frontend.
647 */
648 #define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17
649 /* bool * --
650 * Result is set to true if some variables are updated by
651 * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.
652 * Variables should be queried with GET_VARIABLE.
653 */
654 #define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18
655 /* const bool * --
656 * If true, the libretro implementation supports calls to
657 * retro_load_game() with NULL as argument.
658 * Used by cores which can run without particular game data.
659 * This should be called within retro_set_environment() only.
660 */
661 #define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19
662 /* const char ** --
663 * Retrieves the absolute path from where this libretro
664 * implementation was loaded.
665 * NULL is returned if the libretro was loaded statically
666 * (i.e. linked statically to frontend), or if the path cannot be
667 * determined.
668 * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can
669 * be loaded without ugly hacks.
670 */
671
672 /* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.
673 * It was not used by any known core at the time,
674 * and was removed from the API. */
675 #define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
676 /* const struct retro_frame_time_callback * --
677 * Lets the core know how much time has passed since last
678 * invocation of retro_run().
679 * The frontend can tamper with the timing to fake fast-forward,
680 * slow-motion, frame stepping, etc.
681 * In this case the delta time will use the reference value
682 * in frame_time_callback..
683 */
684 #define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22
685 /* const struct retro_audio_callback * --
686 * Sets an interface which is used to notify a libretro core about audio
687 * being available for writing.
688 * The callback can be called from any thread, so a core using this must
689 * have a thread safe audio implementation.
690 * It is intended for games where audio and video are completely
691 * asynchronous and audio can be generated on the fly.
692 * This interface is not recommended for use with emulators which have
693 * highly synchronous audio.
694 *
695 * The callback only notifies about writability; the libretro core still
696 * has to call the normal audio callbacks
697 * to write audio. The audio callbacks must be called from within the
698 * notification callback.
699 * The amount of audio data to write is up to the implementation.
700 * Generally, the audio callback will be called continously in a loop.
701 *
702 * Due to thread safety guarantees and lack of sync between audio and
703 * video, a frontend can selectively disallow this interface based on
704 * internal configuration. A core using this interface must also
705 * implement the "normal" audio interface.
706 *
707 * A libretro core using SET_AUDIO_CALLBACK should also make use of
708 * SET_FRAME_TIME_CALLBACK.
709 */
710 #define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23
711 /* struct retro_rumble_interface * --
712 * Gets an interface which is used by a libretro core to set
713 * state of rumble motors in controllers.
714 * A strong and weak motor is supported, and they can be
715 * controlled indepedently.
716 * Should be called from either retro_init() or retro_load_game().
717 * Should not be called from retro_set_environment().
718 * Returns false if rumble functionality is unavailable.
719 */
720 #define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24
721 /* uint64_t * --
722 * Gets a bitmask telling which device type are expected to be
723 * handled properly in a call to retro_input_state_t.
724 * Devices which are not handled or recognized always return
725 * 0 in retro_input_state_t.
726 * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).
727 * Should only be called in retro_run().
728 */
729 #define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL)
730 /* struct retro_sensor_interface * --
731 * Gets access to the sensor interface.
732 * The purpose of this interface is to allow
733 * setting state related to sensors such as polling rate,
734 * enabling/disable it entirely, etc.
735 * Reading sensor state is done via the normal
736 * input_state_callback API.
737 */
738 #define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL)
739 /* struct retro_camera_callback * --
740 * Gets an interface to a video camera driver.
741 * A libretro core can use this interface to get access to a
742 * video camera.
743 * New video frames are delivered in a callback in same
744 * thread as retro_run().
745 *
746 * GET_CAMERA_INTERFACE should be called in retro_load_game().
747 *
748 * Depending on the camera implementation used, camera frames
749 * will be delivered as a raw framebuffer,
750 * or as an OpenGL texture directly.
751 *
752 * The core has to tell the frontend here which types of
753 * buffers can be handled properly.
754 * An OpenGL texture can only be handled when using a
755 * libretro GL core (SET_HW_RENDER).
756 * It is recommended to use a libretro GL core when
757 * using camera interface.
758 *
759 * The camera is not started automatically. The retrieved start/stop
760 * functions must be used to explicitly
761 * start and stop the camera driver.
762 */
763 #define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27
764 /* struct retro_log_callback * --
765 * Gets an interface for logging. This is useful for
766 * logging in a cross-platform way
767 * as certain platforms cannot use stderr for logging.
768 * It also allows the frontend to
769 * show logging information in a more suitable way.
770 * If this interface is not used, libretro cores should
771 * log to stderr as desired.
772 */
773 #define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28
774 /* struct retro_perf_callback * --
775 * Gets an interface for performance counters. This is useful
776 * for performance logging in a cross-platform way and for detecting
777 * architecture-specific features, such as SIMD support.
778 */
779 #define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29
780 /* struct retro_location_callback * --
781 * Gets access to the location interface.
782 * The purpose of this interface is to be able to retrieve
783 * location-based information from the host device,
784 * such as current latitude / longitude.
785 */
786 #define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */
787 #define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30
788 /* const char ** --
789 * Returns the "core assets" directory of the frontend.
790 * This directory can be used to store specific assets that the
791 * core relies upon, such as art assets,
792 * input data, etc etc.
793 * The returned value can be NULL.
794 * If so, no such directory is defined,
795 * and it's up to the implementation to find a suitable directory.
796 */
797 #define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31
798 /* const char ** --
799 * Returns the "save" directory of the frontend, unless there is no
800 * save directory available. The save directory should be used to
801 * store SRAM, memory cards, high scores, etc, if the libretro core
802 * cannot use the regular memory interface (retro_get_memory_data()).
803 *
804 * If the frontend cannot designate a save directory, it will return
805 * NULL to indicate that the core should attempt to operate without a
806 * save directory set.
807 *
808 * NOTE: early libretro cores used the system directory for save
809 * files. Cores that need to be backwards-compatible can still check
810 * GET_SYSTEM_DIRECTORY.
811 */
812 #define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32
813 /* const struct retro_system_av_info * --
814 * Sets a new av_info structure. This can only be called from
815 * within retro_run().
816 * This should *only* be used if the core is completely altering the
817 * internal resolutions, aspect ratios, timings, sampling rate, etc.
818 * Calling this can require a full reinitialization of video/audio
819 * drivers in the frontend,
820 *
821 * so it is important to call it very sparingly, and usually only with
822 * the users explicit consent.
823 * An eventual driver reinitialize will happen so that video and
824 * audio callbacks
825 * happening after this call within the same retro_run() call will
826 * target the newly initialized driver.
827 *
828 * This callback makes it possible to support configurable resolutions
829 * in games, which can be useful to
830 * avoid setting the "worst case" in max_width/max_height.
831 *
832 * ***HIGHLY RECOMMENDED*** Do not call this callback every time
833 * resolution changes in an emulator core if it's
834 * expected to be a temporary change, for the reasons of possible
835 * driver reinitialization.
836 * This call is not a free pass for not trying to provide
837 * correct values in retro_get_system_av_info(). If you need to change
838 * things like aspect ratio or nominal width/height,
839 * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant
840 * of SET_SYSTEM_AV_INFO.
841 *
842 * If this returns false, the frontend does not acknowledge a
843 * changed av_info struct.
844 */
845 #define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33
846 /* const struct retro_get_proc_address_interface * --
847 * Allows a libretro core to announce support for the
848 * get_proc_address() interface.
849 * This interface allows for a standard way to extend libretro where
850 * use of environment calls are too indirect,
851 * e.g. for cases where the frontend wants to call directly into the core.
852 *
853 * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK
854 * **MUST** be called from within retro_set_environment().
855 */
856 #define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34
857 /* const struct retro_subsystem_info * --
858 * This environment call introduces the concept of libretro "subsystems".
859 * A subsystem is a variant of a libretro core which supports
860 * different kinds of games.
861 * The purpose of this is to support e.g. emulators which might
862 * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo.
863 * It can also be used to pick among subsystems in an explicit way
864 * if the libretro implementation is a multi-system emulator itself.
865 *
866 * Loading a game via a subsystem is done with retro_load_game_special(),
867 * and this environment call allows a libretro core to expose which
868 * subsystems are supported for use with retro_load_game_special().
869 * A core passes an array of retro_game_special_info which is terminated
870 * with a zeroed out retro_game_special_info struct.
871 *
872 * If a core wants to use this functionality, SET_SUBSYSTEM_INFO
873 * **MUST** be called from within retro_set_environment().
874 */
875 #define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35
876 /* const struct retro_controller_info * --
877 * This environment call lets a libretro core tell the frontend
878 * which controller subclasses are recognized in calls to
879 * retro_set_controller_port_device().
880 *
881 * Some emulators such as Super Nintendo support multiple lightgun
882 * types which must be specifically selected from. It is therefore
883 * sometimes necessary for a frontend to be able to tell the core
884 * about a special kind of input device which is not specifcally
885 * provided by the Libretro API.
886 *
887 * In order for a frontend to understand the workings of those devices,
888 * they must be defined as a specialized subclass of the generic device
889 * types already defined in the libretro API.
890 *
891 * The core must pass an array of const struct retro_controller_info which
892 * is terminated with a blanked out struct. Each element of the
893 * retro_controller_info struct corresponds to the ascending port index
894 * that is passed to retro_set_controller_port_device() when that function
895 * is called to indicate to the core that the frontend has changed the
896 * active device subclass. SEE ALSO: retro_set_controller_port_device()
897 *
898 * The ascending input port indexes provided by the core in the struct
899 * are generally presented by frontends as ascending User # or Player #,
900 * such as Player 1, Player 2, Player 3, etc. Which device subclasses are
901 * supported can vary per input port.
902 *
903 * The first inner element of each entry in the retro_controller_info array
904 * is a retro_controller_description struct that specifies the names and
905 * codes of all device subclasses that are available for the corresponding
906 * User or Player, beginning with the generic Libretro device that the
907 * subclasses are derived from. The second inner element of each entry is the
908 * total number of subclasses that are listed in the retro_controller_description.
909 *
910 * NOTE: Even if special device types are set in the libretro core,
911 * libretro should only poll input based on the base input device types.
912 */
913 #define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL)
914 /* const struct retro_memory_map * --
915 * This environment call lets a libretro core tell the frontend
916 * about the memory maps this core emulates.
917 * This can be used to implement, for example, cheats in a core-agnostic way.
918 *
919 * Should only be used by emulators; it doesn't make much sense for
920 * anything else.
921 * It is recommended to expose all relevant pointers through
922 * retro_get_memory_* as well.
923 *
924 * Can be called from retro_init and retro_load_game.
925 */
926 #define RETRO_ENVIRONMENT_SET_GEOMETRY 37
927 /* const struct retro_game_geometry * --
928 * This environment call is similar to SET_SYSTEM_AV_INFO for changing
929 * video parameters, but provides a guarantee that drivers will not be
930 * reinitialized.
931 * This can only be called from within retro_run().
932 *
933 * The purpose of this call is to allow a core to alter nominal
934 * width/heights as well as aspect ratios on-the-fly, which can be
935 * useful for some emulators to change in run-time.
936 *
937 * max_width/max_height arguments are ignored and cannot be changed
938 * with this call as this could potentially require a reinitialization or a
939 * non-constant time operation.
940 * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required.
941 *
942 * A frontend must guarantee that this environment call completes in
943 * constant time.
944 */
945 #define RETRO_ENVIRONMENT_GET_USERNAME 38
946 /* const char **
947 * Returns the specified username of the frontend, if specified by the user.
948 * This username can be used as a nickname for a core that has online facilities
949 * or any other mode where personalization of the user is desirable.
950 * The returned value can be NULL.
951 * If this environ callback is used by a core that requires a valid username,
952 * a default username should be specified by the core.
953 */
954 #define RETRO_ENVIRONMENT_GET_LANGUAGE 39
955 /* unsigned * --
956 * Returns the specified language of the frontend, if specified by the user.
957 * It can be used by the core for localization purposes.
958 */
959 #define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL)
960 /* struct retro_framebuffer * --
961 * Returns a preallocated framebuffer which the core can use for rendering
962 * the frame into when not using SET_HW_RENDER.
963 * The framebuffer returned from this call must not be used
964 * after the current call to retro_run() returns.
965 *
966 * The goal of this call is to allow zero-copy behavior where a core
967 * can render directly into video memory, avoiding extra bandwidth cost by copying
968 * memory from core to video memory.
969 *
970 * If this call succeeds and the core renders into it,
971 * the framebuffer pointer and pitch can be passed to retro_video_refresh_t.
972 * If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used,
973 * the core must pass the exact
974 * same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER;
975 * i.e. passing a pointer which is offset from the
976 * buffer is undefined. The width, height and pitch parameters
977 * must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER.
978 *
979 * It is possible for a frontend to return a different pixel format
980 * than the one used in SET_PIXEL_FORMAT. This can happen if the frontend
981 * needs to perform conversion.
982 *
983 * It is still valid for a core to render to a different buffer
984 * even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds.
985 *
986 * A frontend must make sure that the pointer obtained from this function is
987 * writeable (and readable).
988 */
989 #define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
990 /* const struct retro_hw_render_interface ** --
991 * Returns an API specific rendering interface for accessing API specific data.
992 * Not all HW rendering APIs support or need this.
993 * The contents of the returned pointer is specific to the rendering API
994 * being used. See the various headers like libretro_vulkan.h, etc.
995 *
996 * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
997 * Similarly, after context_destroyed callback returns,
998 * the contents of the HW_RENDER_INTERFACE are invalidated.
999 */
1000 #define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1001 /* const bool * --
1002 * If true, the libretro implementation supports achievements
1003 * either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS
1004 * or via retro_get_memory_data/retro_get_memory_size.
1005 *
1006 * This must be called before the first call to retro_run.
1007 */
1008 #define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1009 /* const struct retro_hw_render_context_negotiation_interface * --
1010 * Sets an interface which lets the libretro core negotiate with frontend how a context is created.
1011 * The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.
1012 * This interface will be used when the frontend is trying to create a HW rendering context,
1013 * so it will be used after SET_HW_RENDER, but before the context_reset callback.
1014 */
1015 #define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44
1016 /* uint64_t * --
1017 * Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't
1018 * recognize or support. Should be set in either retro_init or retro_load_game, but not both.
1019 */
1020 #define RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT (44 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1021 /* N/A (null) * --
1022 * The frontend will try to use a 'shared' hardware context (mostly applicable
1023 * to OpenGL) when a hardware context is being set up.
1024 *
1025 * Returns true if the frontend supports shared hardware contexts and false
1026 * if the frontend does not support shared hardware contexts.
1027 *
1028 * This will do nothing on its own until SET_HW_RENDER env callbacks are
1029 * being used.
1030 */
1031 #define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1032 /* struct retro_vfs_interface_info * --
1033 * Gets access to the VFS interface.
1034 * VFS presence needs to be queried prior to load_game or any
1035 * get_system/save/other_directory being called to let front end know
1036 * core supports VFS before it starts handing out paths.
1037 * It is recomended to do so in retro_set_environment
1038 */
1039 #define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1040 /* struct retro_led_interface * --
1041 * Gets an interface which is used by a libretro core to set
1042 * state of LEDs.
1043 */
1044 #define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1045 /* int * --
1046 * Tells the core if the frontend wants audio or video.
1047 * If disabled, the frontend will discard the audio or video,
1048 * so the core may decide to skip generating a frame or generating audio.
1049 * This is mainly used for increasing performance.
1050 * Bit 0 (value 1): Enable Video
1051 * Bit 1 (value 2): Enable Audio
1052 * Bit 2 (value 4): Use Fast Savestates.
1053 * Bit 3 (value 8): Hard Disable Audio
1054 * Other bits are reserved for future use and will default to zero.
1055 * If video is disabled:
1056 * * The frontend wants the core to not generate any video,
1057 * including presenting frames via hardware acceleration.
1058 * * The frontend's video frame callback will do nothing.
1059 * * After running the frame, the video output of the next frame should be
1060 * no different than if video was enabled, and saving and loading state
1061 * should have no issues.
1062 * If audio is disabled:
1063 * * The frontend wants the core to not generate any audio.
1064 * * The frontend's audio callbacks will do nothing.
1065 * * After running the frame, the audio output of the next frame should be
1066 * no different than if audio was enabled, and saving and loading state
1067 * should have no issues.
1068 * Fast Savestates:
1069 * * Guaranteed to be created by the same binary that will load them.
1070 * * Will not be written to or read from the disk.
1071 * * Suggest that the core assumes loading state will succeed.
1072 * * Suggest that the core updates its memory buffers in-place if possible.
1073 * * Suggest that the core skips clearing memory.
1074 * * Suggest that the core skips resetting the system.
1075 * * Suggest that the core may skip validation steps.
1076 * Hard Disable Audio:
1077 * * Used for a secondary core when running ahead.
1078 * * Indicates that the frontend will never need audio from the core.
1079 * * Suggests that the core may stop synthesizing audio, but this should not
1080 * compromise emulation accuracy.
1081 * * Audio output for the next frame does not matter, and the frontend will
1082 * never need an accurate audio state in the future.
1083 * * State will never be saved when using Hard Disable Audio.
1084 */
1085 #define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1086 /* struct retro_midi_interface ** --
1087 * Returns a MIDI interface that can be used for raw data I/O.
1088 */
1089
1090 #define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1091 /* bool * --
1092 * Boolean value that indicates whether or not the frontend is in
1093 * fastforwarding mode.
1094 */
1095
1096 #define RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE (50 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1097 /* float * --
1098 * Float value that lets us know what target refresh rate
1099 * is curently in use by the frontend.
1100 *
1101 * The core can use the returned value to set an ideal
1102 * refresh rate/framerate.
1103 */
1104
1105 #define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS (51 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1106 /* bool * --
1107 * Boolean value that indicates whether or not the frontend supports
1108 * input bitmasks being returned by retro_input_state_t. The advantage
1109 * of this is that retro_input_state_t has to be only called once to
1110 * grab all button states instead of multiple times.
1111 *
1112 * If it returns true, you can pass RETRO_DEVICE_ID_JOYPAD_MASK as 'id'
1113 * to retro_input_state_t (make sure 'device' is set to RETRO_DEVICE_JOYPAD).
1114 * It will return a bitmask of all the digital buttons.
1115 */
1116
1117 #define RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION 52
1118 /* unsigned * --
1119 * Unsigned value is the API version number of the core options
1120 * interface supported by the frontend. If callback return false,
1121 * API version is assumed to be 0.
1122 *
1123 * In legacy code, core options are set by passing an array of
1124 * retro_variable structs to RETRO_ENVIRONMENT_SET_VARIABLES.
1125 * This may be still be done regardless of the core options
1126 * interface version.
1127 *
1128 * If version is >= 1 however, core options may instead be set by
1129 * passing an array of retro_core_option_definition structs to
1130 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS, or a 2D array of
1131 * retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
1132 * This allows the core to additionally set option sublabel information
1133 * and/or provide localisation support.
1134 */
1135
1136 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 53
1137 /* const struct retro_core_option_definition ** --
1138 * Allows an implementation to signal the environment
1139 * which variables it might want to check for later using
1140 * GET_VARIABLE.
1141 * This allows the frontend to present these variables to
1142 * a user dynamically.
1143 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1144 * returns an API version of >= 1.
1145 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1146 * This should be called the first time as early as
1147 * possible (ideally in retro_set_environment).
1148 * Afterwards it may be called again for the core to communicate
1149 * updated options to the frontend, but the number of core
1150 * options must not change from the number in the initial call.
1151 *
1152 * 'data' points to an array of retro_core_option_definition structs
1153 * terminated by a { NULL, NULL, NULL, {{0}}, NULL } element.
1154 * retro_core_option_definition::key should be namespaced to not collide
1155 * with other implementations' keys. e.g. A core called
1156 * 'foo' should use keys named as 'foo_option'.
1157 * retro_core_option_definition::desc should contain a human readable
1158 * description of the key.
1159 * retro_core_option_definition::info should contain any additional human
1160 * readable information text that a typical user may need to
1161 * understand the functionality of the option.
1162 * retro_core_option_definition::values is an array of retro_core_option_value
1163 * structs terminated by a { NULL, NULL } element.
1164 * > retro_core_option_definition::values[index].value is an expected option
1165 * value.
1166 * > retro_core_option_definition::values[index].label is a human readable
1167 * label used when displaying the value on screen. If NULL,
1168 * the value itself is used.
1169 * retro_core_option_definition::default_value is the default core option
1170 * setting. It must match one of the expected option values in the
1171 * retro_core_option_definition::values array. If it does not, or the
1172 * default value is NULL, the first entry in the
1173 * retro_core_option_definition::values array is treated as the default.
1174 *
1175 * The number of possible options should be very limited,
1176 * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
1177 * i.e. it should be feasible to cycle through options
1178 * without a keyboard.
1179 *
1180 * Example entry:
1181 * {
1182 * "foo_option",
1183 * "Speed hack coprocessor X",
1184 * "Provides increased performance at the expense of reduced accuracy",
1185 * {
1186 * { "false", NULL },
1187 * { "true", NULL },
1188 * { "unstable", "Turbo (Unstable)" },
1189 * { NULL, NULL },
1190 * },
1191 * "false"
1192 * }
1193 *
1194 * Only strings are operated on. The possible values will
1195 * generally be displayed and stored as-is by the frontend.
1196 */
1197
1198 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL 54
1199 /* const struct retro_core_options_intl * --
1200 * Allows an implementation to signal the environment
1201 * which variables it might want to check for later using
1202 * GET_VARIABLE.
1203 * This allows the frontend to present these variables to
1204 * a user dynamically.
1205 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1206 * returns an API version of >= 1.
1207 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1208 * This should be called the first time as early as
1209 * possible (ideally in retro_set_environment).
1210 * Afterwards it may be called again for the core to communicate
1211 * updated options to the frontend, but the number of core
1212 * options must not change from the number in the initial call.
1213 *
1214 * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS,
1215 * with the addition of localisation support. The description of the
1216 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS callback should be consulted
1217 * for further details.
1218 *
1219 * 'data' points to a retro_core_options_intl struct.
1220 *
1221 * retro_core_options_intl::us is a pointer to an array of
1222 * retro_core_option_definition structs defining the US English
1223 * core options implementation. It must point to a valid array.
1224 *
1225 * retro_core_options_intl::local is a pointer to an array of
1226 * retro_core_option_definition structs defining core options for
1227 * the current frontend language. It may be NULL (in which case
1228 * retro_core_options_intl::us is used by the frontend). Any items
1229 * missing from this array will be read from retro_core_options_intl::us
1230 * instead.
1231 *
1232 * NOTE: Default core option values are always taken from the
1233 * retro_core_options_intl::us array. Any default values in
1234 * retro_core_options_intl::local array will be ignored.
1235 */
1236
1237 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY 55
1238 /* struct retro_core_option_display * --
1239 *
1240 * Allows an implementation to signal the environment to show
1241 * or hide a variable when displaying core options. This is
1242 * considered a *suggestion*. The frontend is free to ignore
1243 * this callback, and its implementation not considered mandatory.
1244 *
1245 * 'data' points to a retro_core_option_display struct
1246 *
1247 * retro_core_option_display::key is a variable identifier
1248 * which has already been set by SET_VARIABLES/SET_CORE_OPTIONS.
1249 *
1250 * retro_core_option_display::visible is a boolean, specifying
1251 * whether variable should be displayed
1252 *
1253 * Note that all core option variables will be set visible by
1254 * default when calling SET_VARIABLES/SET_CORE_OPTIONS.
1255 */
1256
1257 #define RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER 56
1258 /* unsigned * --
1259 *
1260 * Allows an implementation to ask frontend preferred hardware
1261 * context to use. Core should use this information to deal
1262 * with what specific context to request with SET_HW_RENDER.
1263 *
1264 * 'data' points to an unsigned variable
1265 */
1266
1267 #define RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION 57
1268 /* unsigned * --
1269 * Unsigned value is the API version number of the disk control
1270 * interface supported by the frontend. If callback return false,
1271 * API version is assumed to be 0.
1272 *
1273 * In legacy code, the disk control interface is defined by passing
1274 * a struct of type retro_disk_control_callback to
1275 * RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.
1276 * This may be still be done regardless of the disk control
1277 * interface version.
1278 *
1279 * If version is >= 1 however, the disk control interface may
1280 * instead be defined by passing a struct of type
1281 * retro_disk_control_ext_callback to
1282 * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.
1283 * This allows the core to provide additional information about
1284 * disk images to the frontend and/or enables extra
1285 * disk control functionality by the frontend.
1286 */
1287
1288 #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE 58
1289 /* const struct retro_disk_control_ext_callback * --
1290 * Sets an interface which frontend can use to eject and insert
1291 * disk images, and also obtain information about individual
1292 * disk image files registered by the core.
1293 * This is used for games which consist of multiple images and
1294 * must be manually swapped out by the user (e.g. PSX, floppy disk
1295 * based systems).
1296 */
1297
1298 #define RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 59
1299 /* unsigned * --
1300 * Unsigned value is the API version number of the message
1301 * interface supported by the frontend. If callback returns
1302 * false, API version is assumed to be 0.
1303 *
1304 * In legacy code, messages may be displayed in an
1305 * implementation-specific manner by passing a struct
1306 * of type retro_message to RETRO_ENVIRONMENT_SET_MESSAGE.
1307 * This may be still be done regardless of the message
1308 * interface version.
1309 *
1310 * If version is >= 1 however, messages may instead be
1311 * displayed by passing a struct of type retro_message_ext
1312 * to RETRO_ENVIRONMENT_SET_MESSAGE_EXT. This allows the
1313 * core to specify message logging level, priority and
1314 * destination (OSD, logging interface or both).
1315 */
1316
1317 #define RETRO_ENVIRONMENT_SET_MESSAGE_EXT 60
1318 /* const struct retro_message_ext * --
1319 * Sets a message to be displayed in an implementation-specific
1320 * manner for a certain amount of 'frames'. Additionally allows
1321 * the core to specify message logging level, priority and
1322 * destination (OSD, logging interface or both).
1323 * Should not be used for trivial messages, which should simply be
1324 * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
1325 * fallback, stderr).
1326 */
1327
1328 #define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 61
1329 /* unsigned * --
1330 * Unsigned value is the number of active input devices
1331 * provided by the frontend. This may change between
1332 * frames, but will remain constant for the duration
1333 * of each frame.
1334 * If callback returns true, a core need not poll any
1335 * input device with an index greater than or equal to
1336 * the number of active devices.
1337 * If callback returns false, the number of active input
1338 * devices is unknown. In this case, all input devices
1339 * should be considered active.
1340 */
1341
1342 #define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 62
1343 /* const struct retro_audio_buffer_status_callback * --
1344 * Lets the core know the occupancy level of the frontend
1345 * audio buffer. Can be used by a core to attempt frame
1346 * skipping in order to avoid buffer under-runs.
1347 * A core may pass NULL to disable buffer status reporting
1348 * in the frontend.
1349 */
1350
1351 #define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 63
1352 /* const unsigned * --
1353 * Sets minimum frontend audio latency in milliseconds.
1354 * Resultant audio latency may be larger than set value,
1355 * or smaller if a hardware limit is encountered. A frontend
1356 * is expected to honour requests up to 512 ms.
1357 *
1358 * - If value is less than current frontend
1359 * audio latency, callback has no effect
1360 * - If value is zero, default frontend audio
1361 * latency is set
1362 *
1363 * May be used by a core to increase audio latency and
1364 * therefore decrease the probability of buffer under-runs
1365 * (crackling) when performing 'intensive' operations.
1366 * A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK
1367 * to implement audio-buffer-based frame skipping may achieve
1368 * optimal results by setting the audio latency to a 'high'
1369 * (typically 6x or 8x) integer multiple of the expected
1370 * frame time.
1371 *
1372 * WARNING: This can only be called from within retro_run().
1373 * Calling this can require a full reinitialization of audio
1374 * drivers in the frontend, so it is important to call it very
1375 * sparingly, and usually only with the users explicit consent.
1376 * An eventual driver reinitialize will happen so that audio
1377 * callbacks happening after this call within the same retro_run()
1378 * call will target the newly initialized driver.
1379 */
1380
1381 #define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64
1382 /* const struct retro_fastforwarding_override * --
1383 * Used by a libretro core to override the current
1384 * fastforwarding mode of the frontend.
1385 * If NULL is passed to this function, the frontend
1386 * will return true if fastforwarding override
1387 * functionality is supported (no change in
1388 * fastforwarding state will occur in this case).
1389 */
1390
1391 #define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 65
1392 /* const struct retro_system_content_info_override * --
1393 * Allows an implementation to override 'global' content
1394 * info parameters reported by retro_get_system_info().
1395 * Overrides also affect subsystem content info parameters
1396 * set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO.
1397 * This function must be called inside retro_set_environment().
1398 * If callback returns false, content info overrides
1399 * are unsupported by the frontend, and will be ignored.
1400 * If callback returns true, extended game info may be
1401 * retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
1402 * in retro_load_game() or retro_load_game_special().
1403 *
1404 * 'data' points to an array of retro_system_content_info_override
1405 * structs terminated by a { NULL, false, false } element.
1406 * If 'data' is NULL, no changes will be made to the frontend;
1407 * a core may therefore pass NULL in order to test whether
1408 * the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and
1409 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported
1410 * by the frontend.
1411 *
1412 * For struct member descriptions, see the definition of
1413 * struct retro_system_content_info_override.
1414 *
1415 * Example:
1416 *
1417 * - struct retro_system_info:
1418 * {
1419 * "My Core", // library_name
1420 * "v1.0", // library_version
1421 * "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions
1422 * true, // need_fullpath
1423 * false // block_extract
1424 * }
1425 *
1426 * - Array of struct retro_system_content_info_override:
1427 * {
1428 * {
1429 * "md|sms|gg", // extensions
1430 * false, // need_fullpath
1431 * true // persistent_data
1432 * },
1433 * {
1434 * "sg", // extensions
1435 * false, // need_fullpath
1436 * false // persistent_data
1437 * },
1438 * { NULL, false, false }
1439 * }
1440 *
1441 * Result:
1442 * - Files of type m3u, cue, iso, chd will not be
1443 * loaded by the frontend. Frontend will pass a
1444 * valid path to the core, and core will handle
1445 * loading internally
1446 * - Files of type md, sms, gg will be loaded by
1447 * the frontend. A valid memory buffer will be
1448 * passed to the core. This memory buffer will
1449 * remain valid until retro_deinit() returns
1450 * - Files of type sg will be loaded by the frontend.
1451 * A valid memory buffer will be passed to the core.
1452 * This memory buffer will remain valid until
1453 * retro_load_game() (or retro_load_game_special())
1454 * returns
1455 *
1456 * NOTE: If an extension is listed multiple times in
1457 * an array of retro_system_content_info_override
1458 * structs, only the first instance will be registered
1459 */
1460
1461 #define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 66
1462 /* const struct retro_game_info_ext ** --
1463 * Allows an implementation to fetch extended game
1464 * information, providing additional content path
1465 * and memory buffer status details.
1466 * This function may only be called inside
1467 * retro_load_game() or retro_load_game_special().
1468 * If callback returns false, extended game information
1469 * is unsupported by the frontend. In this case, only
1470 * regular retro_game_info will be available.
1471 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed
1472 * to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
1473 * returns true.
1474 *
1475 * 'data' points to an array of retro_game_info_ext structs.
1476 *
1477 * For struct member descriptions, see the definition of
1478 * struct retro_game_info_ext.
1479 *
1480 * - If function is called inside retro_load_game(),
1481 * the retro_game_info_ext array is guaranteed to
1482 * have a size of 1 - i.e. the returned pointer may
1483 * be used to access directly the members of the
1484 * first retro_game_info_ext struct, for example:
1485 *
1486 * struct retro_game_info_ext *game_info_ext;
1487 * if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext))
1488 * printf("Content Directory: %s\n", game_info_ext->dir);
1489 *
1490 * - If the function is called inside retro_load_game_special(),
1491 * the retro_game_info_ext array is guaranteed to have a
1492 * size equal to the num_info argument passed to
1493 * retro_load_game_special()
1494 */
1495
1496 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 67
1497 /* const struct retro_core_options_v2 * --
1498 * Allows an implementation to signal the environment
1499 * which variables it might want to check for later using
1500 * GET_VARIABLE.
1501 * This allows the frontend to present these variables to
1502 * a user dynamically.
1503 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1504 * returns an API version of >= 2.
1505 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1506 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
1507 * This should be called the first time as early as
1508 * possible (ideally in retro_set_environment).
1509 * Afterwards it may be called again for the core to communicate
1510 * updated options to the frontend, but the number of core
1511 * options must not change from the number in the initial call.
1512 * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
1513 * version of >= 2, this callback is guaranteed to succeed
1514 * (i.e. callback return value does not indicate success)
1515 * If callback returns true, frontend has core option category
1516 * support.
1517 * If callback returns false, frontend does not have core option
1518 * category support.
1519 *
1520 * 'data' points to a retro_core_options_v2 struct, containing
1521 * of two pointers:
1522 * - retro_core_options_v2::categories is an array of
1523 * retro_core_option_v2_category structs terminated by a
1524 * { NULL, NULL, NULL } element. If retro_core_options_v2::categories
1525 * is NULL, all core options will have no category and will be shown
1526 * at the top level of the frontend core option interface. If frontend
1527 * does not have core option category support, categories array will
1528 * be ignored.
1529 * - retro_core_options_v2::definitions is an array of
1530 * retro_core_option_v2_definition structs terminated by a
1531 * { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }
1532 * element.
1533 *
1534 * >> retro_core_option_v2_category notes:
1535 *
1536 * - retro_core_option_v2_category::key should contain string
1537 * that uniquely identifies the core option category. Valid
1538 * key characters are [a-z, A-Z, 0-9, _, -]
1539 * Namespace collisions with other implementations' category
1540 * keys are permitted.
1541 * - retro_core_option_v2_category::desc should contain a human
1542 * readable description of the category key.
1543 * - retro_core_option_v2_category::info should contain any
1544 * additional human readable information text that a typical
1545 * user may need to understand the nature of the core option
1546 * category.
1547 *
1548 * Example entry:
1549 * {
1550 * "advanced_settings",
1551 * "Advanced",
1552 * "Options affecting low-level emulation performance and accuracy."
1553 * }
1554 *
1555 * >> retro_core_option_v2_definition notes:
1556 *
1557 * - retro_core_option_v2_definition::key should be namespaced to not
1558 * collide with other implementations' keys. e.g. A core called
1559 * 'foo' should use keys named as 'foo_option'. Valid key characters
1560 * are [a-z, A-Z, 0-9, _, -].
1561 * - retro_core_option_v2_definition::desc should contain a human readable
1562 * description of the key. Will be used when the frontend does not
1563 * have core option category support. Examples: "Aspect Ratio" or
1564 * "Video > Aspect Ratio".
1565 * - retro_core_option_v2_definition::desc_categorized should contain a
1566 * human readable description of the key, which will be used when
1567 * frontend has core option category support. Example: "Aspect Ratio",
1568 * where associated retro_core_option_v2_category::desc is "Video".
1569 * If empty or NULL, the string specified by
1570 * retro_core_option_v2_definition::desc will be used instead.
1571 * retro_core_option_v2_definition::desc_categorized will be ignored
1572 * if retro_core_option_v2_definition::category_key is empty or NULL.
1573 * - retro_core_option_v2_definition::info should contain any additional
1574 * human readable information text that a typical user may need to
1575 * understand the functionality of the option.
1576 * - retro_core_option_v2_definition::info_categorized should contain
1577 * any additional human readable information text that a typical user
1578 * may need to understand the functionality of the option, and will be
1579 * used when frontend has core option category support. This is provided
1580 * to accommodate the case where info text references an option by
1581 * name/desc, and the desc/desc_categorized text for that option differ.
1582 * If empty or NULL, the string specified by
1583 * retro_core_option_v2_definition::info will be used instead.
1584 * retro_core_option_v2_definition::info_categorized will be ignored
1585 * if retro_core_option_v2_definition::category_key is empty or NULL.
1586 * - retro_core_option_v2_definition::category_key should contain a
1587 * category identifier (e.g. "video" or "audio") that will be
1588 * assigned to the core option if frontend has core option category
1589 * support. A categorized option will be shown in a subsection/
1590 * submenu of the frontend core option interface. If key is empty
1591 * or NULL, or if key does not match one of the
1592 * retro_core_option_v2_category::key values in the associated
1593 * retro_core_option_v2_category array, option will have no category
1594 * and will be shown at the top level of the frontend core option
1595 * interface.
1596 * - retro_core_option_v2_definition::values is an array of
1597 * retro_core_option_value structs terminated by a { NULL, NULL }
1598 * element.
1599 * --> retro_core_option_v2_definition::values[index].value is an
1600 * expected option value.
1601 * --> retro_core_option_v2_definition::values[index].label is a
1602 * human readable label used when displaying the value on screen.
1603 * If NULL, the value itself is used.
1604 * - retro_core_option_v2_definition::default_value is the default
1605 * core option setting. It must match one of the expected option
1606 * values in the retro_core_option_v2_definition::values array. If
1607 * it does not, or the default value is NULL, the first entry in the
1608 * retro_core_option_v2_definition::values array is treated as the
1609 * default.
1610 *
1611 * The number of possible option values should be very limited,
1612 * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
1613 * i.e. it should be feasible to cycle through options
1614 * without a keyboard.
1615 *
1616 * Example entries:
1617 *
1618 * - Uncategorized:
1619 *
1620 * {
1621 * "foo_option",
1622 * "Speed hack coprocessor X",
1623 * NULL,
1624 * "Provides increased performance at the expense of reduced accuracy.",
1625 * NULL,
1626 * NULL,
1627 * {
1628 * { "false", NULL },
1629 * { "true", NULL },
1630 * { "unstable", "Turbo (Unstable)" },
1631 * { NULL, NULL },
1632 * },
1633 * "false"
1634 * }
1635 *
1636 * - Categorized:
1637 *
1638 * {
1639 * "foo_option",
1640 * "Advanced > Speed hack coprocessor X",
1641 * "Speed hack coprocessor X",
1642 * "Setting 'Advanced > Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
1643 * "Setting 'Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
1644 * "advanced_settings",
1645 * {
1646 * { "false", NULL },
1647 * { "true", NULL },
1648 * { "unstable", "Turbo (Unstable)" },
1649 * { NULL, NULL },
1650 * },
1651 * "false"
1652 * }
1653 *
1654 * Only strings are operated on. The possible values will
1655 * generally be displayed and stored as-is by the frontend.
1656 */
1657
1658 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 68
1659 /* const struct retro_core_options_v2_intl * --
1660 * Allows an implementation to signal the environment
1661 * which variables it might want to check for later using
1662 * GET_VARIABLE.
1663 * This allows the frontend to present these variables to
1664 * a user dynamically.
1665 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1666 * returns an API version of >= 2.
1667 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1668 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
1669 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
1670 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2.
1671 * This should be called the first time as early as
1672 * possible (ideally in retro_set_environment).
1673 * Afterwards it may be called again for the core to communicate
1674 * updated options to the frontend, but the number of core
1675 * options must not change from the number in the initial call.
1676 * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
1677 * version of >= 2, this callback is guaranteed to succeed
1678 * (i.e. callback return value does not indicate success)
1679 * If callback returns true, frontend has core option category
1680 * support.
1681 * If callback returns false, frontend does not have core option
1682 * category support.
1683 *
1684 * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
1685 * with the addition of localisation support. The description of the
1686 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 callback should be consulted
1687 * for further details.
1688 *
1689 * 'data' points to a retro_core_options_v2_intl struct.
1690 *
1691 * - retro_core_options_v2_intl::us is a pointer to a
1692 * retro_core_options_v2 struct defining the US English
1693 * core options implementation. It must point to a valid struct.
1694 *
1695 * - retro_core_options_v2_intl::local is a pointer to a
1696 * retro_core_options_v2 struct defining core options for
1697 * the current frontend language. It may be NULL (in which case
1698 * retro_core_options_v2_intl::us is used by the frontend). Any items
1699 * missing from this struct will be read from
1700 * retro_core_options_v2_intl::us instead.
1701 *
1702 * NOTE: Default core option values are always taken from the
1703 * retro_core_options_v2_intl::us struct. Any default values in
1704 * the retro_core_options_v2_intl::local struct will be ignored.
1705 */
1706
1707 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 69
1708 /* const struct retro_core_options_update_display_callback * --
1709 * Allows a frontend to signal that a core must update
1710 * the visibility of any dynamically hidden core options,
1711 * and enables the frontend to detect visibility changes.
1712 * Used by the frontend to update the menu display status
1713 * of core options without requiring a call of retro_run().
1714 * Must be called in retro_set_environment().
1715 */
1716
1717 #define RETRO_ENVIRONMENT_SET_VARIABLE 70
1718 /* const struct retro_variable * --
1719 * Allows an implementation to notify the frontend
1720 * that a core option value has changed.
1721 *
1722 * retro_variable::key and retro_variable::value
1723 * must match strings that have been set previously
1724 * via one of the following:
1725 *
1726 * - RETRO_ENVIRONMENT_SET_VARIABLES
1727 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS
1728 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL
1729 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2
1730 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL
1731 *
1732 * After changing a core option value via this
1733 * callback, RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE
1734 * will return true.
1735 *
1736 * If data is NULL, no changes will be registered
1737 * and the callback will return true; an
1738 * implementation may therefore pass NULL in order
1739 * to test whether the callback is supported.
1740 */
1741
1742 #define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1743 /* struct retro_throttle_state * --
1744 * Allows an implementation to get details on the actual rate
1745 * the frontend is attempting to call retro_run().
1746 */
1747
1748 /* VFS functionality */
1749
1750 /* File paths:
1751 * File paths passed as parameters when using this API shall be well formed UNIX-style,
1752 * using "/" (unquoted forward slash) as directory separator regardless of the platform's native separator.
1753 * Paths shall also include at least one forward slash ("game.bin" is an invalid path, use "./game.bin" instead).
1754 * Other than the directory separator, cores shall not make assumptions about path format:
1755 * "C:/path/game.bin", "http://example.com/game.bin", "#game/game.bin", "./game.bin" (without quotes) are all valid paths.
1756 * Cores may replace the basename or remove path components from the end, and/or add new components;
1757 * however, cores shall not append "./", "../" or multiple consecutive forward slashes ("//") to paths they request to front end.
1758 * The frontend is encouraged to make such paths work as well as it can, but is allowed to give up if the core alters paths too much.
1759 * Frontends are encouraged, but not required, to support native file system paths (modulo replacing the directory separator, if applicable).
1760 * Cores are allowed to try using them, but must remain functional if the front rejects such requests.
1761 * Cores are encouraged to use the libretro-common filestream functions for file I/O,
1762 * as they seamlessly integrate with VFS, deal with directory separator replacement as appropriate
1763 * and provide platform-specific fallbacks in cases where front ends do not support VFS. */
1764
1765 /* Opaque file handle
1766 * Introduced in VFS API v1 */
1767 struct retro_vfs_file_handle;
1768
1769 /* Opaque directory handle
1770 * Introduced in VFS API v3 */
1771 struct retro_vfs_dir_handle;
1772
1773 /* File open flags
1774 * Introduced in VFS API v1 */
1775 #define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */
1776 #define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) /* Write only mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified */
1777 #define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/
1778 #define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */
1779
1780 /* These are only hints. The frontend may choose to ignore them. Other than RAM/CPU/etc use,
1781 and how they react to unlikely external interference (for example someone else writing to that file,
1782 or the file's server going down), behavior will not change. */
1783 #define RETRO_VFS_FILE_ACCESS_HINT_NONE (0)
1784 /* Indicate that the file will be accessed many times. The frontend should aggressively cache everything. */
1785 #define RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS (1 << 0)
1786
1787 /* Seek positions */
1788 #define RETRO_VFS_SEEK_POSITION_START 0
1789 #define RETRO_VFS_SEEK_POSITION_CURRENT 1
1790 #define RETRO_VFS_SEEK_POSITION_END 2
1791
1792 /* stat() result flags
1793 * Introduced in VFS API v3 */
1794 #define RETRO_VFS_STAT_IS_VALID (1 << 0)
1795 #define RETRO_VFS_STAT_IS_DIRECTORY (1 << 1)
1796 #define RETRO_VFS_STAT_IS_CHARACTER_SPECIAL (1 << 2)
1797
1798 /* Get path from opaque handle. Returns the exact same path passed to file_open when getting the handle
1799 * Introduced in VFS API v1 */
1800 typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file_handle *stream);
1801
1802 /* Open a file for reading or writing. If path points to a directory, this will
1803 * fail. Returns the opaque file handle, or NULL for error.
1804 * Introduced in VFS API v1 */
1805 typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints);
1806
1807 /* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on success, -1 on failure.
1808 * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
1809 * Introduced in VFS API v1 */
1810 typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *stream);
1811
1812 /* Return the size of the file in bytes, or -1 for error.
1813 * Introduced in VFS API v1 */
1814 typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream);
1815
1816 /* Truncate file to specified size. Returns 0 on success or -1 on error
1817 * Introduced in VFS API v2 */
1818 typedef int64_t (RETRO_CALLCONV *retro_vfs_truncate_t)(struct retro_vfs_file_handle *stream, int64_t length);
1819
1820 /* Get the current read / write position for the file. Returns -1 for error.
1821 * Introduced in VFS API v1 */
1822 typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream);
1823
1824 /* Set the current read/write position for the file. Returns the new position, -1 for error.
1825 * Introduced in VFS API v1 */
1826 typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position);
1827
1828 /* Read data from a file. Returns the number of bytes read, or -1 for error.
1829 * Introduced in VFS API v1 */
1830 typedef int64_t (RETRO_CALLCONV *retro_vfs_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len);
1831
1832 /* Write data to a file. Returns the number of bytes written, or -1 for error.
1833 * Introduced in VFS API v1 */
1834 typedef int64_t (RETRO_CALLCONV *retro_vfs_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len);
1835
1836 /* Flush pending writes to file, if using buffered IO. Returns 0 on sucess, or -1 on failure.
1837 * Introduced in VFS API v1 */
1838 typedef int (RETRO_CALLCONV *retro_vfs_flush_t)(struct retro_vfs_file_handle *stream);
1839
1840 /* Delete the specified file. Returns 0 on success, -1 on failure
1841 * Introduced in VFS API v1 */
1842 typedef int (RETRO_CALLCONV *retro_vfs_remove_t)(const char *path);
1843
1844 /* Rename the specified file. Returns 0 on success, -1 on failure
1845 * Introduced in VFS API v1 */
1846 typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const char *new_path);
1847
1848 /* Stat the specified file. Retruns a bitmask of RETRO_VFS_STAT_* flags, none are set if path was not valid.
1849 * Additionally stores file size in given variable, unless NULL is given.
1850 * Introduced in VFS API v3 */
1851 typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size);
1852
1853 /* Create the specified directory. Returns 0 on success, -1 on unknown failure, -2 if already exists.
1854 * Introduced in VFS API v3 */
1855 typedef int (RETRO_CALLCONV *retro_vfs_mkdir_t)(const char *dir);
1856
1857 /* Open the specified directory for listing. Returns the opaque dir handle, or NULL for error.
1858 * Support for the include_hidden argument may vary depending on the platform.
1859 * Introduced in VFS API v3 */
1860 typedef struct retro_vfs_dir_handle *(RETRO_CALLCONV *retro_vfs_opendir_t)(const char *dir, bool include_hidden);
1861
1862 /* Read the directory entry at the current position, and move the read pointer to the next position.
1863 * Returns true on success, false if already on the last entry.
1864 * Introduced in VFS API v3 */
1865 typedef bool (RETRO_CALLCONV *retro_vfs_readdir_t)(struct retro_vfs_dir_handle *dirstream);
1866
1867 /* Get the name of the last entry read. Returns a string on success, or NULL for error.
1868 * The returned string pointer is valid until the next call to readdir or closedir.
1869 * Introduced in VFS API v3 */
1870 typedef const char *(RETRO_CALLCONV *retro_vfs_dirent_get_name_t)(struct retro_vfs_dir_handle *dirstream);
1871
1872 /* Check if the last entry read was a directory. Returns true if it was, false otherwise (or on error).
1873 * Introduced in VFS API v3 */
1874 typedef bool (RETRO_CALLCONV *retro_vfs_dirent_is_dir_t)(struct retro_vfs_dir_handle *dirstream);
1875
1876 /* Close the directory and release its resources. Must be called if opendir returns non-NULL. Returns 0 on success, -1 on failure.
1877 * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
1878 * Introduced in VFS API v3 */
1879 typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle *dirstream);
1880
1881 struct retro_vfs_interface
1882 {
1883 /* VFS API v1 */
1884 retro_vfs_get_path_t get_path;
1885 retro_vfs_open_t open;
1886 retro_vfs_close_t close;
1887 retro_vfs_size_t size;
1888 retro_vfs_tell_t tell;
1889 retro_vfs_seek_t seek;
1890 retro_vfs_read_t read;
1891 retro_vfs_write_t write;
1892 retro_vfs_flush_t flush;
1893 retro_vfs_remove_t remove;
1894 retro_vfs_rename_t rename;
1895 /* VFS API v2 */
1896 retro_vfs_truncate_t truncate;
1897 /* VFS API v3 */
1898 retro_vfs_stat_t stat;
1899 retro_vfs_mkdir_t mkdir;
1900 retro_vfs_opendir_t opendir;
1901 retro_vfs_readdir_t readdir;
1902 retro_vfs_dirent_get_name_t dirent_get_name;
1903 retro_vfs_dirent_is_dir_t dirent_is_dir;
1904 retro_vfs_closedir_t closedir;
1905 };
1906
1907 struct retro_vfs_interface_info
1908 {
1909 /* Set by core: should this be higher than the version the front end supports,
1910 * front end will return false in the RETRO_ENVIRONMENT_GET_VFS_INTERFACE call
1911 * Introduced in VFS API v1 */
1912 uint32_t required_interface_version;
1913
1914 /* Frontend writes interface pointer here. The frontend also sets the actual
1915 * version, must be at least required_interface_version.
1916 * Introduced in VFS API v1 */
1917 struct retro_vfs_interface *iface;
1918 };
1919
1920 enum retro_hw_render_interface_type
1921 {
1922 RETRO_HW_RENDER_INTERFACE_VULKAN = 0,
1923 RETRO_HW_RENDER_INTERFACE_D3D9 = 1,
1924 RETRO_HW_RENDER_INTERFACE_D3D10 = 2,
1925 RETRO_HW_RENDER_INTERFACE_D3D11 = 3,
1926 RETRO_HW_RENDER_INTERFACE_D3D12 = 4,
1927 RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5,
1928 RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX
1929 };
1930
1931 /* Base struct. All retro_hw_render_interface_* types
1932 * contain at least these fields. */
1933 struct retro_hw_render_interface
1934 {
1935 enum retro_hw_render_interface_type interface_type;
1936 unsigned interface_version;
1937 };
1938
1939 typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state);
1940 struct retro_led_interface
1941 {
1942 retro_set_led_state_t set_led_state;
1943 };
1944
1945 /* Retrieves the current state of the MIDI input.
1946 * Returns true if it's enabled, false otherwise. */
1947 typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);
1948
1949 /* Retrieves the current state of the MIDI output.
1950 * Returns true if it's enabled, false otherwise */
1951 typedef bool (RETRO_CALLCONV *retro_midi_output_enabled_t)(void);
1952
1953 /* Reads next byte from the input stream.
1954 * Returns true if byte is read, false otherwise. */
1955 typedef bool (RETRO_CALLCONV *retro_midi_read_t)(uint8_t *byte);
1956
1957 /* Writes byte to the output stream.
1958 * 'delta_time' is in microseconds and represent time elapsed since previous write.
1959 * Returns true if byte is written, false otherwise. */
1960 typedef bool (RETRO_CALLCONV *retro_midi_write_t)(uint8_t byte, uint32_t delta_time);
1961
1962 /* Flushes previously written data.
1963 * Returns true if successful, false otherwise. */
1964 typedef bool (RETRO_CALLCONV *retro_midi_flush_t)(void);
1965
1966 struct retro_midi_interface
1967 {
1968 retro_midi_input_enabled_t input_enabled;
1969 retro_midi_output_enabled_t output_enabled;
1970 retro_midi_read_t read;
1971 retro_midi_write_t write;
1972 retro_midi_flush_t flush;
1973 };
1974
1975 enum retro_hw_render_context_negotiation_interface_type
1976 {
1977 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0,
1978 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX
1979 };
1980
1981 /* Base struct. All retro_hw_render_context_negotiation_interface_* types
1982 * contain at least these fields. */
1983 struct retro_hw_render_context_negotiation_interface
1984 {
1985 enum retro_hw_render_context_negotiation_interface_type interface_type;
1986 unsigned interface_version;
1987 };
1988
1989 /* Serialized state is incomplete in some way. Set if serialization is
1990 * usable in typical end-user cases but should not be relied upon to
1991 * implement frame-sensitive frontend features such as netplay or
1992 * rerecording. */
1993 #define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0)
1994 /* The core must spend some time initializing before serialization is
1995 * supported. retro_serialize() will initially fail; retro_unserialize()
1996 * and retro_serialize_size() may or may not work correctly either. */
1997 #define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1)
1998 /* Serialization size may change within a session. */
1999 #define RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE (1 << 2)
2000 /* Set by the frontend to acknowledge that it supports variable-sized
2001 * states. */
2002 #define RETRO_SERIALIZATION_QUIRK_FRONT_VARIABLE_SIZE (1 << 3)
2003 /* Serialized state can only be loaded during the same session. */
2004 #define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4)
2005 /* Serialized state cannot be loaded on an architecture with a different
2006 * endianness from the one it was saved on. */
2007 #define RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT (1 << 5)
2008 /* Serialized state cannot be loaded on a different platform from the one it
2009 * was saved on for reasons other than endianness, such as word size
2010 * dependence */
2011 #define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6)
2012
2013 #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */
2014 #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */
2015 #define RETRO_MEMDESC_SYSTEM_RAM (1 << 2) /* The memory area is system RAM. This is main RAM of the gaming system. */
2016 #define RETRO_MEMDESC_SAVE_RAM (1 << 3) /* The memory area is save RAM. This RAM is usually found on a game cartridge, backed up by a battery. */
2017 #define RETRO_MEMDESC_VIDEO_RAM (1 << 4) /* The memory area is video RAM (VRAM) */
2018 #define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */
2019 #define RETRO_MEMDESC_ALIGN_4 (2 << 16)
2020 #define RETRO_MEMDESC_ALIGN_8 (3 << 16)
2021 #define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */
2022 #define RETRO_MEMDESC_MINSIZE_4 (2 << 24)
2023 #define RETRO_MEMDESC_MINSIZE_8 (3 << 24)
2024 struct retro_memory_descriptor
2025 {
2026 uint64_t flags;
2027
2028 /* Pointer to the start of the relevant ROM or RAM chip.
2029 * It's strongly recommended to use 'offset' if possible, rather than
2030 * doing math on the pointer.
2031 *
2032 * If the same byte is mapped my multiple descriptors, their descriptors
2033 * must have the same pointer.
2034 * If 'start' does not point to the first byte in the pointer, put the
2035 * difference in 'offset' instead.
2036 *
2037 * May be NULL if there's nothing usable here (e.g. hardware registers and
2038 * open bus). No flags should be set if the pointer is NULL.
2039 * It's recommended to minimize the number of descriptors if possible,
2040 * but not mandatory. */
2041 void *ptr;
2042 size_t offset;
2043
2044 /* This is the location in the emulated address space
2045 * where the mapping starts. */
2046 size_t start;
2047
2048 /* Which bits must be same as in 'start' for this mapping to apply.
2049 * The first memory descriptor to claim a certain byte is the one
2050 * that applies.
2051 * A bit which is set in 'start' must also be set in this.
2052 * Can be zero, in which case each byte is assumed mapped exactly once.
2053 * In this case, 'len' must be a power of two. */
2054 size_t select;
2055
2056 /* If this is nonzero, the set bits are assumed not connected to the
2057 * memory chip's address pins. */
2058 size_t disconnect;
2059
2060 /* This one tells the size of the current memory area.
2061 * If, after start+disconnect are applied, the address is higher than
2062 * this, the highest bit of the address is cleared.
2063 *
2064 * If the address is still too high, the next highest bit is cleared.
2065 * Can be zero, in which case it's assumed to be infinite (as limited
2066 * by 'select' and 'disconnect'). */
2067 size_t len;
2068
2069 /* To go from emulated address to physical address, the following
2070 * order applies:
2071 * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. */
2072
2073 /* The address space name must consist of only a-zA-Z0-9_-,
2074 * should be as short as feasible (maximum length is 8 plus the NUL),
2075 * and may not be any other address space plus one or more 0-9A-F
2076 * at the end.
2077 * However, multiple memory descriptors for the same address space is
2078 * allowed, and the address space name can be empty. NULL is treated
2079 * as empty.
2080 *
2081 * Address space names are case sensitive, but avoid lowercase if possible.
2082 * The same pointer may exist in multiple address spaces.
2083 *
2084 * Examples:
2085 * blank+blank - valid (multiple things may be mapped in the same namespace)
2086 * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace)
2087 * 'A'+'B' - valid (neither is a prefix of each other)
2088 * 'S'+blank - valid ('S' is not in 0-9A-F)
2089 * 'a'+blank - valid ('a' is not in 0-9A-F)
2090 * 'a'+'A' - valid (neither is a prefix of each other)
2091 * 'AR'+blank - valid ('R' is not in 0-9A-F)
2092 * 'ARB'+blank - valid (the B can't be part of the address either, because
2093 * there is no namespace 'AR')
2094 * blank+'B' - not valid, because it's ambigous which address space B1234
2095 * would refer to.
2096 * The length can't be used for that purpose; the frontend may want
2097 * to append arbitrary data to an address, without a separator. */
2098 const char *addrspace;
2099
2100 /* TODO: When finalizing this one, add a description field, which should be
2101 * "WRAM" or something roughly equally long. */
2102
2103 /* TODO: When finalizing this one, replace 'select' with 'limit', which tells
2104 * which bits can vary and still refer to the same address (limit = ~select).
2105 * TODO: limit? range? vary? something else? */
2106
2107 /* TODO: When finalizing this one, if 'len' is above what 'select' (or
2108 * 'limit') allows, it's bankswitched. Bankswitched data must have both 'len'
2109 * and 'select' != 0, and the mappings don't tell how the system switches the
2110 * banks. */
2111
2112 /* TODO: When finalizing this one, fix the 'len' bit removal order.
2113 * For len=0x1800, pointer 0x1C00 should go to 0x1400, not 0x0C00.
2114 * Algorithm: Take bits highest to lowest, but if it goes above len, clear
2115 * the most recent addition and continue on the next bit.
2116 * TODO: Can the above be optimized? Is "remove the lowest bit set in both
2117 * pointer and 'len'" equivalent? */
2118
2119 /* TODO: Some emulators (MAME?) emulate big endian systems by only accessing
2120 * the emulated memory in 32-bit chunks, native endian. But that's nothing
2121 * compared to Darek Mihocka <http://www.emulators.com/docs/nx07_vm101.htm>
2122 * (section Emulation 103 - Nearly Free Byte Reversal) - he flips the ENTIRE
2123 * RAM backwards! I'll want to represent both of those, via some flags.
2124 *
2125 * I suspect MAME either didn't think of that idea, or don't want the #ifdef.
2126 * Not sure which, nor do I really care. */
2127
2128 /* TODO: Some of those flags are unused and/or don't really make sense. Clean
2129 * them up. */
2130 };
2131
2132 /* The frontend may use the largest value of 'start'+'select' in a
2133 * certain namespace to infer the size of the address space.
2134 *
2135 * If the address space is larger than that, a mapping with .ptr=NULL
2136 * should be at the end of the array, with .select set to all ones for
2137 * as long as the address space is big.
2138 *
2139 * Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags):
2140 * SNES WRAM:
2141 * .start=0x7E0000, .len=0x20000
2142 * (Note that this must be mapped before the ROM in most cases; some of the
2143 * ROM mappers
2144 * try to claim $7E0000, or at least $7E8000.)
2145 * SNES SPC700 RAM:
2146 * .addrspace="S", .len=0x10000
2147 * SNES WRAM mirrors:
2148 * .flags=MIRROR, .start=0x000000, .select=0xC0E000, .len=0x2000
2149 * .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000
2150 * SNES WRAM mirrors, alternate equivalent descriptor:
2151 * .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF
2152 * (Various similar constructions can be created by combining parts of
2153 * the above two.)
2154 * SNES LoROM (512KB, mirrored a couple of times):
2155 * .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024
2156 * .flags=CONST, .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*1024
2157 * SNES HiROM (4MB):
2158 * .flags=CONST, .start=0x400000, .select=0x400000, .len=4*1024*1024
2159 * .flags=CONST, .offset=0x8000, .start=0x008000, .select=0x408000, .len=4*1024*1024
2160 * SNES ExHiROM (8MB):
2161 * .flags=CONST, .offset=0, .start=0xC00000, .select=0xC00000, .len=4*1024*1024
2162 * .flags=CONST, .offset=4*1024*1024, .start=0x400000, .select=0xC00000, .len=4*1024*1024
2163 * .flags=CONST, .offset=0x8000, .start=0x808000, .select=0xC08000, .len=4*1024*1024
2164 * .flags=CONST, .offset=4*1024*1024+0x8000, .start=0x008000, .select=0xC08000, .len=4*1024*1024
2165 * Clarify the size of the address space:
2166 * .ptr=NULL, .select=0xFFFFFF
2167 * .len can be implied by .select in many of them, but was included for clarity.
2168 */
2169
2170 struct retro_memory_map
2171 {
2172 const struct retro_memory_descriptor *descriptors;
2173 unsigned num_descriptors;
2174 };
2175
2176 struct retro_controller_description
2177 {
2178 /* Human-readable description of the controller. Even if using a generic
2179 * input device type, this can be set to the particular device type the
2180 * core uses. */
2181 const char *desc;
2182
2183 /* Device type passed to retro_set_controller_port_device(). If the device
2184 * type is a sub-class of a generic input device type, use the
2185 * RETRO_DEVICE_SUBCLASS macro to create an ID.
2186 *
2187 * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */
2188 unsigned id;
2189 };
2190
2191 struct retro_controller_info
2192 {
2193 const struct retro_controller_description *types;
2194 unsigned num_types;
2195 };
2196
2197 struct retro_subsystem_memory_info
2198 {
2199 /* The extension associated with a memory type, e.g. "psram". */
2200 const char *extension;
2201
2202 /* The memory type for retro_get_memory(). This should be at
2203 * least 0x100 to avoid conflict with standardized
2204 * libretro memory types. */
2205 unsigned type;
2206 };
2207
2208 struct retro_subsystem_rom_info
2209 {
2210 /* Describes what the content is (SGB BIOS, GB ROM, etc). */
2211 const char *desc;
2212
2213 /* Same definition as retro_get_system_info(). */
2214 const char *valid_extensions;
2215
2216 /* Same definition as retro_get_system_info(). */
2217 bool need_fullpath;
2218
2219 /* Same definition as retro_get_system_info(). */
2220 bool block_extract;
2221
2222 /* This is set if the content is required to load a game.
2223 * If this is set to false, a zeroed-out retro_game_info can be passed. */
2224 bool required;
2225
2226 /* Content can have multiple associated persistent
2227 * memory types (retro_get_memory()). */
2228 const struct retro_subsystem_memory_info *memory;
2229 unsigned num_memory;
2230 };
2231
2232 struct retro_subsystem_info
2233 {
2234 /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */
2235 const char *desc;
2236
2237 /* A computer friendly short string identifier for the subsystem type.
2238 * This name must be [a-z].
2239 * E.g. if desc is "Super GameBoy", this can be "sgb".
2240 * This identifier can be used for command-line interfaces, etc.
2241 */
2242 const char *ident;
2243
2244 /* Infos for each content file. The first entry is assumed to be the
2245 * "most significant" content for frontend purposes.
2246 * E.g. with Super GameBoy, the first content should be the GameBoy ROM,
2247 * as it is the most "significant" content to a user.
2248 * If a frontend creates new file paths based on the content used
2249 * (e.g. savestates), it should use the path for the first ROM to do so. */
2250 const struct retro_subsystem_rom_info *roms;
2251
2252 /* Number of content files associated with a subsystem. */
2253 unsigned num_roms;
2254
2255 /* The type passed to retro_load_game_special(). */
2256 unsigned id;
2257 };
2258
2259 typedef void (RETRO_CALLCONV *retro_proc_address_t)(void);
2260
2261 /* libretro API extension functions:
2262 * (None here so far).
2263 *
2264 * Get a symbol from a libretro core.
2265 * Cores should only return symbols which are actual
2266 * extensions to the libretro API.
2267 *
2268 * Frontends should not use this to obtain symbols to standard
2269 * libretro entry points (static linking or dlsym).
2270 *
2271 * The symbol name must be equal to the function name,
2272 * e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".
2273 * The returned function pointer must be cast to the corresponding type.
2274 */
2275 typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym);
2276
2277 struct retro_get_proc_address_interface
2278 {
2279 retro_get_proc_address_t get_proc_address;
2280 };
2281
2282 enum retro_log_level
2283 {
2284 RETRO_LOG_DEBUG = 0,
2285 RETRO_LOG_INFO,
2286 RETRO_LOG_WARN,
2287 RETRO_LOG_ERROR,
2288
2289 RETRO_LOG_DUMMY = INT_MAX
2290 };
2291
2292 /* Logging function. Takes log level argument as well. */
2293 typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level,
2294 const char *fmt, ...);
2295
2296 struct retro_log_callback
2297 {
2298 retro_log_printf_t log;
2299 };
2300
2301 /* Performance related functions */
2302
2303 /* ID values for SIMD CPU features */
2304 #define RETRO_SIMD_SSE (1 << 0)
2305 #define RETRO_SIMD_SSE2 (1 << 1)
2306 #define RETRO_SIMD_VMX (1 << 2)
2307 #define RETRO_SIMD_VMX128 (1 << 3)
2308 #define RETRO_SIMD_AVX (1 << 4)
2309 #define RETRO_SIMD_NEON (1 << 5)
2310 #define RETRO_SIMD_SSE3 (1 << 6)
2311 #define RETRO_SIMD_SSSE3 (1 << 7)
2312 #define RETRO_SIMD_MMX (1 << 8)
2313 #define RETRO_SIMD_MMXEXT (1 << 9)
2314 #define RETRO_SIMD_SSE4 (1 << 10)
2315 #define RETRO_SIMD_SSE42 (1 << 11)
2316 #define RETRO_SIMD_AVX2 (1 << 12)
2317 #define RETRO_SIMD_VFPU (1 << 13)
2318 #define RETRO_SIMD_PS (1 << 14)
2319 #define RETRO_SIMD_AES (1 << 15)
2320 #define RETRO_SIMD_VFPV3 (1 << 16)
2321 #define RETRO_SIMD_VFPV4 (1 << 17)
2322 #define RETRO_SIMD_POPCNT (1 << 18)
2323 #define RETRO_SIMD_MOVBE (1 << 19)
2324 #define RETRO_SIMD_CMOV (1 << 20)
2325 #define RETRO_SIMD_ASIMD (1 << 21)
2326
2327 typedef uint64_t retro_perf_tick_t;
2328 typedef int64_t retro_time_t;
2329
2330 struct retro_perf_counter
2331 {
2332 const char *ident;
2333 retro_perf_tick_t start;
2334 retro_perf_tick_t total;
2335 retro_perf_tick_t call_cnt;
2336
2337 bool registered;
2338 };
2339
2340 /* Returns current time in microseconds.
2341 * Tries to use the most accurate timer available.
2342 */
2343 typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void);
2344
2345 /* A simple counter. Usually nanoseconds, but can also be CPU cycles.
2346 * Can be used directly if desired (when creating a more sophisticated
2347 * performance counter system).
2348 * */
2349 typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void);
2350
2351 /* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */
2352 typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void);
2353
2354 /* Asks frontend to log and/or display the state of performance counters.
2355 * Performance counters can always be poked into manually as well.
2356 */
2357 typedef void (RETRO_CALLCONV *retro_perf_log_t)(void);
2358
2359 /* Register a performance counter.
2360 * ident field must be set with a discrete value and other values in
2361 * retro_perf_counter must be 0.
2362 * Registering can be called multiple times. To avoid calling to
2363 * frontend redundantly, you can check registered field first. */
2364 typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter);
2365
2366 /* Starts a registered counter. */
2367 typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter);
2368
2369 /* Stops a registered counter. */
2370 typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter);
2371
2372 /* For convenience it can be useful to wrap register, start and stop in macros.
2373 * E.g.:
2374 * #ifdef LOG_PERFORMANCE
2375 * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name))
2376 * #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name))
2377 * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name))
2378 * #else
2379 * ... Blank macros ...
2380 * #endif
2381 *
2382 * These can then be used mid-functions around code snippets.
2383 *
2384 * extern struct retro_perf_callback perf_cb; * Somewhere in the core.
2385 *
2386 * void do_some_heavy_work(void)
2387 * {
2388 * RETRO_PERFORMANCE_INIT(cb, work_1;
2389 * RETRO_PERFORMANCE_START(cb, work_1);
2390 * heavy_work_1();
2391 * RETRO_PERFORMANCE_STOP(cb, work_1);
2392 *
2393 * RETRO_PERFORMANCE_INIT(cb, work_2);
2394 * RETRO_PERFORMANCE_START(cb, work_2);
2395 * heavy_work_2();
2396 * RETRO_PERFORMANCE_STOP(cb, work_2);
2397 * }
2398 *
2399 * void retro_deinit(void)
2400 * {
2401 * perf_cb.perf_log(); * Log all perf counters here for example.
2402 * }
2403 */
2404
2405 struct retro_perf_callback
2406 {
2407 retro_perf_get_time_usec_t get_time_usec;
2408 retro_get_cpu_features_t get_cpu_features;
2409
2410 retro_perf_get_counter_t get_perf_counter;
2411 retro_perf_register_t perf_register;
2412 retro_perf_start_t perf_start;
2413 retro_perf_stop_t perf_stop;
2414 retro_perf_log_t perf_log;
2415 };
2416
2417 /* FIXME: Document the sensor API and work out behavior.
2418 * It will be marked as experimental until then.
2419 */
2420 enum retro_sensor_action
2421 {
2422 RETRO_SENSOR_ACCELEROMETER_ENABLE = 0,
2423 RETRO_SENSOR_ACCELEROMETER_DISABLE,
2424 RETRO_SENSOR_GYROSCOPE_ENABLE,
2425 RETRO_SENSOR_GYROSCOPE_DISABLE,
2426 RETRO_SENSOR_ILLUMINANCE_ENABLE,
2427 RETRO_SENSOR_ILLUMINANCE_DISABLE,
2428
2429 RETRO_SENSOR_DUMMY = INT_MAX
2430 };
2431
2432 /* Id values for SENSOR types. */
2433 #define RETRO_SENSOR_ACCELEROMETER_X 0
2434 #define RETRO_SENSOR_ACCELEROMETER_Y 1
2435 #define RETRO_SENSOR_ACCELEROMETER_Z 2
2436 #define RETRO_SENSOR_GYROSCOPE_X 3
2437 #define RETRO_SENSOR_GYROSCOPE_Y 4
2438 #define RETRO_SENSOR_GYROSCOPE_Z 5
2439 #define RETRO_SENSOR_ILLUMINANCE 6
2440
2441 typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port,
2442 enum retro_sensor_action action, unsigned rate);
2443
2444 typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id);
2445
2446 struct retro_sensor_interface
2447 {
2448 retro_set_sensor_state_t set_sensor_state;
2449 retro_sensor_get_input_t get_sensor_input;
2450 };
2451
2452 enum retro_camera_buffer
2453 {
2454 RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0,
2455 RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER,
2456
2457 RETRO_CAMERA_BUFFER_DUMMY = INT_MAX
2458 };
2459
2460 /* Starts the camera driver. Can only be called in retro_run(). */
2461 typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void);
2462
2463 /* Stops the camera driver. Can only be called in retro_run(). */
2464 typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void);
2465
2466 /* Callback which signals when the camera driver is initialized
2467 * and/or deinitialized.
2468 * retro_camera_start_t can be called in initialized callback.
2469 */
2470 typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void);
2471
2472 /* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.
2473 * Width, height and pitch are similar to retro_video_refresh_t.
2474 * First pixel is top-left origin.
2475 */
2476 typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer,
2477 unsigned width, unsigned height, size_t pitch);
2478
2479 /* A callback for when OpenGL textures are used.
2480 *
2481 * texture_id is a texture owned by camera driver.
2482 * Its state or content should be considered immutable, except for things like
2483 * texture filtering and clamping.
2484 *
2485 * texture_target is the texture target for the GL texture.
2486 * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly
2487 * more depending on extensions.
2488 *
2489 * affine points to a packed 3x3 column-major matrix used to apply an affine
2490 * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))
2491 * After transform, normalized texture coord (0, 0) should be bottom-left
2492 * and (1, 1) should be top-right (or (width, height) for RECTANGLE).
2493 *
2494 * GL-specific typedefs are avoided here to avoid relying on gl.h in
2495 * the API definition.
2496 */
2497 typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id,
2498 unsigned texture_target, const float *affine);
2499
2500 struct retro_camera_callback
2501 {
2502 /* Set by libretro core.
2503 * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).
2504 */
2505 uint64_t caps;
2506
2507 /* Desired resolution for camera. Is only used as a hint. */
2508 unsigned width;
2509 unsigned height;
2510
2511 /* Set by frontend. */
2512 retro_camera_start_t start;
2513 retro_camera_stop_t stop;
2514
2515 /* Set by libretro core if raw framebuffer callbacks will be used. */
2516 retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer;
2517
2518 /* Set by libretro core if OpenGL texture callbacks will be used. */
2519 retro_camera_frame_opengl_texture_t frame_opengl_texture;
2520
2521 /* Set by libretro core. Called after camera driver is initialized and
2522 * ready to be started.
2523 * Can be NULL, in which this callback is not called.
2524 */
2525 retro_camera_lifetime_status_t initialized;
2526
2527 /* Set by libretro core. Called right before camera driver is
2528 * deinitialized.
2529 * Can be NULL, in which this callback is not called.
2530 */
2531 retro_camera_lifetime_status_t deinitialized;
2532 };
2533
2534 /* Sets the interval of time and/or distance at which to update/poll
2535 * location-based data.
2536 *
2537 * To ensure compatibility with all location-based implementations,
2538 * values for both interval_ms and interval_distance should be provided.
2539 *
2540 * interval_ms is the interval expressed in milliseconds.
2541 * interval_distance is the distance interval expressed in meters.
2542 */
2543 typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms,
2544 unsigned interval_distance);
2545
2546 /* Start location services. The device will start listening for changes to the
2547 * current location at regular intervals (which are defined with
2548 * retro_location_set_interval_t). */
2549 typedef bool (RETRO_CALLCONV *retro_location_start_t)(void);
2550
2551 /* Stop location services. The device will stop listening for changes
2552 * to the current location. */
2553 typedef void (RETRO_CALLCONV *retro_location_stop_t)(void);
2554
2555 /* Get the position of the current location. Will set parameters to
2556 * 0 if no new location update has happened since the last time. */
2557 typedef bool (RETRO_CALLCONV *retro_location_get_position_t)(double *lat, double *lon,
2558 double *horiz_accuracy, double *vert_accuracy);
2559
2560 /* Callback which signals when the location driver is initialized
2561 * and/or deinitialized.
2562 * retro_location_start_t can be called in initialized callback.
2563 */
2564 typedef void (RETRO_CALLCONV *retro_location_lifetime_status_t)(void);
2565
2566 struct retro_location_callback
2567 {
2568 retro_location_start_t start;
2569 retro_location_stop_t stop;
2570 retro_location_get_position_t get_position;
2571 retro_location_set_interval_t set_interval;
2572
2573 retro_location_lifetime_status_t initialized;
2574 retro_location_lifetime_status_t deinitialized;
2575 };
2576
2577 enum retro_rumble_effect
2578 {
2579 RETRO_RUMBLE_STRONG = 0,
2580 RETRO_RUMBLE_WEAK = 1,
2581
2582 RETRO_RUMBLE_DUMMY = INT_MAX
2583 };
2584
2585 /* Sets rumble state for joypad plugged in port 'port'.
2586 * Rumble effects are controlled independently,
2587 * and setting e.g. strong rumble does not override weak rumble.
2588 * Strength has a range of [0, 0xffff].
2589 *
2590 * Returns true if rumble state request was honored.
2591 * Calling this before first retro_run() is likely to return false. */
2592 typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port,
2593 enum retro_rumble_effect effect, uint16_t strength);
2594
2595 struct retro_rumble_interface
2596 {
2597 retro_set_rumble_state_t set_rumble_state;
2598 };
2599
2600 /* Notifies libretro that audio data should be written. */
2601 typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void);
2602
2603 /* True: Audio driver in frontend is active, and callback is
2604 * expected to be called regularily.
2605 * False: Audio driver in frontend is paused or inactive.
2606 * Audio callback will not be called until set_state has been
2607 * called with true.
2608 * Initial state is false (inactive).
2609 */
2610 typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled);
2611
2612 struct retro_audio_callback
2613 {
2614 retro_audio_callback_t callback;
2615 retro_audio_set_state_callback_t set_state;
2616 };
2617
2618 /* Notifies a libretro core of time spent since last invocation
2619 * of retro_run() in microseconds.
2620 *
2621 * It will be called right before retro_run() every frame.
2622 * The frontend can tamper with timing to support cases like
2623 * fast-forward, slow-motion and framestepping.
2624 *
2625 * In those scenarios the reference frame time value will be used. */
2626 typedef int64_t retro_usec_t;
2627 typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec);
2628 struct retro_frame_time_callback
2629 {
2630 retro_frame_time_callback_t callback;
2631 /* Represents the time of one frame. It is computed as
2632 * 1000000 / fps, but the implementation will resolve the
2633 * rounding to ensure that framestepping, etc is exact. */
2634 retro_usec_t reference;
2635 };
2636
2637 /* Notifies a libretro core of the current occupancy
2638 * level of the frontend audio buffer.
2639 *
2640 * - active: 'true' if audio buffer is currently
2641 * in use. Will be 'false' if audio is
2642 * disabled in the frontend
2643 *
2644 * - occupancy: Given as a value in the range [0,100],
2645 * corresponding to the occupancy percentage
2646 * of the audio buffer
2647 *
2648 * - underrun_likely: 'true' if the frontend expects an
2649 * audio buffer underrun during the
2650 * next frame (indicates that a core
2651 * should attempt frame skipping)
2652 *
2653 * It will be called right before retro_run() every frame. */
2654 typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)(
2655 bool active, unsigned occupancy, bool underrun_likely);
2656 struct retro_audio_buffer_status_callback
2657 {
2658 retro_audio_buffer_status_callback_t callback;
2659 };
2660
2661 /* Pass this to retro_video_refresh_t if rendering to hardware.
2662 * Passing NULL to retro_video_refresh_t is still a frame dupe as normal.
2663 * */
2664 #define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1)
2665
2666 /* Invalidates the current HW context.
2667 * Any GL state is lost, and must not be deinitialized explicitly.
2668 * If explicit deinitialization is desired by the libretro core,
2669 * it should implement context_destroy callback.
2670 * If called, all GPU resources must be reinitialized.
2671 * Usually called when frontend reinits video driver.
2672 * Also called first time video driver is initialized,
2673 * allowing libretro core to initialize resources.
2674 */
2675 typedef void (RETRO_CALLCONV *retro_hw_context_reset_t)(void);
2676
2677 /* Gets current framebuffer which is to be rendered to.
2678 * Could change every frame potentially.
2679 */
2680 typedef uintptr_t (RETRO_CALLCONV *retro_hw_get_current_framebuffer_t)(void);
2681
2682 /* Get a symbol from HW context. */
2683 typedef retro_proc_address_t (RETRO_CALLCONV *retro_hw_get_proc_address_t)(const char *sym);
2684
2685 enum retro_hw_context_type
2686 {
2687 RETRO_HW_CONTEXT_NONE = 0,
2688 /* OpenGL 2.x. Driver can choose to use latest compatibility context. */
2689 RETRO_HW_CONTEXT_OPENGL = 1,
2690 /* OpenGL ES 2.0. */
2691 RETRO_HW_CONTEXT_OPENGLES2 = 2,
2692 /* Modern desktop core GL context. Use version_major/
2693 * version_minor fields to set GL version. */
2694 RETRO_HW_CONTEXT_OPENGL_CORE = 3,
2695 /* OpenGL ES 3.0 */
2696 RETRO_HW_CONTEXT_OPENGLES3 = 4,
2697 /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3,
2698 * use the corresponding enums directly. */
2699 RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,
2700
2701 /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */
2702 RETRO_HW_CONTEXT_VULKAN = 6,
2703
2704 /* Direct3D, set version_major to select the type of interface
2705 * returned by RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */
2706 RETRO_HW_CONTEXT_DIRECT3D = 7,
2707
2708 RETRO_HW_CONTEXT_DUMMY = INT_MAX
2709 };
2710
2711 struct retro_hw_render_callback
2712 {
2713 /* Which API to use. Set by libretro core. */
2714 enum retro_hw_context_type context_type;
2715
2716 /* Called when a context has been created or when it has been reset.
2717 * An OpenGL context is only valid after context_reset() has been called.
2718 *
2719 * When context_reset is called, OpenGL resources in the libretro
2720 * implementation are guaranteed to be invalid.
2721 *
2722 * It is possible that context_reset is called multiple times during an
2723 * application lifecycle.
2724 * If context_reset is called without any notification (context_destroy),
2725 * the OpenGL context was lost and resources should just be recreated
2726 * without any attempt to "free" old resources.
2727 */
2728 retro_hw_context_reset_t context_reset;
2729
2730 /* Set by frontend.
2731 * TODO: This is rather obsolete. The frontend should not
2732 * be providing preallocated framebuffers. */
2733 retro_hw_get_current_framebuffer_t get_current_framebuffer;
2734
2735 /* Set by frontend.
2736 * Can return all relevant functions, including glClear on Windows. */
2737 retro_hw_get_proc_address_t get_proc_address;
2738
2739 /* Set if render buffers should have depth component attached.
2740 * TODO: Obsolete. */
2741 bool depth;
2742
2743 /* Set if stencil buffers should be attached.
2744 * TODO: Obsolete. */
2745 bool stencil;
2746
2747 /* If depth and stencil are true, a packed 24/8 buffer will be added.
2748 * Only attaching stencil is invalid and will be ignored. */
2749
2750 /* Use conventional bottom-left origin convention. If false,
2751 * standard libretro top-left origin semantics are used.
2752 * TODO: Move to GL specific interface. */
2753 bool bottom_left_origin;
2754
2755 /* Major version number for core GL context or GLES 3.1+. */
2756 unsigned version_major;
2757
2758 /* Minor version number for core GL context or GLES 3.1+. */
2759 unsigned version_minor;
2760
2761 /* If this is true, the frontend will go very far to avoid
2762 * resetting context in scenarios like toggling fullscreen, etc.
2763 * TODO: Obsolete? Maybe frontend should just always assume this ...
2764 */
2765 bool cache_context;
2766
2767 /* The reset callback might still be called in extreme situations
2768 * such as if the context is lost beyond recovery.
2769 *
2770 * For optimal stability, set this to false, and allow context to be
2771 * reset at any time.
2772 */
2773
2774 /* A callback to be called before the context is destroyed in a
2775 * controlled way by the frontend. */
2776 retro_hw_context_reset_t context_destroy;
2777
2778 /* OpenGL resources can be deinitialized cleanly at this step.
2779 * context_destroy can be set to NULL, in which resources will
2780 * just be destroyed without any notification.
2781 *
2782 * Even when context_destroy is non-NULL, it is possible that
2783 * context_reset is called without any destroy notification.
2784 * This happens if context is lost by external factors (such as
2785 * notified by GL_ARB_robustness).
2786 *
2787 * In this case, the context is assumed to be already dead,
2788 * and the libretro implementation must not try to free any OpenGL
2789 * resources in the subsequent context_reset.
2790 */
2791
2792 /* Creates a debug context. */
2793 bool debug_context;
2794 };
2795
2796 /* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
2797 * Called by the frontend in response to keyboard events.
2798 * down is set if the key is being pressed, or false if it is being released.
2799 * keycode is the RETROK value of the char.
2800 * character is the text character of the pressed key. (UTF-32).
2801 * key_modifiers is a set of RETROKMOD values or'ed together.
2802 *
2803 * The pressed/keycode state can be indepedent of the character.
2804 * It is also possible that multiple characters are generated from a
2805 * single keypress.
2806 * Keycode events should be treated separately from character events.
2807 * However, when possible, the frontend should try to synchronize these.
2808 * If only a character is posted, keycode should be RETROK_UNKNOWN.
2809 *
2810 * Similarily if only a keycode event is generated with no corresponding
2811 * character, character should be 0.
2812 */
2813 typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode,
2814 uint32_t character, uint16_t key_modifiers);
2815
2816 struct retro_keyboard_callback
2817 {
2818 retro_keyboard_event_t callback;
2819 };
2820
2821 /* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE &
2822 * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.
2823 * Should be set for implementations which can swap out multiple disk
2824 * images in runtime.
2825 *
2826 * If the implementation can do this automatically, it should strive to do so.
2827 * However, there are cases where the user must manually do so.
2828 *
2829 * Overview: To swap a disk image, eject the disk image with
2830 * set_eject_state(true).
2831 * Set the disk index with set_image_index(index). Insert the disk again
2832 * with set_eject_state(false).
2833 */
2834
2835 /* If ejected is true, "ejects" the virtual disk tray.
2836 * When ejected, the disk image index can be set.
2837 */
2838 typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected);
2839
2840 /* Gets current eject state. The initial state is 'not ejected'. */
2841 typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void);
2842
2843 /* Gets current disk index. First disk is index 0.
2844 * If return value is >= get_num_images(), no disk is currently inserted.
2845 */
2846 typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void);
2847
2848 /* Sets image index. Can only be called when disk is ejected.
2849 * The implementation supports setting "no disk" by using an
2850 * index >= get_num_images().
2851 */
2852 typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index);
2853
2854 /* Gets total number of images which are available to use. */
2855 typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void);
2856
2857 struct retro_game_info;
2858
2859 /* Replaces the disk image associated with index.
2860 * Arguments to pass in info have same requirements as retro_load_game().
2861 * Virtual disk tray must be ejected when calling this.
2862 *
2863 * Replacing a disk image with info = NULL will remove the disk image
2864 * from the internal list.
2865 * As a result, calls to get_image_index() can change.
2866 *
2867 * E.g. replace_image_index(1, NULL), and previous get_image_index()
2868 * returned 4 before.
2869 * Index 1 will be removed, and the new index is 3.
2870 */
2871 typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index,
2872 const struct retro_game_info *info);
2873
2874 /* Adds a new valid index (get_num_images()) to the internal disk list.
2875 * This will increment subsequent return values from get_num_images() by 1.
2876 * This image index cannot be used until a disk image has been set
2877 * with replace_image_index. */
2878 typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void);
2879
2880 /* Sets initial image to insert in drive when calling
2881 * core_load_game().
2882 * Since we cannot pass the initial index when loading
2883 * content (this would require a major API change), this
2884 * is set by the frontend *before* calling the core's
2885 * retro_load_game()/retro_load_game_special() implementation.
2886 * A core should therefore cache the index/path values and handle
2887 * them inside retro_load_game()/retro_load_game_special().
2888 * - If 'index' is invalid (index >= get_num_images()), the
2889 * core should ignore the set value and instead use 0
2890 * - 'path' is used purely for error checking - i.e. when
2891 * content is loaded, the core should verify that the
2892 * disk specified by 'index' has the specified file path.
2893 * This is to guard against auto selecting the wrong image
2894 * if (for example) the user should modify an existing M3U
2895 * playlist. We have to let the core handle this because
2896 * set_initial_image() must be called before loading content,
2897 * i.e. the frontend cannot access image paths in advance
2898 * and thus cannot perform the error check itself.
2899 * If set path and content path do not match, the core should
2900 * ignore the set 'index' value and instead use 0
2901 * Returns 'false' if index or 'path' are invalid, or core
2902 * does not support this functionality
2903 */
2904 typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const char *path);
2905
2906 /* Fetches the path of the specified disk image file.
2907 * Returns 'false' if index is invalid (index >= get_num_images())
2908 * or path is otherwise unavailable.
2909 */
2910 typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len);
2911
2912 /* Fetches a core-provided 'label' for the specified disk
2913 * image file. In the simplest case this may be a file name
2914 * (without extension), but for cores with more complex
2915 * content requirements information may be provided to
2916 * facilitate user disk swapping - for example, a core
2917 * running floppy-disk-based content may uniquely label
2918 * save disks, data disks, level disks, etc. with names
2919 * corresponding to in-game disk change prompts (so the
2920 * frontend can provide better user guidance than a 'dumb'
2921 * disk index value).
2922 * Returns 'false' if index is invalid (index >= get_num_images())
2923 * or label is otherwise unavailable.
2924 */
2925 typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len);
2926
2927 struct retro_disk_control_callback
2928 {
2929 retro_set_eject_state_t set_eject_state;
2930 retro_get_eject_state_t get_eject_state;
2931
2932 retro_get_image_index_t get_image_index;
2933 retro_set_image_index_t set_image_index;
2934 retro_get_num_images_t get_num_images;
2935
2936 retro_replace_image_index_t replace_image_index;
2937 retro_add_image_index_t add_image_index;
2938 };
2939
2940 struct retro_disk_control_ext_callback
2941 {
2942 retro_set_eject_state_t set_eject_state;
2943 retro_get_eject_state_t get_eject_state;
2944
2945 retro_get_image_index_t get_image_index;
2946 retro_set_image_index_t set_image_index;
2947 retro_get_num_images_t get_num_images;
2948
2949 retro_replace_image_index_t replace_image_index;
2950 retro_add_image_index_t add_image_index;
2951
2952 /* NOTE: Frontend will only attempt to record/restore
2953 * last used disk index if both set_initial_image()
2954 * and get_image_path() are implemented */
2955 retro_set_initial_image_t set_initial_image; /* Optional - may be NULL */
2956
2957 retro_get_image_path_t get_image_path; /* Optional - may be NULL */
2958 retro_get_image_label_t get_image_label; /* Optional - may be NULL */
2959 };
2960
2961 enum retro_pixel_format
2962 {
2963 /* 0RGB1555, native endian.
2964 * 0 bit must be set to 0.
2965 * This pixel format is default for compatibility concerns only.
2966 * If a 15/16-bit pixel format is desired, consider using RGB565. */
2967 RETRO_PIXEL_FORMAT_0RGB1555 = 0,
2968
2969 /* XRGB8888, native endian.
2970 * X bits are ignored. */
2971 RETRO_PIXEL_FORMAT_XRGB8888 = 1,
2972
2973 /* RGB565, native endian.
2974 * This pixel format is the recommended format to use if a 15/16-bit
2975 * format is desired as it is the pixel format that is typically
2976 * available on a wide range of low-power devices.
2977 *
2978 * It is also natively supported in APIs like OpenGL ES. */
2979 RETRO_PIXEL_FORMAT_RGB565 = 2,
2980
2981 /* Ensure sizeof() == sizeof(int). */
2982 RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX
2983 };
2984
2985 struct retro_message
2986 {
2987 const char *msg; /* Message to be displayed. */
2988 unsigned frames; /* Duration in frames of message. */
2989 };
2990
2991 enum retro_message_target
2992 {
2993 RETRO_MESSAGE_TARGET_ALL = 0,
2994 RETRO_MESSAGE_TARGET_OSD,
2995 RETRO_MESSAGE_TARGET_LOG
2996 };
2997
2998 enum retro_message_type
2999 {
3000 RETRO_MESSAGE_TYPE_NOTIFICATION = 0,
3001 RETRO_MESSAGE_TYPE_NOTIFICATION_ALT,
3002 RETRO_MESSAGE_TYPE_STATUS,
3003 RETRO_MESSAGE_TYPE_PROGRESS
3004 };
3005
3006 struct retro_message_ext
3007 {
3008 /* Message string to be displayed/logged */
3009 const char *msg;
3010 /* Duration (in ms) of message when targeting the OSD */
3011 unsigned duration;
3012 /* Message priority when targeting the OSD
3013 * > When multiple concurrent messages are sent to
3014 * the frontend and the frontend does not have the
3015 * capacity to display them all, messages with the
3016 * *highest* priority value should be shown
3017 * > There is no upper limit to a message priority
3018 * value (within the bounds of the unsigned data type)
3019 * > In the reference frontend (RetroArch), the same
3020 * priority values are used for frontend-generated
3021 * notifications, which are typically assigned values
3022 * between 0 and 3 depending upon importance */
3023 unsigned priority;
3024 /* Message logging level (info, warn, error, etc.) */
3025 enum retro_log_level level;
3026 /* Message destination: OSD, logging interface or both */
3027 enum retro_message_target target;
3028 /* Message 'type' when targeting the OSD
3029 * > RETRO_MESSAGE_TYPE_NOTIFICATION: Specifies that a
3030 * message should be handled in identical fashion to
3031 * a standard frontend-generated notification
3032 * > RETRO_MESSAGE_TYPE_NOTIFICATION_ALT: Specifies that
3033 * message is a notification that requires user attention
3034 * or action, but that it should be displayed in a manner
3035 * that differs from standard frontend-generated notifications.
3036 * This would typically correspond to messages that should be
3037 * displayed immediately (independently from any internal
3038 * frontend message queue), and/or which should be visually
3039 * distinguishable from frontend-generated notifications.
3040 * For example, a core may wish to inform the user of
3041 * information related to a disk-change event. It is
3042 * expected that the frontend itself may provide a
3043 * notification in this case; if the core sends a
3044 * message of type RETRO_MESSAGE_TYPE_NOTIFICATION, an
3045 * uncomfortable 'double-notification' may occur. A message
3046 * of RETRO_MESSAGE_TYPE_NOTIFICATION_ALT should therefore
3047 * be presented such that visual conflict with regular
3048 * notifications does not occur
3049 * > RETRO_MESSAGE_TYPE_STATUS: Indicates that message
3050 * is not a standard notification. This typically
3051 * corresponds to 'status' indicators, such as a core's
3052 * internal FPS, which are intended to be displayed
3053 * either permanently while a core is running, or in
3054 * a manner that does not suggest user attention or action
3055 * is required. 'Status' type messages should therefore be
3056 * displayed in a different on-screen location and in a manner
3057 * easily distinguishable from both standard frontend-generated
3058 * notifications and messages of type RETRO_MESSAGE_TYPE_NOTIFICATION_ALT
3059 * > RETRO_MESSAGE_TYPE_PROGRESS: Indicates that message reports
3060 * the progress of an internal core task. For example, in cases
3061 * where a core itself handles the loading of content from a file,
3062 * this may correspond to the percentage of the file that has been
3063 * read. Alternatively, an audio/video playback core may use a
3064 * message of type RETRO_MESSAGE_TYPE_PROGRESS to display the current
3065 * playback position as a percentage of the runtime. 'Progress' type
3066 * messages should therefore be displayed as a literal progress bar,
3067 * where:
3068 * - 'retro_message_ext.msg' is the progress bar title/label
3069 * - 'retro_message_ext.progress' determines the length of
3070 * the progress bar
3071 * NOTE: Message type is a *hint*, and may be ignored
3072 * by the frontend. If a frontend lacks support for
3073 * displaying messages via alternate means than standard
3074 * frontend-generated notifications, it will treat *all*
3075 * messages as having the type RETRO_MESSAGE_TYPE_NOTIFICATION */
3076 enum retro_message_type type;
3077 /* Task progress when targeting the OSD and message is
3078 * of type RETRO_MESSAGE_TYPE_PROGRESS
3079 * > -1: Unmetered/indeterminate
3080 * > 0-100: Current progress percentage
3081 * NOTE: Since message type is a hint, a frontend may ignore
3082 * progress values. Where relevant, a core should therefore
3083 * include progress percentage within the message string,
3084 * such that the message intent remains clear when displayed
3085 * as a standard frontend-generated notification */
3086 int8_t progress;
3087 };
3088
3089 /* Describes how the libretro implementation maps a libretro input bind
3090 * to its internal input system through a human readable string.
3091 * This string can be used to better let a user configure input. */
3092 struct retro_input_descriptor
3093 {
3094 /* Associates given parameters with a description. */
3095 unsigned port;
3096 unsigned device;
3097 unsigned index;
3098 unsigned id;
3099
3100 /* Human readable description for parameters.
3101 * The pointer must remain valid until
3102 * retro_unload_game() is called. */
3103 const char *description;
3104 };
3105
3106 struct retro_system_info
3107 {
3108 /* All pointers are owned by libretro implementation, and pointers must
3109 * remain valid until it is unloaded. */
3110
3111 const char *library_name; /* Descriptive name of library. Should not
3112 * contain any version numbers, etc. */
3113 const char *library_version; /* Descriptive version of core. */
3114
3115 const char *valid_extensions; /* A string listing probably content
3116 * extensions the core will be able to
3117 * load, separated with pipe.
3118 * I.e. "bin|rom|iso".
3119 * Typically used for a GUI to filter
3120 * out extensions. */
3121
3122 /* Libretro cores that need to have direct access to their content
3123 * files, including cores which use the path of the content files to
3124 * determine the paths of other files, should set need_fullpath to true.
3125 *
3126 * Cores should strive for setting need_fullpath to false,
3127 * as it allows the frontend to perform patching, etc.
3128 *
3129 * If need_fullpath is true and retro_load_game() is called:
3130 * - retro_game_info::path is guaranteed to have a valid path
3131 * - retro_game_info::data and retro_game_info::size are invalid
3132 *
3133 * If need_fullpath is false and retro_load_game() is called:
3134 * - retro_game_info::path may be NULL
3135 * - retro_game_info::data and retro_game_info::size are guaranteed
3136 * to be valid
3137 *
3138 * See also:
3139 * - RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY
3140 * - RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY
3141 */
3142 bool need_fullpath;
3143
3144 /* If true, the frontend is not allowed to extract any archives before
3145 * loading the real content.
3146 * Necessary for certain libretro implementations that load games
3147 * from zipped archives. */
3148 bool block_extract;
3149 };
3150
3151 struct retro_game_geometry
3152 {
3153 unsigned base_width; /* Nominal video width of game. */
3154 unsigned base_height; /* Nominal video height of game. */
3155 unsigned max_width; /* Maximum possible width of game. */
3156 unsigned max_height; /* Maximum possible height of game. */
3157
3158 float aspect_ratio; /* Nominal aspect ratio of game. If
3159 * aspect_ratio is <= 0.0, an aspect ratio
3160 * of base_width / base_height is assumed.
3161 * A frontend could override this setting,
3162 * if desired. */
3163 };
3164
3165 struct retro_system_timing
3166 {
3167 double fps; /* FPS of video content. */
3168 double sample_rate; /* Sampling rate of audio. */
3169 };
3170
3171 struct retro_system_av_info
3172 {
3173 struct retro_game_geometry geometry;
3174 struct retro_system_timing timing;
3175 };
3176
3177 struct retro_variable
3178 {
3179 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
3180 * If NULL, obtains the complete environment string if more
3181 * complex parsing is necessary.
3182 * The environment string is formatted as key-value pairs
3183 * delimited by semicolons as so:
3184 * "key1=value1;key2=value2;..."
3185 */
3186 const char *key;
3187
3188 /* Value to be obtained. If key does not exist, it is set to NULL. */
3189 const char *value;
3190 };
3191
3192 struct retro_core_option_display
3193 {
3194 /* Variable to configure in RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY */
3195 const char *key;
3196
3197 /* Specifies whether variable should be displayed
3198 * when presenting core options to the user */
3199 bool visible;
3200 };
3201
3202 /* Maximum number of values permitted for a core option
3203 * > Note: We have to set a maximum value due the limitations
3204 * of the C language - i.e. it is not possible to create an
3205 * array of structs each containing a variable sized array,
3206 * so the retro_core_option_definition values array must
3207 * have a fixed size. The size limit of 128 is a balancing
3208 * act - it needs to be large enough to support all 'sane'
3209 * core options, but setting it too large may impact low memory
3210 * platforms. In practise, if a core option has more than
3211 * 128 values then the implementation is likely flawed.
3212 * To quote the above API reference:
3213 * "The number of possible options should be very limited
3214 * i.e. it should be feasible to cycle through options
3215 * without a keyboard."
3216 */
3217 #define RETRO_NUM_CORE_OPTION_VALUES_MAX 128
3218
3219 struct retro_core_option_value
3220 {
3221 /* Expected option value */
3222 const char *value;
3223
3224 /* Human-readable value label. If NULL, value itself
3225 * will be displayed by the frontend */
3226 const char *label;
3227 };
3228
3229 struct retro_core_option_definition
3230 {
3231 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. */
3232 const char *key;
3233
3234 /* Human-readable core option description (used as menu label) */
3235 const char *desc;
3236
3237 /* Human-readable core option information (used as menu sublabel) */
3238 const char *info;
3239
3240 /* Array of retro_core_option_value structs, terminated by NULL */
3241 struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
3242
3243 /* Default core option value. Must match one of the values
3244 * in the retro_core_option_value array, otherwise will be
3245 * ignored */
3246 const char *default_value;
3247 };
3248
3249 struct retro_core_options_intl
3250 {
3251 /* Pointer to an array of retro_core_option_definition structs
3252 * - US English implementation
3253 * - Must point to a valid array */
3254 struct retro_core_option_definition *us;
3255
3256 /* Pointer to an array of retro_core_option_definition structs
3257 * - Implementation for current frontend language
3258 * - May be NULL */
3259 struct retro_core_option_definition *local;
3260 };
3261
3262 struct retro_core_option_v2_category
3263 {
3264 /* Variable uniquely identifying the
3265 * option category. Valid key characters
3266 * are [a-z, A-Z, 0-9, _, -] */
3267 const char *key;
3268
3269 /* Human-readable category description
3270 * > Used as category menu label when
3271 * frontend has core option category
3272 * support */
3273 const char *desc;
3274
3275 /* Human-readable category information
3276 * > Used as category menu sublabel when
3277 * frontend has core option category
3278 * support
3279 * > Optional (may be NULL or an empty
3280 * string) */
3281 const char *info;
3282 };
3283
3284 struct retro_core_option_v2_definition
3285 {
3286 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
3287 * Valid key characters are [a-z, A-Z, 0-9, _, -] */
3288 const char *key;
3289
3290 /* Human-readable core option description
3291 * > Used as menu label when frontend does
3292 * not have core option category support
3293 * e.g. "Video > Aspect Ratio" */
3294 const char *desc;
3295
3296 /* Human-readable core option description
3297 * > Used as menu label when frontend has
3298 * core option category support
3299 * e.g. "Aspect Ratio", where associated
3300 * retro_core_option_v2_category::desc
3301 * is "Video"
3302 * > If empty or NULL, the string specified by
3303 * desc will be used as the menu label
3304 * > Will be ignored (and may be set to NULL)
3305 * if category_key is empty or NULL */
3306 const char *desc_categorized;
3307
3308 /* Human-readable core option information
3309 * > Used as menu sublabel */
3310 const char *info;
3311
3312 /* Human-readable core option information
3313 * > Used as menu sublabel when frontend
3314 * has core option category support
3315 * (e.g. may be required when info text
3316 * references an option by name/desc,
3317 * and the desc/desc_categorized text
3318 * for that option differ)
3319 * > If empty or NULL, the string specified by
3320 * info will be used as the menu sublabel
3321 * > Will be ignored (and may be set to NULL)
3322 * if category_key is empty or NULL */
3323 const char *info_categorized;
3324
3325 /* Variable specifying category (e.g. "video",
3326 * "audio") that will be assigned to the option
3327 * if frontend has core option category support.
3328 * > Categorized options will be displayed in a
3329 * subsection/submenu of the frontend core
3330 * option interface
3331 * > Specified string must match one of the
3332 * retro_core_option_v2_category::key values
3333 * in the associated retro_core_option_v2_category
3334 * array; If no match is not found, specified
3335 * string will be considered as NULL
3336 * > If specified string is empty or NULL, option will
3337 * have no category and will be shown at the top
3338 * level of the frontend core option interface */
3339 const char *category_key;
3340
3341 /* Array of retro_core_option_value structs, terminated by NULL */
3342 struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
3343
3344 /* Default core option value. Must match one of the values
3345 * in the retro_core_option_value array, otherwise will be
3346 * ignored */
3347 const char *default_value;
3348 };
3349
3350 struct retro_core_options_v2
3351 {
3352 /* Array of retro_core_option_v2_category structs,
3353 * terminated by NULL
3354 * > If NULL, all entries in definitions array
3355 * will have no category and will be shown at
3356 * the top level of the frontend core option
3357 * interface
3358 * > Will be ignored if frontend does not have
3359 * core option category support */
3360 struct retro_core_option_v2_category *categories;
3361
3362 /* Array of retro_core_option_v2_definition structs,
3363 * terminated by NULL */
3364 struct retro_core_option_v2_definition *definitions;
3365 };
3366
3367 struct retro_core_options_v2_intl
3368 {
3369 /* Pointer to a retro_core_options_v2 struct
3370 * > US English implementation
3371 * > Must point to a valid struct */
3372 struct retro_core_options_v2 *us;
3373
3374 /* Pointer to a retro_core_options_v2 struct
3375 * - Implementation for current frontend language
3376 * - May be NULL */
3377 struct retro_core_options_v2 *local;
3378 };
3379
3380 /* Used by the frontend to monitor changes in core option
3381 * visibility. May be called each time any core option
3382 * value is set via the frontend.
3383 * - On each invocation, the core must update the visibility
3384 * of any dynamically hidden options using the
3385 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY environment
3386 * callback.
3387 * - On the first invocation, returns 'true' if the visibility
3388 * of any core option has changed since the last call of
3389 * retro_load_game() or retro_load_game_special().
3390 * - On each subsequent invocation, returns 'true' if the
3391 * visibility of any core option has changed since the last
3392 * time the function was called. */
3393 typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void);
3394 struct retro_core_options_update_display_callback
3395 {
3396 retro_core_options_update_display_callback_t callback;
3397 };
3398
3399 struct retro_game_info
3400 {
3401 const char *path; /* Path to game, UTF-8 encoded.
3402 * Sometimes used as a reference for building other paths.
3403 * May be NULL if game was loaded from stdin or similar,
3404 * but in this case some cores will be unable to load `data`.
3405 * So, it is preferable to fabricate something here instead
3406 * of passing NULL, which will help more cores to succeed.
3407 * retro_system_info::need_fullpath requires
3408 * that this path is valid. */
3409 const void *data; /* Memory buffer of loaded game. Will be NULL
3410 * if need_fullpath was set. */
3411 size_t size; /* Size of memory buffer. */
3412 const char *meta; /* String of implementation specific meta-data. */
3413 };
3414
3415 #define RETRO_MEMORY_ACCESS_WRITE (1 << 0)
3416 /* The core will write to the buffer provided by retro_framebuffer::data. */
3417 #define RETRO_MEMORY_ACCESS_READ (1 << 1)
3418 /* The core will read from retro_framebuffer::data. */
3419 #define RETRO_MEMORY_TYPE_CACHED (1 << 0)
3420 /* The memory in data is cached.
3421 * If not cached, random writes and/or reading from the buffer is expected to be very slow. */
3422 struct retro_framebuffer
3423 {
3424 void *data; /* The framebuffer which the core can render into.
3425 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.
3426 The initial contents of data are unspecified. */
3427 unsigned width; /* The framebuffer width used by the core. Set by core. */
3428 unsigned height; /* The framebuffer height used by the core. Set by core. */
3429 size_t pitch; /* The number of bytes between the beginning of a scanline,
3430 and beginning of the next scanline.
3431 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
3432 enum retro_pixel_format format; /* The pixel format the core must use to render into data.
3433 This format could differ from the format used in
3434 SET_PIXEL_FORMAT.
3435 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
3436
3437 unsigned access_flags; /* How the core will access the memory in the framebuffer.
3438 RETRO_MEMORY_ACCESS_* flags.
3439 Set by core. */
3440 unsigned memory_flags; /* Flags telling core how the memory has been mapped.
3441 RETRO_MEMORY_TYPE_* flags.
3442 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
3443 };
3444
3445 /* Used by a libretro core to override the current
3446 * fastforwarding mode of the frontend */
3447 struct retro_fastforwarding_override
3448 {
3449 /* Specifies the runtime speed multiplier that
3450 * will be applied when 'fastforward' is true.
3451 * For example, a value of 5.0 when running 60 FPS
3452 * content will cap the fast-forward rate at 300 FPS.
3453 * Note that the target multiplier may not be achieved
3454 * if the host hardware has insufficient processing
3455 * power.
3456 * Setting a value of 0.0 (or greater than 0.0 but
3457 * less than 1.0) will result in an uncapped
3458 * fast-forward rate (limited only by hardware
3459 * capacity).
3460 * If the value is negative, it will be ignored
3461 * (i.e. the frontend will use a runtime speed
3462 * multiplier of its own choosing) */
3463 float ratio;
3464
3465 /* If true, fastforwarding mode will be enabled.
3466 * If false, fastforwarding mode will be disabled. */
3467 bool fastforward;
3468
3469 /* If true, and if supported by the frontend, an
3470 * on-screen notification will be displayed while
3471 * 'fastforward' is true.
3472 * If false, and if supported by the frontend, any
3473 * on-screen fast-forward notifications will be
3474 * suppressed */
3475 bool notification;
3476
3477 /* If true, the core will have sole control over
3478 * when fastforwarding mode is enabled/disabled;
3479 * the frontend will not be able to change the
3480 * state set by 'fastforward' until either
3481 * 'inhibit_toggle' is set to false, or the core
3482 * is unloaded */
3483 bool inhibit_toggle;
3484 };
3485
3486 /* Callbacks */
3487
3488 /* Environment callback. Gives implementations a way of performing
3489 * uncommon tasks. Extensible. */
3490 typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data);
3491
3492 /* Render a frame. Pixel format is 15-bit 0RGB1555 native endian
3493 * unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).
3494 *
3495 * Width and height specify dimensions of buffer.
3496 * Pitch specifices length in bytes between two lines in buffer.
3497 *
3498 * For performance reasons, it is highly recommended to have a frame
3499 * that is packed in memory, i.e. pitch == width * byte_per_pixel.
3500 * Certain graphic APIs, such as OpenGL ES, do not like textures
3501 * that are not packed in memory.
3502 */
3503 typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width,
3504 unsigned height, size_t pitch);
3505
3506 /* Renders a single audio frame. Should only be used if implementation
3507 * generates a single sample at a time.
3508 * Format is signed 16-bit native endian.
3509 */
3510 typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right);
3511
3512 /* Renders multiple audio frames in one go.
3513 *
3514 * One frame is defined as a sample of left and right channels, interleaved.
3515 * I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames.
3516 * Only one of the audio callbacks must ever be used.
3517 */
3518 typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data,
3519 size_t frames);
3520
3521 /* Polls input. */
3522 typedef void (RETRO_CALLCONV *retro_input_poll_t)(void);
3523
3524 /* Queries for input for player 'port'. device will be masked with
3525 * RETRO_DEVICE_MASK.
3526 *
3527 * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that
3528 * have been set with retro_set_controller_port_device()
3529 * will still use the higher level RETRO_DEVICE_JOYPAD to request input.
3530 */
3531 typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device,
3532 unsigned index, unsigned id);
3533
3534 /* Sets callbacks. retro_set_environment() is guaranteed to be called
3535 * before retro_init().
3536 *
3537 * The rest of the set_* functions are guaranteed to have been called
3538 * before the first call to retro_run() is made. */
3539 RETRO_API void retro_set_environment(retro_environment_t);
3540 RETRO_API void retro_set_video_refresh(retro_video_refresh_t);
3541 RETRO_API void retro_set_audio_sample(retro_audio_sample_t);
3542 RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
3543 RETRO_API void retro_set_input_poll(retro_input_poll_t);
3544 RETRO_API void retro_set_input_state(retro_input_state_t);
3545
3546 /* Library global initialization/deinitialization. */
3547 RETRO_API void retro_init(void);
3548 RETRO_API void retro_deinit(void);
3549
3550 /* Must return RETRO_API_VERSION. Used to validate ABI compatibility
3551 * when the API is revised. */
3552 RETRO_API unsigned retro_api_version(void);
3553
3554 /* Gets statically known system info. Pointers provided in *info
3555 * must be statically allocated.
3556 * Can be called at any time, even before retro_init(). */
3557 RETRO_API void retro_get_system_info(struct retro_system_info *info);
3558
3559 /* Gets information about system audio/video timings and geometry.
3560 * Can be called only after retro_load_game() has successfully completed.
3561 * NOTE: The implementation of this function might not initialize every
3562 * variable if needed.
3563 * E.g. geom.aspect_ratio might not be initialized if core doesn't
3564 * desire a particular aspect ratio. */
3565 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info);
3566
3567 /* Sets device to be used for player 'port'.
3568 * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all
3569 * available ports.
3570 * Setting a particular device type is not a guarantee that libretro cores
3571 * will only poll input based on that particular device type. It is only a
3572 * hint to the libretro core when a core cannot automatically detect the
3573 * appropriate input device type on its own. It is also relevant when a
3574 * core can change its behavior depending on device type.
3575 *
3576 * As part of the core's implementation of retro_set_controller_port_device,
3577 * the core should call RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS to notify the
3578 * frontend if the descriptions for any controls have changed as a
3579 * result of changing the device type.
3580 */
3581 RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device);
3582
3583 /* Resets the current game. */
3584 RETRO_API void retro_reset(void);
3585
3586 /* Runs the game for one video frame.
3587 * During retro_run(), input_poll callback must be called at least once.
3588 *
3589 * If a frame is not rendered for reasons where a game "dropped" a frame,
3590 * this still counts as a frame, and retro_run() should explicitly dupe
3591 * a frame if GET_CAN_DUPE returns true.
3592 * In this case, the video callback can take a NULL argument for data.
3593 */
3594 RETRO_API void retro_run(void);
3595
3596 /* Returns the amount of data the implementation requires to serialize
3597 * internal state (save states).
3598 * Between calls to retro_load_game() and retro_unload_game(), the
3599 * returned size is never allowed to be larger than a previous returned
3600 * value, to ensure that the frontend can allocate a save state buffer once.
3601 */
3602 RETRO_API size_t retro_serialize_size(void);
3603
3604 /* Serializes internal state. If failed, or size is lower than
3605 * retro_serialize_size(), it should return false, true otherwise. */
3606 RETRO_API bool retro_serialize(void *data, size_t size);
3607 RETRO_API bool retro_unserialize(const void *data, size_t size);
3608
3609 RETRO_API void retro_cheat_reset(void);
3610 RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);
3611
3612 /* Loads a game.
3613 * Return true to indicate successful loading and false to indicate load failure.
3614 */
3615 RETRO_API bool retro_load_game(const struct retro_game_info *game);
3616
3617 /* Loads a "special" kind of game. Should not be used,
3618 * except in extreme cases. */
3619 RETRO_API bool retro_load_game_special(
3620 unsigned game_type,
3621 const struct retro_game_info *info, size_t num_info
3622 );
3623
3624 /* Unloads the currently loaded game. Called before retro_deinit(void). */
3625 RETRO_API void retro_unload_game(void);
3626
3627 /* Gets region of game. */
3628 RETRO_API unsigned retro_get_region(void);
3629
3630 /* Gets region of memory. */
3631 RETRO_API void *retro_get_memory_data(unsigned id);
3632 RETRO_API size_t retro_get_memory_size(unsigned id);
3633
3634 #ifdef __cplusplus
3635 }
3636 #endif
3637
3638 #endif
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.