libretro.h 158 KB

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