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 #include "libretro_options.h"
15 
16 /*
17  ********************************
18  * VERSION: 1.3
19  ********************************
20  *
21  * - 1.3: Move translations to libretro_core_options_intl.h
22  *        - libretro_core_options_intl.h includes BOM and utf-8
23  *          fix for MSVC 2010-2013
24  *        - Added HAVE_NO_LANGEXTRA flag to disable translations
25  *          on platforms/compilers without BOM support
26  * - 1.2: Use core options v1 interface when
27  *        RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1
28  *        (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1)
29  * - 1.1: Support generation of core options v0 retro_core_option_value
30  *        arrays containing options with a single value
31  * - 1.0: First commit
32 */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  ********************************
40  * Core Option Definitions
41  ********************************
42 */
43 
44 /* RETRO_LANGUAGE_ENGLISH */
45 
46 /* Default language:
47  * - All other languages must include the same keys and values
48  * - Will be used as a fallback in the event that frontend language
49  *   is not available
50  * - Will be used as a fallback for any missing entries in
51  *   frontend language definition */
52 
53 struct retro_core_option_definition option_defs_us[] = {
54 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN)
55    {
56       BEETLE_OPT(renderer),
57       "Renderer (Restart)",
58       "Choose video renderer. The software renderer is the most accurate but has steep performance requirements when running at increased internal GPU resolutions. The hardware renderers, while less accurate, improve performance over the software renderer at increased internal resolutions and enable various graphical enhancements. 'Hardware (Auto)' automatically selects the Vulkan or OpenGL renderer depending upon the current libretro frontend video driver. If the provided video driver is not Vulkan or OpenGL 3.3-compatible then the core will fall back to the software renderer.",
59       {
60          { "hardware",    "Hardware (Auto)" },
61 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
62          { "hardware_gl", "Hardware (OpenGL)" },
63 #endif
64 #if defined(HAVE_VULKAN)
65          { "hardware_vk", "Hardware (Vulkan)" },
66 #endif
67          { "software",    "Software" },
68          { NULL, NULL },
69       },
70       "hardware"
71    },
72    {
73       BEETLE_OPT(renderer_software_fb),
74       "Software Framebuffer",
75       "Enable accurate emulation of framebuffer effects (e.g. motion blur, FF7 battle swirl) when using hardware renderers by running a copy of the software renderer at native resolution in the background. If disabled, these operations are omitted (OpenGL) or rendered on the GPU (Vulkan). Disabling can improve performance but may cause severe graphical errors. Leave enabled if unsure.",
76       {
77          { "enabled",  NULL },
78          { "disabled", NULL },
79          { NULL, NULL },
80       },
81       "enabled"
82    },
83 #endif
84    {
85       BEETLE_OPT(internal_resolution),
86       "Internal GPU Resolution",
87       "Set internal resolution multiplier. Resolutions higher than '1x (Native)' improve fidelity of 3D models at the expense of increased performance requirements. 2D elements are generally unaffected by this setting.",
88       {
89          { "1x(native)", "1x (Native)" },
90          { "2x",         NULL },
91          { "4x",         NULL },
92          { "8x",         NULL },
93          { "16x",        NULL },
94          { NULL, NULL },
95       },
96       "1x(native)"
97    },
98 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
99    {
100       BEETLE_OPT(depth),
101       "Internal Color Depth",
102       "Set internal color depth. Higher color depth can reduce color banding effects without the use of dithering. 16 bpp emulates original hardware but may have visible banding if dithering is not enabled. 'Dithering Pattern' is recommended to be disabled when this option is set to 32 bpp.",
103       {
104          { "16bpp(native)", "16 bpp (Native)" },
105          { "32bpp",         "32 bpp" },
106          { NULL, NULL },
107       },
108       "16bpp(native)"
109    },
110    // Sort of, it's more like 15-bit high color and 24-bit true color for visible output. The alpha channel is used for mask bit. Vulkan renderer uses ABGR1555_555 for 31 bits internal? FMVs are always 24-bit on all renderers like original hardware (BGR888, no alpha)
111 #endif
112    {
113       BEETLE_OPT(dither_mode),
114       "Dithering Pattern",
115       "Set dithering pattern configuration. '1x (Native)' emulates native low resolution dithering used by original hardware to smooth out color banding artefacts visible at native color depth. 'Internal Resolution' scales dithering granularity to the configured internal resolution for cleaner results. Recommended to be disabled when running at 32 bpp color depth. Note: On Vulkan, enabling this will force downsampling to native color depth while disabling will automatically enable output at higher color depth.",
116       {
117          { "1x(native)",          "1x (Native)" },
118          { "internal resolution", "Internal Resolution" },
119          { "disabled",            NULL },
120          { NULL, NULL },
121       },
122       "1x(native)"
123    },
124 #ifdef HAVE_VULKAN
125    {
126       BEETLE_OPT(scaled_uv_offset),
127       "Texture UV Offset",
128       "Sample textures for 3D polygons at an offset for higher than 1x internal resolution. Reduce texture seams but may cause unintended graphical glitches.",
129       {
130          { "enabled",  NULL },
131          { "disabled", NULL },
132          { NULL, NULL },
133       },
134       "enabled"
135    },
136 #endif
137 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN)
138    {
139       BEETLE_OPT(filter),
140       "Texture Filtering",
141       "Select texture filtering method. 'Nearest' emulates original hardware. 'Bilinear' and '3-Point' are smoothing filters, which reduce pixelation via blurring. 'SABR', 'xBR', and 'JINC2' are upscaling filters that may improve texture fidelity/sharpness at the expense of increased performance requirements. Only supported by the hardware renderers.",
142       {
143          { "nearest",  "Nearest" },
144          { "SABR",     NULL },
145          { "xBR",      NULL },
146          { "bilinear", "Bilinear" },
147          { "3-point",  "3-Point" },
148          { "JINC2",    NULL },
149          { NULL, NULL },
150       },
151       "nearest"
152    },
153 #ifdef HAVE_VULKAN
154    {
155       BEETLE_OPT(filter_exclude_sprite),
156       "Exclude Sprites from Filtering",
157       "Do not apply texture filtering to sprites. Prevent seams in various games with 2D sprite-rendered backgrounds. Use together with Adaptive Smoothing or another post-processing filter for best effect.",
158       {
159          { "disable", NULL },
160          { "opaque", "Opaque Only" },
161          { "all", "Opaque and Semi-Transparent" },
162          { NULL, NULL },
163       },
164       "disable"
165    },
166    {
167       BEETLE_OPT(filter_exclude_2d_polygon),
168       "Exclude 2D Polygons from Filtering",
169       "Do not apply texture filtering to 2D polygons. 2D polygons are detected with a heuristic and there may be glitches. Use together with Adaptive Smoothing or another post-processing filter for best effect.",
170       {
171          { "disable", NULL },
172          { "opaque", "Opaque Only" },
173          { "all", "Opaque and Semi-Transparent" },
174          { NULL, NULL },
175       },
176       "disable"
177    },
178 #endif
179 #endif
180 #ifdef HAVE_VULKAN
181    {
182       BEETLE_OPT(adaptive_smoothing),
183       "Adaptive Smoothing",
184       "When enabled, smooths 2D artwork and UI elements without blurring 3D rendered objects. Only supported by the Vulkan renderer.",
185       {
186          { "disabled", NULL },
187          { "enabled",  NULL },
188          { NULL, NULL },
189       },
190       "disabled"
191    },
192    {
193       BEETLE_OPT(super_sampling),
194       "Supersampling (Downsample to Native Resolution)",
195       "When enabled, downsamples rendered content from upscaled internal resolution down to native resolution. Combining this with higher internal resolution multipliers allows for games to be displayed with anti-aliased 3D objects at native low resolution. Produces best results when applied to titles that mix 2D and 3D elements (e.g. 3D characters on pre-rendered backgrounds), and works well in conjunction with CRT shaders. Only supported by the Vulkan renderer. Note: 'Dithering Pattern' is recommended to be disabled when enabling this option.",
196       {
197          { "disabled", NULL },
198          { "enabled",  NULL },
199          { NULL, NULL },
200       },
201       "disabled"
202    },
203    {
204       BEETLE_OPT(msaa),
205       "Multi-Sampled Anti Aliasing",
206       "Set MSAA level for rendered content. Improves the appearance of 3D objects. Only supported by the Vulkan renderer.",
207       {
208          { "1x",  "1x (Default)" },
209          { "2x",  NULL },
210          { "4x",  NULL },
211          { "8x",  NULL },
212          { "16x", NULL },
213          { NULL, NULL },
214       },
215       "1x"
216    },
217    {
218       BEETLE_OPT(mdec_yuv),
219       "MDEC YUV Chroma Filter",
220       "Improves the quality of FMV playback by reducing 'macroblocking' artefacts (squares/jagged edges). Only supported by the Vulkan renderer.",
221       {
222          { "disabled", NULL },
223          { "enabled",  NULL },
224          { NULL, NULL },
225       },
226       "disabled"
227    },
228    {
229       BEETLE_OPT(track_textures),
230       "Track Textures",
231       "Prerequisite for texture dumping and replacement.  Will probably crash in most games.",
232       {
233          { "disabled", NULL },
234          { "enabled",  NULL },
235          { NULL, NULL },
236       },
237       "disabled"
238    },
239 #ifdef TEXTURE_DUMPING_ENABLED
240    {
241       BEETLE_OPT(dump_textures),
242       "Dump Textures",
243       "Dumps used textures to <cd>-texture-dump/",
244       {
245          { "disabled", NULL },
246          { "enabled",  NULL },
247          { NULL, NULL },
248       },
249       "disabled"
250    },
251 #endif
252    {
253       BEETLE_OPT(replace_textures),
254       "Replace Textures",
255       "Replaces textures using hd versions from <cd>-texture-replacements/",
256       {
257          { "disabled", NULL },
258          { "enabled",  NULL },
259          { NULL, NULL },
260       },
261       "disabled"
262    },
263 #endif
264 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
265    {
266       BEETLE_OPT(wireframe),
267       "Wireframe Mode (Debug)",
268       "When enabled, renders 3D models in outline form without textures or shading. Only supported by the OpenGL hardware renderer. Note: This is for debugging purposes, and should normally be disabled.",
269       {
270          { "disabled", NULL },
271          { "enabled",  NULL },
272          { NULL, NULL },
273       },
274       "disabled"
275    },
276 #endif
277 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN)
278    {
279       BEETLE_OPT(display_vram),
280       "Display Full VRAM (Debug)",
281       "When enabled, visualises the entire emulated console's VRAM. Only supported by the OpenGL and Vulkan hardware renderers. Note: This is for debugging purposes, and should normally be disabled.",
282       {
283          { "disabled", NULL },
284          { "enabled",  NULL },
285          { NULL, NULL },
286       },
287       "disabled"
288    },
289 #endif
290    {
291       BEETLE_OPT(pgxp_mode),
292       "PGXP Operation Mode",
293       "Allows 3D objects to be rendered with subpixel precision, minimizing distortion and jitter of 3D objects seen on original hardware due to the usage of fixed point vertex coordinates. 'Memory Only' mode has minimal compatibility issues and is recommended for general use. 'Memory + CPU (Buggy)' mode can reduce jitter even further but has high performance requirements and may cause various geometry errors.",
294       {
295          { "disabled",     NULL },
296          { "memory only",  "Memory Only" },
297          { "memory + CPU", "Memory + CPU (Buggy)" },
298          { NULL, NULL },
299       },
300       "disabled"
301    },
302    {
303       BEETLE_OPT(pgxp_2d_tol),
304       "PGXP 2D Geometry Tolerance",
305       "Hide more glaring errors in PGXP operations: the value specifies the tolerance in which PGXP values will be kept in case of geometries without proper depth information.",
306       {
307          { "disabled", NULL },
308          { "0px", NULL },
309          { "1px", NULL },
310          { "2px", NULL },
311          { "3px", NULL },
312          { "4px", NULL },
313          { "5px", NULL },
314          { "6px", NULL },
315          { "7px", NULL },
316          { "8px", NULL },
317          { NULL, NULL },
318       },
319       "disabled"
320    },
321    {
322       BEETLE_OPT(pgxp_nclip),
323       "PGXP Primitive Culling",
324       "Use PGXP's NCLIP implementation. Improves appearance by reducing holes in geometries with PGXP coordinates. Known to cause some games to lock up in various circumstances.",
325       {
326          { "disabled", NULL },
327          { "enabled", NULL },
328          { NULL, NULL },
329       },
330       "disabled"
331    },
332 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN)
333    {
334       BEETLE_OPT(pgxp_vertex),
335       "PGXP Vertex Cache",
336       "Allows PGXP-enhanced vertex positions to be cached for re-use across polygon draws. Can potentially improve object alignment and reduce visible seams when rendering textures, but false positives when querying the cache may produce graphical glitches. It is currently recommended to leave this option disabled. This option is applied only when PGXP Operation Mode is enabled. Only supported by the hardware renderers.",
337       {
338          { "disabled", NULL },
339          { "enabled",  NULL },
340          { NULL, NULL },
341       },
342       "disabled"
343    },
344    {
345       BEETLE_OPT(pgxp_texture),
346       "PGXP Perspective Correct Texturing",
347       "When enabled, replaces native PSX affine texture mapping with perspective correct texture mapping. Eliminates position-dependent distortion and warping of textures, resulting in properly aligned textures. This option is applied only when PGXP Operation Mode is enabled. Only supported by the hardware renderers.",
348       {
349          { "disabled", NULL },
350          { "enabled",  NULL },
351          { NULL, NULL },
352       },
353       "disabled"
354    },
355 #endif
356    {
357       BEETLE_OPT(display_internal_fps),
358       "Display Internal FPS",
359       "Display the internal frame rate at which the emulated PlayStation system is rendering content. Note: Requires onscreen notifications to be enabled in the libretro frontend.",
360       {
361          { "disabled", NULL },
362          { "enabled",  NULL },
363          { NULL, NULL },
364       },
365       "disabled"
366    },
367    {
368       BEETLE_OPT(line_render),
369       "Line-to-Quad Hack",
370       "Choose line-to-quad hack method. Some games (e.g. Doom, Hexen, Soul Blade, etc) draw horizontal lines by stretching single-pixel-high triangles across the screen, which are rasterized as a row of pixels on original hardware. This hack detects these small triangles and converts them to quads as required, allowing them to be displayed properly on the hardware renderers and at upscaled internal resolutions. 'Aggressive' is required for some titles (e.g. Dark Forces, Duke Nukem) but may otherwise introduce graphical glitches. Leave at 'Default' if unsure.",
371       {
372          { "default",    "Default" },
373          { "aggressive", "Aggressive" },
374          { "disabled",   NULL },
375          { NULL, NULL },
376       },
377       "default"
378    },
379    {
380       BEETLE_OPT(frame_duping),
381       "Frame Duping (Speedup)",
382       "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.",
383       {
384          { "disabled", NULL },
385          { "enabled",  NULL },
386          { NULL, NULL },
387       },
388       "disabled"
389    },
390 #if defined(HAVE_LIGHTREC)
391    {
392       BEETLE_OPT(cpu_dynarec),
393       "CPU Dynarec",
394       "Dynamically recompile CPU instructions to native instructions. Much faster than interpreter, but CPU timing is less accurate, and may have bugs.",
395       {
396          { "disabled", "Disabled (Beetle Interpreter)" },
397          { "execute",  "Max Performance" },
398          { "execute_one",  "Cycle Timing Check" },
399          { "run_interpreter", "Lightrec Interpreter" },
400          { NULL, NULL },
401       },
402       "disabled"
403    },
404    {
405       BEETLE_OPT(dynarec_invalidate),
406       "Dynarec Code Invalidation",
407       "Some games require Full invalidation, some require DMA Only.",
408       {
409          { "full", "Full" },
410          { "dma",  "DMA Only (Slightly Faster)" },
411          { NULL, NULL },
412       },
413       "full"
414    },
415    {
416       BEETLE_OPT(dynarec_eventcycles),
417       "Dynarec DMA/GPU Event Cycles",
418       "Max cycles run by CPU before a GPU or DMA Update is checked, higher number will be faster, has much less impact on beetle interpreter than dynarec",
419       {
420          { "128", "128 (Default)" },
421          { "256",  NULL },
422          { "384",  NULL },
423          { "512",  NULL },
424          { "640",  NULL },
425          { "768",  NULL },
426          { "896",  NULL },
427          { "1024",  NULL },
428          { NULL, NULL },
429       },
430       "128"
431    },
432 #endif
433    {
434       BEETLE_OPT(cpu_freq_scale),
435       "CPU Frequency Scaling (Overclock)",
436       "Enable overclocking (or underclocking) of the emulated PSX CPU. Overclocking can eliminate slowdown and improve frame rates in certain games at the expense of increased performance requirements. Note that some games have an internal frame rate limiter and may not benefit from overclocking. May cause certain effects to animate faster than intended in some titles when overclocked.",
437       {
438          { "50%",           NULL },
439          { "60%",           NULL },
440          { "70%",           NULL },
441          { "80%",           NULL },
442          { "90%",           NULL },
443          { "100%(native)", "100% (Native)" },
444          { "110%",          NULL },
445          { "120%",          NULL },
446          { "130%",          NULL },
447          { "140%",          NULL },
448          { "150%",          NULL },
449          { "160%",          NULL },
450          { "170%",          NULL },
451          { "180%",          NULL },
452          { "190%",          NULL },
453          { "200%",          NULL },
454          { "210%",          NULL },
455          { "220%",          NULL },
456          { "230%",          NULL },
457          { "240%",          NULL },
458          { "250%",          NULL },
459          { "260%",          NULL },
460          { "270%",          NULL },
461          { "280%",          NULL },
462          { "290%",          NULL },
463          { "300%",          NULL },
464          { "310%",          NULL },
465          { "320%",          NULL },
466          { "330%",          NULL },
467          { "340%",          NULL },
468          { "350%",          NULL },
469          { "360%",          NULL },
470          { "370%",          NULL },
471          { "380%",          NULL },
472          { "390%",          NULL },
473          { "400%",          NULL },
474          { "410%",          NULL },
475          { "420%",          NULL },
476          { "430%",          NULL },
477          { "440%",          NULL },
478          { "450%",          NULL },
479          { "460%",          NULL },
480          { "470%",          NULL },
481          { "480%",          NULL },
482          { "490%",          NULL },
483          { "500%",          NULL },
484          { "510%",          NULL },
485          { "520%",          NULL },
486          { "530%",          NULL },
487          { "540%",          NULL },
488          { "550%",          NULL },
489          { "560%",          NULL },
490          { "570%",          NULL },
491          { "580%",          NULL },
492          { "590%",          NULL },
493          { "600%",          NULL },
494          { "610%",          NULL },
495          { "620%",          NULL },
496          { "630%",          NULL },
497          { "640%",          NULL },
498          { "650%",          NULL },
499          { "660%",          NULL },
500          { "670%",          NULL },
501          { "680%",          NULL },
502          { "690%",          NULL },
503          { "700%",          NULL },
504          { "710%",          NULL },
505          { "720%",          NULL },
506          { "730%",          NULL },
507          { "740%",          NULL },
508          { "750%",          NULL },
509          { NULL, NULL },
510       },
511       "100%(native)"
512    },
513    {
514       BEETLE_OPT(gte_overclock),
515       "GTE Overclock",
516       "When enabled, lowers all emulated GTE (CPU coprocessor for 3D graphics) operations to a constant one-cycle latency. For games that make heavy use of the GTE, this can greatly improve frame rate and frame time stability.",
517       {
518          { "disabled", NULL },
519          { "enabled",  NULL },
520          { NULL, NULL },
521       },
522       "disabled"
523    },
524    {
525       BEETLE_OPT(gpu_overclock),
526       "GPU Rasterizer Overclock",
527       "Enable overclocking of the 2D rasterizer contained within the emulated PSX's GPU. Does not improve 3D rendering, and in general has little effect.",
528       {
529          { "1x(native)", "1x (Native)" },
530          { "2x",         NULL },
531          { "4x",         NULL },
532          { "8x",         NULL },
533          { "16x",        NULL },
534          { "32x",        NULL },
535          { NULL, NULL },
536       },
537       "1x(native)"
538    },
539    {
540       BEETLE_OPT(skip_bios),
541       "Skip BIOS",
542       "Skips the PlayStation BIOS boot animation normally displayed when loading content. Note: Enabling this causes compatibility issues with a number of games (PAL copy protected games, Saga Frontier, etc).",
543       {
544          { "disabled", NULL },
545          { "enabled",  NULL },
546          { NULL, NULL },
547       },
548       "disabled"
549    },
550    {
551       BEETLE_OPT(core_timing_fps),
552       "Core-Reported FPS Timing",
553       "Sets FPS timing that the core will report to the frontend. Automatic toggling will allow the core to switch between reporting progressive and interlaced rates, but may cause frontend video/audio driver reinits.",
554       {
555          { "force_progressive", "Progressive Rate (Default)" },
556          { "force_interlaced",  "Force Interlaced Rate" },
557          { "auto_toggle", "Allow Automatic Toggling" },
558       },
559       "force_progressive"
560    },
561    {
562       BEETLE_OPT(aspect_ratio),
563       "Core Aspect Ratio",
564       "Set core provided aspect ratio. This setting is ignored when the Widescreen Mode Hack or Display Full VRAM options are enabled.",
565       {
566          { "corrected", "Corrected" },
567          { "uncorrected", "Uncorrected" },
568          { "4:3",  "Force 4:3" },
569          { "ntsc", "Force NTSC" },
570       },
571       "corrected"
572    },
573    {
574       BEETLE_OPT(widescreen_hack),
575       "Widescreen Mode Hack",
576       "When enabled, renders 3D content anamorphically and outputs the emulated framebuffer at a widescreen aspect ratio. Produces best results with fully 3D games. 2D elements will be horizontally stretched and may be misaligned.",
577       {
578          { "disabled", NULL },
579          { "enabled",  NULL },
580          { NULL, NULL },
581       },
582       "disabled"
583    },
584    {
585       BEETLE_OPT(widescreen_hack_aspect_ratio),
586       "Widescreen Mode Hack Aspect Ratio",
587       "The aspect ratio that's used by the Widescreen Mode Hack.",
588       {
589          { "16:10", NULL },
590          { "16:9",  NULL },
591          { "21:9",  NULL }, // 64:27
592          { "32:9",  NULL },
593          { NULL,    NULL },
594       },
595       "16:9"
596    },
597    {
598       BEETLE_OPT(pal_video_timing_override),
599       "PAL (European) Video Timing Override",
600       "Due to different standards PAL games often appear slowed down compared to the American or Japanese NTSC releases. This option can be used to override PAL timings in order to attempt to run these games with the NTSC framerate. This option has no effect when running NTSC content.",
601       {
602          { "disabled", NULL },
603          { "enabled",  NULL },
604       },
605       "disabled"
606    },
607    {
608       BEETLE_OPT(crop_overscan),
609       "Crop Horizontal Overscan",
610       "By default, the renderers add horizontal padding (pillarboxes on either side of the image) to emulate the same black bars generated in analog video output by real PSX hardware. Enabling this option removes horizontal padding.",
611       {
612          { "enabled",  NULL },
613          { "disabled", NULL },
614          { NULL, NULL },
615       },
616       "enabled"
617    },
618    {
619       BEETLE_OPT(image_crop),
620       "Additional Cropping",
621       "When 'Crop Horizontal Overscan' is enabled, this option further reduces the width of the cropped image by the specified number of pixels. Only supported by the software renderer.",
622       {
623          { "disabled", NULL },
624          { "1px",      NULL },
625          { "2px",      NULL },
626          { "3px",      NULL },
627          { "4px",      NULL },
628          { "5px",      NULL },
629          { "6px",      NULL },
630          { "7px",      NULL },
631          { "8px",      NULL },
632          { "9px",      NULL },
633          { "10px",     NULL },
634          { "11px",     NULL },
635          { "12px",     NULL },
636          { "13px",     NULL },
637          { "14px",     NULL },
638          { "15px",     NULL },
639          { "16px",     NULL },
640          { "17px",     NULL },
641          { "18px",     NULL },
642          { "19px",     NULL },
643          { "20px",     NULL },
644          { NULL, NULL },
645       },
646       "disabled"
647    },
648    {
649       BEETLE_OPT(image_offset),
650       "Offset Cropped Image",
651       "When 'Crop Horizontal Overscan' is enabled, allows the resultant cropped image to be offset horizontally to the right (positive) or left (negative) by the specified number of pixels. May be used to correct alignment issues. Only supported by the software renderer.",
652       {
653          { "-12px",    NULL },
654          { "-11px",    NULL },
655          { "-10px",    NULL },
656          { "-9px",     NULL },
657          { "-8px",     NULL },
658          { "-7px",     NULL },
659          { "-6px",     NULL },
660          { "-5px",     NULL },
661          { "-4px",     NULL },
662          { "-3px",     NULL },
663          { "-2px",     NULL },
664          { "-1px",     NULL },
665          { "disabled", NULL },
666          { "+1px",     NULL },
667          { "+2px",     NULL },
668          { "+3px",     NULL },
669          { "+4px",     NULL },
670          { "+5px",     NULL },
671          { "+6px",     NULL },
672          { "+7px",     NULL },
673          { "+8px",     NULL },
674          { "+9px",     NULL },
675          { "+10px",    NULL },
676          { "+11px",    NULL },
677          { "+12px",    NULL },
678          { NULL, NULL },
679       },
680       "disabled"
681    },
682 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN)
683    {
684       BEETLE_OPT(image_offset_cycles),
685       "Horizontal Image Offset (GPU Cycles)",
686       "Specify number of GPU cycles to offset image by. Positive values move image to the right, negative values move image to the left. Only supported by the hardware renderers.",
687       {
688          { "-40",      NULL },
689          { "-39",      NULL },
690          { "-38",      NULL },
691          { "-37",      NULL },
692          { "-36",      NULL },
693          { "-35",      NULL },
694          { "-34",      NULL },
695          { "-33",      NULL },
696          { "-32",      NULL },
697          { "-31",      NULL },
698          { "-30",      NULL },
699          { "-29",      NULL },
700          { "-28",      NULL },
701          { "-27",      NULL },
702          { "-26",      NULL },
703          { "-25",      NULL },
704          { "-24",      NULL },
705          { "-23",      NULL },
706          { "-22",      NULL },
707          { "-21",      NULL },
708          { "-20",      NULL },
709          { "-19",      NULL },
710          { "-18",      NULL },
711          { "-17",      NULL },
712          { "-16",      NULL },
713          { "-15",      NULL },
714          { "-14",      NULL },
715          { "-13",      NULL },
716          { "-12",      NULL },
717          { "-11",      NULL },
718          { "-10",      NULL },
719          { "-9",       NULL },
720          { "-8",       NULL },
721          { "-7",       NULL },
722          { "-6",       NULL },
723          { "-5",       NULL },
724          { "-4",       NULL },
725          { "-3",       NULL },
726          { "-2",       NULL },
727          { "-1",       NULL },
728          { "0",        NULL },
729          { "+1",       NULL },
730          { "+2",       NULL },
731          { "+3",       NULL },
732          { "+4",       NULL },
733          { "+5",       NULL },
734          { "+6",       NULL },
735          { "+7",       NULL },
736          { "+8",       NULL },
737          { "+9",       NULL },
738          { "+10",      NULL },
739          { "+11",      NULL },
740          { "+12",      NULL },
741          { "+13",      NULL },
742          { "+14",      NULL },
743          { "+15",      NULL },
744          { "+16",      NULL },
745          { "+17",      NULL },
746          { "+18",      NULL },
747          { "+19",      NULL },
748          { "+20",      NULL },
749          { "+21",      NULL },
750          { "+22",      NULL },
751          { "+23",      NULL },
752          { "+24",      NULL },
753          { "+25",      NULL },
754          { "+26",      NULL },
755          { "+27",      NULL },
756          { "+28",      NULL },
757          { "+29",      NULL },
758          { "+30",      NULL },
759          { "+31",      NULL },
760          { "+32",      NULL },
761          { "+33",      NULL },
762          { "+34",      NULL },
763          { "+35",      NULL },
764          { "+36",      NULL },
765          { "+37",      NULL },
766          { "+38",      NULL },
767          { "+39",      NULL },
768          { "+40",      NULL },
769          { NULL, NULL},
770       },
771       "0"
772    },
773 #endif
774    {
775       BEETLE_OPT(initial_scanline),
776       "Initial Scanline - NTSC",
777       "Select the first displayed scanline when running NTSC content. Setting a value greater than zero will reduce the height of output images by cropping pixels from the topmost edge. May be used to counteract letterboxing.",
778       {
779          { "0",  NULL },
780          { "1",  NULL },
781          { "2",  NULL },
782          { "3",  NULL },
783          { "4",  NULL },
784          { "5",  NULL },
785          { "6",  NULL },
786          { "7",  NULL },
787          { "8",  NULL },
788          { "9",  NULL },
789          { "10", NULL },
790          { "11", NULL },
791          { "12", NULL },
792          { "13", NULL },
793          { "14", NULL },
794          { "15", NULL },
795          { "16", NULL },
796          { "17", NULL },
797          { "18", NULL },
798          { "19", NULL },
799          { "20", NULL },
800          { "21", NULL },
801          { "22", NULL },
802          { "23", NULL },
803          { "24", NULL },
804          { "25", NULL },
805          { "26", NULL },
806          { "27", NULL },
807          { "28", NULL },
808          { "29", NULL },
809          { "30", NULL },
810          { "31", NULL },
811          { "32", NULL },
812          { "33", NULL },
813          { "34", NULL },
814          { "35", NULL },
815          { "36", NULL },
816          { "37", NULL },
817          { "38", NULL },
818          { "39", NULL },
819          { "40", NULL },
820          { NULL, NULL },
821       },
822       "0"
823    },
824    {
825       BEETLE_OPT(last_scanline),
826       "Last Scanline - NTSC",
827       "Select the last displayed scanline when running NTSC content. Setting a value less than 239 will reduce the height of output images by cropping pixels from the bottommost edge. May be used to counteract letterboxing.",
828       {
829          { "210", NULL },
830          { "211", NULL },
831          { "212", NULL },
832          { "213", NULL },
833          { "214", NULL },
834          { "215", NULL },
835          { "216", NULL },
836          { "217", NULL },
837          { "218", NULL },
838          { "219", NULL },
839          { "220", NULL },
840          { "221", NULL },
841          { "222", NULL },
842          { "223", NULL },
843          { "224", NULL },
844          { "225", NULL },
845          { "226", NULL },
846          { "227", NULL },
847          { "228", NULL },
848          { "229", NULL },
849          { "230", NULL },
850          { "231", NULL },
851          { "232", NULL },
852          { "233", NULL },
853          { "234", NULL },
854          { "235", NULL },
855          { "236", NULL },
856          { "237", NULL },
857          { "238", NULL },
858          { "239", NULL },
859          { NULL, NULL },
860       },
861       "239"
862    },
863    {
864       BEETLE_OPT(initial_scanline_pal),
865       "Initial Scanline - PAL",
866       "Select the first displayed scanline when running PAL content. Setting a value greater than zero will reduce the height of output images by cropping pixels from the topmost edge. May be used to counteract letterboxing.",
867       {
868          { "0",  NULL },
869          { "1",  NULL },
870          { "2",  NULL },
871          { "3",  NULL },
872          { "4",  NULL },
873          { "5",  NULL },
874          { "6",  NULL },
875          { "7",  NULL },
876          { "8",  NULL },
877          { "9",  NULL },
878          { "10", NULL },
879          { "11", NULL },
880          { "12", NULL },
881          { "13", NULL },
882          { "14", NULL },
883          { "15", NULL },
884          { "16", NULL },
885          { "17", NULL },
886          { "18", NULL },
887          { "19", NULL },
888          { "20", NULL },
889          { "21", NULL },
890          { "22", NULL },
891          { "23", NULL },
892          { "24", NULL },
893          { "25", NULL },
894          { "26", NULL },
895          { "27", NULL },
896          { "28", NULL },
897          { "29", NULL },
898          { "30", NULL },
899          { "31", NULL },
900          { "32", NULL },
901          { "33", NULL },
902          { "34", NULL },
903          { "35", NULL },
904          { "36", NULL },
905          { "37", NULL },
906          { "38", NULL },
907          { "39", NULL },
908          { "40", NULL },
909          { NULL, NULL },
910       },
911       "0"
912    },
913    {
914       BEETLE_OPT(last_scanline_pal),
915       "Last Scanline - PAL",
916       "Select the last displayed scanline when running PAL content. Setting a value less than 287 will reduce the height of output images by cropping pixels from the bottommost edge. May be used to counteract letterboxing.",
917       {
918          { "230", NULL },
919          { "231", NULL },
920          { "232", NULL },
921          { "233", NULL },
922          { "234", NULL },
923          { "235", NULL },
924          { "236", NULL },
925          { "237", NULL },
926          { "238", NULL },
927          { "239", NULL },
928          { "240", NULL },
929          { "241", NULL },
930          { "242", NULL },
931          { "243", NULL },
932          { "244", NULL },
933          { "245", NULL },
934          { "246", NULL },
935          { "247", NULL },
936          { "248", NULL },
937          { "249", NULL },
938          { "250", NULL },
939          { "251", NULL },
940          { "252", NULL },
941          { "253", NULL },
942          { "254", NULL },
943          { "255", NULL },
944          { "256", NULL },
945          { "257", NULL },
946          { "258", NULL },
947          { "259", NULL },
948          { "260", NULL },
949          { "261", NULL },
950          { "262", NULL },
951          { "263", NULL },
952          { "264", NULL },
953          { "265", NULL },
954          { "266", NULL },
955          { "267", NULL },
956          { "268", NULL },
957          { "269", NULL },
958          { "270", NULL },
959          { "271", NULL },
960          { "272", NULL },
961          { "273", NULL },
962          { "274", NULL },
963          { "275", NULL },
964          { "276", NULL },
965          { "277", NULL },
966          { "278", NULL },
967          { "279", NULL },
968          { "280", NULL },
969          { "281", NULL },
970          { "282", NULL },
971          { "283", NULL },
972          { "284", NULL },
973          { "285", NULL },
974          { "286", NULL },
975          { "287", NULL },
976          { NULL, NULL },
977       },
978       "287"
979    },
980 #ifndef EMSCRIPTEN
981    {
982       BEETLE_OPT(cd_access_method),
983       "CD Access Method (Restart)",
984       "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' loads the entire disk image into memory when launching content which may improve in-game loading times at the cost of an initial delay at startup. 'Pre-Cache' may cause issues on systems with low RAM.",
985       {
986          { "sync",     "Synchronous" },
987          { "async",    "Asynchronous" },
988          { "precache", "Pre-Cache" },
989          { NULL, NULL },
990       },
991       "sync"
992    },
993 #endif
994    {
995       BEETLE_OPT(cd_fastload),
996       "CD Loading Speed",
997       "Select disk access speed multiplier. Setting this higher than '2x (Native)' can greatly reduce in-game loading times, but may introduce timing errors. Some games may not function properly if this option is increased above a certain value.",
998       {
999          { "2x(native)", "2x (Native)" },
1000          { "4x",          NULL },
1001          { "6x",          NULL },
1002          { "8x",          NULL },
1003          { "10x",         NULL },
1004          { "12x",         NULL },
1005          { "14x",         NULL },
1006          { NULL, NULL },
1007       },
1008       "2x(native)"
1009    },
1010    {
1011       BEETLE_OPT(use_mednafen_memcard0_method),
1012       "Memory Card 0 Method (Restart)",
1013       "Choose the save data format used for memory card 0. 'Mednafen' may be used for compatibility with the stand-alone version of Mednafen. When used with Beetle PSX, Libretro (.srm) and Mednafen (.mcr) saves have internally identical formats and can be converted between one another via renaming.",
1014       {
1015          { "libretro", "Libretro" },
1016          { "mednafen", "Mednafen" },
1017          { NULL, NULL },
1018       },
1019       "libretro"
1020    },
1021    {
1022       BEETLE_OPT(enable_memcard1),
1023       "Enable Memory Card 1 (Restart)",
1024       "Select whether to emulate a second memory card in slot 1. When disabled, games can only access the memory card in slot 0. Note: Some games require this option to be disabled for correct operation (e.g. Codename Tenka). Note: Memory Card 1 uses the Mednafen (.mcr) save format.",
1025       {
1026          { "enabled",  NULL },
1027          { "disabled", NULL },
1028          { NULL, NULL },
1029       },
1030       "enabled"
1031    },
1032    {
1033       BEETLE_OPT(shared_memory_cards),
1034       "Shared Memory Cards (Restart)",
1035       "When enabled, all games will save to and load from the same memory card files. When disabled, separate memory card files will be generated for each item of loaded content. Note: 'Memory Card 0 Method' must be set to 'Mednafen' for shared memory cards to take effect.",
1036       {
1037          { "disabled", NULL },
1038          { "enabled",  NULL },
1039          { NULL, NULL },
1040       },
1041       "disabled"
1042    },
1043    {
1044       BEETLE_OPT(analog_calibration),
1045       "Analog Self-Calibration",
1046       "When the input device is set to DualShock, Analog Controller, Analog Joystick, or neGcon, this option allows dynamic calibration of analog inputs. Maximum registered input values are monitored in real time and used to scale analog coordinates passed to the emulator. This should be used for games such as Mega Man Legends 2 that expect larger values than what modern controllers provide. For best results, analog sticks should be rotated at full extent to tune the calibration algorithm each time content is loaded.",
1047       {
1048          { "disabled", NULL },
1049          { "enabled",  NULL },
1050          { NULL, NULL },
1051       },
1052       "disabled"
1053    },
1054    {
1055       BEETLE_OPT(analog_toggle),
1056       "Enable DualShock Analog Mode Toggle",
1057       "When the input device type is DualShock, sets whether or not the emulated DualShock can be toggled between DIGITAL and ANALOG mode like original hardware. When this option is disabled, the DualShock is locked to ANALOG mode and when enabled, the DualShock can be toggled between DIGITAL and ANALOG mode by pressing and holding START+SELECT+L1+L2+R1+R2.",
1058       {
1059          { "disabled", NULL },
1060          { "enabled",  NULL },
1061          { NULL, NULL },
1062       },
1063       "disabled"
1064    },
1065    {
1066       BEETLE_OPT(enable_multitap_port1),
1067       "Port 1: Multitap Enable",
1068       "Enables/Disables multitap functionality on port 1.",
1069       {
1070          { "disabled", NULL },
1071          { "enabled",  NULL },
1072          { NULL, NULL },
1073       },
1074       "disabled"
1075    },
1076    {
1077       BEETLE_OPT(enable_multitap_port2),
1078       "Port 2: Multitap Enable",
1079       "Enables/Disables multitap functionality on port 2.",
1080       {
1081          { "disabled", NULL },
1082          { "enabled",  NULL },
1083          { NULL, NULL },
1084       },
1085       "disabled"
1086    },
1087    {
1088       BEETLE_OPT(gun_input_mode),
1089       "Gun Input Mode",
1090       "Specify whether to use a mouse-controlled 'Light Gun' or a 'Touchscreen' input when device type is set to 'Guncon / G-Con 45' or 'Justifier'.",
1091       {
1092          { "lightgun",    "Light Gun" },
1093          { "touchscreen", "Touchscreen" },
1094          { NULL, NULL },
1095       },
1096       "lightgun"
1097    },
1098    // Shouldn't the gun_input_mode just be Mouse vs. Touchscreen?
1099    {
1100       BEETLE_OPT(gun_cursor),
1101       "Gun Cursor",
1102       "Select the gun cursor to be displayed on screen while using the the 'Guncon / G-Con 45' and 'Justifier' input device types. When disabled, cross hairs are always hidden.",
1103       {
1104          { "cross", "Cross" },
1105          { "dot",   "Dot" },
1106          { "off",   "disabled" },
1107          { NULL, NULL },
1108       },
1109       "cross"
1110    },
1111    {
1112       BEETLE_OPT(mouse_sensitivity),
1113       "Mouse Sensitivity",
1114       "Configure the response of the 'Mouse' input device type.",
1115       {
1116          { "5%",   NULL },
1117          { "10%",  NULL },
1118          { "15%",  NULL },
1119          { "20%",  NULL },
1120          { "25%",  NULL },
1121          { "30%",  NULL },
1122          { "35%",  NULL },
1123          { "40%",  NULL },
1124          { "45%",  NULL },
1125          { "50%",  NULL },
1126          { "55%",  NULL },
1127          { "60%",  NULL },
1128          { "65%",  NULL },
1129          { "70%",  NULL },
1130          { "75%",  NULL },
1131          { "80%",  NULL },
1132          { "85%",  NULL },
1133          { "90%",  NULL },
1134          { "95%",  NULL },
1135          { "100%", NULL },
1136          { "105%", NULL },
1137          { "110%", NULL },
1138          { "115%", NULL },
1139          { "120%", NULL },
1140          { "125%", NULL },
1141          { "130%", NULL },
1142          { "135%", NULL },
1143          { "140%", NULL },
1144          { "145%", NULL },
1145          { "150%", NULL },
1146          { "155%", NULL },
1147          { "160%", NULL },
1148          { "165%", NULL },
1149          { "170%", NULL },
1150          { "175%", NULL },
1151          { "180%", NULL },
1152          { "185%", NULL },
1153          { "190%", NULL },
1154          { "195%", NULL },
1155          { "200%", NULL },
1156          { NULL, NULL },
1157       },
1158       "100%"
1159    },
1160    {
1161       BEETLE_OPT(negcon_response),
1162       "NegCon Twist Response",
1163       "Specifies the response of the RetroPad left analog stick when simulating the 'twist' action of emulated 'neGcon' input devices. Analog stick displacement may be mapped to negCon rotation angle either linearly, quadratically or cubically. 'Quadratic' allows for greater precision than 'Linear' when making small movements. 'Cubic' further increases small movement precision, but 'exaggerates' larger movements. Note: 'Linear' is only recommended when using racing wheel peripherals. Conventional gamepads implement analog input in a manner fundamentally different from the neGcon 'twist' mechanism, such that linear mapping over-amplifies small movements, impairing fine control. In most cases, 'Quadratic' provides the closest approximation of real hardware.",
1164       {
1165          { "linear",    "Linear" },
1166          { "quadratic", "Quadratic" },
1167          { "cubic",     "Cubic" },
1168          { NULL, NULL },
1169       },
1170       "linear"
1171    },
1172    {
1173       BEETLE_OPT(negcon_deadzone),
1174       "NegCon Twist Deadzone",
1175       "Sets the deadzone of the RetroPad left analog stick when simulating the 'twist' action of emulated 'neGcon' input devices. Used to eliminate controller drift. Note: Most negCon-compatible titles provide in-game options for setting a 'twist' deadzone value. To avoid loss of precision, the in-game deadzone should *always* be set to zero. Any required adjustments should *only* be applied via this core option. This is particularly important when 'NegCon Twist Response' is set to 'Quadratic' or 'Cubic'.",
1176       {
1177          { "0%",  NULL },
1178          { "5%",  NULL },
1179          { "10%", NULL },
1180          { "15%", NULL },
1181          { "20%", NULL },
1182          { "25%", NULL },
1183          { "30%", NULL },
1184          { NULL, NULL },
1185       },
1186       "0%"
1187    },
1188    {
1189       BEETLE_OPT(memcard_left_index),
1190       "Memory Card Left Index",
1191       "Changes the memory card currently loaded in the left slot. This option will only work if Memory Card 0 method is set to Mednafen. The default card is index 0.",
1192       {
1193          { "0",  NULL },
1194          { "1",  NULL },
1195          { "2",  NULL },
1196          { "3",  NULL },
1197          { "4",  NULL },
1198          { "5",  NULL },
1199          { "6",  NULL },
1200          { "7",  NULL },
1201          { "8",  NULL },
1202          { "9",  NULL },
1203          { "10",  NULL },
1204          { "11",  NULL },
1205          { "12",  NULL },
1206          { "13",  NULL },
1207          { "14",  NULL },
1208          { "15",  NULL },
1209          { "16",  NULL },
1210          { "17",  NULL },
1211          { "18",  NULL },
1212          { "19",  NULL },
1213          { "20",  NULL },
1214          { "21",  NULL },
1215          { "22",  NULL },
1216          { "23",  NULL },
1217          { "24",  NULL },
1218          { "25",  NULL },
1219          { "26",  NULL },
1220          { "27",  NULL },
1221          { "28",  NULL },
1222          { "29",  NULL },
1223          { "30",  NULL },
1224          { "31",  NULL },
1225          { "32",  NULL },
1226          { "33",  NULL },
1227          { "34",  NULL },
1228          { "35",  NULL },
1229          { "36",  NULL },
1230          { "37",  NULL },
1231          { "38",  NULL },
1232          { "39",  NULL },
1233          { "40",  NULL },
1234          { "41",  NULL },
1235          { "42",  NULL },
1236          { "43",  NULL },
1237          { "44",  NULL },
1238          { "45",  NULL },
1239          { "46",  NULL },
1240          { "47",  NULL },
1241          { "48",  NULL },
1242          { "49",  NULL },
1243          { "50",  NULL },
1244          { "51",  NULL },
1245          { "52",  NULL },
1246          { "53",  NULL },
1247          { "54",  NULL },
1248          { "55",  NULL },
1249          { "56",  NULL },
1250          { "57",  NULL },
1251          { "58",  NULL },
1252          { "59",  NULL },
1253          { "60",  NULL },
1254          { "61",  NULL },
1255          { "62",  NULL },
1256          { "63",  NULL },
1257          { NULL, NULL },
1258       },
1259       "0"
1260    },
1261    {
1262       BEETLE_OPT(memcard_right_index),
1263       "Memory Card Right Index",
1264       "Changes the memory card currently loaded in the right slot. This option will only work if Memory Card 1 is enabled. The default card is index 1.",
1265       {
1266          { "0",  NULL },
1267          { "1",  NULL },
1268          { "2",  NULL },
1269          { "3",  NULL },
1270          { "4",  NULL },
1271          { "5",  NULL },
1272          { "6",  NULL },
1273          { "7",  NULL },
1274          { "8",  NULL },
1275          { "9",  NULL },
1276          { "10",  NULL },
1277          { "11",  NULL },
1278          { "12",  NULL },
1279          { "13",  NULL },
1280          { "14",  NULL },
1281          { "15",  NULL },
1282          { "16",  NULL },
1283          { "17",  NULL },
1284          { "18",  NULL },
1285          { "19",  NULL },
1286          { "20",  NULL },
1287          { "21",  NULL },
1288          { "22",  NULL },
1289          { "23",  NULL },
1290          { "24",  NULL },
1291          { "25",  NULL },
1292          { "26",  NULL },
1293          { "27",  NULL },
1294          { "28",  NULL },
1295          { "29",  NULL },
1296          { "30",  NULL },
1297          { "31",  NULL },
1298          { "32",  NULL },
1299          { "33",  NULL },
1300          { "34",  NULL },
1301          { "35",  NULL },
1302          { "36",  NULL },
1303          { "37",  NULL },
1304          { "38",  NULL },
1305          { "39",  NULL },
1306          { "40",  NULL },
1307          { "41",  NULL },
1308          { "42",  NULL },
1309          { "43",  NULL },
1310          { "44",  NULL },
1311          { "45",  NULL },
1312          { "46",  NULL },
1313          { "47",  NULL },
1314          { "48",  NULL },
1315          { "49",  NULL },
1316          { "50",  NULL },
1317          { "51",  NULL },
1318          { "52",  NULL },
1319          { "53",  NULL },
1320          { "54",  NULL },
1321          { "55",  NULL },
1322          { "56",  NULL },
1323          { "57",  NULL },
1324          { "58",  NULL },
1325          { "59",  NULL },
1326          { "60",  NULL },
1327          { "61",  NULL },
1328          { "62",  NULL },
1329          { "63",  NULL },
1330          { NULL, NULL },
1331       },
1332       "1"
1333    },
1334    { NULL, NULL, NULL, {{0}}, NULL },
1335 };
1336 
1337 /*
1338  ********************************
1339  * Language Mapping
1340  ********************************
1341 */
1342 
1343 #ifndef HAVE_NO_LANGEXTRA
1344 struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
1345    option_defs_us, /* RETRO_LANGUAGE_ENGLISH */
1346    NULL,           /* RETRO_LANGUAGE_JAPANESE */
1347    NULL,           /* RETRO_LANGUAGE_FRENCH */
1348    NULL,           /* RETRO_LANGUAGE_SPANISH */
1349    NULL,           /* RETRO_LANGUAGE_GERMAN */
1350    option_defs_it, /* RETRO_LANGUAGE_ITALIAN */
1351    NULL,           /* RETRO_LANGUAGE_DUTCH */
1352    NULL,           /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
1353    NULL,           /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
1354    NULL,           /* RETRO_LANGUAGE_RUSSIAN */
1355    NULL,           /* RETRO_LANGUAGE_KOREAN */
1356    NULL,           /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
1357    NULL,           /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
1358    NULL,           /* RETRO_LANGUAGE_ESPERANTO */
1359    NULL,           /* RETRO_LANGUAGE_POLISH */
1360    NULL,           /* RETRO_LANGUAGE_VIETNAMESE */
1361    NULL,           /* RETRO_LANGUAGE_ARABIC */
1362    NULL,           /* RETRO_LANGUAGE_GREEK */
1363    NULL,           /* RETRO_LANGUAGE_TURKISH */
1364 };
1365 #endif
1366 
1367 /*
1368  ********************************
1369  * Functions
1370  ********************************
1371 */
1372 
1373 /* Handles configuration/setting of core options.
1374  * Should be called as early as possible - ideally inside
1375  * retro_set_environment(), and no later than retro_load_game()
1376  * > We place the function body in the header to avoid the
1377  *   necessity of adding more .c files (i.e. want this to
1378  *   be as painless as possible for core devs)
1379  */
1380 
libretro_set_core_options(retro_environment_t environ_cb)1381 static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
1382 {
1383    unsigned version = 0;
1384 
1385    if (!environ_cb)
1386       return;
1387 
1388    if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1))
1389    {
1390 #ifndef HAVE_NO_LANGEXTRA
1391       struct retro_core_options_intl core_options_intl;
1392       unsigned language = 0;
1393 
1394       core_options_intl.us    = option_defs_us;
1395       core_options_intl.local = NULL;
1396 
1397       if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
1398           (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
1399          core_options_intl.local = option_defs_intl[language];
1400 
1401       environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
1402 #else
1403       environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
1404 #endif
1405    }
1406    else
1407    {
1408       size_t i;
1409       size_t num_options               = 0;
1410       struct retro_variable *variables = NULL;
1411       char **values_buf                = NULL;
1412 
1413       /* Determine number of options */
1414       while (true)
1415       {
1416          if (option_defs_us[num_options].key)
1417             num_options++;
1418          else
1419             break;
1420       }
1421 
1422       /* Allocate arrays */
1423       variables  = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
1424       values_buf = (char **)calloc(num_options, sizeof(char *));
1425 
1426       if (!variables || !values_buf)
1427          goto error;
1428 
1429       /* Copy parameters from option_defs_us array */
1430       for (i = 0; i < num_options; i++)
1431       {
1432          const char *key                        = option_defs_us[i].key;
1433          const char *desc                       = option_defs_us[i].desc;
1434          const char *default_value              = option_defs_us[i].default_value;
1435          struct retro_core_option_value *values = option_defs_us[i].values;
1436          size_t buf_len                         = 3;
1437          size_t default_index                   = 0;
1438 
1439          values_buf[i] = NULL;
1440 
1441          if (desc)
1442          {
1443             size_t num_values = 0;
1444 
1445             /* Determine number of values */
1446             while (true)
1447             {
1448                if (values[num_values].value)
1449                {
1450                   /* Check if this is the default value */
1451                   if (default_value)
1452                      if (strcmp(values[num_values].value, default_value) == 0)
1453                         default_index = num_values;
1454 
1455                   buf_len += strlen(values[num_values].value);
1456                   num_values++;
1457                }
1458                else
1459                   break;
1460             }
1461 
1462             /* Build values string */
1463             if (num_values > 0)
1464             {
1465                size_t j;
1466 
1467                buf_len += num_values - 1;
1468                buf_len += strlen(desc);
1469 
1470                values_buf[i] = (char *)calloc(buf_len, sizeof(char));
1471                if (!values_buf[i])
1472                   goto error;
1473 
1474                strcpy(values_buf[i], desc);
1475                strcat(values_buf[i], "; ");
1476 
1477                /* Default value goes first */
1478                strcat(values_buf[i], values[default_index].value);
1479 
1480                /* Add remaining values */
1481                for (j = 0; j < num_values; j++)
1482                {
1483                   if (j != default_index)
1484                   {
1485                      strcat(values_buf[i], "|");
1486                      strcat(values_buf[i], values[j].value);
1487                   }
1488                }
1489             }
1490          }
1491 
1492          variables[i].key   = key;
1493          variables[i].value = values_buf[i];
1494       }
1495 
1496       /* Set variables */
1497       environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
1498 
1499 error:
1500 
1501       /* Clean up */
1502       if (values_buf)
1503       {
1504          for (i = 0; i < num_options; i++)
1505          {
1506             if (values_buf[i])
1507             {
1508                free(values_buf[i]);
1509                values_buf[i] = NULL;
1510             }
1511          }
1512 
1513          free(values_buf);
1514          values_buf = NULL;
1515       }
1516 
1517       if (variables)
1518       {
1519          free(variables);
1520          variables = NULL;
1521       }
1522    }
1523 }
1524 
1525 #ifdef __cplusplus
1526 }
1527 #endif
1528 
1529 #endif
1530