libretro_core_options.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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: 1.3
  13. ********************************
  14. *
  15. * - 1.3: Move translations to libretro_core_options_intl.h
  16. * - libretro_core_options_intl.h includes BOM and utf-8
  17. * fix for MSVC 2010-2013
  18. * - Added HAVE_NO_LANGEXTRA flag to disable translations
  19. * on platforms/compilers without BOM support
  20. * - 1.2: Use core options v1 interface when
  21. * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1
  22. * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1)
  23. * - 1.1: Support generation of core options v0 retro_core_option_value
  24. * arrays containing options with a single value
  25. * - 1.0: First commit
  26. */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /*
  31. ********************************
  32. * Core Option Definitions
  33. ********************************
  34. */
  35. /* RETRO_LANGUAGE_ENGLISH */
  36. /* Default language:
  37. * - All other languages must include the same keys and values
  38. * - Will be used as a fallback in the event that frontend language
  39. * is not available
  40. * - Will be used as a fallback for any missing entries in
  41. * frontend language definition */
  42. struct retro_core_option_definition option_defs_us[] = {
  43. {
  44. "picodrive_input1",
  45. "Input device 1",
  46. "Choose which kind of controller is plugged in slot 1.",
  47. {
  48. { "3 button pad", "3 Button Pad" },
  49. { "6 button pad", "6 Button Pad" },
  50. { "None", NULL },
  51. { NULL, NULL },
  52. },
  53. "3 button pad"
  54. },
  55. {
  56. "picodrive_input2",
  57. "Input device 2",
  58. "Choose which kind of controller is plugged in slot 2.",
  59. {
  60. { "3 button pad", NULL },
  61. { "6 button pad", NULL },
  62. { "None", NULL },
  63. { NULL, NULL },
  64. },
  65. "3 button pad"
  66. },
  67. {
  68. "picodrive_ramcart",
  69. "MegaCD RAM cart",
  70. "Emulate a MegaCD RAM cart, used for save game data. WARNING: When enabled, internal save data (BRAM) will be discarded.",
  71. {
  72. { "disabled", NULL },
  73. { "enabled", NULL },
  74. { NULL, NULL },
  75. },
  76. "disabled"
  77. },
  78. {
  79. "picodrive_smstype",
  80. "Master System type",
  81. "Choose which type of system the core should emulate for Master system",
  82. {
  83. { "Auto", NULL },
  84. { "Game Gear", NULL },
  85. { "Master System", NULL },
  86. { NULL, NULL },
  87. },
  88. "Auto"
  89. },
  90. {
  91. "picodrive_smsfm",
  92. "Master System FM sound unit",
  93. "Enable the FM Sound Unit emulation. Some MS games produce much better sound, but non-Japanese titles might possibly not run.",
  94. {
  95. { "off", NULL },
  96. { "on", NULL },
  97. { NULL, NULL },
  98. },
  99. "off"
  100. },
  101. {
  102. "picodrive_smsmapper",
  103. "Master System ROM mapping",
  104. "Choose which ROM mapper the core should apply. Auto will work for a wide range, but in some cases automatic detection fails.",
  105. {
  106. { "Auto", NULL },
  107. { "Sega", NULL },
  108. { "Codemasters", NULL },
  109. { "Korea", NULL },
  110. { "Korea MSX", NULL },
  111. { "Korea X-in-1", NULL },
  112. { "Korea 4-Pak", NULL },
  113. { "Korea Janggun", NULL },
  114. { "Korea Nemesis", NULL },
  115. { NULL, NULL },
  116. },
  117. "Auto"
  118. },
  119. {
  120. "picodrive_ggghost",
  121. "Game Gear LCD ghosting",
  122. "Enable LCD ghosting emulation.",
  123. {
  124. { "off", NULL },
  125. { "weak", NULL },
  126. { "normal", NULL },
  127. { NULL, NULL },
  128. },
  129. "off"
  130. },
  131. {
  132. "picodrive_region",
  133. "Region",
  134. "Force a specific region.",
  135. {
  136. { "Auto", NULL },
  137. { "Japan NTSC", NULL },
  138. { "Japan PAL", NULL },
  139. { "US", NULL },
  140. { "Europe", NULL },
  141. { NULL, NULL },
  142. },
  143. "Auto"
  144. },
  145. {
  146. "picodrive_aspect",
  147. "Core-provided aspect ratio",
  148. "Choose the core-provided aspect ratio. RetroArch's aspect ratio must be set to Core provided in the Video settings.",
  149. {
  150. { "PAR", NULL },
  151. { "4/3", NULL },
  152. { "CRT", NULL },
  153. { NULL, NULL },
  154. },
  155. "PAR"
  156. },
  157. {
  158. "picodrive_sprlim",
  159. "No sprite limit",
  160. "Enable this to remove the sprite limit.",
  161. {
  162. { "disabled", NULL },
  163. { "enabled", NULL },
  164. { NULL, NULL },
  165. },
  166. "disabled"
  167. },
  168. {
  169. "picodrive_overscan",
  170. "Show Overscan",
  171. "Crop out the potentially random glitchy video output that would have been hidden by the bezel around the edge of a standard-definition television screen.",
  172. {
  173. { "disabled", NULL },
  174. { "enabled", NULL },
  175. { NULL, NULL },
  176. },
  177. "disabled"
  178. },
  179. {
  180. "picodrive_overclk68k",
  181. "68K Overclock",
  182. "Overclock the emulated 68K chip.",
  183. {
  184. { "disabled", NULL },
  185. { "+25%", NULL },
  186. { "+50%", NULL },
  187. { "+75%", NULL },
  188. { "+100%", NULL },
  189. { "+200%", NULL },
  190. { "+400%", NULL },
  191. { NULL, NULL },
  192. },
  193. "disabled"
  194. },
  195. #ifdef DRC_SH2
  196. {
  197. "picodrive_drc",
  198. "Dynamic recompilers",
  199. "Enable dynamic recompilers which help to improve performance. Less accurate than interpreter CPU cores, but much faster.",
  200. {
  201. { "enabled", NULL },
  202. { "disabled", NULL },
  203. { NULL, NULL },
  204. },
  205. "enabled"
  206. },
  207. #endif
  208. {
  209. "picodrive_audio_filter",
  210. "Audio filter",
  211. "Enable a low pass audio filter to better simulate the characteristic sound of a Model 1 Genesis. This option is ignored when running Master System and PICO titles. Only the Genesis and its add-on hardware (Sega CD, 32X) employed a physical low pass filter.",
  212. {
  213. { "disabled", NULL },
  214. { "low-pass", "Low-Pass" },
  215. { NULL, NULL },
  216. },
  217. "disabled"
  218. },
  219. {
  220. "picodrive_lowpass_range",
  221. "Low-pass filter %",
  222. "Specify the cut-off frequency of the audio low pass filter. A higher value increases the perceived 'strength' of the filter, since a wider range of the high frequency spectrum is attenuated.",
  223. {
  224. { "5", NULL },
  225. { "10", NULL },
  226. { "15", NULL },
  227. { "20", NULL },
  228. { "25", NULL },
  229. { "30", NULL },
  230. { "35", NULL },
  231. { "40", NULL },
  232. { "45", NULL },
  233. { "50", NULL },
  234. { "55", NULL },
  235. { "60", NULL },
  236. { "65", NULL },
  237. { "70", NULL },
  238. { "75", NULL },
  239. { "80", NULL },
  240. { "85", NULL },
  241. { "90", NULL },
  242. { "95", NULL },
  243. { NULL, NULL },
  244. },
  245. "60"
  246. },
  247. {
  248. "picodrive_frameskip",
  249. "Frameskip",
  250. "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.",
  251. {
  252. { "disabled", NULL },
  253. { "auto", "Auto" },
  254. { "manual", "Manual" },
  255. { NULL, NULL },
  256. },
  257. "disabled"
  258. },
  259. {
  260. "picodrive_frameskip_threshold",
  261. "Frameskip Threshold (%)",
  262. "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.",
  263. {
  264. { "15", NULL },
  265. { "18", NULL },
  266. { "21", NULL },
  267. { "24", NULL },
  268. { "27", NULL },
  269. { "30", NULL },
  270. { "33", NULL },
  271. { "36", NULL },
  272. { "39", NULL },
  273. { "42", NULL },
  274. { "45", NULL },
  275. { "48", NULL },
  276. { "51", NULL },
  277. { "54", NULL },
  278. { "57", NULL },
  279. { "60", NULL },
  280. { NULL, NULL },
  281. },
  282. "33"
  283. },
  284. {
  285. "picodrive_renderer",
  286. "Renderer",
  287. "Fast renderer can't render any mid-frame image changes so it is useful only for some games.",
  288. {
  289. { "accurate", "Accurate" },
  290. { "good", "Good" },
  291. { "fast", "Fast" },
  292. { NULL, NULL },
  293. },
  294. "accurate"
  295. },
  296. {
  297. "picodrive_sound_rate",
  298. "Sound quality",
  299. "Sound quality (in Hz). A lower value may increase performance.",
  300. {
  301. { "16000", NULL },
  302. { "22050", NULL },
  303. { "32000", NULL },
  304. { "44100", NULL },
  305. { NULL, NULL },
  306. },
  307. "44100"
  308. },
  309. { NULL, NULL, NULL, {{0}}, NULL },
  310. };
  311. /*
  312. ********************************
  313. * Language Mapping
  314. ********************************
  315. */
  316. #ifndef HAVE_NO_LANGEXTRA
  317. struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
  318. option_defs_us, /* RETRO_LANGUAGE_ENGLISH */
  319. NULL, /* RETRO_LANGUAGE_JAPANESE */
  320. NULL, /* RETRO_LANGUAGE_FRENCH */
  321. NULL, /* RETRO_LANGUAGE_SPANISH */
  322. NULL, /* RETRO_LANGUAGE_GERMAN */
  323. NULL, /* RETRO_LANGUAGE_ITALIAN */
  324. NULL, /* RETRO_LANGUAGE_DUTCH */
  325. NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
  326. NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
  327. NULL, /* RETRO_LANGUAGE_RUSSIAN */
  328. NULL, /* RETRO_LANGUAGE_KOREAN */
  329. NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
  330. NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
  331. NULL, /* RETRO_LANGUAGE_ESPERANTO */
  332. NULL, /* RETRO_LANGUAGE_POLISH */
  333. NULL, /* RETRO_LANGUAGE_VIETNAMESE */
  334. NULL, /* RETRO_LANGUAGE_ARABIC */
  335. NULL, /* RETRO_LANGUAGE_GREEK */
  336. option_defs_tr, /* RETRO_LANGUAGE_TURKISH */
  337. };
  338. #endif
  339. /*
  340. ********************************
  341. * Functions
  342. ********************************
  343. */
  344. /* Handles configuration/setting of core options.
  345. * Should be called as early as possible - ideally inside
  346. * retro_set_environment(), and no later than retro_load_game()
  347. * > We place the function body in the header to avoid the
  348. * necessity of adding more .c files (i.e. want this to
  349. * be as painless as possible for core devs)
  350. */
  351. static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
  352. {
  353. unsigned version = 0;
  354. if (!environ_cb)
  355. return;
  356. if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1))
  357. {
  358. #ifndef HAVE_NO_LANGEXTRA
  359. struct retro_core_options_intl core_options_intl;
  360. unsigned language = 0;
  361. core_options_intl.us = option_defs_us;
  362. core_options_intl.local = NULL;
  363. if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
  364. (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
  365. core_options_intl.local = option_defs_intl[language];
  366. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
  367. #else
  368. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
  369. #endif
  370. }
  371. else
  372. {
  373. size_t i;
  374. size_t num_options = 0;
  375. struct retro_variable *variables = NULL;
  376. char **values_buf = NULL;
  377. /* Determine number of options */
  378. while (true)
  379. {
  380. if (option_defs_us[num_options].key)
  381. num_options++;
  382. else
  383. break;
  384. }
  385. /* Allocate arrays */
  386. variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
  387. values_buf = (char **)calloc(num_options, sizeof(char *));
  388. if (!variables || !values_buf)
  389. goto error;
  390. /* Copy parameters from option_defs_us array */
  391. for (i = 0; i < num_options; i++)
  392. {
  393. const char *key = option_defs_us[i].key;
  394. const char *desc = option_defs_us[i].desc;
  395. const char *default_value = option_defs_us[i].default_value;
  396. struct retro_core_option_value *values = option_defs_us[i].values;
  397. size_t buf_len = 3;
  398. size_t default_index = 0;
  399. values_buf[i] = NULL;
  400. if (desc)
  401. {
  402. size_t num_values = 0;
  403. /* Determine number of values */
  404. while (true)
  405. {
  406. if (values[num_values].value)
  407. {
  408. /* Check if this is the default value */
  409. if (default_value)
  410. if (strcmp(values[num_values].value, default_value) == 0)
  411. default_index = num_values;
  412. buf_len += strlen(values[num_values].value);
  413. num_values++;
  414. }
  415. else
  416. break;
  417. }
  418. /* Build values string */
  419. if (num_values > 0)
  420. {
  421. size_t j;
  422. buf_len += num_values - 1;
  423. buf_len += strlen(desc);
  424. values_buf[i] = (char *)calloc(buf_len, sizeof(char));
  425. if (!values_buf[i])
  426. goto error;
  427. strcpy(values_buf[i], desc);
  428. strcat(values_buf[i], "; ");
  429. /* Default value goes first */
  430. strcat(values_buf[i], values[default_index].value);
  431. /* Add remaining values */
  432. for (j = 0; j < num_values; j++)
  433. {
  434. if (j != default_index)
  435. {
  436. strcat(values_buf[i], "|");
  437. strcat(values_buf[i], values[j].value);
  438. }
  439. }
  440. }
  441. }
  442. variables[i].key = key;
  443. variables[i].value = values_buf[i];
  444. }
  445. /* Set variables */
  446. environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
  447. error:
  448. /* Clean up */
  449. if (values_buf)
  450. {
  451. for (i = 0; i < num_options; i++)
  452. {
  453. if (values_buf[i])
  454. {
  455. free(values_buf[i]);
  456. values_buf[i] = NULL;
  457. }
  458. }
  459. free(values_buf);
  460. values_buf = NULL;
  461. }
  462. if (variables)
  463. {
  464. free(variables);
  465. variables = NULL;
  466. }
  467. }
  468. }
  469. #ifdef __cplusplus
  470. }
  471. #endif
  472. #endif