libretro_core_options.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. {
  232. "picodrive_renderer",
  233. "Renderer",
  234. "Fast renderer can't render any mid-frame image changes so it is useful only for some games.",
  235. {
  236. { "accurate", "Accurate" },
  237. { "good", "Good" },
  238. { "fast", "Fast" },
  239. { NULL, NULL },
  240. },
  241. "accurate"
  242. },
  243. {
  244. "picodrive_sound_rate",
  245. "Sound quality",
  246. "Sound quality (in Hz). A lower value may increase performance.",
  247. {
  248. { "16000", NULL },
  249. { "22050", NULL },
  250. { "32000", NULL },
  251. { "44100", NULL },
  252. { NULL, NULL },
  253. },
  254. "44100"
  255. },
  256. { NULL, NULL, NULL, {{0}}, NULL },
  257. };
  258. /*
  259. ********************************
  260. * Language Mapping
  261. ********************************
  262. */
  263. #ifndef HAVE_NO_LANGEXTRA
  264. struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
  265. option_defs_us, /* RETRO_LANGUAGE_ENGLISH */
  266. NULL, /* RETRO_LANGUAGE_JAPANESE */
  267. NULL, /* RETRO_LANGUAGE_FRENCH */
  268. NULL, /* RETRO_LANGUAGE_SPANISH */
  269. NULL, /* RETRO_LANGUAGE_GERMAN */
  270. NULL, /* RETRO_LANGUAGE_ITALIAN */
  271. NULL, /* RETRO_LANGUAGE_DUTCH */
  272. NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
  273. NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
  274. NULL, /* RETRO_LANGUAGE_RUSSIAN */
  275. NULL, /* RETRO_LANGUAGE_KOREAN */
  276. NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
  277. NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
  278. NULL, /* RETRO_LANGUAGE_ESPERANTO */
  279. NULL, /* RETRO_LANGUAGE_POLISH */
  280. NULL, /* RETRO_LANGUAGE_VIETNAMESE */
  281. NULL, /* RETRO_LANGUAGE_ARABIC */
  282. NULL, /* RETRO_LANGUAGE_GREEK */
  283. option_defs_tr, /* RETRO_LANGUAGE_TURKISH */
  284. };
  285. #endif
  286. /*
  287. ********************************
  288. * Functions
  289. ********************************
  290. */
  291. /* Handles configuration/setting of core options.
  292. * Should be called as early as possible - ideally inside
  293. * retro_set_environment(), and no later than retro_load_game()
  294. * > We place the function body in the header to avoid the
  295. * necessity of adding more .c files (i.e. want this to
  296. * be as painless as possible for core devs)
  297. */
  298. static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
  299. {
  300. unsigned version = 0;
  301. if (!environ_cb)
  302. return;
  303. if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1))
  304. {
  305. #ifndef HAVE_NO_LANGEXTRA
  306. struct retro_core_options_intl core_options_intl;
  307. unsigned language = 0;
  308. core_options_intl.us = option_defs_us;
  309. core_options_intl.local = NULL;
  310. if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
  311. (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
  312. core_options_intl.local = option_defs_intl[language];
  313. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
  314. #else
  315. environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
  316. #endif
  317. }
  318. else
  319. {
  320. size_t i;
  321. size_t num_options = 0;
  322. struct retro_variable *variables = NULL;
  323. char **values_buf = NULL;
  324. /* Determine number of options */
  325. while (true)
  326. {
  327. if (option_defs_us[num_options].key)
  328. num_options++;
  329. else
  330. break;
  331. }
  332. /* Allocate arrays */
  333. variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
  334. values_buf = (char **)calloc(num_options, sizeof(char *));
  335. if (!variables || !values_buf)
  336. goto error;
  337. /* Copy parameters from option_defs_us array */
  338. for (i = 0; i < num_options; i++)
  339. {
  340. const char *key = option_defs_us[i].key;
  341. const char *desc = option_defs_us[i].desc;
  342. const char *default_value = option_defs_us[i].default_value;
  343. struct retro_core_option_value *values = option_defs_us[i].values;
  344. size_t buf_len = 3;
  345. size_t default_index = 0;
  346. values_buf[i] = NULL;
  347. if (desc)
  348. {
  349. size_t num_values = 0;
  350. /* Determine number of values */
  351. while (true)
  352. {
  353. if (values[num_values].value)
  354. {
  355. /* Check if this is the default value */
  356. if (default_value)
  357. if (strcmp(values[num_values].value, default_value) == 0)
  358. default_index = num_values;
  359. buf_len += strlen(values[num_values].value);
  360. num_values++;
  361. }
  362. else
  363. break;
  364. }
  365. /* Build values string */
  366. if (num_values > 0)
  367. {
  368. size_t j;
  369. buf_len += num_values - 1;
  370. buf_len += strlen(desc);
  371. values_buf[i] = (char *)calloc(buf_len, sizeof(char));
  372. if (!values_buf[i])
  373. goto error;
  374. strcpy(values_buf[i], desc);
  375. strcat(values_buf[i], "; ");
  376. /* Default value goes first */
  377. strcat(values_buf[i], values[default_index].value);
  378. /* Add remaining values */
  379. for (j = 0; j < num_values; j++)
  380. {
  381. if (j != default_index)
  382. {
  383. strcat(values_buf[i], "|");
  384. strcat(values_buf[i], values[j].value);
  385. }
  386. }
  387. }
  388. }
  389. variables[i].key = key;
  390. variables[i].value = values_buf[i];
  391. }
  392. /* Set variables */
  393. environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
  394. error:
  395. /* Clean up */
  396. if (values_buf)
  397. {
  398. for (i = 0; i < num_options; i++)
  399. {
  400. if (values_buf[i])
  401. {
  402. free(values_buf[i]);
  403. values_buf[i] = NULL;
  404. }
  405. }
  406. free(values_buf);
  407. values_buf = NULL;
  408. }
  409. if (variables)
  410. {
  411. free(variables);
  412. variables = NULL;
  413. }
  414. }
  415. }
  416. #ifdef __cplusplus
  417. }
  418. #endif
  419. #endif