dma: add optional slow linked list walking
[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    {
427       "pcsx_rearmed_gpu_slow_llists",
428       "(GPU) Slow linked list processing",
429       NULL,
430       "Slower but more accurate GPU linked list processing. Needed by only a few games like Vampire Hunter D. Should be autodetected in most cases.",
431       NULL,
432       "video",
433       {
434          { "auto", NULL },
435          { "disabled", NULL },
436          { "enabled",  NULL },
437          { NULL, NULL },
438       },
439       "auto",
440    },
441 #ifdef GPU_NEON
442    {
443       "pcsx_rearmed_neon_interlace_enable",
444       "(GPU) Show Interlaced Video",
445       "Show Interlaced Video",
446       "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.",
447       NULL,
448       "gpu_neon",
449       {
450          { "disabled", NULL },
451          { "enabled",  NULL },
452          { NULL, NULL },
453       },
454       "disabled",
455    },
456    {
457       "pcsx_rearmed_neon_enhancement_enable",
458       "(GPU) Enhanced Resolution (Slow)",
459       "Enhanced Resolution (Slow)",
460       "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.",
461       NULL,
462       "gpu_neon",
463       {
464          { "disabled", NULL },
465          { "enabled",  NULL },
466          { NULL, NULL },
467       },
468       "disabled",
469    },
470    {
471       "pcsx_rearmed_neon_enhancement_no_main",
472       "(GPU) Enhanced Resolution Speed Hack",
473       "Enhanced Resolution Speed Hack",
474       "Improves performance when 'Enhanced Resolution (Slow)' is enabled, but reduces compatibility and may cause rendering errors.",
475       NULL,
476       "gpu_neon",
477       {
478          { "disabled", NULL },
479          { "enabled",  NULL },
480          { NULL, NULL },
481       },
482       "disabled",
483    },
484 #endif /* GPU_NEON */
485 #ifdef GPU_PEOPS
486    {
487       "pcsx_rearmed_show_gpu_peops_settings",
488       "Show Advanced P.E.Op.S. GPU Settings",
489       NULL,
490       "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.",
491       NULL,
492       NULL,
493       {
494          { "disabled", NULL },
495          { "enabled",  NULL },
496          { NULL, NULL },
497       },
498       "disabled",
499    },
500    {
501       "pcsx_rearmed_gpu_peops_odd_even_bit",
502       "(GPU) Odd/Even Bit Hack",
503       "Odd/Even Bit Hack",
504       "A hack fix used to correct lock-ups that may occur in games such as Chrono Cross. Disable unless required.",
505       NULL,
506       "gpu_peops",
507       {
508          { "disabled", NULL },
509          { "enabled",  NULL },
510          { NULL, NULL },
511       },
512       "disabled",
513    },
514    {
515       "pcsx_rearmed_gpu_peops_expand_screen_width",
516       "(GPU) Expand Screen Width",
517       "Expand Screen Width",
518       "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.",
519       NULL,
520       "gpu_peops",
521       {
522          { "disabled", NULL },
523          { "enabled",  NULL },
524          { NULL, NULL },
525       },
526       "disabled",
527    },
528    {
529       "pcsx_rearmed_gpu_peops_ignore_brightness",
530       "(GPU) Ignore Brightness Color",
531       "Ignore Brightness Color",
532       "A hack fix used to repair black screens in Lunar Silver Star Story Complete when entering a house or a menu. Disable unless required.",
533       NULL,
534       "gpu_peops",
535       {
536          { "disabled", NULL },
537          { "enabled",  NULL },
538          { NULL, NULL },
539       },
540       "disabled",
541    },
542    {
543       "pcsx_rearmed_gpu_peops_disable_coord_check",
544       "(GPU) Disable Coordinate Check",
545       "Disable Coordinate Check",
546       "Legacy compatibility mode. May improve games that fail to run correctly on newer GPU hardware. Disable unless required.",
547       NULL,
548       "gpu_peops",
549       {
550          { "disabled", NULL },
551          { "enabled",  NULL },
552          { NULL, NULL },
553       },
554       "disabled",
555    },
556    {
557       "pcsx_rearmed_gpu_peops_lazy_screen_update",
558       "(GPU) Lazy Screen Update",
559       "Lazy Screen Update",
560       "A partial fix to prevent text box flickering in Dragon Warrior VII. May also improve Pandemonium 2. Disable unless required.",
561       NULL,
562       "gpu_peops",
563       {
564          { "disabled", NULL },
565          { "enabled",  NULL },
566          { NULL, NULL },
567       },
568       "disabled",
569    },
570    {
571       "pcsx_rearmed_gpu_peops_repeated_triangles",
572       "(GPU) Repeat Flat Tex Triangles",
573       "Repeat Flat Tex Triangles",
574       "A hack fix used to correct rendering errors in Star Wars: Dark Forces. Disable unless required.",
575       NULL,
576       "gpu_peops",
577       {
578          { "disabled", NULL },
579          { "enabled",  NULL },
580          { NULL, NULL },
581       },
582       "disabled",
583    },
584    {
585       "pcsx_rearmed_gpu_peops_quads_with_triangles",
586       "(GPU) Draw Tex-Quads as Triangles",
587       "Draw Tex-Quads as Triangles",
588       "Corrects graphical distortions that may occur when games utilize Gouraud Shading, at the expense of reduced texture quality. Disable unless required.",
589       NULL,
590       "gpu_peops",
591       {
592          { "disabled", NULL },
593          { "enabled",  NULL },
594          { NULL, NULL },
595       },
596       "disabled",
597    },
598    {
599       "pcsx_rearmed_gpu_peops_fake_busy_state",
600       "(GPU) Fake 'GPU Busy' States",
601       "Fake 'GPU Busy' States",
602       "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.",
603       NULL,
604       "gpu_peops",
605       {
606          { "disabled", NULL },
607          { "enabled",  NULL },
608          { NULL, NULL },
609       },
610       "disabled",
611    },
612 #endif /* GPU_PEOPS */
613 #ifdef GPU_UNAI
614    {
615       "pcsx_rearmed_show_gpu_unai_settings",
616       "Show Advanced UNAI GPU Settings",
617       NULL,
618       "Show low-level configuration options for the UNAI GPU plugin. Quick Menu may need to be toggled for this setting to take effect.",
619       NULL,
620       NULL,
621       {
622          { "disabled", NULL },
623          { "enabled",  NULL },
624          { NULL, NULL},
625       },
626       "disabled",
627    },
628    {
629       "pcsx_rearmed_gpu_unai_blending",
630       "(GPU) Texture Blending",
631       "Texture Blending",
632       "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.",
633       NULL,
634       "gpu_unai",
635       {
636          { "disabled", NULL },
637          { "enabled",  NULL },
638          { NULL, NULL},
639       },
640       "enabled",
641    },
642    {
643       "pcsx_rearmed_gpu_unai_lighting",
644       "(GPU) Lighting Effects",
645       "Lighting Effects",
646       "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.).",
647       NULL,
648       "gpu_unai",
649       {
650          { "disabled", NULL },
651          { "enabled",  NULL },
652          { NULL, NULL},
653       },
654       "enabled",
655    },
656    {
657       "pcsx_rearmed_gpu_unai_fast_lighting",
658       "(GPU) Fast Lighting",
659       "Fast Lighting",
660       "Improves performance when 'Lighting Effects' are enabled, but may cause moderate/severe rendering errors.",
661       NULL,
662       "gpu_unai",
663       {
664          { "disabled", NULL },
665          { "enabled",  NULL },
666          { NULL, NULL},
667       },
668       "disabled",
669    },
670    {
671       "pcsx_rearmed_gpu_unai_scale_hires",
672       "(GPU) Hi-Res Downscaling",
673       "Hi-Res Downscaling",
674       "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.",
675       NULL,
676       "gpu_unai",
677       {
678          { "disabled", NULL },
679          { "enabled",  NULL },
680          { NULL, NULL},
681       },
682 #ifdef _MIYOO
683       "enabled",
684 #else
685       "disabled",
686 #endif
687    },
688 #endif /* GPU_UNAI */
689    {
690       "pcsx_rearmed_spu_reverb",
691       "Audio Reverb Effects",
692       "Reverb Effects",
693       "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.",
694       NULL,
695       "audio",
696       {
697          { "disabled", NULL },
698          { "enabled",  NULL },
699          { NULL, NULL },
700       },
701 #ifdef HAVE_PRE_ARMV7
702       "disabled",
703 #else
704       "enabled",
705 #endif
706    },
707    {
708       "pcsx_rearmed_spu_interpolation",
709       "Sound Interpolation",
710       NULL,
711       "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.",
712       NULL,
713       "audio",
714       {
715          { "simple",   "Simple" },
716          { "gaussian", "Gaussian" },
717          { "cubic",    "Cubic" },
718          { "off",      "disabled" },
719          { NULL, NULL },
720       },
721 #ifdef HAVE_PRE_ARMV7
722       "off",
723 #else
724       "simple",
725 #endif
726    },
727    {
728       "pcsx_rearmed_nocdaudio",
729       "CD Audio",
730       NULL,
731       "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.",
732       NULL,
733       "audio",
734       {
735          { "disabled", NULL },
736          { "enabled",  NULL },
737          { NULL, NULL },
738       },
739       "enabled",
740    },
741    {
742       "pcsx_rearmed_noxadecoding",
743       "XA Decoding",
744       NULL,
745       "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.",
746       NULL,
747       "audio",
748       {
749          { "disabled", NULL },
750          { "enabled",  NULL },
751          { NULL, NULL },
752       },
753       "enabled",
754    },
755    {
756       "pcsx_rearmed_show_input_settings",
757       "Show Input Settings",
758       NULL,
759       "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.",
760       NULL,
761       NULL,
762       {
763          { "disabled", NULL },
764          { "enabled",  NULL },
765          { NULL, NULL },
766       },
767       "disabled",
768    },
769    {
770       "pcsx_rearmed_analog_axis_modifier",
771       "Analog Axis Bounds",
772       NULL,
773       "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.",
774       NULL,
775       "input",
776       {
777          { "circle", "Circle" },
778          { "square", "Square" },
779          { NULL, NULL },
780       },
781       "circle",
782    },
783    {
784       "pcsx_rearmed_vibration",
785       "Rumble Effects",
786       NULL,
787       "Enable haptic feedback when using a rumble-equipped gamepad with input device set to 'dualshock'.",
788       NULL,
789       "input",
790       {
791          { "disabled", NULL },
792          { "enabled",  NULL },
793          { NULL, NULL },
794       },
795       "enabled",
796    },
797    {
798       "pcsx_rearmed_multitap",
799       "Multitap Mode (Restart)",
800       NULL,
801       "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.",
802       NULL,
803       "input",
804       {
805          { "disabled",      NULL },
806          { "port 1",        "Port 1" },
807          { "port 2",        "Port 2" },
808          { "ports 1 and 2", "Ports 1 and 2" },
809          { NULL, NULL },
810       },
811       "disabled",
812    },
813    {
814       "pcsx_rearmed_negcon_deadzone",
815       "NegCon Twist Deadzone",
816       NULL,
817       "Set the deadzone of the RetroPad left analog stick when simulating the 'twist' action of emulated neGcon Controllers. Used to eliminate drift/unwanted input.",
818       NULL,
819       "input",
820       {
821          { "0",  "0%" },
822          { "3",  "3%" },
823          { "5",  "5%" },
824          { "7",  "7%" },
825          { "10", "10%" },
826          { "13", "13%" },
827          { "15", "15%" },
828          { "17", "17%" },
829          { "20", "20%" },
830          { "23", "23%" },
831          { "25", "25%" },
832          { "27", "27%" },
833          { "30", "30%" },
834          { NULL, NULL },
835       },
836       "0",
837    },
838    {
839       "pcsx_rearmed_negcon_response",
840       "NegCon Twist Response",
841       NULL,
842       "Specify the analog response when using a RetroPad left analog stick to simulate the 'twist' action of emulated neGcon Controllers.",
843       NULL,
844       "input",
845       {
846          { "linear",    "Linear" },
847          { "quadratic", "Quadratic" },
848          { "cubic",     "Cubic" },
849          { NULL, NULL },
850       },
851       "linear",
852    },
853    {
854       "pcsx_rearmed_input_sensitivity",
855       "Mouse Sensitivity",
856       NULL,
857       "Adjust responsiveness of emulated 'mouse' input devices.",
858       NULL,
859       "input",
860       {
861          { "0.05", NULL },
862          { "0.10", NULL },
863          { "0.15", NULL },
864          { "0.20", NULL },
865          { "0.25", NULL },
866          { "0.30", NULL },
867          { "0.35", NULL },
868          { "0.40", NULL },
869          { "0.45", NULL },
870          { "0.50", NULL },
871          { "0.55", NULL },
872          { "0.60", NULL },
873          { "0.65", NULL },
874          { "0.70", NULL },
875          { "0.75", NULL },
876          { "0.80", NULL },
877          { "0.85", NULL },
878          { "0.90", NULL },
879          { "0.95", NULL },
880          { "1.00", NULL },
881          { "1.05", NULL },
882          { "1.10", NULL },
883          { "1.15", NULL },
884          { "1.20", NULL },
885          { "1.25", NULL },
886          { "1.30", NULL },
887          { "1.35", NULL },
888          { "1.40", NULL },
889          { "1.45", NULL },
890          { "1.50", NULL },
891          { "1.55", NULL },
892          { "1.60", NULL },
893          { "1.65", NULL },
894          { "1.70", NULL },
895          { "1.75", NULL },
896          { "1.80", NULL },
897          { "1.85", NULL },
898          { "1.90", NULL },
899          { "1.95", NULL },
900          { "2.00", NULL },
901       },
902       "1.00",
903    },
904    {
905       "pcsx_rearmed_gunconadjustx",
906       "Guncon X Axis Offset",
907       NULL,
908       "Apply an X axis offset to light gun input when emulating a Guncon device. Can be used to correct aiming misalignments.",
909       NULL,
910       "input",
911       {
912          { "-25", NULL },
913          { "-24", NULL },
914          { "-23", NULL },
915          { "-22", NULL },
916          { "-21", NULL },
917          { "-20", NULL },
918          { "-19", NULL },
919          { "-18", NULL },
920          { "-17", NULL },
921          { "-16", NULL },
922          { "-15", NULL },
923          { "-14", NULL },
924          { "-13", NULL },
925          { "-12", NULL },
926          { "-11", NULL },
927          { "-10", NULL },
928          { "-9",  NULL },
929          { "-8",  NULL },
930          { "-7",  NULL },
931          { "-6",  NULL },
932          { "-5",  NULL },
933          { "-4",  NULL },
934          { "-3",  NULL },
935          { "-2",  NULL },
936          { "-1",  NULL },
937          { "0",   NULL },
938          { "1",   NULL },
939          { "2",   NULL },
940          { "3",   NULL },
941          { "4",   NULL },
942          { "5",   NULL },
943          { "6",   NULL },
944          { "7",   NULL },
945          { "8",   NULL },
946          { "9",   NULL },
947          { "10",  NULL },
948          { "11",  NULL },
949          { "12",  NULL },
950          { "13",  NULL },
951          { "14",  NULL },
952          { "15",  NULL },
953          { "16",  NULL },
954          { "17",  NULL },
955          { "18",  NULL },
956          { "19",  NULL },
957          { "20",  NULL },
958          { "21",  NULL },
959          { "22",  NULL },
960          { "23",  NULL },
961          { "24",  NULL },
962          { "25",  NULL },
963          { NULL, NULL },
964       },
965       "0",
966    },
967    {
968       "pcsx_rearmed_gunconadjusty",
969       "Guncon Y Axis Offset",
970       NULL,
971       "Apply a Y axis offset to light gun input when emulating a Guncon device. Can be used to correct aiming misalignments.",
972       NULL,
973       "input",
974       {
975          { "-25", NULL },
976          { "-24", NULL },
977          { "-23", NULL },
978          { "-22", NULL },
979          { "-21", NULL },
980          { "-20", NULL },
981          { "-19", NULL },
982          { "-18", NULL },
983          { "-17", NULL },
984          { "-16", NULL },
985          { "-15", NULL },
986          { "-14", NULL },
987          { "-13", NULL },
988          { "-12", NULL },
989          { "-11", NULL },
990          { "-10", NULL },
991          { "-9",  NULL },
992          { "-8",  NULL },
993          { "-7",  NULL },
994          { "-6",  NULL },
995          { "-5",  NULL },
996          { "-4",  NULL },
997          { "-3",  NULL },
998          { "-2",  NULL },
999          { "-1",  NULL },
1000          { "0",   NULL },
1001          { "1",   NULL },
1002          { "2",   NULL },
1003          { "3",   NULL },
1004          { "4",   NULL },
1005          { "5",   NULL },
1006          { "6",   NULL },
1007          { "7",   NULL },
1008          { "8",   NULL },
1009          { "9",   NULL },
1010          { "10",  NULL },
1011          { "11",  NULL },
1012          { "12",  NULL },
1013          { "13",  NULL },
1014          { "14",  NULL },
1015          { "15",  NULL },
1016          { "16",  NULL },
1017          { "17",  NULL },
1018          { "18",  NULL },
1019          { "19",  NULL },
1020          { "20",  NULL },
1021          { "21",  NULL },
1022          { "22",  NULL },
1023          { "23",  NULL },
1024          { "24",  NULL },
1025          { "25",  NULL },
1026          { NULL, NULL },
1027       },
1028       "0",
1029    },
1030    {
1031       "pcsx_rearmed_gunconadjustratiox",
1032       "Guncon X Axis Response",
1033       NULL,
1034       "Adjust relative magnitude of horizontal light gun motion when emulating a Guncon device. Can be used to correct aiming misalignments.",
1035       NULL,
1036       "input",
1037       {
1038          { "0.75", NULL },
1039          { "0.76", NULL },
1040          { "0.77", NULL },
1041          { "0.78", NULL },
1042          { "0.79", NULL },
1043          { "0.80", NULL },
1044          { "0.81", NULL },
1045          { "0.82", NULL },
1046          { "0.83", NULL },
1047          { "0.84", NULL },
1048          { "0.85", NULL },
1049          { "0.86", NULL },
1050          { "0.87", NULL },
1051          { "0.88", NULL },
1052          { "0.89", NULL },
1053          { "0.90", NULL },
1054          { "0.91", NULL },
1055          { "0.92", NULL },
1056          { "0.93", NULL },
1057          { "0.94", NULL },
1058          { "0.95", NULL },
1059          { "0.96", NULL },
1060          { "0.97", NULL },
1061          { "0.98", NULL },
1062          { "0.99", NULL },
1063          { "1.00", NULL },
1064          { "1.01", NULL },
1065          { "1.02", NULL },
1066          { "1.03", NULL },
1067          { "1.04", NULL },
1068          { "1.05", NULL },
1069          { "1.06", NULL },
1070          { "1.07", NULL },
1071          { "1.08", NULL },
1072          { "1.09", NULL },
1073          { "1.10", NULL },
1074          { "1.11", NULL },
1075          { "1.12", NULL },
1076          { "1.13", NULL },
1077          { "1.14", NULL },
1078          { "1.15", NULL },
1079          { "1.16", NULL },
1080          { "1.17", NULL },
1081          { "1.18", NULL },
1082          { "1.19", NULL },
1083          { "1.20", NULL },
1084          { "1.21", NULL },
1085          { "1.22", NULL },
1086          { "1.23", NULL },
1087          { "1.24", NULL },
1088          { "1.25", NULL },
1089          { NULL, NULL },
1090       },
1091       "1.00",
1092    },
1093    {
1094       "pcsx_rearmed_gunconadjustratioy",
1095       "Guncon Y Axis Response",
1096       NULL,
1097       "Adjust relative magnitude of vertical light gun motion when emulating a Guncon device. Can be used to correct aiming misalignments.",
1098       NULL,
1099       "input",
1100       {
1101          { "0.75", NULL },
1102          { "0.76", NULL },
1103          { "0.77", NULL },
1104          { "0.78", NULL },
1105          { "0.79", NULL },
1106          { "0.80", NULL },
1107          { "0.81", NULL },
1108          { "0.82", NULL },
1109          { "0.83", NULL },
1110          { "0.84", NULL },
1111          { "0.85", NULL },
1112          { "0.86", NULL },
1113          { "0.87", NULL },
1114          { "0.88", NULL },
1115          { "0.89", NULL },
1116          { "0.90", NULL },
1117          { "0.91", NULL },
1118          { "0.92", NULL },
1119          { "0.93", NULL },
1120          { "0.94", NULL },
1121          { "0.95", NULL },
1122          { "0.96", NULL },
1123          { "0.97", NULL },
1124          { "0.98", NULL },
1125          { "0.99", NULL },
1126          { "1.00", NULL },
1127          { "1.01", NULL },
1128          { "1.02", NULL },
1129          { "1.03", NULL },
1130          { "1.04", NULL },
1131          { "1.05", NULL },
1132          { "1.06", NULL },
1133          { "1.07", NULL },
1134          { "1.08", NULL },
1135          { "1.09", NULL },
1136          { "1.10", NULL },
1137          { "1.11", NULL },
1138          { "1.12", NULL },
1139          { "1.13", NULL },
1140          { "1.14", NULL },
1141          { "1.15", NULL },
1142          { "1.16", NULL },
1143          { "1.17", NULL },
1144          { "1.18", NULL },
1145          { "1.19", NULL },
1146          { "1.20", NULL },
1147          { "1.21", NULL },
1148          { "1.22", NULL },
1149          { "1.23", NULL },
1150          { "1.24", NULL },
1151          { "1.25", NULL },
1152          { NULL, NULL },
1153       },
1154       "1.00",
1155    },
1156    {
1157       "pcsx_rearmed_icache_emulation",
1158       "Instruction Cache Emulation",
1159       NULL,
1160       "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]",
1161       NULL,
1162       "compat_hack",
1163       {
1164          { "disabled", NULL },
1165          { "enabled",  NULL },
1166          { NULL, NULL },
1167       },
1168       "disabled",
1169    },
1170 #if !defined(DRC_DISABLE) && !defined(LIGHTREC)
1171    {
1172       "pcsx_rearmed_nocompathacks",
1173       "Disable Automatic Compatibility Hacks",
1174       NULL,
1175       "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.",
1176       NULL,
1177       "compat_hack",
1178       {
1179          { "disabled", NULL },
1180          { "enabled",  NULL },
1181          { NULL, NULL },
1182       },
1183       "disabled",
1184    },
1185    {
1186       "pcsx_rearmed_nosmccheck",
1187       "(Speed Hack) Disable SMC Checks",
1188       "Disable SMC Checks",
1189       "Will cause crashes when loading, and lead to memory card failure.",
1190       NULL,
1191       "speed_hack",
1192       {
1193          { "disabled", NULL },
1194          { "enabled",  NULL },
1195          { NULL, NULL },
1196       },
1197       "disabled",
1198    },
1199    {
1200       "pcsx_rearmed_gteregsunneeded",
1201       "(Speed Hack) Assume GTE Registers Unneeded",
1202       "Assume GTE Registers Unneeded",
1203       "May cause rendering errors.",
1204       NULL,
1205       "speed_hack",
1206       {
1207          { "disabled", NULL },
1208          { "enabled",  NULL },
1209          { NULL, NULL },
1210       },
1211       "disabled",
1212    },
1213    {
1214       "pcsx_rearmed_nogteflags",
1215       "(Speed Hack) Disable GTE Flags",
1216       "Disable GTE Flags",
1217       "Will cause rendering errors.",
1218       NULL,
1219       "speed_hack",
1220       {
1221          { "disabled", NULL },
1222          { "enabled",  NULL },
1223          { NULL, NULL },
1224       },
1225       "disabled",
1226    },
1227    {
1228       "pcsx_rearmed_nostalls",
1229       "(Speed Hack) Disable CPU/GTE Stalls",
1230       "Disable CPU/GTE Stalls",
1231       "Will cause some games to run too quickly.",
1232       NULL,
1233       "speed_hack",
1234       {
1235          { "disabled", NULL },
1236          { "enabled",  NULL },
1237          { NULL, NULL },
1238       },
1239       "disabled",
1240    },
1241 #endif /* !DRC_DISABLE && !LIGHTREC */
1242    { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
1243 };
1244
1245 struct retro_core_options_v2 options_us = {
1246    option_cats_us,
1247    option_defs_us
1248 };
1249
1250 /*
1251  ********************************
1252  * Language Mapping
1253  ********************************
1254 */
1255
1256 #ifndef HAVE_NO_LANGEXTRA
1257 struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = {
1258    &options_us, /* RETRO_LANGUAGE_ENGLISH */
1259    NULL,        /* RETRO_LANGUAGE_JAPANESE */
1260    NULL,        /* RETRO_LANGUAGE_FRENCH */
1261    NULL,        /* RETRO_LANGUAGE_SPANISH */
1262    NULL,        /* RETRO_LANGUAGE_GERMAN */
1263    NULL,        /* RETRO_LANGUAGE_ITALIAN */
1264    NULL,        /* RETRO_LANGUAGE_DUTCH */
1265    NULL,        /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
1266    NULL,        /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
1267    NULL,        /* RETRO_LANGUAGE_RUSSIAN */
1268    NULL,        /* RETRO_LANGUAGE_KOREAN */
1269    NULL,        /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
1270    NULL,        /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
1271    NULL,        /* RETRO_LANGUAGE_ESPERANTO */
1272    NULL,        /* RETRO_LANGUAGE_POLISH */
1273    NULL,        /* RETRO_LANGUAGE_VIETNAMESE */
1274    NULL,        /* RETRO_LANGUAGE_ARABIC */
1275    NULL,        /* RETRO_LANGUAGE_GREEK */
1276    &options_tr, /* RETRO_LANGUAGE_TURKISH */
1277 };
1278 #endif
1279
1280 /*
1281  ********************************
1282  * Functions
1283  ********************************
1284 */
1285
1286 /* Handles configuration/setting of core options.
1287  * Should be called as early as possible - ideally inside
1288  * retro_set_environment(), and no later than retro_load_game()
1289  * > We place the function body in the header to avoid the
1290  *   necessity of adding more .c files (i.e. want this to
1291  *   be as painless as possible for core devs)
1292  */
1293
1294 static INLINE void libretro_set_core_options(retro_environment_t environ_cb,
1295       bool *categories_supported)
1296 {
1297    unsigned version  = 0;
1298 #ifndef HAVE_NO_LANGEXTRA
1299    unsigned language = 0;
1300 #endif
1301
1302    if (!environ_cb || !categories_supported)
1303       return;
1304
1305    *categories_supported = false;
1306
1307    if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version))
1308       version = 0;
1309
1310    if (version >= 2)
1311    {
1312 #ifndef HAVE_NO_LANGEXTRA
1313       struct retro_core_options_v2_intl core_options_intl;
1314
1315       core_options_intl.us    = &options_us;
1316       core_options_intl.local = NULL;
1317
1318       if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
1319           (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
1320          core_options_intl.local = options_intl[language];
1321
1322       *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL,
1323             &core_options_intl);
1324 #else
1325       *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
1326             &options_us);
1327 #endif
1328    }
1329    else
1330    {
1331       size_t i, j;
1332       size_t option_index              = 0;
1333       size_t num_options               = 0;
1334       struct retro_core_option_definition
1335             *option_v1_defs_us         = NULL;
1336 #ifndef HAVE_NO_LANGEXTRA
1337       size_t num_options_intl          = 0;
1338       struct retro_core_option_v2_definition
1339             *option_defs_intl          = NULL;
1340       struct retro_core_option_definition
1341             *option_v1_defs_intl       = NULL;
1342       struct retro_core_options_intl
1343             core_options_v1_intl;
1344 #endif
1345       struct retro_variable *variables = NULL;
1346       char **values_buf                = NULL;
1347
1348       /* Determine total number of options */
1349       while (true)
1350       {
1351          if (option_defs_us[num_options].key)
1352             num_options++;
1353          else
1354             break;
1355       }
1356
1357       if (version >= 1)
1358       {
1359          /* Allocate US array */
1360          option_v1_defs_us = (struct retro_core_option_definition *)
1361                calloc(num_options + 1, sizeof(struct retro_core_option_definition));
1362
1363          /* Copy parameters from option_defs_us array */
1364          for (i = 0; i < num_options; i++)
1365          {
1366             struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i];
1367             struct retro_core_option_value *option_values         = option_def_us->values;
1368             struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i];
1369             struct retro_core_option_value *option_v1_values      = option_v1_def_us->values;
1370
1371             option_v1_def_us->key           = option_def_us->key;
1372             option_v1_def_us->desc          = option_def_us->desc;
1373             option_v1_def_us->info          = option_def_us->info;
1374             option_v1_def_us->default_value = option_def_us->default_value;
1375
1376             /* Values must be copied individually... */
1377             while (option_values->value)
1378             {
1379                option_v1_values->value = option_values->value;
1380                option_v1_values->label = option_values->label;
1381
1382                option_values++;
1383                option_v1_values++;
1384             }
1385          }
1386
1387 #ifndef HAVE_NO_LANGEXTRA
1388          if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
1389              (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) &&
1390              options_intl[language])
1391             option_defs_intl = options_intl[language]->definitions;
1392
1393          if (option_defs_intl)
1394          {
1395             /* Determine number of intl options */
1396             while (true)
1397             {
1398                if (option_defs_intl[num_options_intl].key)
1399                   num_options_intl++;
1400                else
1401                   break;
1402             }
1403
1404             /* Allocate intl array */
1405             option_v1_defs_intl = (struct retro_core_option_definition *)
1406                   calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition));
1407
1408             /* Copy parameters from option_defs_intl array */
1409             for (i = 0; i < num_options_intl; i++)
1410             {
1411                struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i];
1412                struct retro_core_option_value *option_values           = option_def_intl->values;
1413                struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i];
1414                struct retro_core_option_value *option_v1_values        = option_v1_def_intl->values;
1415
1416                option_v1_def_intl->key           = option_def_intl->key;
1417                option_v1_def_intl->desc          = option_def_intl->desc;
1418                option_v1_def_intl->info          = option_def_intl->info;
1419                option_v1_def_intl->default_value = option_def_intl->default_value;
1420
1421                /* Values must be copied individually... */
1422                while (option_values->value)
1423                {
1424                   option_v1_values->value = option_values->value;
1425                   option_v1_values->label = option_values->label;
1426
1427                   option_values++;
1428                   option_v1_values++;
1429                }
1430             }
1431          }
1432
1433          core_options_v1_intl.us    = option_v1_defs_us;
1434          core_options_v1_intl.local = option_v1_defs_intl;
1435
1436          environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl);
1437 #else
1438          environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us);
1439 #endif
1440       }
1441       else
1442       {
1443          /* Allocate arrays */
1444          variables  = (struct retro_variable *)calloc(num_options + 1,
1445                sizeof(struct retro_variable));
1446          values_buf = (char **)calloc(num_options, sizeof(char *));
1447
1448          if (!variables || !values_buf)
1449             goto error;
1450
1451          /* Copy parameters from option_defs_us array */
1452          for (i = 0; i < num_options; i++)
1453          {
1454             const char *key                        = option_defs_us[i].key;
1455             const char *desc                       = option_defs_us[i].desc;
1456             const char *default_value              = option_defs_us[i].default_value;
1457             struct retro_core_option_value *values = option_defs_us[i].values;
1458             size_t buf_len                         = 3;
1459             size_t default_index                   = 0;
1460
1461             values_buf[i] = NULL;
1462
1463             /* Skip options that are irrelevant when using the
1464              * old style core options interface */
1465             if ((strcmp(key, "pcsx_rearmed_show_input_settings") == 0) ||
1466                 (strcmp(key, "pcsx_rearmed_show_gpu_peops_settings") == 0) ||
1467                 (strcmp(key, "pcsx_rearmed_show_gpu_unai_settings") == 0))
1468                continue;
1469
1470             if (desc)
1471             {
1472                size_t num_values = 0;
1473
1474                /* Determine number of values */
1475                while (true)
1476                {
1477                   if (values[num_values].value)
1478                   {
1479                      /* Check if this is the default value */
1480                      if (default_value)
1481                         if (strcmp(values[num_values].value, default_value) == 0)
1482                            default_index = num_values;
1483
1484                      buf_len += strlen(values[num_values].value);
1485                      num_values++;
1486                   }
1487                   else
1488                      break;
1489                }
1490
1491                /* Build values string */
1492                if (num_values > 0)
1493                {
1494                   buf_len += num_values - 1;
1495                   buf_len += strlen(desc);
1496
1497                   values_buf[i] = (char *)calloc(buf_len, sizeof(char));
1498                   if (!values_buf[i])
1499                      goto error;
1500
1501                   strcpy(values_buf[i], desc);
1502                   strcat(values_buf[i], "; ");
1503
1504                   /* Default value goes first */
1505                   strcat(values_buf[i], values[default_index].value);
1506
1507                   /* Add remaining values */
1508                   for (j = 0; j < num_values; j++)
1509                   {
1510                      if (j != default_index)
1511                      {
1512                         strcat(values_buf[i], "|");
1513                         strcat(values_buf[i], values[j].value);
1514                      }
1515                   }
1516                }
1517             }
1518
1519             variables[option_index].key   = key;
1520             variables[option_index].value = values_buf[i];
1521             option_index++;
1522          }
1523
1524          /* Set variables */
1525          environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
1526       }
1527
1528 error:
1529       /* Clean up */
1530
1531       if (option_v1_defs_us)
1532       {
1533          free(option_v1_defs_us);
1534          option_v1_defs_us = NULL;
1535       }
1536
1537 #ifndef HAVE_NO_LANGEXTRA
1538       if (option_v1_defs_intl)
1539       {
1540          free(option_v1_defs_intl);
1541          option_v1_defs_intl = NULL;
1542       }
1543 #endif
1544
1545       if (values_buf)
1546       {
1547          for (i = 0; i < num_options; i++)
1548          {
1549             if (values_buf[i])
1550             {
1551                free(values_buf[i]);
1552                values_buf[i] = NULL;
1553             }
1554          }
1555
1556          free(values_buf);
1557          values_buf = NULL;
1558       }
1559
1560       if (variables)
1561       {
1562          free(variables);
1563          variables = NULL;
1564       }
1565    }
1566 }
1567
1568 #ifdef __cplusplus
1569 }
1570 #endif
1571
1572 #endif