libretro_core_options.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. #ifndef LIBRETRO_CORE_OPTIONS_H__
  2. #define LIBRETRO_CORE_OPTIONS_H__
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <libretro.h>
  6. #include <retro_inline.h>
  7. #ifndef HAVE_NO_LANGEXTRA
  8. #include "libretro_core_options_intl.h"
  9. #endif
  10. /*
  11. ********************************
  12. * VERSION: 2.0
  13. ********************************
  14. *
  15. * - 2.0: Add support for core options v2 interface
  16. * - 1.3: Move translations to libretro_core_options_intl.h
  17. * - libretro_core_options_intl.h includes BOM and utf-8
  18. * fix for MSVC 2010-2013
  19. * - Added HAVE_NO_LANGEXTRA flag to disable translations
  20. * on platforms/compilers without BOM support
  21. * - 1.2: Use core options v1 interface when
  22. * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1
  23. * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1)
  24. * - 1.1: Support generation of core options v0 retro_core_option_value
  25. * arrays containing options with a single value
  26. * - 1.0: First commit
  27. */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /*
  32. ********************************
  33. * Core Option Definitions
  34. ********************************
  35. */
  36. /* RETRO_LANGUAGE_ENGLISH */
  37. /* Default language:
  38. * - All other languages must include the same keys and values
  39. * - Will be used as a fallback in the event that frontend language
  40. * is not available
  41. * - Will be used as a fallback for any missing entries in
  42. * frontend language definition */
  43. struct retro_core_option_v2_category option_cats_us[] = {
  44. {
  45. "system",
  46. "System",
  47. "Configure region / base hardware selection / ROM mapping / Sega CD RAM cart."
  48. },
  49. {
  50. "video",
  51. "Video",
  52. "Configure aspect ratio / LCD filter / video renderer."
  53. },
  54. {
  55. "audio",
  56. "Audio",
  57. "Configure sample rate / emulated audio devices / low pass filter / DAC noise."
  58. },
  59. {
  60. "input",
  61. "Input",
  62. "Configure input devices."
  63. },
  64. {
  65. "performance",
  66. "Performance",
  67. #ifdef DRC_SH2
  68. "Configure dynamic recompiler / frameskipping."
  69. #else
  70. "Configure frameskipping parameters."
  71. #endif
  72. },
  73. {
  74. "hacks",
  75. "Emulation Hacks",
  76. "Configure sprite limit removal / processor overclocking."
  77. },
  78. { NULL, NULL, NULL },
  79. };
  80. struct retro_core_option_v2_definition option_defs_us[] = {
  81. {
  82. "picodrive_region",
  83. "System Region",
  84. "Region",
  85. "Specify which region the system is from. 'PAL'/'Europe' is 50hz while 'NTSC'/'US' is 60hz. Games may run faster or slower than normal (or produce errors) if the incorrect region is selected.",
  86. NULL,
  87. "system",
  88. {
  89. { "Auto", NULL },
  90. { "Japan NTSC", NULL },
  91. { "Japan PAL", NULL },
  92. { "US", NULL },
  93. { "Europe", NULL },
  94. { NULL, NULL },
  95. },
  96. "Auto"
  97. },
  98. {
  99. "picodrive_smstype",
  100. "Master System Type",
  101. NULL,
  102. "Choose which type of hardware (SMS or Game Gear) the core should emulate when running Master System content.",
  103. NULL,
  104. "system",
  105. {
  106. { "Auto", NULL },
  107. { "Game Gear", NULL },
  108. { "Master System", NULL },
  109. { NULL, NULL },
  110. },
  111. "Auto"
  112. },
  113. {
  114. "picodrive_smsmapper",
  115. "Master System ROM Mapping",
  116. NULL,
  117. "Choose which ROM mapper the core should apply. 'Auto' will work for a wide range of content, but in some cases automatic detection fails.",
  118. NULL,
  119. "system",
  120. {
  121. { "Auto", NULL },
  122. { "Sega", NULL },
  123. { "Codemasters", NULL },
  124. { "Korea", NULL },
  125. { "Korea MSX", NULL },
  126. { "Korea X-in-1", NULL },
  127. { "Korea 4-Pak", NULL },
  128. { "Korea Janggun", NULL },
  129. { "Korea Nemesis", NULL },
  130. { NULL, NULL },
  131. },
  132. "Auto"
  133. },
  134. {
  135. "picodrive_ramcart",
  136. "Sega CD RAM Cart",
  137. NULL,
  138. "Emulate a Sega CD RAM cart, used for save game data. WARNING: When enabled, internal save data (BRAM) will be discarded.",
  139. NULL,
  140. "system",
  141. {
  142. { "disabled", NULL },
  143. { "enabled", NULL },
  144. { NULL, NULL },
  145. },
  146. "disabled"
  147. },
  148. {
  149. "picodrive_aspect",
  150. "Core-Provided Aspect Ratio",
  151. NULL,
  152. "Choose the preferred content aspect ratio. This will only apply when RetroArch's aspect ratio is set to 'Core Provided' in the Video settings.",
  153. NULL,
  154. "video",
  155. {
  156. { "PAR", NULL },
  157. { "4/3", "4:3" },
  158. { "CRT", NULL },
  159. { NULL, NULL },
  160. },
  161. "PAR"
  162. },
  163. {
  164. "picodrive_ggghost",
  165. "LCD Ghosting Filter",
  166. NULL,
  167. "Apply an image 'ghosting' filter to mimic the display characteristics of the Game Gear and 'Genesis Nomad' LCD panels.",
  168. NULL,
  169. "video",
  170. {
  171. { "off", "disabled" },
  172. { "weak", "Weak" },
  173. { "normal", "Normal" },
  174. { NULL, NULL },
  175. },
  176. "off"
  177. },
  178. {
  179. "picodrive_renderer",
  180. "Video Renderer",
  181. "Renderer",
  182. "Specify video rendering method. 'Accurate' is slowest, but most exact. 'Good' is faster, but fails if colors change mid-frame too often. 'Fast' renders the complete frame in one pass, and is incompatible with games that rely on mid-frame palette/sprite table updates.",
  183. NULL,
  184. "video",
  185. {
  186. { "accurate", "Accurate" },
  187. { "good", "Good" },
  188. { "fast", "Fast" },
  189. { NULL, NULL },
  190. },
  191. "accurate"
  192. },
  193. {
  194. "picodrive_sound_rate",
  195. "Audio Sample Rate (Hz)",
  196. "Sample Rate (Hz)",
  197. "Higher values increase sound quality. Lower values may increase performance.",
  198. NULL,
  199. "audio",
  200. {
  201. { "16000", NULL },
  202. { "22050", NULL },
  203. { "32000", NULL },
  204. { "44100", NULL },
  205. { NULL, NULL },
  206. },
  207. "44100"
  208. },
  209. {
  210. "picodrive_smsfm",
  211. "Master System FM Sound Unit",
  212. NULL,
  213. "Enable emulation of the SMS FM Sound Unit. This produces higher quality audio in some games, but non-Japanese titles may fail to run.",
  214. NULL,
  215. "audio",
  216. {
  217. { "off", "disabled" },
  218. { "on", "enabled" },
  219. { NULL, NULL },
  220. },
  221. "off"
  222. },
  223. {
  224. "picodrive_dacnoise",
  225. "Mega Drive FM DAC noise",
  226. NULL,
  227. "Enable emulation of YM2612 DAC noise. This option generates a distortion which existed on most Model 1 Mega Drive/Genesis, but not on newer models.",
  228. NULL,
  229. "audio",
  230. {
  231. { "off", "disabled" },
  232. { "on", "enabled" },
  233. { NULL, NULL },
  234. },
  235. "off"
  236. },
  237. {
  238. "picodrive_audio_filter",
  239. "Audio Filter",
  240. NULL,
  241. "Enable a low pass audio filter to better simulate the characteristic sound of a Model 1 Mega Drive/Genesis. Note that although only the Genesis and its add-on hardware (Sega CD, 32X) employed a physical low pass filter, the filter setting is not restricted to that.",
  242. NULL,
  243. "audio",
  244. {
  245. { "disabled", NULL },
  246. { "low-pass", "Low-Pass" },
  247. { NULL, NULL },
  248. },
  249. "disabled"
  250. },
  251. {
  252. "picodrive_lowpass_range",
  253. "Low-Pass Filter %",
  254. NULL,
  255. "Specify the cut-off frequency of the low pass audio filter. A higher value increases the perceived 'strength' of the filter, since a wider range of the high frequency spectrum is attenuated.",
  256. NULL,
  257. "audio",
  258. {
  259. { "5", NULL },
  260. { "10", NULL },
  261. { "15", NULL },
  262. { "20", NULL },
  263. { "25", NULL },
  264. { "30", NULL },
  265. { "35", NULL },
  266. { "40", NULL },
  267. { "45", NULL },
  268. { "50", NULL },
  269. { "55", NULL },
  270. { "60", NULL },
  271. { "65", NULL },
  272. { "70", NULL },
  273. { "75", NULL },
  274. { "80", NULL },
  275. { "85", NULL },
  276. { "90", NULL },
  277. { "95", NULL },
  278. { NULL, NULL },
  279. },
  280. "60"
  281. },
  282. {
  283. "picodrive_input1",
  284. "Input Device 1",
  285. NULL,
  286. "Choose which type of controller is plugged into slot 1.",
  287. NULL,
  288. "input",
  289. {
  290. { "3 button pad", "3 Button Pad" },
  291. { "6 button pad", "6 Button Pad" },
  292. { "None", NULL },
  293. { NULL, NULL },
  294. },
  295. "3 button pad"
  296. },
  297. {
  298. "picodrive_input2",
  299. "Input Device 2",
  300. NULL,
  301. "Choose which type of controller is plugged into slot 2.",
  302. NULL,
  303. "input",
  304. {
  305. { "3 button pad", "3 Button Pad" },
  306. { "6 button pad", "6 Button Pad" },
  307. { "None", NULL },
  308. { NULL, NULL },
  309. },
  310. "3 button pad"
  311. },
  312. #ifdef DRC_SH2
  313. {
  314. "picodrive_drc",
  315. "Dynamic Recompilers",
  316. NULL,
  317. "Enable dynamic recompilers which help to improve performance. Less accurate than interpreter CPU cores, but significantly faster.",
  318. NULL,
  319. "performance",
  320. {
  321. { "enabled", NULL },
  322. { "disabled", NULL },
  323. { NULL, NULL },
  324. },
  325. "enabled"
  326. },
  327. #endif
  328. {
  329. "picodrive_frameskip",
  330. "Frameskip",
  331. NULL,
  332. "Skip frames to avoid audio buffer under-run (crackling). Improves performance at the expense of visual smoothness. 'Auto' skips frames when advised by the frontend. 'Manual' utilises the 'Frameskip Threshold (%)' setting.",
  333. NULL,
  334. "performance",
  335. {
  336. { "disabled", NULL },
  337. { "auto", "Auto" },
  338. { "manual", "Manual" },
  339. { NULL, NULL },
  340. },
  341. "disabled"
  342. },
  343. {
  344. "picodrive_frameskip_threshold",
  345. "Frameskip Threshold (%)",
  346. NULL,
  347. "When 'Frameskip' is set to 'Manual', specifies the audio buffer occupancy threshold (percentage) below which frames will be skipped. Higher values reduce the risk of crackling by causing frames to be dropped more frequently.",
  348. NULL,
  349. "performance",
  350. {
  351. { "15", NULL },
  352. { "18", NULL },
  353. { "21", NULL },
  354. { "24", NULL },
  355. { "27", NULL },
  356. { "30", NULL },
  357. { "33", NULL },
  358. { "36", NULL },
  359. { "39", NULL },
  360. { "42", NULL },
  361. { "45", NULL },
  362. { "48", NULL },
  363. { "51", NULL },
  364. { "54", NULL },
  365. { "57", NULL },
  366. { "60", NULL },
  367. { NULL, NULL },
  368. },
  369. "33"
  370. },
  371. {
  372. "picodrive_sprlim",
  373. "No Sprite Limit",
  374. NULL,
  375. "Removes the original sprite-per-scanline hardware limit. This reduces flickering but can cause visual glitches, as some games exploit the hardware limit to generate special effects.",
  376. NULL,
  377. "hacks",
  378. {
  379. { "disabled", NULL },
  380. { "enabled", NULL },
  381. { NULL, NULL },
  382. },
  383. "disabled"
  384. },
  385. {
  386. "picodrive_overclk68k",
  387. "68K Overclock",
  388. NULL,
  389. "Overclock the emulated 68K chip. Can reduce slowdown, but may cause glitches.",
  390. NULL,
  391. "hacks",
  392. {
  393. { "disabled", NULL },
  394. { "+25%", NULL },
  395. { "+50%", NULL },
  396. { "+75%", NULL },
  397. { "+100%", NULL },
  398. { "+200%", NULL },
  399. { "+400%", NULL },
  400. { NULL, NULL },
  401. },
  402. "disabled"
  403. },
  404. { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
  405. };
  406. struct retro_core_options_v2 options_us = {
  407. option_cats_us,
  408. option_defs_us
  409. };
  410. /*
  411. ********************************
  412. * Language Mapping
  413. ********************************
  414. */
  415. #ifndef HAVE_NO_LANGEXTRA
  416. struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = {
  417. &options_us, /* RETRO_LANGUAGE_ENGLISH */
  418. NULL, /* RETRO_LANGUAGE_JAPANESE */
  419. NULL, /* RETRO_LANGUAGE_FRENCH */
  420. NULL, /* RETRO_LANGUAGE_SPANISH */
  421. NULL, /* RETRO_LANGUAGE_GERMAN */
  422. NULL, /* RETRO_LANGUAGE_ITALIAN */
  423. NULL, /* RETRO_LANGUAGE_DUTCH */
  424. NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
  425. NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
  426. NULL, /* RETRO_LANGUAGE_RUSSIAN */
  427. NULL, /* RETRO_LANGUAGE_KOREAN */
  428. NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
  429. NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
  430. NULL, /* RETRO_LANGUAGE_ESPERANTO */
  431. NULL, /* RETRO_LANGUAGE_POLISH */
  432. NULL, /* RETRO_LANGUAGE_VIETNAMESE */
  433. NULL, /* RETRO_LANGUAGE_ARABIC */
  434. NULL, /* RETRO_LANGUAGE_GREEK */
  435. &options_tr, /* RETRO_LANGUAGE_TURKISH */
  436. NULL, /* RETRO_LANGUAGE_SLOVAK */
  437. NULL, /* RETRO_LANGUAGE_PERSIAN */
  438. NULL, /* RETRO_LANGUAGE_HEBREW */
  439. NULL, /* RETRO_LANGUAGE_ASTURIAN */
  440. NULL, /* RETRO_LANGUAGE_FINNISH */
  441. };
  442. #endif
  443. /*
  444. ********************************
  445. * Functions
  446. ********************************
  447. */
  448. /* Handles configuration/setting of core options.
  449. * Should be called as early as possible - ideally inside
  450. * retro_set_environment(), and no later than retro_load_game()
  451. * > We place the function body in the header to avoid the
  452. * necessity of adding more .c files (i.e. want this to
  453. * be as painless as possible for core devs)
  454. */
  455. static INLINE void libretro_set_core_options(retro_environment_t environ_cb,
  456. bool *categories_supported)
  457. {
  458. unsigned version = 0;
  459. #ifndef HAVE_NO_LANGEXTRA
  460. unsigned language = 0;
  461. #endif
  462. if (!environ_cb || !categories_supported)
  463. return;
  464. *categories_supported = false;
  465. if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version))
  466. version = 0;
  467. if (version >= 2)
  468. {
  469. #ifndef HAVE_NO_LANGEXTRA
  470. struct retro_core_options_v2_intl core_options_intl;
  471. core_options_intl.us = &options_us;
  472. core_options_intl.local = NULL;
  473. if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
  474. (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
  475. core_options_intl.local = options_intl[language];
  476. *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL,
  477. &core_options_intl);
  478. #else
  479. *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
  480. &options_us);
  481. #endif
  482. }
  483. else
  484. {
  485. size_t i, j;
  486. size_t option_index = 0;
  487. size_t num_options = 0;
  488. struct retro_core_option_definition
  489. *option_v1_defs_us = NULL;
  490. #ifndef HAVE_NO_LANGEXTRA
  491. size_t num_options_intl = 0;
  492. struct retro_core_option_v2_definition
  493. *option_defs_intl = NULL;
  494. struct retro_core_option_definition
  495. *option_v1_defs_intl = NULL;
  496. struct retro_core_options_intl
  497. core_options_v1_intl;
  498. #endif
  499. struct retro_variable *variables = NULL;
  500. char **values_buf = NULL;
  501. /* Determine total number of options */
  502. while (true)
  503. {
  504. if (option_defs_us[num_options].key)
  505. num_options++;
  506. else
  507. break;
  508. }
  509. if (version >= 1)
  510. {
  511. /* Allocate US array */
  512. option_v1_defs_us = (struct retro_core_option_definition *)
  513. calloc(num_options + 1, sizeof(struct retro_core_option_definition));
  514. /* Copy parameters from option_defs_us array */
  515. for (i = 0; i < num_options; i++)
  516. {
  517. struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i];
  518. struct retro_core_option_value *option_values = option_def_us->values;
  519. struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i];
  520. struct retro_core_option_value *option_v1_values = option_v1_def_us->values;
  521. option_v1_def_us->key = option_def_us->key;
  522. option_v1_def_us->desc = option_def_us->desc;
  523. option_v1_def_us->info = option_def_us->info;
  524. option_v1_def_us->default_value = option_def_us->default_value;
  525. /* Values must be copied individually... */
  526. while (option_values->value)
  527. {
  528. option_v1_values->value = option_values->value;
  529. option_v1_values->label = option_values->label;
  530. option_values++;
  531. option_v1_values++;
  532. }
  533. }
  534. #ifndef HAVE_NO_LANGEXTRA
  535. if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
  536. (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) &&
  537. options_intl[language])
  538. option_defs_intl = options_intl[language]->definitions;
  539. if (option_defs_intl)
  540. {
  541. /* Determine number of intl options */
  542. while (true)
  543. {
  544. if (option_defs_intl[num_options_intl].key)
  545. num_options_intl++;
  546. else
  547. break;
  548. }
  549. /* Allocate intl array */
  550. option_v1_defs_intl = (struct retro_core_option_definition *)
  551. calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition));
  552. /* Copy parameters from option_defs_intl array */
  553. for (i = 0; i < num_options_intl; i++)
  554. {
  555. struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i];
  556. struct retro_core_option_value *option_values = option_def_intl->values;
  557. struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i];
  558. struct retro_core_option_value *option_v1_values = option_v1_def_intl->values;
  559. option_v1_def_intl->key = option_def_intl->key;
  560. option_v1_def_intl->desc = option_def_intl->desc;
  561. option_v1_def_intl->info = option_def_intl->info;
  562. option_v1_def_intl->default_value = option_def_intl->default_value;
  563. /* Values must be copied individually... */
  564. while (option_values->value)
  565. {
  566. option_v1_values->value = option_values->value;
  567. option_v1_values->label = option_values->label;
  568. option_values++;
  569. option_v1_values++;
  570. }
  571. }
  572. }
  573. core_options_v1_intl.us = option_v1_defs_us;
  574. core_options_v1_intl.local = option_v1_defs_intl;
  575. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl);
  576. #else
  577. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us);
  578. #endif
  579. }
  580. else
  581. {
  582. /* Allocate arrays */
  583. variables = (struct retro_variable *)calloc(num_options + 1,
  584. sizeof(struct retro_variable));
  585. values_buf = (char **)calloc(num_options, sizeof(char *));
  586. if (!variables || !values_buf)
  587. goto error;
  588. /* Copy parameters from option_defs_us array */
  589. for (i = 0; i < num_options; i++)
  590. {
  591. const char *key = option_defs_us[i].key;
  592. const char *desc = option_defs_us[i].desc;
  593. const char *default_value = option_defs_us[i].default_value;
  594. struct retro_core_option_value *values = option_defs_us[i].values;
  595. size_t buf_len = 3;
  596. size_t default_index = 0;
  597. values_buf[i] = NULL;
  598. if (desc)
  599. {
  600. size_t num_values = 0;
  601. /* Determine number of values */
  602. while (true)
  603. {
  604. if (values[num_values].value)
  605. {
  606. /* Check if this is the default value */
  607. if (default_value)
  608. if (strcmp(values[num_values].value, default_value) == 0)
  609. default_index = num_values;
  610. buf_len += strlen(values[num_values].value);
  611. num_values++;
  612. }
  613. else
  614. break;
  615. }
  616. /* Build values string */
  617. if (num_values > 0)
  618. {
  619. buf_len += num_values - 1;
  620. buf_len += strlen(desc);
  621. values_buf[i] = (char *)calloc(buf_len, sizeof(char));
  622. if (!values_buf[i])
  623. goto error;
  624. strcpy(values_buf[i], desc);
  625. strcat(values_buf[i], "; ");
  626. /* Default value goes first */
  627. strcat(values_buf[i], values[default_index].value);
  628. /* Add remaining values */
  629. for (j = 0; j < num_values; j++)
  630. {
  631. if (j != default_index)
  632. {
  633. strcat(values_buf[i], "|");
  634. strcat(values_buf[i], values[j].value);
  635. }
  636. }
  637. }
  638. }
  639. variables[option_index].key = key;
  640. variables[option_index].value = values_buf[i];
  641. option_index++;
  642. }
  643. /* Set variables */
  644. environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
  645. }
  646. error:
  647. /* Clean up */
  648. if (option_v1_defs_us)
  649. {
  650. free(option_v1_defs_us);
  651. option_v1_defs_us = NULL;
  652. }
  653. #ifndef HAVE_NO_LANGEXTRA
  654. if (option_v1_defs_intl)
  655. {
  656. free(option_v1_defs_intl);
  657. option_v1_defs_intl = NULL;
  658. }
  659. #endif
  660. if (values_buf)
  661. {
  662. for (i = 0; i < num_options; i++)
  663. {
  664. if (values_buf[i])
  665. {
  666. free(values_buf[i]);
  667. values_buf[i] = NULL;
  668. }
  669. }
  670. free(values_buf);
  671. values_buf = NULL;
  672. }
  673. if (variables)
  674. {
  675. free(variables);
  676. variables = NULL;
  677. }
  678. }
  679. }
  680. #ifdef __cplusplus
  681. }
  682. #endif
  683. #endif