39bc32b6c28090bac90610e7c6a1b79b898611e7
[pcsx_rearmed.git] / frontend / libretro_core_options.h
1 #ifndef LIBRETRO_CORE_OPTIONS_H__
2 #define LIBRETRO_CORE_OPTIONS_H__
3
4 #include <stdlib.h>
5 #include <string.h>
6
7 #include <libretro.h>
8 #include <retro_inline.h>
9
10 #ifndef HAVE_NO_LANGEXTRA
11 #include "libretro_core_options_intl.h"
12 #endif
13
14 /*
15  ********************************
16  * VERSION: 2.0
17  ********************************
18  *
19  * - 2.0: Add support for core options v2 interface
20  * - 1.3: Move translations to libretro_core_options_intl.h
21  *        - libretro_core_options_intl.h includes BOM and utf-8
22  *          fix for MSVC 2010-2013
23  *        - Added HAVE_NO_LANGEXTRA flag to disable translations
24  *          on platforms/compilers without BOM support
25  * - 1.2: Use core options v1 interface when
26  *        RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1
27  *        (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1)
28  * - 1.1: Support generation of core options v0 retro_core_option_value
29  *        arrays containing options with a single value
30  * - 1.0: First commit
31 */
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /*
38  ********************************
39  * Core Option Definitions
40  ********************************
41 */
42
43 /* RETRO_LANGUAGE_ENGLISH */
44
45 /* Default language:
46  * - All other languages must include the same keys and values
47  * - Will be used as a fallback in the event that frontend language
48  *   is not available
49  * - Will be used as a fallback for any missing entries in
50  *   frontend language definition
51  */
52
53 struct retro_core_option_v2_category option_cats_us[] = {
54    {
55       "system",
56       "System",
57       "Configure base hardware parameters: region, BIOS selection, memory cards, etc."
58    },
59    {
60       "video",
61       "Video",
62       "Configure base display parameters."
63    },
64 #ifdef GPU_NEON
65    {
66       "gpu_neon",
67       "GPU Plugin",
68       "Configure low-level settings of the NEON GPU plugin."
69    },
70 #endif
71 #ifdef GPU_PEOPS
72    {
73       "gpu_peops",
74       "GPU Plugin (Advanced)",
75       "Configure low-level settings of the P.E.Op.S. GPU plugin."
76    },
77 #endif
78 #ifdef GPU_UNAI
79    {
80       "gpu_unai",
81       "GPU Plugin (Advanced)",
82       "Configure low-level settings of the UNAI GPU plugin."
83    },
84 #endif
85    {
86       "audio",
87       "Audio",
88       "Configure sound emulation: reverb, interpolation, CD audio decoding."
89    },
90    {
91       "input",
92       "Input",
93       "Configure input devices: analog response, haptic feedback, Multitaps, light guns, etc."
94    },
95    {
96       "compat_hack",
97       "Compatibility Fixes",
98       "Configure settings/workarounds required for correct operation of specific games."
99    },
100 #if !defined(DRC_DISABLE) && !defined(LIGHTREC)
101    {
102       "speed_hack",
103       "Speed Hacks (Advanced)",
104       "Configure hacks that may improve performance at the expense of decreased accuracy/stability."
105    },
106 #endif
107    { NULL, NULL, NULL },
108 };
109
110 struct retro_core_option_v2_definition option_defs_us[] = {
111    {
112       "pcsx_rearmed_region",
113       "Region",
114       NULL,
115       "Specify which region the system is from. 'NTSC' is 60 Hz while 'PAL' is 50 Hz. 'Auto' will detect the region of the currently loaded content. Games may run faster or slower than normal if the incorrect region is selected.",
116       NULL,
117       "system",
118       {
119          { "auto", "Auto" },
120          { "NTSC", NULL },
121          { "PAL",  NULL },
122          { NULL, NULL },
123       },
124       "auto",
125    },
126    {
127       "pcsx_rearmed_bios",
128       "BIOS Selection",
129       NULL,
130       "Specify which BIOS to use. 'Auto' will attempt to load a real bios file from the frontend 'system' directory, falling back to high level emulation if unavailable. 'HLE' forces high level BIOS emulation. It is recommended to use an official bios file for better compatibility.",
131       NULL,
132       "system",
133       {
134          { "auto", "Auto" },
135          { "HLE",  NULL },
136          { NULL, NULL },
137       },
138       "auto",
139    },
140    {
141       "pcsx_rearmed_show_bios_bootlogo",
142       "Show BIOS Boot Logo",
143       NULL,
144       "When using an official BIOS file, specify whether to show the PlayStation logo upon starting or resetting content. Warning: Enabling the boot logo may reduce game compatibility.",
145       NULL,
146       "system",
147       {
148          { "disabled", NULL },
149          { "enabled",  NULL },
150          { NULL, NULL },
151       },
152       "disabled",
153    },
154    {
155       "pcsx_rearmed_memcard2",
156       "Enable Second Memory Card (Shared)",
157       NULL,
158       "Emulate a second memory card in slot 2. This will be shared by all games.",
159       NULL,
160       "system",
161       {
162          { "disabled", NULL },
163          { "enabled",  NULL },
164          { NULL, NULL },
165       },
166       "disabled",
167    },
168 #ifndef _WIN32
169    {
170       "pcsx_rearmed_async_cd",
171       "CD Access Method (Restart)",
172       NULL,
173       "Select method used to read data from content disk images. 'Synchronous' mimics original hardware. 'Asynchronous' can reduce stuttering on devices with slow storage. 'Pre-Cache (CHD)' loads disk image into memory for faster access (CHD files only).",
174       NULL,
175       "system",
176       {
177          { "sync",     "Synchronous" },
178          { "async",    "Asynchronous" },
179          { "precache", "Pre-Cache (CHD)" },
180          { NULL, NULL},
181       },
182       "sync",
183    },
184 #endif
185 #ifndef DRC_DISABLE
186    {
187       "pcsx_rearmed_drc",
188       "Dynamic Recompiler",
189       NULL,
190       "Dynamically recompile PSX CPU instructions to native instructions. Much faster than using an interpreter, but may be less accurate on some platforms.",
191       NULL,
192       "system",
193       {
194          { "disabled", NULL },
195          { "enabled",  NULL },
196          { NULL, NULL },
197       },
198       "enabled",
199    },
200 #endif
201    {
202       "pcsx_rearmed_psxclock",
203       "PSX CPU Clock Speed",
204       NULL,
205       "Overclock or under-clock the PSX CPU. Try adjusting this if the game is too slow, too fast or hangs."
206 #if defined(LIGHTREC)
207       " Currently doesn't work with Lightrec dynarec."
208 #endif
209 #if defined(HAVE_PRE_ARMV7) && !defined(_3DS)
210       " Default is 50."
211 #else
212       " Default is 57."
213 #endif
214       ,
215       NULL,
216       "system",
217       {
218          { "30",  NULL },
219          { "31",  NULL },
220          { "32",  NULL },
221          { "33",  NULL },
222          { "34",  NULL },
223          { "35",  NULL },
224          { "36",  NULL },
225          { "37",  NULL },
226          { "38",  NULL },
227          { "39",  NULL },
228          { "40",  NULL },
229          { "41",  NULL },
230          { "42",  NULL },
231          { "43",  NULL },
232          { "44",  NULL },
233          { "45",  NULL },
234          { "46",  NULL },
235          { "47",  NULL },
236          { "48",  NULL },
237          { "49",  NULL },
238          { "50",  NULL },
239          { "51",  NULL },
240          { "52",  NULL },
241          { "53",  NULL },
242          { "54",  NULL },
243          { "55",  NULL },
244          { "56",  NULL },
245          { "57",  NULL },
246          { "58",  NULL },
247          { "59",  NULL },
248          { "60",  NULL },
249          { "61",  NULL },
250          { "62",  NULL },
251          { "63",  NULL },
252          { "64",  NULL },
253          { "65",  NULL },
254          { "66",  NULL },
255          { "67",  NULL },
256          { "68",  NULL },
257          { "69",  NULL },
258          { "70",  NULL },
259          { "71",  NULL },
260          { "72",  NULL },
261          { "73",  NULL },
262          { "74",  NULL },
263          { "75",  NULL },
264          { "76",  NULL },
265          { "77",  NULL },
266          { "78",  NULL },
267          { "79",  NULL },
268          { "80",  NULL },
269          { "81",  NULL },
270          { "82",  NULL },
271          { "83",  NULL },
272          { "84",  NULL },
273          { "85",  NULL },
274          { "86",  NULL },
275          { "87",  NULL },
276          { "88",  NULL },
277          { "89",  NULL },
278          { "90",  NULL },
279          { "91",  NULL },
280          { "92",  NULL },
281          { "93",  NULL },
282          { "94",  NULL },
283          { "95",  NULL },
284          { "96",  NULL },
285          { "97",  NULL },
286          { "98",  NULL },
287          { "99",  NULL },
288          { "100", NULL },
289          { NULL, NULL },
290       },
291 #if defined(HAVE_PRE_ARMV7) && !defined(_3DS)
292       "50",
293 #else
294       "57",
295 #endif
296    },
297    {
298       "pcsx_rearmed_dithering",
299       "Dithering Pattern",
300       NULL,
301       "Enable emulation of the dithering technique used by the PSX to smooth out color banding artifacts. Increases performance requirements.",
302       NULL,
303       "video",
304       {
305          { "disabled", NULL },
306          { "enabled",  NULL },
307          { NULL, NULL },
308       },
309 #if defined HAVE_LIBNX || defined _3DS
310       "disabled",
311 #else
312       "enabled",
313 #endif
314    },
315    {
316       "pcsx_rearmed_duping_enable",
317       "Frame Duping (Speedup)",
318       NULL,
319       "When enabled and supported by the libretro frontend, provides a small performance increase by directing the frontend to repeat the previous frame if the core has nothing new to display.",
320       NULL,
321       "video",
322       {
323          { "disabled", NULL },
324          { "enabled",  NULL },
325          { NULL, NULL },
326       },
327       "enabled",
328    },
329 #ifdef THREAD_RENDERING
330    {
331       "pcsx_rearmed_gpu_thread_rendering",
332       "Threaded Rendering",
333       NULL,
334       "When enabled, runs GPU commands in a secondary thread. 'Synchronous' improves performance while maintaining proper frame pacing. 'Asynchronous' improves performance even further, but may cause dropped frames and increased latency. Produces best results with games that run natively at less than 60 frames per second.",
335       NULL,
336       "video",
337       {
338          { "disabled", NULL },
339          { "sync",     "Synchronous" },
340          { "async",    "Asynchronous" },
341          { NULL, NULL},
342       },
343       "disabled",
344    },
345 #endif
346    {
347       "pcsx_rearmed_frameskip_type",
348       "Frameskip",
349       NULL,
350       "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. 'Auto (Threshold)' utilises the 'Frameskip Threshold (%)' setting. 'Fixed Interval' utilises the 'Frameskip Interval' setting.",
351       NULL,
352       "video",
353       {
354          { "disabled",       NULL },
355          { "auto",           "Auto" },
356          { "auto_threshold", "Auto (Threshold)" },
357          { "fixed_interval", "Fixed Interval" },
358          { NULL, NULL },
359       },
360       "disabled"
361    },
362    {
363       "pcsx_rearmed_frameskip_threshold",
364       "Frameskip Threshold (%)",
365       NULL,
366       "When 'Frameskip' is set to 'Auto (Threshold)', 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.",
367       NULL,
368       "video",
369       {
370          { "15", NULL },
371          { "18", NULL },
372          { "21", NULL },
373          { "24", NULL },
374          { "27", NULL },
375          { "30", NULL },
376          { "33", NULL },
377          { "36", NULL },
378          { "39", NULL },
379          { "42", NULL },
380          { "45", NULL },
381          { "48", NULL },
382          { "51", NULL },
383          { "54", NULL },
384          { "57", NULL },
385          { "60", NULL },
386          { NULL, NULL },
387       },
388       "33"
389    },
390    {
391       "pcsx_rearmed_frameskip_interval",
392       "Frameskip Interval",
393       NULL,
394       "Specify the maximum number of frames that can be skipped before a new frame is rendered.",
395       NULL,
396       "video",
397       {
398          { "1",  NULL },
399          { "2",  NULL },
400          { "3",  NULL },
401          { "4",  NULL },
402          { "5",  NULL },
403          { "6",  NULL },
404          { "7",  NULL },
405          { "8",  NULL },
406          { "9",  NULL },
407          { "10", NULL },
408          { NULL, NULL },
409       },
410       "3"
411    },
412    {
413       "pcsx_rearmed_display_internal_fps",
414       "Display Internal FPS",
415       NULL,
416       "Show the internal frame rate at which the emulated PlayStation system is rendering content. Note: Requires on-screen notifications to be enabled in the libretro frontend.",
417       NULL,
418       "video",
419       {
420          { "disabled", NULL },
421          { "enabled",  NULL },
422          { NULL, NULL },
423       },
424       "disabled",
425    },
426 #ifdef GPU_NEON
427    {
428       "pcsx_rearmed_neon_interlace_enable",
429       "(GPU) Show Interlaced Video",
430       "Show Interlaced Video",
431       "When enabled, games that run in high resolution video modes (480i, 512i) will produced interlaced video output. While this displays correctly on CRT televisions, it will produce artifacts on modern displays. When disabled, all video is output in progressive format.",
432       NULL,
433       "gpu_neon",
434       {
435          { "disabled", NULL },
436          { "enabled",  NULL },
437          { NULL, NULL },
438       },
439       "disabled",
440    },
441    {
442       "pcsx_rearmed_neon_enhancement_enable",
443       "(GPU) Enhanced Resolution (Slow)",
444       "Enhanced Resolution (Slow)",
445       "Render games that do not already run in high resolution video modes (480i, 512i) at twice the native internal resolution. Improves the fidelity of 3D models at the expense of increased performance requirements. 2D elements are generally unaffected by this setting.",
446       NULL,
447       "gpu_neon",
448       {
449          { "disabled", NULL },
450          { "enabled",  NULL },
451          { NULL, NULL },
452       },
453       "disabled",
454    },
455    {
456       "pcsx_rearmed_neon_enhancement_no_main",
457       "(GPU) Enhanced Resolution Speed Hack",
458       "Enhanced Resolution Speed Hack",
459       "Improves performance when 'Enhanced Resolution (Slow)' is enabled, but reduces compatibility and may cause rendering errors.",
460       NULL,
461       "gpu_neon",
462       {
463          { "disabled", NULL },
464          { "enabled",  NULL },
465          { NULL, NULL },
466       },
467       "disabled",
468    },
469 #endif /* GPU_NEON */
470 #ifdef GPU_PEOPS
471    {
472       "pcsx_rearmed_show_gpu_peops_settings",
473       "Show Advanced P.E.Op.S. GPU Settings",
474       NULL,
475       "Show low-level configuration options for the P.E.Op.S. GPU plugin. Quick Menu may need to be toggled for this setting to take effect.",
476       NULL,
477       NULL,
478       {
479          { "disabled", NULL },
480          { "enabled",  NULL },
481          { NULL, NULL },
482       },
483       "disabled",
484    },
485    {
486       "pcsx_rearmed_gpu_peops_odd_even_bit",
487       "(GPU) Odd/Even Bit Hack",
488       "Odd/Even Bit Hack",
489       "A hack fix used to correct lock-ups that may occur in games such as Chrono Cross. Disable unless required.",
490       NULL,
491       "gpu_peops",
492       {
493          { "disabled", NULL },
494          { "enabled",  NULL },
495          { NULL, NULL },
496       },
497       "disabled",
498    },
499    {
500       "pcsx_rearmed_gpu_peops_expand_screen_width",
501       "(GPU) Expand Screen Width",
502       "Expand Screen Width",
503       "Intended for use only with Capcom 2D fighting games. Enlarges the display area at the right side of the screen to show all background elements without cut-off. May cause rendering errors.",
504       NULL,
505       "gpu_peops",
506       {
507          { "disabled", NULL },
508          { "enabled",  NULL },
509          { NULL, NULL },
510       },
511       "disabled",
512    },
513    {
514       "pcsx_rearmed_gpu_peops_ignore_brightness",
515       "(GPU) Ignore Brightness Color",
516       "Ignore Brightness Color",
517       "A hack fix used to repair black screens in Lunar Silver Star Story Complete when entering a house or a menu. Disable unless required.",
518       NULL,
519       "gpu_peops",
520       {
521          { "disabled", NULL },
522          { "enabled",  NULL },
523          { NULL, NULL },
524       },
525       "disabled",
526    },
527    {
528       "pcsx_rearmed_gpu_peops_disable_coord_check",
529       "(GPU) Disable Coordinate Check",
530       "Disable Coordinate Check",
531       "Legacy compatibility mode. May improve games that fail to run correctly on newer GPU hardware. Disable unless required.",
532       NULL,
533       "gpu_peops",
534       {
535          { "disabled", NULL },
536          { "enabled",  NULL },
537          { NULL, NULL },
538       },
539       "disabled",
540    },
541    {
542       "pcsx_rearmed_gpu_peops_lazy_screen_update",
543       "(GPU) Lazy Screen Update",
544       "Lazy Screen Update",
545       "A partial fix to prevent text box flickering in Dragon Warrior VII. May also improve Pandemonium 2. Disable unless required.",
546       NULL,
547       "gpu_peops",
548       {
549          { "disabled", NULL },
550          { "enabled",  NULL },
551          { NULL, NULL },
552       },
553       "disabled",
554    },
555    {
556       "pcsx_rearmed_gpu_peops_repeated_triangles",
557       "(GPU) Repeat Flat Tex Triangles",
558       "Repeat Flat Tex Triangles",
559       "A hack fix used to correct rendering errors in Star Wars: Dark Forces. Disable unless required.",
560       NULL,
561       "gpu_peops",
562       {
563          { "disabled", NULL },
564          { "enabled",  NULL },
565          { NULL, NULL },
566       },
567       "disabled",
568    },
569    {
570       "pcsx_rearmed_gpu_peops_quads_with_triangles",
571       "(GPU) Draw Tex-Quads as Triangles",
572       "Draw Tex-Quads as Triangles",
573       "Corrects graphical distortions that may occur when games utilize Gouraud Shading, at the expense of reduced texture quality. Disable unless required.",
574       NULL,
575       "gpu_peops",
576       {
577          { "disabled", NULL },
578          { "enabled",  NULL },
579          { NULL, NULL },
580       },
581       "disabled",
582    },
583    {
584       "pcsx_rearmed_gpu_peops_fake_busy_state",
585       "(GPU) Fake 'GPU Busy' States",
586       "Fake 'GPU Busy' States",
587       "Emulate the 'GPU is busy' (drawing primitives) status flag of the original hardware instead of assuming the GPU is always ready for commands. May improve compatibility at the expense of reduced performance. Disable unless required.",
588       NULL,
589       "gpu_peops",
590       {
591          { "disabled", NULL },
592          { "enabled",  NULL },
593          { NULL, NULL },
594       },
595       "disabled",
596    },
597 #endif /* GPU_PEOPS */
598 #ifdef GPU_UNAI
599    {
600       "pcsx_rearmed_show_gpu_unai_settings",
601       "Show Advanced UNAI GPU Settings",
602       NULL,
603       "Show low-level configuration options for the UNAI GPU plugin. Quick Menu may need to be toggled for this setting to take effect.",
604       NULL,
605       NULL,
606       {
607          { "disabled", NULL },
608          { "enabled",  NULL },
609          { NULL, NULL},
610       },
611       "disabled",
612    },
613    {
614       "pcsx_rearmed_gpu_unai_blending",
615       "(GPU) Texture Blending",
616       "Texture Blending",
617       "Enable alpha-based (and additive) texture blending. Required for various rendering effects, including transparency (e.g. water, shadows). Can be disabled to improve performance at the expense of severe display errors/inaccuracies.",
618       NULL,
619       "gpu_unai",
620       {
621          { "disabled", NULL },
622          { "enabled",  NULL },
623          { NULL, NULL},
624       },
625       "enabled",
626    },
627    {
628       "pcsx_rearmed_gpu_unai_lighting",
629       "(GPU) Lighting Effects",
630       "Lighting Effects",
631       "Enable simulated lighting effects (via vertex coloring combined with texture mapping). Required by almost all 3D games. Can be disabled to improve performance at the expense of severe display errors/inaccuracies (missing shadows, flat textures, etc.).",
632       NULL,
633       "gpu_unai",
634       {
635          { "disabled", NULL },
636          { "enabled",  NULL },
637          { NULL, NULL},
638       },
639       "enabled",
640    },
641    {
642       "pcsx_rearmed_gpu_unai_fast_lighting",
643       "(GPU) Fast Lighting",
644       "Fast Lighting",
645       "Improves performance when 'Lighting Effects' are enabled, but may cause moderate/severe rendering errors.",
646       NULL,
647       "gpu_unai",
648       {
649          { "disabled", NULL },
650          { "enabled",  NULL },
651          { NULL, NULL},
652       },
653       "disabled",
654    },
655    {
656       "pcsx_rearmed_gpu_unai_scale_hires",
657       "(GPU) Hi-Res Downscaling",
658       "Hi-Res Downscaling",
659       "When enabled, games that run in high resolution video modes (480i, 512i) will be downscaled to 320x240. Can improve performance, and is recommended on devices with native 240p display resolutions.",
660       NULL,
661       "gpu_unai",
662       {
663          { "disabled", NULL },
664          { "enabled",  NULL },
665          { NULL, NULL},
666       },
667 #ifdef _MIYOO
668       "enabled",
669 #else
670       "disabled",
671 #endif
672    },
673 #endif /* GPU_UNAI */
674    {
675       "pcsx_rearmed_spu_reverb",
676       "Audio Reverb Effects",
677       "Reverb Effects",
678       "Enable emulation of the reverb feature provided by the PSX SPU. Can be disabled to improve performance at the expense of reduced audio quality/authenticity.",
679       NULL,
680       "audio",
681       {
682          { "disabled", NULL },
683          { "enabled",  NULL },
684          { NULL, NULL },
685       },
686 #ifdef HAVE_PRE_ARMV7
687       "disabled",
688 #else
689       "enabled",
690 #endif
691    },
692    {
693       "pcsx_rearmed_spu_interpolation",
694       "Sound Interpolation",
695       NULL,
696       "Enable emulation of the in-built audio interpolation provided by the PSX SPU. 'Gaussian' sounds closest to original hardware. 'Simple' improves performance but reduces quality. 'Cubic' has the highest performance requirements but produces increased clarity. Can be disabled entirely for maximum performance, at the expense of greatly reduced audio quality.",
697       NULL,
698       "audio",
699       {
700          { "simple",   "Simple" },
701          { "gaussian", "Gaussian" },
702          { "cubic",    "Cubic" },
703          { "off",      "disabled" },
704          { NULL, NULL },
705       },
706 #ifdef HAVE_PRE_ARMV7
707       "off",
708 #else
709       "simple",
710 #endif
711    },
712    {
713       "pcsx_rearmed_nocdaudio",
714       "CD Audio",
715       NULL,
716       "Enable playback of CD (CD-DA) audio tracks. Can be disabled to improve performance in games that include CD audio, at the expense of missing music.",
717       NULL,
718       "audio",
719       {
720          { "disabled", NULL },
721          { "enabled",  NULL },
722          { NULL, NULL },
723       },
724       "enabled",
725    },
726    {
727       "pcsx_rearmed_noxadecoding",
728       "XA Decoding",
729       NULL,
730       "Enable playback of XA (eXtended Architecture ADPCM) audio tracks. Can be disabled to improve performance in games that include XA audio, at the expense of missing music.",
731       NULL,
732       "audio",
733       {
734          { "disabled", NULL },
735          { "enabled",  NULL },
736          { NULL, NULL },
737       },
738       "enabled",
739    },
740    {
741       "pcsx_rearmed_show_input_settings",
742       "Show Input Settings",
743       NULL,
744       "Show configuration options for all input devices: analog response, Multitaps, light guns, etc. Quick Menu may need to be toggled for this setting to take effect.",
745       NULL,
746       NULL,
747       {
748          { "disabled", NULL },
749          { "enabled",  NULL },
750          { NULL, NULL },
751       },
752       "disabled",
753    },
754    {
755       "pcsx_rearmed_analog_axis_modifier",
756       "Analog Axis Bounds",
757       NULL,
758       "Specify range limits for the left and right analog sticks when input device is set to 'analog' or 'dualshock'. 'Square' bounds improve input response when using controllers with highly circular ranges that are unable to fully saturate the X and Y axes at 45 degree deflections.",
759       NULL,
760       "input",
761       {
762          { "circle", "Circle" },
763          { "square", "Square" },
764          { NULL, NULL },
765       },
766       "circle",
767    },
768    {
769       "pcsx_rearmed_vibration",
770       "Rumble Effects",
771       NULL,
772       "Enable haptic feedback when using a rumble-equipped gamepad with input device set to 'dualshock'.",
773       NULL,
774       "input",
775       {
776          { "disabled", NULL },
777          { "enabled",  NULL },
778          { NULL, NULL },
779       },
780       "enabled",
781    },
782    {
783       "pcsx_rearmed_multitap",
784       "Multitap Mode (Restart)",
785       NULL,
786       "Connect a virtual PSX Multitap peripheral to either controller 'Port 1' or controller 'Port 2' for 5 player simultaneous input, or to both 'Ports 1 and 2' for 8 player input. Mutlitap usage requires compatible games. To avoid input defects, option should be disabled when running games that have no support for Multitap features.",
787       NULL,
788       "input",
789       {
790          { "disabled",      NULL },
791          { "port 1",        "Port 1" },
792          { "port 2",        "Port 2" },
793          { "ports 1 and 2", "Ports 1 and 2" },
794          { NULL, NULL },
795       },
796       "disabled",
797    },
798    {
799       "pcsx_rearmed_negcon_deadzone",
800       "NegCon Twist Deadzone",
801       NULL,
802       "Set the deadzone of the RetroPad left analog stick when simulating the 'twist' action of emulated neGcon Controllers. Used to eliminate drift/unwanted input.",
803       NULL,
804       "input",
805       {
806          { "0",  "0%" },
807          { "3",  "3%" },
808          { "5",  "5%" },
809          { "7",  "7%" },
810          { "10", "10%" },
811          { "13", "13%" },
812          { "15", "15%" },
813          { "17", "17%" },
814          { "20", "20%" },
815          { "23", "23%" },
816          { "25", "25%" },
817          { "27", "27%" },
818          { "30", "30%" },
819          { NULL, NULL },
820       },
821       "0",
822    },
823    {
824       "pcsx_rearmed_negcon_response",
825       "NegCon Twist Response",
826       NULL,
827       "Specify the analog response when using a RetroPad left analog stick to simulate the 'twist' action of emulated neGcon Controllers.",
828       NULL,
829       "input",
830       {
831          { "linear",    "Linear" },
832          { "quadratic", "Quadratic" },
833          { "cubic",     "Cubic" },
834          { NULL, NULL },
835       },
836       "linear",
837    },
838    {
839       "pcsx_rearmed_input_sensitivity",
840       "Mouse Sensitivity",
841       NULL,
842       "Adjust responsiveness of emulated 'mouse' input devices.",
843       NULL,
844       "input",
845       {
846          { "0.05", NULL },
847          { "0.10", NULL },
848          { "0.15", NULL },
849          { "0.20", NULL },
850          { "0.25", NULL },
851          { "0.30", NULL },
852          { "0.35", NULL },
853          { "0.40", NULL },
854          { "0.45", NULL },
855          { "0.50", NULL },
856          { "0.55", NULL },
857          { "0.60", NULL },
858          { "0.65", NULL },
859          { "0.70", NULL },
860          { "0.75", NULL },
861          { "0.80", NULL },
862          { "0.85", NULL },
863          { "0.90", NULL },
864          { "0.95", NULL },
865          { "1.00", NULL },
866          { "1.05", NULL },
867          { "1.10", NULL },
868          { "1.15", NULL },
869          { "1.20", NULL },
870          { "1.25", NULL },
871          { "1.30", NULL },
872          { "1.35", NULL },
873          { "1.40", NULL },
874          { "1.45", NULL },
875          { "1.50", NULL },
876          { "1.55", NULL },
877          { "1.60", NULL },
878          { "1.65", NULL },
879          { "1.70", NULL },
880          { "1.75", NULL },
881          { "1.80", NULL },
882          { "1.85", NULL },
883          { "1.90", NULL },
884          { "1.95", NULL },
885          { "2.00", NULL },
886       },
887       "1.00",
888    },
889    {
890       "pcsx_rearmed_gunconadjustx",
891       "Guncon X Axis Offset",
892       NULL,
893       "Apply an X axis offset to light gun input when emulating a Guncon device. Can be used to correct aiming misalignments.",
894       NULL,
895       "input",
896       {
897          { "-25", NULL },
898          { "-24", NULL },
899          { "-23", NULL },
900          { "-22", NULL },
901          { "-21", NULL },
902          { "-20", NULL },
903          { "-19", NULL },
904          { "-18", NULL },
905          { "-17", NULL },
906          { "-16", NULL },
907          { "-15", NULL },
908          { "-14", NULL },
909          { "-13", NULL },
910          { "-12", NULL },
911          { "-11", NULL },
912          { "-10", NULL },
913          { "-9",  NULL },
914          { "-8",  NULL },
915          { "-7",  NULL },
916          { "-6",  NULL },
917          { "-5",  NULL },
918          { "-4",  NULL },
919          { "-3",  NULL },
920          { "-2",  NULL },
921          { "-1",  NULL },
922          { "0",   NULL },
923          { "1",   NULL },
924          { "2",   NULL },
925          { "3",   NULL },
926          { "4",   NULL },
927          { "5",   NULL },
928          { "6",   NULL },
929          { "7",   NULL },
930          { "8",   NULL },
931          { "9",   NULL },
932          { "10",  NULL },
933          { "11",  NULL },
934          { "12",  NULL },
935          { "13",  NULL },
936          { "14",  NULL },
937          { "15",  NULL },
938          { "16",  NULL },
939          { "17",  NULL },
940          { "18",  NULL },
941          { "19",  NULL },
942          { "20",  NULL },
943          { "21",  NULL },
944          { "22",  NULL },
945          { "23",  NULL },
946          { "24",  NULL },
947          { "25",  NULL },
948          { NULL, NULL },
949       },
950       "0",
951    },
952    {
953       "pcsx_rearmed_gunconadjusty",
954       "Guncon Y Axis Offset",
955       NULL,
956       "Apply a Y axis offset to light gun input when emulating a Guncon device. Can be used to correct aiming misalignments.",
957       NULL,
958       "input",
959       {
960          { "-25", NULL },
961          { "-24", NULL },
962          { "-23", NULL },
963          { "-22", NULL },
964          { "-21", NULL },
965          { "-20", NULL },
966          { "-19", NULL },
967          { "-18", NULL },
968          { "-17", NULL },
969          { "-16", NULL },
970          { "-15", NULL },
971          { "-14", NULL },
972          { "-13", NULL },
973          { "-12", NULL },
974          { "-11", NULL },
975          { "-10", NULL },
976          { "-9",  NULL },
977          { "-8",  NULL },
978          { "-7",  NULL },
979          { "-6",  NULL },
980          { "-5",  NULL },
981          { "-4",  NULL },
982          { "-3",  NULL },
983          { "-2",  NULL },
984          { "-1",  NULL },
985          { "0",   NULL },
986          { "1",   NULL },
987          { "2",   NULL },
988          { "3",   NULL },
989          { "4",   NULL },
990          { "5",   NULL },
991          { "6",   NULL },
992          { "7",   NULL },
993          { "8",   NULL },
994          { "9",   NULL },
995          { "10",  NULL },
996          { "11",  NULL },
997          { "12",  NULL },
998          { "13",  NULL },
999          { "14",  NULL },
1000          { "15",  NULL },
1001          { "16",  NULL },
1002          { "17",  NULL },
1003          { "18",  NULL },
1004          { "19",  NULL },
1005          { "20",  NULL },
1006          { "21",  NULL },
1007          { "22",  NULL },
1008          { "23",  NULL },
1009          { "24",  NULL },
1010          { "25",  NULL },
1011          { NULL, NULL },
1012       },
1013       "0",
1014    },
1015    {
1016       "pcsx_rearmed_gunconadjustratiox",
1017       "Guncon X Axis Response",
1018       NULL,
1019       "Adjust relative magnitude of horizontal light gun motion when emulating a Guncon device. Can be used to correct aiming misalignments.",
1020       NULL,
1021       "input",
1022       {
1023          { "0.75", NULL },
1024          { "0.76", NULL },
1025          { "0.77", NULL },
1026          { "0.78", NULL },
1027          { "0.79", NULL },
1028          { "0.80", NULL },
1029          { "0.81", NULL },
1030          { "0.82", NULL },
1031          { "0.83", NULL },
1032          { "0.84", NULL },
1033          { "0.85", NULL },
1034          { "0.86", NULL },
1035          { "0.87", NULL },
1036          { "0.88", NULL },
1037          { "0.89", NULL },
1038          { "0.90", NULL },
1039          { "0.91", NULL },
1040          { "0.92", NULL },
1041          { "0.93", NULL },
1042          { "0.94", NULL },
1043          { "0.95", NULL },
1044          { "0.96", NULL },
1045          { "0.97", NULL },
1046          { "0.98", NULL },
1047          { "0.99", NULL },
1048          { "1.00", NULL },
1049          { "1.01", NULL },
1050          { "1.02", NULL },
1051          { "1.03", NULL },
1052          { "1.04", NULL },
1053          { "1.05", NULL },
1054          { "1.06", NULL },
1055          { "1.07", NULL },
1056          { "1.08", NULL },
1057          { "1.09", NULL },
1058          { "1.10", NULL },
1059          { "1.11", NULL },
1060          { "1.12", NULL },
1061          { "1.13", NULL },
1062          { "1.14", NULL },
1063          { "1.15", NULL },
1064          { "1.16", NULL },
1065          { "1.17", NULL },
1066          { "1.18", NULL },
1067          { "1.19", NULL },
1068          { "1.20", NULL },
1069          { "1.21", NULL },
1070          { "1.22", NULL },
1071          { "1.23", NULL },
1072          { "1.24", NULL },
1073          { "1.25", NULL },
1074          { NULL, NULL },
1075       },
1076       "1.00",
1077    },
1078    {
1079       "pcsx_rearmed_gunconadjustratioy",
1080       "Guncon Y Axis Response",
1081       NULL,
1082       "Adjust relative magnitude of vertical light gun motion when emulating a Guncon device. Can be used to correct aiming misalignments.",
1083       NULL,
1084       "input",
1085       {
1086          { "0.75", NULL },
1087          { "0.76", NULL },
1088          { "0.77", NULL },
1089          { "0.78", NULL },
1090          { "0.79", NULL },
1091          { "0.80", NULL },
1092          { "0.81", NULL },
1093          { "0.82", NULL },
1094          { "0.83", NULL },
1095          { "0.84", NULL },
1096          { "0.85", NULL },
1097          { "0.86", NULL },
1098          { "0.87", NULL },
1099          { "0.88", NULL },
1100          { "0.89", NULL },
1101          { "0.90", NULL },
1102          { "0.91", NULL },
1103          { "0.92", NULL },
1104          { "0.93", NULL },
1105          { "0.94", NULL },
1106          { "0.95", NULL },
1107          { "0.96", NULL },
1108          { "0.97", NULL },
1109          { "0.98", NULL },
1110          { "0.99", NULL },
1111          { "1.00", NULL },
1112          { "1.01", NULL },
1113          { "1.02", NULL },
1114          { "1.03", NULL },
1115          { "1.04", NULL },
1116          { "1.05", NULL },
1117          { "1.06", NULL },
1118          { "1.07", NULL },
1119          { "1.08", NULL },
1120          { "1.09", NULL },
1121          { "1.10", NULL },
1122          { "1.11", NULL },
1123          { "1.12", NULL },
1124          { "1.13", NULL },
1125          { "1.14", NULL },
1126          { "1.15", NULL },
1127          { "1.16", NULL },
1128          { "1.17", NULL },
1129          { "1.18", NULL },
1130          { "1.19", NULL },
1131          { "1.20", NULL },
1132          { "1.21", NULL },
1133          { "1.22", NULL },
1134          { "1.23", NULL },
1135          { "1.24", NULL },
1136          { "1.25", NULL },
1137          { NULL, NULL },
1138       },
1139       "1.00",
1140    },
1141    {
1142       "pcsx_rearmed_icache_emulation",
1143       "Instruction Cache Emulation",
1144       NULL,
1145       "Enable emulation of the PSX CPU instruction cache. Improves accuracy at the expense of increased performance overheads. Required for Formula One 2001, Formula One Arcade and Formula One 99. [Interpreter only and partial on lightrec, unsupported when using ARMv7 backend]",
1146       NULL,
1147       "compat_hack",
1148       {
1149          { "disabled", NULL },
1150          { "enabled",  NULL },
1151          { NULL, NULL },
1152       },
1153       "disabled",
1154    },
1155 #if !defined(DRC_DISABLE) && !defined(LIGHTREC)
1156    {
1157       "pcsx_rearmed_nocompathacks",
1158       "Disable Automatic Compatibility Hacks",
1159       NULL,
1160       "By default, PCSX-ReARMed will apply auxiliary compatibility hacks automatically, based on the currently loaded content. This behaviour is required for correct operation, but may be disabled if desired.",
1161       NULL,
1162       "compat_hack",
1163       {
1164          { "disabled", NULL },
1165          { "enabled",  NULL },
1166          { NULL, NULL },
1167       },
1168       "disabled",
1169    },
1170    {
1171       "pcsx_rearmed_nosmccheck",
1172       "(Speed Hack) Disable SMC Checks",
1173       "Disable SMC Checks",
1174       "Will cause crashes when loading, and lead to memory card failure.",
1175       NULL,
1176       "speed_hack",
1177       {
1178          { "disabled", NULL },
1179          { "enabled",  NULL },
1180          { NULL, NULL },
1181       },
1182       "disabled",
1183    },
1184    {
1185       "pcsx_rearmed_gteregsunneeded",
1186       "(Speed Hack) Assume GTE Registers Unneeded",
1187       "Assume GTE Registers Unneeded",
1188       "May cause rendering errors.",
1189       NULL,
1190       "speed_hack",
1191       {
1192          { "disabled", NULL },
1193          { "enabled",  NULL },
1194          { NULL, NULL },
1195       },
1196       "disabled",
1197    },
1198    {
1199       "pcsx_rearmed_nogteflags",
1200       "(Speed Hack) Disable GTE Flags",
1201       "Disable GTE Flags",
1202       "Will cause rendering errors.",
1203       NULL,
1204       "speed_hack",
1205       {
1206          { "disabled", NULL },
1207          { "enabled",  NULL },
1208          { NULL, NULL },
1209       },
1210       "disabled",
1211    },
1212    {
1213       "pcsx_rearmed_nostalls",
1214       "(Speed Hack) Disable CPU/GTE Stalls",
1215       "Disable CPU/GTE Stalls",
1216       "Will cause some games to run too quickly.",
1217       NULL,
1218       "speed_hack",
1219       {
1220          { "disabled", NULL },
1221          { "enabled",  NULL },
1222          { NULL, NULL },
1223       },
1224       "disabled",
1225    },
1226 #endif /* !DRC_DISABLE && !LIGHTREC */
1227    { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
1228 };
1229
1230 struct retro_core_options_v2 options_us = {
1231    option_cats_us,
1232    option_defs_us
1233 };
1234
1235 /*
1236  ********************************
1237  * Language Mapping
1238  ********************************
1239 */
1240
1241 #ifndef HAVE_NO_LANGEXTRA
1242 struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = {
1243    &options_us, /* RETRO_LANGUAGE_ENGLISH */
1244    NULL,        /* RETRO_LANGUAGE_JAPANESE */
1245    NULL,        /* RETRO_LANGUAGE_FRENCH */
1246    NULL,        /* RETRO_LANGUAGE_SPANISH */
1247    NULL,        /* RETRO_LANGUAGE_GERMAN */
1248    NULL,        /* RETRO_LANGUAGE_ITALIAN */
1249    NULL,        /* RETRO_LANGUAGE_DUTCH */
1250    NULL,        /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
1251    NULL,        /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
1252    NULL,        /* RETRO_LANGUAGE_RUSSIAN */
1253    NULL,        /* RETRO_LANGUAGE_KOREAN */
1254    NULL,        /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
1255    NULL,        /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
1256    NULL,        /* RETRO_LANGUAGE_ESPERANTO */
1257    NULL,        /* RETRO_LANGUAGE_POLISH */
1258    NULL,        /* RETRO_LANGUAGE_VIETNAMESE */
1259    NULL,        /* RETRO_LANGUAGE_ARABIC */
1260    NULL,        /* RETRO_LANGUAGE_GREEK */
1261    &options_tr, /* RETRO_LANGUAGE_TURKISH */
1262 };
1263 #endif
1264
1265 /*
1266  ********************************
1267  * Functions
1268  ********************************
1269 */
1270
1271 /* Handles configuration/setting of core options.
1272  * Should be called as early as possible - ideally inside
1273  * retro_set_environment(), and no later than retro_load_game()
1274  * > We place the function body in the header to avoid the
1275  *   necessity of adding more .c files (i.e. want this to
1276  *   be as painless as possible for core devs)
1277  */
1278
1279 static INLINE void libretro_set_core_options(retro_environment_t environ_cb,
1280       bool *categories_supported)
1281 {
1282    unsigned version  = 0;
1283 #ifndef HAVE_NO_LANGEXTRA
1284    unsigned language = 0;
1285 #endif
1286
1287    if (!environ_cb || !categories_supported)
1288       return;
1289
1290    *categories_supported = false;
1291
1292    if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version))
1293       version = 0;
1294
1295    if (version >= 2)
1296    {
1297 #ifndef HAVE_NO_LANGEXTRA
1298       struct retro_core_options_v2_intl core_options_intl;
1299
1300       core_options_intl.us    = &options_us;
1301       core_options_intl.local = NULL;
1302
1303       if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
1304           (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
1305          core_options_intl.local = options_intl[language];
1306
1307       *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL,
1308             &core_options_intl);
1309 #else
1310       *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
1311             &options_us);
1312 #endif
1313    }
1314    else
1315    {
1316       size_t i, j;
1317       size_t option_index              = 0;
1318       size_t num_options               = 0;
1319       struct retro_core_option_definition
1320             *option_v1_defs_us         = NULL;
1321 #ifndef HAVE_NO_LANGEXTRA
1322       size_t num_options_intl          = 0;
1323       struct retro_core_option_v2_definition
1324             *option_defs_intl          = NULL;
1325       struct retro_core_option_definition
1326             *option_v1_defs_intl       = NULL;
1327       struct retro_core_options_intl
1328             core_options_v1_intl;
1329 #endif
1330       struct retro_variable *variables = NULL;
1331       char **values_buf                = NULL;
1332
1333       /* Determine total number of options */
1334       while (true)
1335       {
1336          if (option_defs_us[num_options].key)
1337             num_options++;
1338          else
1339             break;
1340       }
1341
1342       if (version >= 1)
1343       {
1344          /* Allocate US array */
1345          option_v1_defs_us = (struct retro_core_option_definition *)
1346                calloc(num_options + 1, sizeof(struct retro_core_option_definition));
1347
1348          /* Copy parameters from option_defs_us array */
1349          for (i = 0; i < num_options; i++)
1350          {
1351             struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i];
1352             struct retro_core_option_value *option_values         = option_def_us->values;
1353             struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i];
1354             struct retro_core_option_value *option_v1_values      = option_v1_def_us->values;
1355
1356             option_v1_def_us->key           = option_def_us->key;
1357             option_v1_def_us->desc          = option_def_us->desc;
1358             option_v1_def_us->info          = option_def_us->info;
1359             option_v1_def_us->default_value = option_def_us->default_value;
1360
1361             /* Values must be copied individually... */
1362             while (option_values->value)
1363             {
1364                option_v1_values->value = option_values->value;
1365                option_v1_values->label = option_values->label;
1366
1367                option_values++;
1368                option_v1_values++;
1369             }
1370          }
1371
1372 #ifndef HAVE_NO_LANGEXTRA
1373          if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
1374              (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) &&
1375              options_intl[language])
1376             option_defs_intl = options_intl[language]->definitions;
1377
1378          if (option_defs_intl)
1379          {
1380             /* Determine number of intl options */
1381             while (true)
1382             {
1383                if (option_defs_intl[num_options_intl].key)
1384                   num_options_intl++;
1385                else
1386                   break;
1387             }
1388
1389             /* Allocate intl array */
1390             option_v1_defs_intl = (struct retro_core_option_definition *)
1391                   calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition));
1392
1393             /* Copy parameters from option_defs_intl array */
1394             for (i = 0; i < num_options_intl; i++)
1395             {
1396                struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i];
1397                struct retro_core_option_value *option_values           = option_def_intl->values;
1398                struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i];
1399                struct retro_core_option_value *option_v1_values        = option_v1_def_intl->values;
1400
1401                option_v1_def_intl->key           = option_def_intl->key;
1402                option_v1_def_intl->desc          = option_def_intl->desc;
1403                option_v1_def_intl->info          = option_def_intl->info;
1404                option_v1_def_intl->default_value = option_def_intl->default_value;
1405
1406                /* Values must be copied individually... */
1407                while (option_values->value)
1408                {
1409                   option_v1_values->value = option_values->value;
1410                   option_v1_values->label = option_values->label;
1411
1412                   option_values++;
1413                   option_v1_values++;
1414                }
1415             }
1416          }
1417
1418          core_options_v1_intl.us    = option_v1_defs_us;
1419          core_options_v1_intl.local = option_v1_defs_intl;
1420
1421          environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl);
1422 #else
1423          environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us);
1424 #endif
1425       }
1426       else
1427       {
1428          /* Allocate arrays */
1429          variables  = (struct retro_variable *)calloc(num_options + 1,
1430                sizeof(struct retro_variable));
1431          values_buf = (char **)calloc(num_options, sizeof(char *));
1432
1433          if (!variables || !values_buf)
1434             goto error;
1435
1436          /* Copy parameters from option_defs_us array */
1437          for (i = 0; i < num_options; i++)
1438          {
1439             const char *key                        = option_defs_us[i].key;
1440             const char *desc                       = option_defs_us[i].desc;
1441             const char *default_value              = option_defs_us[i].default_value;
1442             struct retro_core_option_value *values = option_defs_us[i].values;
1443             size_t buf_len                         = 3;
1444             size_t default_index                   = 0;
1445
1446             values_buf[i] = NULL;
1447
1448             /* Skip options that are irrelevant when using the
1449              * old style core options interface */
1450             if ((strcmp(key, "pcsx_rearmed_show_input_settings") == 0) ||
1451                 (strcmp(key, "pcsx_rearmed_show_gpu_peops_settings") == 0) ||
1452                 (strcmp(key, "pcsx_rearmed_show_gpu_unai_settings") == 0))
1453                continue;
1454
1455             if (desc)
1456             {
1457                size_t num_values = 0;
1458
1459                /* Determine number of values */
1460                while (true)
1461                {
1462                   if (values[num_values].value)
1463                   {
1464                      /* Check if this is the default value */
1465                      if (default_value)
1466                         if (strcmp(values[num_values].value, default_value) == 0)
1467                            default_index = num_values;
1468
1469                      buf_len += strlen(values[num_values].value);
1470                      num_values++;
1471                   }
1472                   else
1473                      break;
1474                }
1475
1476                /* Build values string */
1477                if (num_values > 0)
1478                {
1479                   buf_len += num_values - 1;
1480                   buf_len += strlen(desc);
1481
1482                   values_buf[i] = (char *)calloc(buf_len, sizeof(char));
1483                   if (!values_buf[i])
1484                      goto error;
1485
1486                   strcpy(values_buf[i], desc);
1487                   strcat(values_buf[i], "; ");
1488
1489                   /* Default value goes first */
1490                   strcat(values_buf[i], values[default_index].value);
1491
1492                   /* Add remaining values */
1493                   for (j = 0; j < num_values; j++)
1494                   {
1495                      if (j != default_index)
1496                      {
1497                         strcat(values_buf[i], "|");
1498                         strcat(values_buf[i], values[j].value);
1499                      }
1500                   }
1501                }
1502             }
1503
1504             variables[option_index].key   = key;
1505             variables[option_index].value = values_buf[i];
1506             option_index++;
1507          }
1508
1509          /* Set variables */
1510          environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
1511       }
1512
1513 error:
1514       /* Clean up */
1515
1516       if (option_v1_defs_us)
1517       {
1518          free(option_v1_defs_us);
1519          option_v1_defs_us = NULL;
1520       }
1521
1522 #ifndef HAVE_NO_LANGEXTRA
1523       if (option_v1_defs_intl)
1524       {
1525          free(option_v1_defs_intl);
1526          option_v1_defs_intl = NULL;
1527       }
1528 #endif
1529
1530       if (values_buf)
1531       {
1532          for (i = 0; i < num_options; i++)
1533          {
1534             if (values_buf[i])
1535             {
1536                free(values_buf[i]);
1537                values_buf[i] = NULL;
1538             }
1539          }
1540
1541          free(values_buf);
1542          values_buf = NULL;
1543       }
1544
1545       if (variables)
1546       {
1547          free(variables);
1548          variables = NULL;
1549       }
1550    }
1551 }
1552
1553 #ifdef __cplusplus
1554 }
1555 #endif
1556
1557 #endif