libretro_core_options.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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_sprlim",
  69. "No sprite limit",
  70. "Enable this to remove the sprite limit.",
  71. {
  72. { "disabled", NULL },
  73. { "enabled", NULL },
  74. { NULL, NULL },
  75. },
  76. "disabled"
  77. },
  78. {
  79. "picodrive_ramcart",
  80. "MegaCD RAM cart",
  81. "Emulate a MegaCD RAM cart, used for save game data. WARNING: When enabled, internal save data (BRAM) will be discarded.",
  82. {
  83. { "disabled", NULL },
  84. { "enabled", NULL },
  85. { NULL, NULL },
  86. },
  87. "disabled"
  88. },
  89. {
  90. "picodrive_region",
  91. "Region",
  92. "Force a specific region.",
  93. {
  94. { "Auto", NULL },
  95. { "Japan NTSC", NULL },
  96. { "Japan PAL", NULL },
  97. { "US", NULL },
  98. { "Europe", NULL },
  99. { NULL, NULL },
  100. },
  101. "Auto"
  102. },
  103. {
  104. "picodrive_aspect",
  105. "Core-provided aspect ratio",
  106. "Choose the core-provided aspect ratio. RetroArch's aspect ratio must be set to Core provided in the Video settings.",
  107. {
  108. { "PAR", NULL },
  109. { "4/3", NULL },
  110. { "CRT", NULL },
  111. { NULL, NULL },
  112. },
  113. "PAR"
  114. },
  115. {
  116. "picodrive_overscan",
  117. "Show Overscan",
  118. "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.",
  119. {
  120. { "disabled", NULL },
  121. { "enabled", NULL },
  122. { NULL, NULL },
  123. },
  124. "disabled"
  125. },
  126. {
  127. "picodrive_overclk68k",
  128. "68K Overclock",
  129. "Overclock the emulated 68K chip.",
  130. {
  131. { "disabled", NULL },
  132. { "+25%", NULL },
  133. { "+50%", NULL },
  134. { "+75%", NULL },
  135. { "+100%", NULL },
  136. { "+200%", NULL },
  137. { "+400%", NULL },
  138. { NULL, NULL },
  139. },
  140. "disabled"
  141. },
  142. #ifdef DRC_SH2
  143. {
  144. "picodrive_drc",
  145. "Dynamic recompilers",
  146. "Enable dynamic recompilers which help to improve performance. Less accurate than interpreter CPU cores, but much faster.",
  147. {
  148. { "enabled", NULL },
  149. { "disabled", NULL },
  150. { NULL, NULL },
  151. },
  152. "enabled"
  153. },
  154. #endif
  155. {
  156. "picodrive_audio_filter",
  157. "Audio filter",
  158. "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.",
  159. {
  160. { "disabled", NULL },
  161. { "low-pass", "Low-Pass" },
  162. { NULL, NULL },
  163. },
  164. "disabled"
  165. },
  166. {
  167. "picodrive_lowpass_range",
  168. "Low-pass filter %",
  169. "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.",
  170. {
  171. { "5", NULL },
  172. { "10", NULL },
  173. { "15", NULL },
  174. { "20", NULL },
  175. { "25", NULL },
  176. { "30", NULL },
  177. { "35", NULL },
  178. { "40", NULL },
  179. { "45", NULL },
  180. { "50", NULL },
  181. { "55", NULL },
  182. { "60", NULL },
  183. { "65", NULL },
  184. { "70", NULL },
  185. { "75", NULL },
  186. { "80", NULL },
  187. { "85", NULL },
  188. { "90", NULL },
  189. { "95", NULL },
  190. { NULL, NULL },
  191. },
  192. "60"
  193. },
  194. {
  195. "picodrive_frameskip",
  196. "Frameskip",
  197. "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.",
  198. {
  199. { "disabled", NULL },
  200. { "auto", "Auto" },
  201. { "manual", "Manual" },
  202. { NULL, NULL },
  203. },
  204. "disabled"
  205. },
  206. {
  207. "picodrive_frameskip_threshold",
  208. "Frameskip Threshold (%)",
  209. "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.",
  210. {
  211. { "15", NULL },
  212. { "18", NULL },
  213. { "21", NULL },
  214. { "24", NULL },
  215. { "27", NULL },
  216. { "30", NULL },
  217. { "33", NULL },
  218. { "36", NULL },
  219. { "39", NULL },
  220. { "42", NULL },
  221. { "45", NULL },
  222. { "48", NULL },
  223. { "51", NULL },
  224. { "54", NULL },
  225. { "57", NULL },
  226. { "60", NULL },
  227. { NULL, NULL },
  228. },
  229. "33"
  230. },
  231. #if !defined(RENDER_GSKIT_PS2)
  232. {
  233. "picodrive_renderer",
  234. "Renderer",
  235. "Fast renderer can't render any mid-frame image changes so it is useful only for some games.",
  236. {
  237. { "accurate", "Accurate" },
  238. { "fast", "Fast" },
  239. { NULL, NULL },
  240. },
  241. "accurate"
  242. },
  243. #endif
  244. {
  245. "picodrive_sound_rate",
  246. "Sound quality",
  247. "Sound quality (in Hz). A lower value may increase performance.",
  248. {
  249. { "16000", NULL },
  250. { "22050", NULL },
  251. { "32000", NULL },
  252. { "44100", NULL },
  253. { NULL, NULL },
  254. },
  255. "44100"
  256. },
  257. { NULL, NULL, NULL, {{0}}, NULL },
  258. };
  259. /*
  260. ********************************
  261. * Language Mapping
  262. ********************************
  263. */
  264. #ifndef HAVE_NO_LANGEXTRA
  265. struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
  266. option_defs_us, /* RETRO_LANGUAGE_ENGLISH */
  267. NULL, /* RETRO_LANGUAGE_JAPANESE */
  268. NULL, /* RETRO_LANGUAGE_FRENCH */
  269. NULL, /* RETRO_LANGUAGE_SPANISH */
  270. NULL, /* RETRO_LANGUAGE_GERMAN */
  271. NULL, /* RETRO_LANGUAGE_ITALIAN */
  272. NULL, /* RETRO_LANGUAGE_DUTCH */
  273. NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
  274. NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
  275. NULL, /* RETRO_LANGUAGE_RUSSIAN */
  276. NULL, /* RETRO_LANGUAGE_KOREAN */
  277. NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
  278. NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
  279. NULL, /* RETRO_LANGUAGE_ESPERANTO */
  280. NULL, /* RETRO_LANGUAGE_POLISH */
  281. NULL, /* RETRO_LANGUAGE_VIETNAMESE */
  282. NULL, /* RETRO_LANGUAGE_ARABIC */
  283. NULL, /* RETRO_LANGUAGE_GREEK */
  284. option_defs_tr, /* RETRO_LANGUAGE_TURKISH */
  285. };
  286. #endif
  287. /*
  288. ********************************
  289. * Functions
  290. ********************************
  291. */
  292. /* Handles configuration/setting of core options.
  293. * Should be called as early as possible - ideally inside
  294. * retro_set_environment(), and no later than retro_load_game()
  295. * > We place the function body in the header to avoid the
  296. * necessity of adding more .c files (i.e. want this to
  297. * be as painless as possible for core devs)
  298. */
  299. static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
  300. {
  301. unsigned version = 0;
  302. if (!environ_cb)
  303. return;
  304. if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1))
  305. {
  306. #ifndef HAVE_NO_LANGEXTRA
  307. struct retro_core_options_intl core_options_intl;
  308. unsigned language = 0;
  309. core_options_intl.us = option_defs_us;
  310. core_options_intl.local = NULL;
  311. if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
  312. (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
  313. core_options_intl.local = option_defs_intl[language];
  314. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
  315. #else
  316. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
  317. #endif
  318. }
  319. else
  320. {
  321. size_t i;
  322. size_t num_options = 0;
  323. struct retro_variable *variables = NULL;
  324. char **values_buf = NULL;
  325. /* Determine number of options */
  326. while (true)
  327. {
  328. if (option_defs_us[num_options].key)
  329. num_options++;
  330. else
  331. break;
  332. }
  333. /* Allocate arrays */
  334. variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
  335. values_buf = (char **)calloc(num_options, sizeof(char *));
  336. if (!variables || !values_buf)
  337. goto error;
  338. /* Copy parameters from option_defs_us array */
  339. for (i = 0; i < num_options; i++)
  340. {
  341. const char *key = option_defs_us[i].key;
  342. const char *desc = option_defs_us[i].desc;
  343. const char *default_value = option_defs_us[i].default_value;
  344. struct retro_core_option_value *values = option_defs_us[i].values;
  345. size_t buf_len = 3;
  346. size_t default_index = 0;
  347. values_buf[i] = NULL;
  348. if (desc)
  349. {
  350. size_t num_values = 0;
  351. /* Determine number of values */
  352. while (true)
  353. {
  354. if (values[num_values].value)
  355. {
  356. /* Check if this is the default value */
  357. if (default_value)
  358. if (strcmp(values[num_values].value, default_value) == 0)
  359. default_index = num_values;
  360. buf_len += strlen(values[num_values].value);
  361. num_values++;
  362. }
  363. else
  364. break;
  365. }
  366. /* Build values string */
  367. if (num_values > 0)
  368. {
  369. size_t j;
  370. buf_len += num_values - 1;
  371. buf_len += strlen(desc);
  372. values_buf[i] = (char *)calloc(buf_len, sizeof(char));
  373. if (!values_buf[i])
  374. goto error;
  375. strcpy(values_buf[i], desc);
  376. strcat(values_buf[i], "; ");
  377. /* Default value goes first */
  378. strcat(values_buf[i], values[default_index].value);
  379. /* Add remaining values */
  380. for (j = 0; j < num_values; j++)
  381. {
  382. if (j != default_index)
  383. {
  384. strcat(values_buf[i], "|");
  385. strcat(values_buf[i], values[j].value);
  386. }
  387. }
  388. }
  389. }
  390. variables[i].key = key;
  391. variables[i].value = values_buf[i];
  392. }
  393. /* Set variables */
  394. environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
  395. error:
  396. /* Clean up */
  397. if (values_buf)
  398. {
  399. for (i = 0; i < num_options; i++)
  400. {
  401. if (values_buf[i])
  402. {
  403. free(values_buf[i]);
  404. values_buf[i] = NULL;
  405. }
  406. }
  407. free(values_buf);
  408. values_buf = NULL;
  409. }
  410. if (variables)
  411. {
  412. free(variables);
  413. variables = NULL;
  414. }
  415. }
  416. }
  417. #ifdef __cplusplus
  418. }
  419. #endif
  420. #endif