#ifndef LIBRETRO_CORE_OPTIONS_H__ #define LIBRETRO_CORE_OPTIONS_H__ #include #include #include #include #ifndef HAVE_NO_LANGEXTRA #include "libretro_core_options_intl.h" #endif /* ******************************** * VERSION: 2.0 ******************************** * * - 2.0: Migrate to core options v2 with categories * and visibility callback support * - 1.3: Move translations to libretro_core_options_intl.h * - 1.0: First commit */ #ifdef __cplusplus extern "C" { #endif /* ******************************** * Core Option Categories ******************************** */ static struct retro_core_option_v2_category option_cats_us[] = { { "system", "System", "System hardware and region settings" }, { "video", "Video", "Display and rendering settings" }, { "hacks", "Hacks", "Performance hacks and accuracy trade-offs" }, { NULL, NULL, NULL }, }; /* ******************************** * Core Option Definitions (v2) ******************************** */ static struct retro_core_option_v2_definition option_defs_us[] = { /* System */ { "geolith_system_type", "System Type (Restart)", "System Type", "Specify the System Type: AES, MVS, or Universe BIOS System", NULL, "system", { { "aes", "Neo Geo AES (Home Console)" }, { "mvs", "Neo Geo MVS (Arcade)" }, { "uni", "Universe BIOS (Community-enhanced BIOS)" }, { NULL, NULL }, }, "aes" }, { "geolith_unibios_hw", "Universe BIOS Hardware (Restart)", "Universe BIOS Hardware", "Specify the hardware the Universe BIOS should detect", NULL, "system", { { "aes", "Neo Geo AES (Home Console)" }, { "mvs", "Neo Geo MVS (Arcade)" }, { NULL, NULL }, }, "mvs" }, { "geolith_cd_system_type", "CD System Type (Restart)", "CD System Type", "Specify the CD System Type when loading Neo Geo CD disc images", NULL, "system", { { "cd_front", "Neo Geo CD (Front Loader)" }, { "cd_top", "Neo Geo CD (Top Loader)" }, { "cdz", "Neo Geo CDZ" }, { "cdz_unibios", "Neo Geo CDZ (Universe BIOS)" }, { NULL, NULL }, }, "cdz" }, { "geolith_region", "Region (Restart)", "Region", "Specify the Region: USA, Japan, Asia, Europe", NULL, "system", { { "us", "USA" }, { "jp", "Japan" }, { "as", "Asia" }, { "eu", "Europe" }, { NULL, NULL }, }, "us" }, { "geolith_memcard", "Memory Card", NULL, "Enable or Disable the Memory Card", NULL, "system", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "on" }, { "geolith_memcard_wp", "Memory Card Write Protect", NULL, "Enable or Disable the Memory Card Write Protect pin", NULL, "system", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "off" }, { "geolith_settingmode", "Setting Mode (Restart, DIP Switch)", "Setting Mode", "Bring up the System ROM menu at boot on arcade systems", NULL, "system", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "off" }, { "geolith_4player", "Four Player Mode (Restart, Asia/Japan MVS Only)", "Four Player Mode", "Set Four Player (dual MVS cabinet) mode for Asia/Japan MVS systems", NULL, "system", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "off" }, { "geolith_freeplay", "Freeplay (DIP Switch)", "Freeplay", "Play MVS games without the need to insert coins", NULL, "system", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "off" }, /* Video */ { "geolith_overscan_t", "Mask Overscan (Top)", NULL, "Mask off pixels hidden by a bezel or border on original CRTs (top)", NULL, "video", { { "16", NULL }, { "12", NULL }, { "8", NULL }, { "4", NULL }, { "0", NULL }, { NULL, NULL }, }, "8" }, { "geolith_overscan_b", "Mask Overscan (Bottom)", NULL, "Mask off pixels hidden by a bezel or border on original CRTs (bottom)", NULL, "video", { { "16", NULL }, { "12", NULL }, { "8", NULL }, { "4", NULL }, { "0", NULL }, { NULL, NULL }, }, "8" }, { "geolith_overscan_l", "Mask Overscan (Left)", NULL, "Mask off pixels hidden by a bezel or border on original CRTs (left)", NULL, "video", { { "16", NULL }, { "12", NULL }, { "8", NULL }, { "4", NULL }, { "0", NULL }, { NULL, NULL }, }, "8" }, { "geolith_overscan_r", "Mask Overscan (Right)", NULL, "Mask off pixels hidden by a bezel or border on original CRTs (right)", NULL, "video", { { "16", NULL }, { "12", NULL }, { "8", NULL }, { "4", NULL }, { "0", NULL }, { NULL, NULL }, }, "8" }, { "geolith_palette", "Palette", NULL, "Set the Palette", NULL, "video", { { "resnet", "Resistor Network" }, { "raw", "Raw" }, { NULL, NULL }, }, "resnet" }, { "geolith_aspect", "Aspect Ratio", NULL, "Set the Aspect Ratio", NULL, "video", { { "1:1", "Perfectly Square Pixels (1:1 PAR)" }, { "45:44", "Ostensibly Accurate NTSC Aspect Ratio (45:44 PAR)" }, { "4:3", "Very Traditional NTSC Aspect Ratio (4:3 DAR)" }, { NULL, NULL }, }, "1:1" }, /* Hacks */ { "geolith_sprlimit", "Sprites-per-line limit (Hack)", "Sprites-per-line Limit", "Set the sprites-per-line limit - increasing causes glitches in some games", NULL, "hacks", { { "96", "Hardware Accurate (96)" }, { "192", "Double (192)" }, { "288", "Triple (288)" }, { "381", "MAX 381 MEGA PRO-GEAR SPEC" }, { NULL, NULL }, }, "96" }, { "geolith_oc", "Overclocking (Hack)", "Overclocking", "Annihilate your accuracy with The 24MHz Shock - expect glitches", NULL, "hacks", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "off" }, { "geolith_disable_adpcm_wrap", "Disable ADPCM Accumulator Wrap (Hack)", "Disable ADPCM Accumulator Wrap", "ADPCM Accumulator Wrap may be disabled to fix sound effects in buggy " "games, for example Ganryu and Nightmare in the Dark. This is a hack, " "and should remain Off for most games.", NULL, "hacks", { { "off", "Off" }, { "on", "On" }, { NULL, NULL }, }, "off" }, { "geolith_cd_speed_hack", "CD Speed Hack", NULL, "Patch BIOS busy-wait loops to reduce loading times (Does not work for " "Universe BIOS)", NULL, "hacks", { { "enabled", "Enabled" }, { "disabled", "Disabled" }, { NULL, NULL }, }, "disabled" }, { "geolith_cd_dma_len_limit", "CD DMA Length Limit", NULL, "Correct the BIOS upload pointers when a CD buffer DMA is larger than " "one sector, fixing corrupted sound in Art of Fighting's bonus stage. " "This is a hack, and real hardware behaviour is unconfirmed.", NULL, "hacks", { { "enabled", "Enabled" }, { "disabled", "Disabled" }, { NULL, NULL }, }, "disabled" }, { "geolith_cd_skip_loading", "Skip CD Loading", NULL, "Fast-forward through CD loading screens", NULL, "hacks", { { "enabled", "Enabled" }, { "disabled", "Disabled" }, { NULL, NULL }, }, "disabled" }, { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }, }; static struct retro_core_options_v2 options_us = { option_cats_us, option_defs_us, }; /* ******************************** * Language Mapping ******************************** */ #ifndef HAVE_NO_LANGEXTRA static struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = { &options_us, /* RETRO_LANGUAGE_ENGLISH */ NULL, /* RETRO_LANGUAGE_JAPANESE */ NULL, /* RETRO_LANGUAGE_FRENCH */ NULL, /* RETRO_LANGUAGE_SPANISH */ NULL, /* RETRO_LANGUAGE_GERMAN */ NULL, /* RETRO_LANGUAGE_ITALIAN */ NULL, /* RETRO_LANGUAGE_DUTCH */ NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ NULL, /* RETRO_LANGUAGE_RUSSIAN */ NULL, /* RETRO_LANGUAGE_KOREAN */ NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ NULL, /* RETRO_LANGUAGE_ESPERANTO */ NULL, /* RETRO_LANGUAGE_POLISH */ NULL, /* RETRO_LANGUAGE_VIETNAMESE */ NULL, /* RETRO_LANGUAGE_ARABIC */ NULL, /* RETRO_LANGUAGE_GREEK */ NULL, /* RETRO_LANGUAGE_TURKISH */ NULL, /* RETRO_LANGUAGE_SLOVAK */ NULL, /* RETRO_LANGUAGE_PERSIAN */ NULL, /* RETRO_LANGUAGE_HEBREW */ NULL, /* RETRO_LANGUAGE_ASTURIAN */ NULL, /* RETRO_LANGUAGE_FINNISH */ }; #endif /* ******************************** * Functions ******************************** */ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) { unsigned version = 0; if (!environ_cb) return; if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 2)) { #ifndef HAVE_NO_LANGEXTRA struct retro_core_options_v2_intl core_options_intl; unsigned language = 0; core_options_intl.us = &options_us; core_options_intl.local = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH)) core_options_intl.local = options_intl[language]; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL, &core_options_intl); #else environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, &options_us); #endif } else if (version >= 1) { /* Build v1 option definitions from v2 (strip category fields) */ size_t i; size_t num_options = 0; struct retro_core_option_definition *option_v1 = NULL; for (;;) { if (!option_defs_us[num_options].key) break; num_options++; } option_v1 = (struct retro_core_option_definition *) calloc(num_options + 1, sizeof(struct retro_core_option_definition)); if (!option_v1) return; for (i = 0; i < num_options; i++) { option_v1[i].key = option_defs_us[i].key; option_v1[i].desc = option_defs_us[i].desc; option_v1[i].info = option_defs_us[i].info; option_v1[i].default_value = option_defs_us[i].default_value; memcpy(option_v1[i].values, option_defs_us[i].values, sizeof(option_v1[i].values)); } #ifndef HAVE_NO_LANGEXTRA { struct retro_core_options_intl core_options_intl; core_options_intl.us = option_v1; core_options_intl.local = NULL; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl); } #else environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_v1); #endif free(option_v1); } else { size_t i; size_t num_options = 0; struct retro_variable *variables = NULL; char **values_buf = NULL; /* Determine number of options */ for (;;) { if (!option_defs_us[num_options].key) break; num_options++; } /* Allocate arrays */ variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable)); values_buf = (char **)calloc(num_options, sizeof(char *)); if (!variables || !values_buf) goto error; /* Copy parameters from option_defs_us array */ for (i = 0; i < num_options; i++) { const char *key = option_defs_us[i].key; const char *desc = option_defs_us[i].desc; const char *default_value = option_defs_us[i].default_value; struct retro_core_option_value *values = option_defs_us[i].values; size_t buf_len = 3; size_t default_index = 0; values_buf[i] = NULL; if (desc) { size_t num_values = 0; /* Determine number of values */ for (;;) { if (!values[num_values].value) break; /* Check if this is the default value */ if (default_value) if (strcmp(values[num_values].value, default_value) == 0) default_index = num_values; buf_len += strlen(values[num_values].value); num_values++; } /* Build values string */ if (num_values > 0) { size_t j; buf_len += num_values - 1; buf_len += strlen(desc); values_buf[i] = (char *)calloc(buf_len, sizeof(char)); if (!values_buf[i]) goto error; strcpy(values_buf[i], desc); strcat(values_buf[i], "; "); /* Default value goes first */ strcat(values_buf[i], values[default_index].value); /* Add remaining values */ for (j = 0; j < num_values; j++) { if (j != default_index) { strcat(values_buf[i], "|"); strcat(values_buf[i], values[j].value); } } } } variables[i].key = key; variables[i].value = values_buf[i]; } /* Set variables */ environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); error: /* Clean up */ if (values_buf) { for (i = 0; i < num_options; i++) { if (values_buf[i]) { free(values_buf[i]); values_buf[i] = NULL; } } free(values_buf); values_buf = NULL; } if (variables) { free(variables); variables = NULL; } } } #ifdef __cplusplus } #endif #endif