Update libretro_core_options.h
[pcsx_rearmed.git] / frontend / libretro_core_options.h
CommitLineData
919cac88 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#ifdef __cplusplus
11extern "C" {
12#endif
13
14/*
15 ********************************
16 * Core Option Definitions
17 ********************************
18*/
19
20/* RETRO_LANGUAGE_ENGLISH */
21
22/* Default language:
23 * - All other languages must include the same keys and values
24 * - Will be used as a fallback in the event that frontend language
25 * is not available
26 * - Will be used as a fallback for any missing entries in
27 * frontend language definition
28 */
29
30#ifdef HAVE_PRE_ARMV7
31#define PSX_CLOCK_DEFAULT "50"
32#define PSX_CLOCK_LABEL "Overclock or underclock the PSX clock. Default is 50"
33#else
34#define PSX_CLOCK_DEFAULT "57"
35#define PSX_CLOCK_LABEL "Overclock or underclock the PSX clock. Default is 57"
36#endif
37
38struct retro_core_option_definition option_defs_us[] = {
39 {
40 "pcsx_rearmed_frameskip",
41 "Frameskip",
42 "Choose how much frames should be skipped to improve performance at the expense of visual smoothness.",
43 {
44 { "0", NULL },
45 { "1", NULL },
46 { "2", NULL },
47 { "3", NULL },
48 { NULL, NULL},
49 },
50 "0",
51 },
52 {
53 "pcsx_rearmed_bios",
54 "Use BIOS",
55 "Allows you to use real bios file (if available) or emulated bios (HLE). Its recommended to use official bios file for better compatibility.",
56 {
57 { "auto", "auto" },
58 { "HLE", "hle" },
59 { NULL, NULL},
60 },
61 "auto",
62 },
63 {
64 "pcsx_rearmed_region",
65 "Region",
66 "Choose what region the system is from. 60 Hz for NTSC, 50 Hz for PAL.",
67 {
68 { "auto", "auto" },
69 { "NTSC", "ntsc" },
70 { "PAL", "pal" },
71 { NULL, NULL},
72 },
73 "auto",
74 },
75 {
76 "pcsx_rearmed_memcard2",
c8108d88 77 "Enable Second Memory Card (Shared)",
ef2683f1 78 "Enabled the memory card slot 2. This memory card is shared amongst all games.",
919cac88 79 {
80 { "disable", NULL },
81 { "enabled", NULL },
82 { NULL, NULL},
83 },
84 "disable",
85 },
86 {
87 "pcsx_rearmed_pad1type",
88 "Pad 1 Type",
89 "Pad type for player 1",
90 {
91 { "standard", NULL },
92 { "analog", NULL },
93 { "dualshock", NULL },
94 { "negcon", NULL },
95 { "none", NULL },
96 { NULL, NULL},
97 },
98 "standard",
99 },
100 {
101 "pcsx_rearmed_pad2type",
102 "Pad 2 Type",
103 "Pad type for player 2",
104 {
105 { "standard", NULL },
106 { "analog", NULL },
107 { "dualshock", NULL },
108 { "negcon", NULL },
109 { "none", NULL },
110 { NULL, NULL},
111 },
112 "standard",
113 },
114 {
115 "pcsx_rearmed_pad3type",
116 "Pad 3 Type",
117 "Pad type for player 3",
118 {
119 { "standard", NULL },
120 { "analog", NULL },
121 { "dualshock", NULL },
122 { "negcon", NULL },
123 { "none", NULL },
124 { NULL, NULL},
125 },
126 "none",
127 },
128 {
129 "pcsx_rearmed_pad4type",
130 "Pad 4 Type",
131 "Pad type for player 4",
132 {
133 { "standard", NULL },
134 { "analog", NULL },
135 { "dualshock", NULL },
136 { "negcon", NULL },
137 { "none", NULL },
138 { NULL, NULL},
139 },
140 "none",
141 },
142 {
143 "pcsx_rearmed_pad5type",
144 "Pad 5 Type",
145 "Pad type for player 5",
146 {
147 { "standard", NULL },
148 { "analog", NULL },
149 { "dualshock", NULL },
150 { "negcon", NULL },
151 { "none", NULL },
152 { NULL, NULL},
153 },
154 "none",
155 },{
156 "pcsx_rearmed_pad6type",
157 "Pad 6 Type",
158 "Pad type for player 6",
159 {
160 { "standard", NULL },
161 { "analog", NULL },
162 { "dualshock", NULL },
163 { "negcon", NULL },
164 { "none", NULL },
165 { NULL, NULL},
166 },
167 "none",
168 },{
169 "pcsx_rearmed_pad7type",
170 "Pad 7 Type",
171 "Pad type for player 7",
172 {
173 { "standard", NULL },
174 { "analog", NULL },
175 { "dualshock", NULL },
176 { "negcon", NULL },
177 { "none", NULL },
178 { NULL, NULL},
179 },
180 "none",
181 },{
182 "pcsx_rearmed_pad8type",
183 "Pad 8 Type",
184 "Pad type for player 8",
185 {
186 { "standard", NULL },
187 { "analog", NULL },
188 { "dualshock", NULL },
189 { "negcon", NULL },
190 { "none", NULL },
191 { NULL, NULL},
192 },
193 "none",
194 },
195 {
196 "pcsx_rearmed_multitap1",
197 "Multitap 1",
198 "Enables/Disables multitap on port 1, allowing upto 5 players in games that permit it.",
199 {
200 { "auto", NULL },
201 { "disabled", NULL },
202 { "enabled", NULL },
203 { NULL, NULL},
204 },
205 "auto",
206 },
207 {
208 "pcsx_rearmed_multitap2",
209 "Multitap 2",
ef2683f1 210 "Enables/Disables multitap on port 2, allowing up to 8 players in games that permit it. Multitap 1 has to be enabled for this to work.",
919cac88 211 {
212 { "auto", NULL },
213 { "disabled", NULL },
214 { "enabled", NULL },
215 { NULL, NULL},
216 },
217 "auto",
218 },
219 {
220 "pcsx_rearmed_negcon_deadzone",
c8108d88 221 "NegCon Twist Deadzone (Percent)",
919cac88 222 "Sets the deadzone of the RetroPad left analog stick when simulating the 'twist' action of emulated neGcon Controllers. Used to eliminate drift/unwanted input.",
223 {
224 { "0", NULL },
225 { "5", NULL },
226 { "10", NULL },
227 { "15", NULL },
228 { "20", NULL },
229 { "25", NULL },
230 { "30", NULL },
231 { NULL, NULL},
232 },
233 "0",
234 },
235 {
236 "pcsx_rearmed_negcon_response",
237 "NegCon Twist Response",
238 "Specifies the analog response when using a RetroPad left analog stick to simulate the 'twist' action of emulated neGcon Controllers.",
239 {
240 { "linear", NULL },
241 { "quadratic", NULL },
242 { "cubic", NULL },
243 { NULL, NULL},
244 },
245 "linear",
246 },
247 {
248 "pcsx_rearmed_vibration",
249 "Enable Vibration",
c8108d88 250 "Enables vibration feedback for controllers that supports vibration features.",
919cac88 251 {
252 { "disabled", NULL },
253 { "enabled", NULL },
254 { NULL, NULL},
255 },
256 "enabled",
257 },
258 {
259 "pcsx_rearmed_dithering",
260 "Enable Dithering",
261 "If Off, disables the dithering pattern the PSX applies to combat color banding.",
262 {
263 { "disabled", NULL },
264 { "enabled", NULL },
265 { NULL, NULL},
266 },
267 "enabled",
268 },
269
270#ifndef DRC_DISABLE
271 {
272 "pcsx_rearmed_drc",
c8108d88 273 "Dynamic Recompiler",
ef2683f1 274 "Enables core to use dynamic recompiler or interpreter (slower) CPU instructions.",
919cac88 275 {
276 { "disabled", NULL },
277 { "enabled", NULL },
278 { NULL, NULL},
279 },
280 "enabled",
281 },
282 {
283 "pcsx_rearmed_psxclock",
c8108d88 284 "PSX CPU Clock",
919cac88 285 PSX_CLOCK_LABEL,
286 {
287 { "30", NULL },
288 { "31", NULL },
289 { "32", NULL },
290 { "33", NULL },
291 { "34", NULL },
292 { "35", NULL },
293 { "36", NULL },
294 { "37", NULL },
295 { "38", NULL },
296 { "39", NULL },
297 { "40", NULL },
298 { "41", NULL },
299 { "42", NULL },
300 { "43", NULL },
301 { "44", NULL },
302 { "45", NULL },
303 { "46", NULL },
304 { "47", NULL },
305 { "48", NULL },
306 { "49", NULL },
307 { "50", NULL },
308 { "51", NULL },
309 { "52", NULL },
310 { "53", NULL },
311 { "54", NULL },
312 { "55", NULL },
313 { "56", NULL },
314 { "57", NULL },
315 { "58", NULL },
316 { "59", NULL },
317 { "60", NULL },
318 { "61", NULL },
319 { "62", NULL },
320 { "63", NULL },
321 { "64", NULL },
322 { "65", NULL },
323 { "66", NULL },
324 { "67", NULL },
325 { "68", NULL },
326 { "69", NULL },
327 { "70", NULL },
328 { "71", NULL },
329 { "72", NULL },
330 { "73", NULL },
331 { "74", NULL },
332 { "75", NULL },
333 { "76", NULL },
334 { "77", NULL },
335 { "78", NULL },
336 { "79", NULL },
337 { "80", NULL },
338 { "81", NULL },
339 { "82", NULL },
340 { "83", NULL },
341 { "84", NULL },
342 { "85", NULL },
343 { "86", NULL },
344 { "87", NULL },
345 { "88", NULL },
346 { "89", NULL },
347 { "90", NULL },
348 { "91", NULL },
349 { "92", NULL },
350 { "93", NULL },
351 { "94", NULL },
352 { "95", NULL },
353 { "96", NULL },
354 { "97", NULL },
355 { "98", NULL },
356 { "99", NULL },
357 { "100", NULL },
358 { NULL, NULL},
359 },
360 PSX_CLOCK_DEFAULT,
361 },
362#endif /* DRC_DISABLE */
363
364#ifdef __ARM_NEON__
365 {
366 "pcsx_rearmed_neon_interlace_enable",
c8108d88 367 "Enable Interlacing Mode",
919cac88 368 "Enables fake scanlines effect.",
369 {
370 { "disabled", NULL },
371 { "enabled", NULL },
372 { NULL, NULL},
373 },
374 "disabled",
375 },
376 {
377 "pcsx_rearmed_neon_enhancement_enable",
c8108d88 378 "Enhanced Resolution (Slow)",
ef2683f1 379 "Renders in double resolution at the cost of lower performance.",
919cac88 380 {
381 { "disabled", NULL },
382 { "enabled", NULL },
383 { NULL, NULL},
384 },
385 "disabled",
386 },
387 {
388 "pcsx_rearmed_neon_enhancement_no_main",
c8108d88 389 "Enhanced Resolution (Speed Hack)",
919cac88 390 "Speed hack for Enhanced resolution option (glitches some games).",
391 {
392 { "disabled", NULL },
393 { "enabled", NULL },
394 { NULL, NULL},
395 },
396 "disabled",
397 },
398#endif /* __ARM_NEON__ */
399
400 {
401 "pcsx_rearmed_duping_enable",
c8108d88 402 "Frame Duping",
919cac88 403 "A speedup, redraws/reuses the last frame if there was no new data.",
404 {
405 { "disabled", NULL },
406 { "enabled", NULL },
407 { NULL, NULL},
408 },
409 "enabled",
410 },
411 {
412 "pcsx_rearmed_display_internal_fps",
413 "Display Internal FPS",
414 "Shows an on-screen frames per second counter when enabled.",
415 {
416 { "disabled", NULL },
417 { "enabled", NULL },
418 { NULL, NULL},
419 },
420 "disabled",
421 },
c8108d88 422
423 /* GPU PEOPS OPTIONS */
424#ifdef DRC_DISABLE
425 {
426 "pcsx_rearmed_show_gpu_peops_settings",
427 "Show Advance GPU Settings",
ef2683f1 428 "Enable or disable various GPU fixes. A core restart might be needed for settings to take effect. NOTE: Quick Menu must be toggled for this setting to take effect.",
c8108d88 429 {
430 { "disabled", NULL },
431 { "enabled", NULL },
432 { NULL, NULL},
433 },
434 "disabled",
435 },
436 {
437 "pcsx_rearmed_gpu_peops_fix_0",
438 "(GPU) Odd/Even Bit Hack",
439 "Needed for Chrono Cross.",
440 {
441 { "disabled", NULL },
442 { "enabled", NULL },
443 { NULL, NULL},
444 },
445 "disabled",
446 },
447 {
448 "pcsx_rearmed_gpu_peops_fix_1",
449 "(GPU) Expand Screen Width",
450 "Capcom fighting games",
451 {
452 { "disabled", NULL },
453 { "enabled", NULL },
454 { NULL, NULL},
455 },
456 "disabled",
457 },
458 {
459 "pcsx_rearmed_gpu_peops_fix_2",
460 "(GPU) Ignore Brightness Color",
ef2683f1 461 "Black screens in Lunar Silver Star Story games",
c8108d88 462 {
463 { "disabled", NULL },
464 { "enabled", NULL },
465 { NULL, NULL},
466 },
467 "disabled",
468 },
469 {
470 "pcsx_rearmed_gpu_peops_fix_3",
471 "(GPU) Disable Coordinate Check",
472 "Compatibility mode",
473 {
474 { "disabled", NULL },
475 { "enabled", NULL },
476 { NULL, NULL},
477 },
478 "disabled",
479 },
480 {
481 "pcsx_rearmed_gpu_peops_fix_6",
482 "(GPU) Lazy Screen Update",
483 "Pandemonium 2",
484 {
485 { "disabled", NULL },
486 { "enabled", NULL },
487 { NULL, NULL},
488 },
489 "disabled",
490 },
491 {
492 "pcsx_rearmed_gpu_peops_fix_7",
493 "(GPU) Old Frame Skipping",
494 "Skip every second frame",
495 {
496 { "disabled", NULL },
497 { "enabled", NULL },
498 { NULL, NULL},
499 },
500 "enabled",
501 },
502 {
503 "pcsx_rearmed_gpu_peops_fix_8",
504 "(GPU) Repeated Flat Tex Triangles",
ef2683f1 505 "Needed by Star Wars: Dark Forces",
c8108d88 506 {
507 { "disabled", NULL },
508 { "enabled", NULL },
509 { NULL, NULL},
510 },
511 "disabled",
512 },
513 {
514 "pcsx_rearmed_gpu_peops_fix_9",
515 "(GPU) Draw Quads with Triangles",
516 "Better g-colors, worse textures",
517 {
518 { "disabled", NULL },
519 { "enabled", NULL },
520 { NULL, NULL},
521 },
522 "disabled",
523 },
524 {
525 "pcsx_rearmed_gpu_peops_fix_10",
526 "(GPU) Fake 'Gpu Busy' States",
527 "Toggle busy flags after drawing",
528 {
529 { "disabled", NULL },
530 { "enabled", NULL },
531 { NULL, NULL},
532 },
533 "disabled",
534 },
535#endif
536
919cac88 537 {
538 "pcsx_rearmed_show_bios_bootlogo",
539 "Show Bios Bootlogo",
ef2683f1 540 "When enabled, shows the PlayStation logo when starting or resetting. (Breaks some games).",
919cac88 541 {
542 { "disabled", NULL },
543 { "enabled", NULL },
544 { NULL, NULL},
545 },
546 "disabled",
547 },
548 {
549 "pcsx_rearmed_spu_reverb",
550 "Sound Reverb",
551 "Enables or disables audio reverb effect.",
552 {
553 { "disabled", NULL },
554 { "enabled", NULL },
555 { NULL, NULL},
556 },
557 "enabled",
558 },
559 {
560 "pcsx_rearmed_spu_interpolation",
c8108d88 561 "Sound Interpolation",
919cac88 562 NULL,
563 {
564 { "simple", NULL },
565 { "gaussian", NULL },
566 { "cubic", NULL },
567 { "off", NULL },
568 { NULL, NULL},
569 },
570 "simple",
571 },
572 {
573 "pcsx_rearmed_idiablofix",
574 "Diablo Music Fix",
575 NULL,
576 {
577 { "disabled", NULL },
578 { "enabled", NULL },
579 { NULL, NULL},
580 },
581 "disabled",
582 },
583 {
584 "pcsx_rearmed_pe2_fix",
585 "Parasite Eve 2/Vandal Hearts 1/2 Fix",
586 NULL,
587 {
588 { "disabled", NULL },
589 { "enabled", NULL },
590 { NULL, NULL},
591 },
592 "disabled",
593 },
594 {
595 "pcsx_rearmed_inuyasha_fix",
596 "InuYasha Sengoku Battle Fix",
597 NULL,
598 {
599 { "disabled", NULL },
600 { "enabled", NULL },
601 { NULL, NULL},
602 },
603 "disabled",
604 },
605
606 /* ADVANCED OPTIONS */
607 {
608 "pcsx_rearmed_noxadecoding",
609 "XA Decoding",
610 NULL,
611 {
612 { "disabled", NULL },
613 { "enabled", NULL },
614 { NULL, NULL},
615 },
616 "enabled",
617 },
618 {
619 "pcsx_rearmed_nocdaudio",
620 "CD Audio",
621 NULL,
622 {
623 { "disabled", NULL },
624 { "enabled", NULL },
625 { NULL, NULL},
626 },
627 "enabled",
628 },
629
630#ifndef DRC_DISABLE
631 {
632 "pcsx_rearmed_nosmccheck",
633 "(Speed Hack) Disable SMC Checks",
634 "Will cause crashes when loading, break memcards.",
635 {
636 { "disabled", NULL },
637 { "enabled", NULL },
638 { NULL, NULL},
639 },
640 "disabled",
641 },
642 {
643 "pcsx_rearmed_gteregsunneeded",
644 "(Speed Hack) Assume GTE Regs Unneeded",
645 "May cause graphical glitches.",
646 {
647 { "disabled", NULL },
648 { "enabled", NULL },
649 { NULL, NULL},
650 },
651 "disabled",
652 },
653 {
654 "pcsx_rearmed_nogteflags",
655 "(Speed Hack) Disable GTE Flags",
656 "Will cause graphical glitches.",
657 {
658 { "disabled", NULL },
659 { "enabled", NULL },
660 { NULL, NULL},
661 },
662 "disabled",
663 },
664#endif /* DRC_DISABLE */
665
666 { NULL, NULL, NULL, { NULL, NULL }, NULL },
667};
668
669/* RETRO_LANGUAGE_JAPANESE */
670
671/* RETRO_LANGUAGE_FRENCH */
672
673/* RETRO_LANGUAGE_SPANISH */
674
675/* RETRO_LANGUAGE_GERMAN */
676
677/* RETRO_LANGUAGE_ITALIAN */
678
679/* RETRO_LANGUAGE_DUTCH */
680
681/* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
682
683/* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
684
685/* RETRO_LANGUAGE_RUSSIAN */
686
687/* RETRO_LANGUAGE_KOREAN */
688
689/* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
690
691/* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
692
693/* RETRO_LANGUAGE_ESPERANTO */
694
695/* RETRO_LANGUAGE_POLISH */
696
697/* RETRO_LANGUAGE_VIETNAMESE */
698
699/* RETRO_LANGUAGE_ARABIC */
700
701/* RETRO_LANGUAGE_GREEK */
702
703/* RETRO_LANGUAGE_TURKISH */
704
705/*
706 ********************************
707 * Language Mapping
708 ********************************
709*/
710
711struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
712 option_defs_us, /* RETRO_LANGUAGE_ENGLISH */
713 NULL, /* RETRO_LANGUAGE_JAPANESE */
714 NULL, /* RETRO_LANGUAGE_FRENCH */
715 NULL, /* RETRO_LANGUAGE_SPANISH */
716 NULL, /* RETRO_LANGUAGE_GERMAN */
717 NULL, /* RETRO_LANGUAGE_ITALIAN */
718 NULL, /* RETRO_LANGUAGE_DUTCH */
719 NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
720 NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
721 NULL, /* RETRO_LANGUAGE_RUSSIAN */
722 NULL, /* RETRO_LANGUAGE_KOREAN */
723 NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
724 NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
725 NULL, /* RETRO_LANGUAGE_ESPERANTO */
726 NULL, /* RETRO_LANGUAGE_POLISH */
727 NULL, /* RETRO_LANGUAGE_VIETNAMESE */
728 NULL, /* RETRO_LANGUAGE_ARABIC */
729 NULL, /* RETRO_LANGUAGE_GREEK */
730 NULL, /* RETRO_LANGUAGE_TURKISH */
731};
732
733/*
734 ********************************
735 * Functions
736 ********************************
737*/
738
739/* Handles configuration/setting of core options.
740 * Should only be called inside retro_set_environment().
741 * > We place the function body in the header to avoid the
742 * necessity of adding more .c files (i.e. want this to
743 * be as painless as possible for core devs)
744 */
745
746static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
747{
748 unsigned version = 0;
749
750 if (!environ_cb)
751 return;
752
753 if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version == 1))
754 {
755 struct retro_core_options_intl core_options_intl;
756 unsigned language = 0;
757
758 core_options_intl.us = option_defs_us;
759 core_options_intl.local = NULL;
760
761 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
762 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
763 core_options_intl.local = option_defs_intl[language];
764
765 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
766 }
767 else
768 {
769 size_t i;
770 size_t option_index = 0;
771 size_t num_options = 0;
772 struct retro_variable *variables = NULL;
773 char **values_buf = NULL;
774
775 /* Determine number of options
776 * > Note: We are going to skip a number of irrelevant
777 * core options when building the retro_variable array,
778 * but we'll allocate space for all of them. The difference
779 * in resource usage is negligible, and this allows us to
780 * keep the code 'cleaner' */
781 while (true)
782 {
783 if (option_defs_us[num_options].key)
784 num_options++;
785 else
786 break;
787 }
788
789 /* Allocate arrays */
790 variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
791 values_buf = (char **)calloc(num_options, sizeof(char *));
792
793 if (!variables || !values_buf)
794 goto error;
795
796 /* Copy parameters from option_defs_us array */
797 for (i = 0; i < num_options; i++)
798 {
799 const char *key = option_defs_us[i].key;
800 const char *desc = option_defs_us[i].desc;
801 const char *default_value = option_defs_us[i].default_value;
802 struct retro_core_option_value *values = option_defs_us[i].values;
803 size_t buf_len = 3;
804 size_t default_index = 0;
805
806 values_buf[i] = NULL;
807
808 /* Skip options that are irrelevant when using the
809 * old style core options interface */
c8108d88 810 if ((strcmp(key, "pcsx_rearmed_show_gpu_peops_settings") == 0))
919cac88 811 continue;
812
813 if (desc)
814 {
815 size_t num_values = 0;
816
817 /* Determine number of values */
818 while (true)
819 {
820 if (values[num_values].value)
821 {
822 /* Check if this is the default value */
823 if (default_value)
824 if (strcmp(values[num_values].value, default_value) == 0)
825 default_index = num_values;
826
827 buf_len += strlen(values[num_values].value);
828 num_values++;
829 }
830 else
831 break;
832 }
833
834 /* Build values string */
835 if (num_values > 1)
836 {
837 size_t j;
838
839 buf_len += num_values - 1;
840 buf_len += strlen(desc);
841
842 values_buf[i] = (char *)calloc(buf_len, sizeof(char));
843 if (!values_buf[i])
844 goto error;
845
846 strcpy(values_buf[i], desc);
847 strcat(values_buf[i], "; ");
848
849 /* Default value goes first */
850 strcat(values_buf[i], values[default_index].value);
851
852 /* Add remaining values */
853 for (j = 0; j < num_values; j++)
854 {
855 if (j != default_index)
856 {
857 strcat(values_buf[i], "|");
858 strcat(values_buf[i], values[j].value);
859 }
860 }
861 }
862 }
863
864 variables[option_index].key = key;
865 variables[option_index].value = values_buf[i];
866 option_index++;
867 }
868
869 /* Set variables */
870 environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
871
872error:
873
874 /* Clean up */
875 if (values_buf)
876 {
877 for (i = 0; i < num_options; i++)
878 {
879 if (values_buf[i])
880 {
881 free(values_buf[i]);
882 values_buf[i] = NULL;
883 }
884 }
885
886 free(values_buf);
887 values_buf = NULL;
888 }
889
890 if (variables)
891 {
892 free(variables);
893 variables = NULL;
894 }
895 }
896}
897
898#ifdef __cplusplus
899}
900#endif
901
902#endif