Merge pull request #194 from jdgleaver/core-options-v2

Add core options v2 support
This commit is contained in:
Autechre 2021-08-09 14:19:08 +02:00 committed by GitHub
commit 9d08b04317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1010 additions and 117 deletions

View File

@ -1131,6 +1131,13 @@ enum retro_mod
* retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
* This allows the core to additionally set option sublabel information
* and/or provide localisation support.
*
* If version is >= 2, core options may instead be set by passing
* a retro_core_options_v2 struct to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
* or an array of retro_core_options_v2 structs to
* RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL. This allows the core
* to additionally set optional core option category information
* for frontends with core option category support.
*/
#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 53
@ -1172,7 +1179,7 @@ enum retro_mod
* default value is NULL, the first entry in the
* retro_core_option_definition::values array is treated as the default.
*
* The number of possible options should be very limited,
* The number of possible option values should be very limited,
* and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
* i.e. it should be feasible to cycle through options
* without a keyboard.
@ -1205,6 +1212,7 @@ enum retro_mod
* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
* returns an API version of >= 1.
* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
* This should be called the first time as early as
* possible (ideally in retro_set_environment).
* Afterwards it may be called again for the core to communicate
@ -1388,6 +1396,322 @@ enum retro_mod
* fastforwarding state will occur in this case).
*/
#define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 65
/* const struct retro_system_content_info_override * --
* Allows an implementation to override 'global' content
* info parameters reported by retro_get_system_info().
* Overrides also affect subsystem content info parameters
* set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO.
* This function must be called inside retro_set_environment().
* If callback returns false, content info overrides
* are unsupported by the frontend, and will be ignored.
* If callback returns true, extended game info may be
* retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
* in retro_load_game() or retro_load_game_special().
*
* 'data' points to an array of retro_system_content_info_override
* structs terminated by a { NULL, false, false } element.
* If 'data' is NULL, no changes will be made to the frontend;
* a core may therefore pass NULL in order to test whether
* the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and
* RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported
* by the frontend.
*
* For struct member descriptions, see the definition of
* struct retro_system_content_info_override.
*
* Example:
*
* - struct retro_system_info:
* {
* "My Core", // library_name
* "v1.0", // library_version
* "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions
* true, // need_fullpath
* false // block_extract
* }
*
* - Array of struct retro_system_content_info_override:
* {
* {
* "md|sms|gg", // extensions
* false, // need_fullpath
* true // persistent_data
* },
* {
* "sg", // extensions
* false, // need_fullpath
* false // persistent_data
* },
* { NULL, false, false }
* }
*
* Result:
* - Files of type m3u, cue, iso, chd will not be
* loaded by the frontend. Frontend will pass a
* valid path to the core, and core will handle
* loading internally
* - Files of type md, sms, gg will be loaded by
* the frontend. A valid memory buffer will be
* passed to the core. This memory buffer will
* remain valid until retro_deinit() returns
* - Files of type sg will be loaded by the frontend.
* A valid memory buffer will be passed to the core.
* This memory buffer will remain valid until
* retro_load_game() (or retro_load_game_special())
* returns
*
* NOTE: If an extension is listed multiple times in
* an array of retro_system_content_info_override
* structs, only the first instance will be registered
*/
#define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 66
/* const struct retro_game_info_ext ** --
* Allows an implementation to fetch extended game
* information, providing additional content path
* and memory buffer status details.
* This function may only be called inside
* retro_load_game() or retro_load_game_special().
* If callback returns false, extended game information
* is unsupported by the frontend. In this case, only
* regular retro_game_info will be available.
* RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed
* to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
* returns true.
*
* 'data' points to an array of retro_game_info_ext structs.
*
* For struct member descriptions, see the definition of
* struct retro_game_info_ext.
*
* - If function is called inside retro_load_game(),
* the retro_game_info_ext array is guaranteed to
* have a size of 1 - i.e. the returned pointer may
* be used to access directly the members of the
* first retro_game_info_ext struct, for example:
*
* struct retro_game_info_ext *game_info_ext;
* if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext))
* printf("Content Directory: %s\n", game_info_ext->dir);
*
* - If the function is called inside retro_load_game_special(),
* the retro_game_info_ext array is guaranteed to have a
* size equal to the num_info argument passed to
* retro_load_game_special()
*/
#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 67
/* const struct retro_core_options_v2 * --
* Allows an implementation to signal the environment
* which variables it might want to check for later using
* GET_VARIABLE.
* This allows the frontend to present these variables to
* a user dynamically.
* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
* returns an API version of >= 2.
* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
* This should be called the first time as early as
* possible (ideally in retro_set_environment).
* Afterwards it may be called again for the core to communicate
* updated options to the frontend, but the number of core
* options must not change from the number in the initial call.
* If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
* version of >= 2, this callback is guaranteed to succeed
* (i.e. callback return value does not indicate success)
* If callback returns true, frontend has core option category
* support.
* If callback returns false, frontend does not have core option
* category support.
*
* 'data' points to a retro_core_options_v2 struct, containing
* of two pointers:
* - retro_core_options_v2::categories is an array of
* retro_core_option_v2_category structs terminated by a
* { NULL, NULL, NULL } element. If retro_core_options_v2::categories
* is NULL, all core options will have no category and will be shown
* at the top level of the frontend core option interface. If frontend
* does not have core option category support, categories array will
* be ignored.
* - retro_core_options_v2::definitions is an array of
* retro_core_option_v2_definition structs terminated by a
* { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }
* element.
*
* >> retro_core_option_v2_category notes:
*
* - retro_core_option_v2_category::key should contain string
* that uniquely identifies the core option category. Valid
* key characters are [a-z, A-Z, 0-9, _, -]
* Namespace collisions with other implementations' category
* keys are permitted.
* - retro_core_option_v2_category::desc should contain a human
* readable description of the category key.
* - retro_core_option_v2_category::info should contain any
* additional human readable information text that a typical
* user may need to understand the nature of the core option
* category.
*
* Example entry:
* {
* "advanced_settings",
* "Advanced",
* "Options affecting low-level emulation performance and accuracy."
* }
*
* >> retro_core_option_v2_definition notes:
*
* - retro_core_option_v2_definition::key should be namespaced to not
* collide with other implementations' keys. e.g. A core called
* 'foo' should use keys named as 'foo_option'. Valid key characters
* are [a-z, A-Z, 0-9, _, -].
* - retro_core_option_v2_definition::desc should contain a human readable
* description of the key. Will be used when the frontend does not
* have core option category support. Examples: "Aspect Ratio" or
* "Video > Aspect Ratio".
* - retro_core_option_v2_definition::desc_categorized should contain a
* human readable description of the key, which will be used when
* frontend has core option category support. Example: "Aspect Ratio",
* where associated retro_core_option_v2_category::desc is "Video".
* If empty or NULL, the string specified by
* retro_core_option_v2_definition::desc will be used instead.
* retro_core_option_v2_definition::desc_categorized will be ignored
* if retro_core_option_v2_definition::category_key is empty or NULL.
* - retro_core_option_v2_definition::info should contain any additional
* human readable information text that a typical user may need to
* understand the functionality of the option.
* - retro_core_option_v2_definition::info_categorized should contain
* any additional human readable information text that a typical user
* may need to understand the functionality of the option, and will be
* used when frontend has core option category support. This is provided
* to accommodate the case where info text references an option by
* name/desc, and the desc/desc_categorized text for that option differ.
* If empty or NULL, the string specified by
* retro_core_option_v2_definition::info will be used instead.
* retro_core_option_v2_definition::info_categorized will be ignored
* if retro_core_option_v2_definition::category_key is empty or NULL.
* - retro_core_option_v2_definition::category_key should contain a
* category identifier (e.g. "video" or "audio") that will be
* assigned to the core option if frontend has core option category
* support. A categorized option will be shown in a subsection/
* submenu of the frontend core option interface. If key is empty
* or NULL, or if key does not match one of the
* retro_core_option_v2_category::key values in the associated
* retro_core_option_v2_category array, option will have no category
* and will be shown at the top level of the frontend core option
* interface.
* - retro_core_option_v2_definition::values is an array of
* retro_core_option_value structs terminated by a { NULL, NULL }
* element.
* --> retro_core_option_v2_definition::values[index].value is an
* expected option value.
* --> retro_core_option_v2_definition::values[index].label is a
* human readable label used when displaying the value on screen.
* If NULL, the value itself is used.
* - retro_core_option_v2_definition::default_value is the default
* core option setting. It must match one of the expected option
* values in the retro_core_option_v2_definition::values array. If
* it does not, or the default value is NULL, the first entry in the
* retro_core_option_v2_definition::values array is treated as the
* default.
*
* The number of possible option values should be very limited,
* and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
* i.e. it should be feasible to cycle through options
* without a keyboard.
*
* Example entries:
*
* - Uncategorized:
*
* {
* "foo_option",
* "Speed hack coprocessor X",
* NULL,
* "Provides increased performance at the expense of reduced accuracy.",
* NULL,
* NULL,
* {
* { "false", NULL },
* { "true", NULL },
* { "unstable", "Turbo (Unstable)" },
* { NULL, NULL },
* },
* "false"
* }
*
* - Categorized:
*
* {
* "foo_option",
* "Advanced > Speed hack coprocessor X",
* "Speed hack coprocessor X",
* "Setting 'Advanced > Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
* "Setting 'Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
* "advanced_settings",
* {
* { "false", NULL },
* { "true", NULL },
* { "unstable", "Turbo (Unstable)" },
* { NULL, NULL },
* },
* "false"
* }
*
* Only strings are operated on. The possible values will
* generally be displayed and stored as-is by the frontend.
*/
#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 68
/* const struct retro_core_options_v2_intl * --
* Allows an implementation to signal the environment
* which variables it might want to check for later using
* GET_VARIABLE.
* This allows the frontend to present these variables to
* a user dynamically.
* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
* returns an API version of >= 2.
* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2.
* This should be called the first time as early as
* possible (ideally in retro_set_environment).
* Afterwards it may be called again for the core to communicate
* updated options to the frontend, but the number of core
* options must not change from the number in the initial call.
* If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
* version of >= 2, this callback is guaranteed to succeed
* (i.e. callback return value does not indicate success)
* If callback returns true, frontend has core option category
* support.
* If callback returns false, frontend does not have core option
* category support.
*
* This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
* with the addition of localisation support. The description of the
* RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 callback should be consulted
* for further details.
*
* 'data' points to a retro_core_options_v2_intl struct.
*
* - retro_core_options_v2_intl::us is a pointer to a
* retro_core_options_v2 struct defining the US English
* core options implementation. It must point to a valid struct.
*
* - retro_core_options_v2_intl::local is a pointer to a
* retro_core_options_v2 struct defining core options for
* the current frontend language. It may be NULL (in which case
* retro_core_options_v2_intl::us is used by the frontend). Any items
* missing from this struct will be read from
* retro_core_options_v2_intl::us instead.
*
* NOTE: Default core option values are always taken from the
* retro_core_options_v2_intl::us struct. Any default values in
* the retro_core_options_v2_intl::local struct will be ignored.
*/
/* VFS functionality */
/* File paths:
@ -2791,6 +3115,213 @@ struct retro_system_info
bool block_extract;
};
/* Defines overrides which modify frontend handling of
* specific content file types.
* An array of retro_system_content_info_override is
* passed to RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
* NOTE: In the following descriptions, references to
* retro_load_game() may be replaced with
* retro_load_game_special() */
struct retro_system_content_info_override
{
/* A list of file extensions for which the override
* should apply, delimited by a 'pipe' character
* (e.g. "md|sms|gg")
* Permitted file extensions are limited to those
* included in retro_system_info::valid_extensions
* and/or retro_subsystem_rom_info::valid_extensions */
const char *extensions;
/* Overrides the need_fullpath value set in
* retro_system_info and/or retro_subsystem_rom_info.
* To reiterate:
*
* If need_fullpath is true and retro_load_game() is called:
* - retro_game_info::path is guaranteed to contain a valid
* path to an existent file
* - retro_game_info::data and retro_game_info::size are invalid
*
* If need_fullpath is false and retro_load_game() is called:
* - retro_game_info::path may be NULL
* - retro_game_info::data and retro_game_info::size are guaranteed
* to be valid
*
* In addition:
*
* If need_fullpath is true and retro_load_game() is called:
* - retro_game_info_ext::full_path is guaranteed to contain a valid
* path to an existent file
* - retro_game_info_ext::archive_path may be NULL
* - retro_game_info_ext::archive_file may be NULL
* - retro_game_info_ext::dir is guaranteed to contain a valid path
* to the directory in which the content file exists
* - retro_game_info_ext::name is guaranteed to contain the
* basename of the content file, without extension
* - retro_game_info_ext::ext is guaranteed to contain the
* extension of the content file in lower case format
* - retro_game_info_ext::data and retro_game_info_ext::size
* are invalid
*
* If need_fullpath is false and retro_load_game() is called:
* - If retro_game_info_ext::file_in_archive is false:
* - retro_game_info_ext::full_path is guaranteed to contain
* a valid path to an existent file
* - retro_game_info_ext::archive_path may be NULL
* - retro_game_info_ext::archive_file may be NULL
* - retro_game_info_ext::dir is guaranteed to contain a
* valid path to the directory in which the content file exists
* - retro_game_info_ext::name is guaranteed to contain the
* basename of the content file, without extension
* - retro_game_info_ext::ext is guaranteed to contain the
* extension of the content file in lower case format
* - If retro_game_info_ext::file_in_archive is true:
* - retro_game_info_ext::full_path may be NULL
* - retro_game_info_ext::archive_path is guaranteed to
* contain a valid path to an existent compressed file
* inside which the content file is located
* - retro_game_info_ext::archive_file is guaranteed to
* contain a valid path to an existent content file
* inside the compressed file referred to by
* retro_game_info_ext::archive_path
* e.g. for a compressed file '/path/to/foo.zip'
* containing 'bar.sfc'
* > retro_game_info_ext::archive_path will be '/path/to/foo.zip'
* > retro_game_info_ext::archive_file will be 'bar.sfc'
* - retro_game_info_ext::dir is guaranteed to contain a
* valid path to the directory in which the compressed file
* (containing the content file) exists
* - retro_game_info_ext::name is guaranteed to contain
* EITHER
* 1) the basename of the compressed file (containing
* the content file), without extension
* OR
* 2) the basename of the content file inside the
* compressed file, without extension
* In either case, a core should consider 'name' to
* be the canonical name/ID of the the content file
* - retro_game_info_ext::ext is guaranteed to contain the
* extension of the content file inside the compressed file,
* in lower case format
* - retro_game_info_ext::data and retro_game_info_ext::size are
* guaranteed to be valid */
bool need_fullpath;
/* If need_fullpath is false, specifies whether the content
* data buffer available in retro_load_game() is 'persistent'
*
* If persistent_data is false and retro_load_game() is called:
* - retro_game_info::data and retro_game_info::size
* are valid only until retro_load_game() returns
* - retro_game_info_ext::data and retro_game_info_ext::size
* are valid only until retro_load_game() returns
*
* If persistent_data is true and retro_load_game() is called:
* - retro_game_info::data and retro_game_info::size
* are valid until retro_deinit() returns
* - retro_game_info_ext::data and retro_game_info_ext::size
* are valid until retro_deinit() returns */
bool persistent_data;
};
/* Similar to retro_game_info, but provides extended
* information about the source content file and
* game memory buffer status.
* And array of retro_game_info_ext is returned by
* RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
* NOTE: In the following descriptions, references to
* retro_load_game() may be replaced with
* retro_load_game_special() */
struct retro_game_info_ext
{
/* - If file_in_archive is false, contains a valid
* path to an existent content file (UTF-8 encoded)
* - If file_in_archive is true, may be NULL */
const char *full_path;
/* - If file_in_archive is false, may be NULL
* - If file_in_archive is true, contains a valid path
* to an existent compressed file inside which the
* content file is located (UTF-8 encoded) */
const char *archive_path;
/* - If file_in_archive is false, may be NULL
* - If file_in_archive is true, contain a valid path
* to an existent content file inside the compressed
* file referred to by archive_path (UTF-8 encoded)
* e.g. for a compressed file '/path/to/foo.zip'
* containing 'bar.sfc'
* > archive_path will be '/path/to/foo.zip'
* > archive_file will be 'bar.sfc' */
const char *archive_file;
/* - If file_in_archive is false, contains a valid path
* to the directory in which the content file exists
* (UTF-8 encoded)
* - If file_in_archive is true, contains a valid path
* to the directory in which the compressed file
* (containing the content file) exists (UTF-8 encoded) */
const char *dir;
/* Contains the canonical name/ID of the content file
* (UTF-8 encoded). Intended for use when identifying
* 'complementary' content named after the loaded file -
* i.e. companion data of a different format (a CD image
* required by a ROM), texture packs, internally handled
* save files, etc.
* - If file_in_archive is false, contains the basename
* of the content file, without extension
* - If file_in_archive is true, then string is
* implementation specific. A frontend may choose to
* set a name value of:
* EITHER
* 1) the basename of the compressed file (containing
* the content file), without extension
* OR
* 2) the basename of the content file inside the
* compressed file, without extension
* RetroArch sets the 'name' value according to (1).
* A frontend that supports routine loading of
* content from archives containing multiple unrelated
* content files may set the 'name' value according
* to (2). */
const char *name;
/* - If file_in_archive is false, contains the extension
* of the content file in lower case format
* - If file_in_archive is true, contains the extension
* of the content file inside the compressed file,
* in lower case format */
const char *ext;
/* String of implementation specific meta-data. */
const char *meta;
/* Memory buffer of loaded game content. Will be NULL:
* IF
* - retro_system_info::need_fullpath is true and
* retro_system_content_info_override::need_fullpath
* is unset
* OR
* - retro_system_content_info_override::need_fullpath
* is true */
const void *data;
/* Size of game content memory buffer, in bytes */
size_t size;
/* True if loaded content file is inside a compressed
* archive */
bool file_in_archive;
/* - If data is NULL, value is unset/ignored
* - If data is non-NULL:
* - If persistent_data is false, data and size are
* valid only until retro_load_game() returns
* - If persistent_data is true, data and size are
* are valid until retro_deinit() returns */
bool persistent_data;
};
struct retro_game_geometry
{
unsigned base_width; /* Nominal video width of game. */
@ -2902,6 +3433,124 @@ struct retro_core_options_intl
struct retro_core_option_definition *local;
};
struct retro_core_option_v2_category
{
/* Variable uniquely identifying the
* option category. Valid key characters
* are [a-z, A-Z, 0-9, _, -] */
const char *key;
/* Human-readable category description
* > Used as category menu label when
* frontend has core option category
* support */
const char *desc;
/* Human-readable category information
* > Used as category menu sublabel when
* frontend has core option category
* support
* > Optional (may be NULL or an empty
* string) */
const char *info;
};
struct retro_core_option_v2_definition
{
/* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
* Valid key characters are [a-z, A-Z, 0-9, _, -] */
const char *key;
/* Human-readable core option description
* > Used as menu label when frontend does
* not have core option category support
* e.g. "Video > Aspect Ratio" */
const char *desc;
/* Human-readable core option description
* > Used as menu label when frontend has
* core option category support
* e.g. "Aspect Ratio", where associated
* retro_core_option_v2_category::desc
* is "Video"
* > If empty or NULL, the string specified by
* desc will be used as the menu label
* > Will be ignored (and may be set to NULL)
* if category_key is empty or NULL */
const char *desc_categorized;
/* Human-readable core option information
* > Used as menu sublabel */
const char *info;
/* Human-readable core option information
* > Used as menu sublabel when frontend
* has core option category support
* (e.g. may be required when info text
* references an option by name/desc,
* and the desc/desc_categorized text
* for that option differ)
* > If empty or NULL, the string specified by
* info will be used as the menu sublabel
* > Will be ignored (and may be set to NULL)
* if category_key is empty or NULL */
const char *info_categorized;
/* Variable specifying category (e.g. "video",
* "audio") that will be assigned to the option
* if frontend has core option category support.
* > Categorized options will be displayed in a
* subsection/submenu of the frontend core
* option interface
* > Specified string must match one of the
* retro_core_option_v2_category::key values
* in the associated retro_core_option_v2_category
* array; If no match is not found, specified
* string will be considered as NULL
* > If specified string is empty or NULL, option will
* have no category and will be shown at the top
* level of the frontend core option interface */
const char *category_key;
/* Array of retro_core_option_value structs, terminated by NULL */
struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
/* Default core option value. Must match one of the values
* in the retro_core_option_value array, otherwise will be
* ignored */
const char *default_value;
};
struct retro_core_options_v2
{
/* Array of retro_core_option_v2_category structs,
* terminated by NULL
* > If NULL, all entries in definitions array
* will have no category and will be shown at
* the top level of the frontend core option
* interface
* > Will be ignored if frontend does not have
* core option category support */
struct retro_core_option_v2_category *categories;
/* Array of retro_core_option_v2_definition structs,
* terminated by NULL */
struct retro_core_option_v2_definition *definitions;
};
struct retro_core_options_v2_intl
{
/* Pointer to a retro_core_options_v2 struct
* > US English implementation
* > Must point to a valid struct */
struct retro_core_options_v2 *us;
/* Pointer to a retro_core_options_v2 struct
* - Implementation for current frontend language
* - May be NULL */
struct retro_core_options_v2 *local;
};
struct retro_game_info
{
const char *path; /* Path to game, UTF-8 encoded.

View File

@ -41,10 +41,11 @@ static retro_environment_t environ_cb;
static gambatte::video_pixel_t* video_buf;
static gambatte::GB gb;
static bool libretro_supports_bitmasks = false;
static bool libretro_supports_ff_override = false;
static bool libretro_ff_enabled = false;
static bool libretro_ff_enabled_prev = false;
static bool libretro_supports_option_categories = false;
static bool libretro_supports_bitmasks = false;
static bool libretro_supports_ff_override = false;
static bool libretro_ff_enabled = false;
static bool libretro_ff_enabled_prev = false;
static bool show_gb_link_settings = true;
@ -996,10 +997,11 @@ void retro_deinit(void)
if (libretro_ff_enabled)
set_fastforward_override(false);
libretro_supports_bitmasks = false;
libretro_supports_ff_override = false;
libretro_ff_enabled = false;
libretro_ff_enabled_prev = false;
libretro_supports_option_categories = false;
libretro_supports_bitmasks = false;
libretro_supports_ff_override = false;
libretro_ff_enabled = false;
libretro_ff_enabled_prev = false;
libretro_input_state = 0;
up_down_allowed = false;
@ -1018,7 +1020,24 @@ void retro_set_environment(retro_environment_t cb)
struct retro_vfs_interface_info vfs_iface_info;
environ_cb = cb;
libretro_set_core_options(environ_cb);
/* Set core options */
libretro_supports_option_categories = false;
libretro_set_core_options(environ_cb,
&libretro_supports_option_categories);
/* If frontend supports core option categories,
* gambatte_show_gb_link_settings is unused and
* should be hidden */
if (libretro_supports_option_categories)
{
struct retro_core_option_display option_display;
option_display.visible = false;
option_display.key = "gambatte_show_gb_link_settings";
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY,
&option_display);
}
vfs_iface_info.required_interface_version = 1;
vfs_iface_info.iface = NULL;
@ -1481,12 +1500,16 @@ static void check_variables(void)
break;
}
/* Show/hide core options */
/* Show/hide core options
* > If frontend supports core option categories,
* then gambatte_show_gb_link_settings is ignored
* and no options should be hidden */
var.key = "gambatte_show_gb_link_settings";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
if (!libretro_supports_option_categories &&
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
bool show_gb_link_settings_prev = show_gb_link_settings;

View File

@ -13,9 +13,10 @@
/*
********************************
* VERSION: 1.3
* VERSION: 2.0
********************************
*
* - 2.0: Add support for core options v2 interface
* - 1.3: Move translations to libretro_core_options_intl.h
* - libretro_core_options_intl.h includes BOM and utf-8
* fix for MSVC 2010-2013
@ -48,11 +49,23 @@ extern "C" {
* - Will be used as a fallback for any missing entries in
* frontend language definition */
struct retro_core_option_definition option_defs_us[] = {
struct retro_core_option_v2_category option_cats_us[] = {
{
"gb_link",
"Game Boy Link",
"Configure networked 'Game Boy Link' (multiplayer) options."
},
{ NULL, NULL, NULL },
};
struct retro_core_option_v2_definition option_defs_us[] = {
{
"gambatte_gb_colorization",
"GB Colorization",
NULL,
"Enables colorization of Game Boy games. 'Auto' selects the 'best' (most colorful/appropriate) palette. 'GBC' selects game-specific Game Boy Color palette if defined, otherwise 'GBC - Dark Green'. 'SGB' selects game-specific Super Game Boy palette if defined, otherwise 'SGB - 1A', 'Internal' uses 'Internal Palette' core option. 'Custom' loads user-created palette from system directory.",
NULL,
NULL,
{
{ "disabled", NULL },
{ "auto", "Auto" },
@ -67,7 +80,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_internal_palette",
"Internal Palette",
NULL,
"Selects palette used for colorizing Game Boy games when 'GB Colorization' is set to 'Internal', or when 'GB Colorization' is set to 'Auto' and game has no pre-defined SGB/GBC palette. 'GB' palettes mimic the display of original Game Boy hardware. 'GBC' palettes are identical to the built-in presets of the Game Boy Color. 'SGB' palettes are identical to the built-in presets of the Super Game Boy.",
NULL,
NULL,
{
{ "GB - DMG", NULL },
{ "GB - Pocket", NULL },
@ -129,7 +145,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_palette_twb64_1",
"> TWB64 - Pack 1 Palette",
NULL,
"Selects internal colorization palette when 'Internal Palette' is set to 'TWB64 - Pack 1'.",
NULL,
NULL,
{
{ "TWB64 001 - Aqours Blue", NULL },
{ "TWB64 002 - Anime Expo Ver.", NULL },
@ -238,7 +257,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_palette_twb64_2",
"> TWB64 - Pack 2 Palette",
NULL,
"Selects internal colorization palette when 'Internal Palette' is set to 'TWB64 - Pack 2'.",
NULL,
NULL,
{
{ "TWB64 101 - 765PRO Pink", NULL },
{ "TWB64 102 - CINDERELLA Blue", NULL },
@ -347,7 +369,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gbc_color_correction",
"Color Correction",
NULL,
"Adjusts output colors to match the display of real Game Boy Color hardware. 'GBC Only' ensures that correction will only be applied when playing Game Boy Color games, or when using a Game Boy Color palette to colorize a Game Boy game. 'Always' applies color correction to all content, and will produce unexpected/suboptimal results when using 'GB' or 'SGB' internal color palettes.",
NULL,
NULL,
{
{ "GBC only", "GBC Only" },
{ "always", "Always" },
@ -359,7 +384,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gbc_color_correction_mode",
"Color Correction Mode",
NULL,
"Specifies method used when performing color correction. 'Accurate' produces output almost indistinguishable from a real Game Boy Color LCD panel. 'Fast' merely darkens colors and reduces saturation, and may be used on low-end hardware if the 'Accurate' method is too slow.",
NULL,
NULL,
{
{ "accurate", "Accurate" },
{ "fast", "Fast" },
@ -370,7 +398,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gbc_frontlight_position",
"Color Correction - Frontlight Position",
NULL,
"Simulates the physical response of the Game Boy Color LCD panel when illuminated from different angles. 'Central' represents standard color reproduction. 'Above Screen' increases brightness. 'Below Screen' reduces brightness. This setting only applies when 'Color Correction Mode' is set to 'Accurate'.",
NULL,
NULL,
{
{ "central", "Central" },
{ "above screen", "Above Screen" },
@ -382,7 +413,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_dark_filter_level",
"Dark Filter Level (percent)",
NULL,
"Enable luminosity-based brightness reduction. May be used to avoid glare/eye strain when playing games with white backgrounds, which are intended for display on a non-backlit Game Boy Color and can therefore appear uncomfortably bright when viewed on a modern backlit screen.",
NULL,
NULL,
{
{ "0", NULL },
{ "5", NULL },
@ -402,7 +436,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_hwmode",
"Emulated Hardware (restart)",
NULL,
"Specify which type of hardware to emulate. 'Auto' is recommended. Selecting 'GBA' unlocks extra features in certain 'GBA enhanced' Game Boy Color games (Shantae, Wendy - Every Witch Way, Legend of Zelda: Oracle of Seasons/Ages...).",
NULL,
NULL,
{
{ "Auto", NULL },
{ "GB", NULL },
@ -415,7 +452,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_bootloader",
"Use Official Bootloader (restart)",
NULL,
"Enable support for official Game Boy and Game Boy Color bootloaders, with corresponding start-up logo animations.",
NULL,
NULL,
{
{ "enabled", NULL },
{ "disabled", NULL },
@ -426,7 +466,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_mix_frames",
"Interframe Blending",
NULL,
"Simulates LCD ghosting effects. 'Simple' performs a 50:50 mix of the current and previous frames. 'LCD Ghosting' mimics natural LCD response times by combining multiple buffered frames. 'Simple' blending is required when playing games that rely on LCD ghosting for transparency effects (Wave Race, Ballistic, Chikyuu Kaihou Gun ZAS...).",
NULL,
NULL,
{
{ "disabled", NULL },
{ "mix", "Simple" },
@ -439,7 +482,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_up_down_allowed",
"Allow Opposing Directions",
NULL,
"Enabling this will allow pressing / quickly alternating / holding both left and right (or up and down) directions at the same time. This may cause movement-based glitches.",
NULL,
NULL,
{
{ "disabled", NULL },
{ "enabled", NULL },
@ -450,7 +496,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_turbo_period",
"Turbo Button Period",
NULL,
"Specify the repeat interval (in frames) when holding down the Turbo A/B buttons.",
NULL,
NULL,
{
{ "4", NULL },
{ "5", NULL },
@ -576,7 +625,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_rumble_level",
"Gamepad Rumble Strength",
NULL,
"Enables haptic feedback effects for supported games (Pokemon Pinball, Perfect Dark...).",
NULL,
NULL,
{
{ "0", NULL },
{ "1", NULL },
@ -597,7 +649,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_show_gb_link_settings",
"Show Game Boy Link Settings",
NULL,
"Enable configuration of networked 'Game Boy Link' (multiplayer) options. NOTE: Quick Menu must be toggled for this setting to take effect.",
NULL,
NULL,
{
{ "enabled", NULL },
{ "disabled", NULL },
@ -608,7 +663,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_mode",
"Game Boy Link Mode",
"Link Mode",
"When enabling networked 'Game Boy Link' functionality, specify whether current instance should run as a server or client.",
NULL,
"gb_link",
{
{ "Not Connected", NULL },
{ "Network Server", NULL },
@ -620,7 +678,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_port",
"Network Link Port",
"Port",
"Specify port used for 'Game Boy Link' network communication.",
NULL,
"gb_link",
{
{ "56400", NULL },
{ "56401", NULL },
@ -650,7 +711,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_1",
"Network Link Server Address Pt. 01: x__.___.___.___",
"Server Address Pt. 01: x__.___.___.___",
"1st digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"1st digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -669,7 +733,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_2",
"Network Link Server Address Pt. 02: _x_.___.___.___",
"Server Address Pt. 02: _x_.___.___.___",
"2nd digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"2nd digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -688,7 +755,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_3",
"Network Link Server Address Pt. 03: __x.___.___.___",
"Server Address Pt. 03: __x.___.___.___",
"3rd digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"3rd digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -707,7 +777,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_4",
"Network Link Server Address Pt. 04: ___.x__.___.___",
"Server Address Pt. 04: ___.x__.___.___",
"4th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"4th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -726,7 +799,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_5",
"Network Link Server Address Pt. 05: ___._x_.___.___",
"Server Address Pt. 05: ___._x_.___.___",
"5th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"5th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -745,7 +821,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_6",
"Network Link Server Address Pt. 06: ___.__x.___.___",
"Server Address Pt. 06: ___.__x.___.___",
"6th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"6th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -764,7 +843,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_7",
"Network Link Server Address Pt. 07: ___.___.x__.___",
"Server Address Pt. 07: ___.___.x__.___",
"7th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"7th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -783,7 +865,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_8",
"Network Link Server Address Pt. 08: ___.___._x_.___",
"Server Address Pt. 08: ___.___._x_.___",
"8th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"8th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -802,7 +887,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_9",
"Network Link Server Address Pt. 09: ___.___.__x.___",
"Server Address Pt. 09: ___.___.__x.___",
"9th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"9th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -821,7 +909,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_10",
"Network Link Server Address Pt. 10: ___.___.___.x__",
"Server Address Pt. 10: ___.___.___.x__",
"10th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"10th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -840,7 +931,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_11",
"Network Link Server Address Pt. 11: ___.___.___._x_",
"Server Address Pt. 11: ___.___.___._x_",
"11th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"11th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -859,7 +953,10 @@ struct retro_core_option_definition option_defs_us[] = {
{
"gambatte_gb_link_network_server_ip_12",
"Network Link Server Address Pt. 12: ___.___.___.__x",
"Server Address Pt. 12: ___.___.___.__x",
"12th digit of remote 'Game Boy Link' network server IP address. Only used when 'Game Boy Link Mode' is set to 'Network Client'.",
"12th digit of remote 'Game Boy Link' network server IP address. Only used when 'Link Mode' is set to 'Network Client'.",
"gb_link",
{
{ "0", NULL },
{ "1", NULL },
@ -876,7 +973,12 @@ struct retro_core_option_definition option_defs_us[] = {
"0"
},
#endif
{ NULL, NULL, NULL, {{0}}, NULL },
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
struct retro_core_options_v2 options_us = {
option_cats_us,
option_defs_us
};
/*
@ -886,26 +988,26 @@ struct retro_core_option_definition option_defs_us[] = {
*/
#ifndef HAVE_NO_LANGEXTRA
struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
option_defs_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 */
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 */
};
#endif
@ -923,45 +1025,61 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
* be as painless as possible for core devs)
*/
static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
static INLINE void libretro_set_core_options(retro_environment_t environ_cb,
bool *categories_supported)
{
unsigned version = 0;
unsigned version = 0;
#ifndef HAVE_NO_LANGEXTRA
unsigned language = 0;
#endif
if (!environ_cb)
if (!environ_cb || !categories_supported)
return;
if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1))
*categories_supported = false;
if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version))
version = 0;
if (version >= 2)
{
#ifndef HAVE_NO_LANGEXTRA
struct retro_core_options_intl core_options_intl;
unsigned language = 0;
struct retro_core_options_v2_intl core_options_intl;
core_options_intl.us = option_defs_us;
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 = option_defs_intl[language];
core_options_intl.local = options_intl[language];
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
*categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL,
&core_options_intl);
#else
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
*categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
&options_us);
#endif
}
else
{
size_t i;
size_t i, j;
size_t option_index = 0;
size_t num_options = 0;
struct retro_core_option_definition
*option_v1_defs_us = NULL;
#ifndef HAVE_NO_LANGEXTRA
size_t num_options_intl = 0;
struct retro_core_option_v2_definition
*option_defs_intl = NULL;
struct retro_core_option_definition
*option_v1_defs_intl = NULL;
struct retro_core_options_intl
core_options_v1_intl;
#endif
struct retro_variable *variables = NULL;
char **values_buf = NULL;
/* Determine number of options
* > Note: We are going to skip a number of irrelevant
* core options when building the retro_variable array,
* but we'll allocate space for all of them. The difference
* in resource usage is negligible, and this allows us to
* keep the code 'cleaner' */
/* Determine total number of options */
while (true)
{
if (option_defs_us[num_options].key)
@ -970,92 +1088,194 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
break;
}
/* 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++)
if (version >= 1)
{
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;
/* Allocate US array */
option_v1_defs_us = (struct retro_core_option_definition *)
calloc(num_options + 1, sizeof(struct retro_core_option_definition));
values_buf[i] = NULL;
/* Skip options that are irrelevant when using the
* old style core options interface */
if (strcmp(key, "gambatte_show_gb_link_settings") == 0)
continue;
if (desc)
/* Copy parameters from option_defs_us array */
for (i = 0; i < num_options; i++)
{
size_t num_values = 0;
struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i];
struct retro_core_option_value *option_values = option_def_us->values;
struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i];
struct retro_core_option_value *option_v1_values = option_v1_def_us->values;
/* Determine number of values */
option_v1_def_us->key = option_def_us->key;
option_v1_def_us->desc = option_def_us->desc;
option_v1_def_us->info = option_def_us->info;
option_v1_def_us->default_value = option_def_us->default_value;
/* Values must be copied individually... */
while (option_values->value)
{
option_v1_values->value = option_values->value;
option_v1_values->label = option_values->label;
option_values++;
option_v1_values++;
}
}
#ifndef HAVE_NO_LANGEXTRA
if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
(language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) &&
options_intl[language])
option_defs_intl = options_intl[language]->definitions;
if (option_defs_intl)
{
/* Determine number of intl options */
while (true)
{
if (values[num_values].value)
{
/* 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++;
}
if (option_defs_intl[num_options_intl].key)
num_options_intl++;
else
break;
}
/* Build values string */
if (num_values > 0)
/* Allocate intl array */
option_v1_defs_intl = (struct retro_core_option_definition *)
calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition));
/* Copy parameters from option_defs_intl array */
for (i = 0; i < num_options_intl; i++)
{
size_t j;
struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i];
struct retro_core_option_value *option_values = option_def_intl->values;
struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i];
struct retro_core_option_value *option_v1_values = option_v1_def_intl->values;
buf_len += num_values - 1;
buf_len += strlen(desc);
option_v1_def_intl->key = option_def_intl->key;
option_v1_def_intl->desc = option_def_intl->desc;
option_v1_def_intl->info = option_def_intl->info;
option_v1_def_intl->default_value = option_def_intl->default_value;
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++)
/* Values must be copied individually... */
while (option_values->value)
{
if (j != default_index)
{
strcat(values_buf[i], "|");
strcat(values_buf[i], values[j].value);
}
option_v1_values->value = option_values->value;
option_v1_values->label = option_values->label;
option_values++;
option_v1_values++;
}
}
}
variables[option_index].key = key;
variables[option_index].value = values_buf[i];
option_index++;
core_options_v1_intl.us = option_v1_defs_us;
core_options_v1_intl.local = option_v1_defs_intl;
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl);
#else
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us);
#endif
}
else
{
/* 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;
/* Skip options that are irrelevant when using the
* old style core options interface */
if (strcmp(key, "gambatte_show_gb_link_settings") == 0)
continue;
if (desc)
{
size_t num_values = 0;
/* Determine number of values */
while (true)
{
if (values[num_values].value)
{
/* 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++;
}
else
break;
}
/* 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[option_index].key = key;
variables[option_index].value = values_buf[i];
option_index++;
}
/* Set variables */
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
}
/* Set variables */
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
error:
/* Clean up */
if (option_v1_defs_us)
{
free(option_v1_defs_us);
option_v1_defs_us = NULL;
}
#ifndef HAVE_NO_LANGEXTRA
if (option_v1_defs_intl)
{
free(option_v1_defs_intl);
option_v1_defs_intl = NULL;
}
#endif
if (values_buf)
{
for (i = 0; i < num_options; i++)

View File

@ -11,9 +11,10 @@
/*
********************************
* VERSION: 1.3
* VERSION: 2.0
********************************
*
* - 2.0: Add support for core options v2 interface
* - 1.3: Move translations to libretro_core_options_intl.h
* - libretro_core_options_intl.h includes BOM and utf-8
* fix for MSVC 2010-2013