This commit is contained in:
Lior Halphon 2022-06-12 21:29:03 +03:00
commit 20e9b1c655
3 changed files with 1076 additions and 161 deletions

View File

@ -34,7 +34,6 @@ static const char slash = '/';
#define MAX_VIDEO_HEIGHT 224 #define MAX_VIDEO_HEIGHT 224
#define MAX_VIDEO_PIXELS (MAX_VIDEO_WIDTH * MAX_VIDEO_HEIGHT) #define MAX_VIDEO_PIXELS (MAX_VIDEO_WIDTH * MAX_VIDEO_HEIGHT)
#define RETRO_MEMORY_GAMEBOY_1_SRAM ((1 << 8) | RETRO_MEMORY_SAVE_RAM) #define RETRO_MEMORY_GAMEBOY_1_SRAM ((1 << 8) | RETRO_MEMORY_SAVE_RAM)
#define RETRO_MEMORY_GAMEBOY_1_RTC ((2 << 8) | RETRO_MEMORY_RTC) #define RETRO_MEMORY_GAMEBOY_1_RTC ((2 << 8) | RETRO_MEMORY_RTC)
#define RETRO_MEMORY_GAMEBOY_2_SRAM ((3 << 8) | RETRO_MEMORY_SAVE_RAM) #define RETRO_MEMORY_GAMEBOY_2_SRAM ((3 << 8) | RETRO_MEMORY_SAVE_RAM)
@ -42,8 +41,12 @@ static const char slash = '/';
#define RETRO_GAME_TYPE_GAMEBOY_LINK_2P 0x101 #define RETRO_GAME_TYPE_GAMEBOY_LINK_2P 0x101
char battery_save_path[512]; enum rom_type {
char symbols_path[512]; ROM_TYPE_INVALID,
ROM_TYPE_DMG,
ROM_TYPE_SGB,
ROM_TYPE_CGB
};
enum model { enum model {
MODEL_DMG_B, MODEL_DMG_B,
@ -77,8 +80,22 @@ enum audio_out {
GB_2 GB_2
}; };
static enum model model[2]; static enum model model[2] = {
static enum model auto_model = MODEL_CGB_E; MODEL_DMG_B,
MODEL_DMG_B
};
static enum model auto_model[2] = {
MODEL_CGB_E,
MODEL_CGB_E
};
static enum model auto_sgb_model[2] = {
MODEL_SGB_NTSC,
MODEL_SGB_NTSC
};
static bool auto_sgb_enabled[2] = {
false,
false
};
static uint32_t *frame_buf = NULL; static uint32_t *frame_buf = NULL;
static uint32_t *frame_buf_copy = NULL; static uint32_t *frame_buf_copy = NULL;
@ -108,8 +125,6 @@ static struct {
} output_audio_buffer = {NULL, 0, 0}; } output_audio_buffer = {NULL, 0, 0};
char retro_system_directory[4096]; char retro_system_directory[4096];
char retro_save_directory[4096];
char retro_game_path[4096];
GB_gameboy_t gameboy[2]; GB_gameboy_t gameboy[2];
@ -314,6 +329,7 @@ static void set_variable_visibility(void)
for (i = 0; i < num_options; i++) { for (i = 0; i < num_options; i++) {
const char *key = option_defs_us[i].key; const char *key = option_defs_us[i].key;
if ((strcmp(key, "sameboy_model") == 0) || if ((strcmp(key, "sameboy_model") == 0) ||
(strcmp(key, "sameboy_auto_sgb_model") == 0) ||
(strcmp(key, "sameboy_rtc") == 0) || (strcmp(key, "sameboy_rtc") == 0) ||
(strcmp(key, "sameboy_scaling_filter") == 0) || (strcmp(key, "sameboy_scaling_filter") == 0) ||
(strcmp(key, "sameboy_mono_palette") == 0) || (strcmp(key, "sameboy_mono_palette") == 0) ||
@ -326,11 +342,13 @@ static void set_variable_visibility(void)
option_display_singlecart.key = key; option_display_singlecart.key = key;
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_singlecart); environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_singlecart);
} }
else if ((strcmp(key, "sameboy_link") == 0) || else if ((strcmp(key, "sameboy_link") == 0) ||
(strcmp(key, "sameboy_screen_layout") == 0) || (strcmp(key, "sameboy_screen_layout") == 0) ||
(strcmp(key, "sameboy_audio_output") == 0) || (strcmp(key, "sameboy_audio_output") == 0) ||
(strcmp(key, "sameboy_model_1") == 0) || (strcmp(key, "sameboy_model_1") == 0) ||
(strcmp(key, "sameboy_auto_sgb_model_1") == 0) ||
(strcmp(key, "sameboy_model_2") == 0) || (strcmp(key, "sameboy_model_2") == 0) ||
(strcmp(key, "sameboy_auto_sgb_model_2") == 0) ||
(strcmp(key, "sameboy_mono_palette_1") == 0) || (strcmp(key, "sameboy_mono_palette_1") == 0) ||
(strcmp(key, "sameboy_mono_palette_2") == 0) || (strcmp(key, "sameboy_mono_palette_2") == 0) ||
(strcmp(key, "sameboy_color_correction_mode_1") == 0) || (strcmp(key, "sameboy_color_correction_mode_1") == 0) ||
@ -360,8 +378,8 @@ static const struct retro_subsystem_memory_info gb2_memory[] = {
}; };
static const struct retro_subsystem_rom_info gb_roms[] = { static const struct retro_subsystem_rom_info gb_roms[] = {
{ "GameBoy #1", "gb|gbc", true, false, true, gb1_memory, 1 }, { "GameBoy #1", "gb|gbc", false, false, true, gb1_memory, 1 },
{ "GameBoy #2", "gb|gbc", true, false, true, gb2_memory, 1 }, { "GameBoy #2", "gb|gbc", false, false, true, gb2_memory, 1 },
}; };
static const struct retro_subsystem_info subsystems[] = { static const struct retro_subsystem_info subsystems[] = {
@ -585,10 +603,9 @@ static void init_for_current_model(unsigned id)
effective_model = model[i]; effective_model = model[i];
if (effective_model == MODEL_AUTO) { if (effective_model == MODEL_AUTO) {
effective_model = auto_model; effective_model = auto_model[i];
} }
if (GB_is_inited(&gameboy[i])) { if (GB_is_inited(&gameboy[i])) {
GB_switch_model_and_reset(&gameboy[i], libretro_to_internal_model[effective_model]); GB_switch_model_and_reset(&gameboy[i], libretro_to_internal_model[effective_model]);
retro_set_memory_maps(); retro_set_memory_maps();
@ -655,6 +672,10 @@ static void check_variables()
var.key = "sameboy_model"; var.key = "sameboy_model";
var.value = NULL; var.value = NULL;
model[0] = MODEL_AUTO;
auto_sgb_enabled[0] = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
enum model new_model = model[0]; enum model new_model = model[0];
if (strcmp(var.value, "Game Boy") == 0) { if (strcmp(var.value, "Game Boy") == 0) {
@ -678,6 +699,10 @@ static void check_variables()
else if (strcmp(var.value, "Super Game Boy 2") == 0) { else if (strcmp(var.value, "Super Game Boy 2") == 0) {
new_model = MODEL_SGB2; new_model = MODEL_SGB2;
} }
else if (strcmp(var.value, "Auto (SGB)") == 0) {
new_model = MODEL_AUTO;
auto_sgb_enabled[0] = true;
}
else { else {
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
} }
@ -685,6 +710,26 @@ static void check_variables()
model[0] = new_model; model[0] = new_model;
} }
var.key = "sameboy_auto_sgb_model";
var.value = NULL;
auto_sgb_model[0] = MODEL_SGB_NTSC;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
enum model new_model = auto_sgb_model[0];
if (strcmp(var.value, "Super Game Boy PAL") == 0) {
new_model = MODEL_SGB_PAL;
}
else if (strcmp(var.value, "Super Game Boy 2") == 0) {
new_model = MODEL_SGB2;
}
else {
new_model = MODEL_SGB_NTSC;
}
auto_sgb_model[0] = new_model;
}
var.key = "sameboy_rtc"; var.key = "sameboy_rtc";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
@ -842,6 +887,10 @@ static void check_variables()
var.key = "sameboy_model_1"; var.key = "sameboy_model_1";
var.value = NULL; var.value = NULL;
model[0] = MODEL_AUTO;
auto_sgb_enabled[0] = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
enum model new_model = model[0]; enum model new_model = model[0];
if (strcmp(var.value, "Game Boy") == 0) { if (strcmp(var.value, "Game Boy") == 0) {
@ -865,6 +914,10 @@ static void check_variables()
else if (strcmp(var.value, "Super Game Boy 2") == 0) { else if (strcmp(var.value, "Super Game Boy 2") == 0) {
new_model = MODEL_SGB2; new_model = MODEL_SGB2;
} }
else if (strcmp(var.value, "Auto (SGB)") == 0) {
new_model = MODEL_AUTO;
auto_sgb_enabled[0] = true;
}
else { else {
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
} }
@ -872,8 +925,32 @@ static void check_variables()
model[0] = new_model; model[0] = new_model;
} }
var.key = "sameboy_auto_sgb_model_1";
var.value = NULL;
auto_sgb_model[0] = MODEL_SGB_NTSC;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
enum model new_model = auto_sgb_model[0];
if (strcmp(var.value, "Super Game Boy PAL") == 0) {
new_model = MODEL_SGB_PAL;
}
else if (strcmp(var.value, "Super Game Boy 2") == 0) {
new_model = MODEL_SGB2;
}
else {
new_model = MODEL_SGB_NTSC;
}
auto_sgb_model[0] = new_model;
}
var.key = "sameboy_model_2"; var.key = "sameboy_model_2";
var.value = NULL; var.value = NULL;
model[1] = MODEL_AUTO;
auto_sgb_enabled[1] = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
enum model new_model = model[1]; enum model new_model = model[1];
if (strcmp(var.value, "Game Boy") == 0) { if (strcmp(var.value, "Game Boy") == 0) {
@ -897,6 +974,10 @@ static void check_variables()
else if (strcmp(var.value, "Super Game Boy 2") == 0) { else if (strcmp(var.value, "Super Game Boy 2") == 0) {
new_model = MODEL_SGB2; new_model = MODEL_SGB2;
} }
else if (strcmp(var.value, "Auto (SGB)") == 0) {
new_model = MODEL_AUTO;
auto_sgb_enabled[1] = true;
}
else { else {
new_model = MODEL_AUTO; new_model = MODEL_AUTO;
} }
@ -904,6 +985,26 @@ static void check_variables()
model[1] = new_model; model[1] = new_model;
} }
var.key = "sameboy_auto_sgb_model_2";
var.value = NULL;
auto_sgb_model[1] = MODEL_SGB_NTSC;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
enum model new_model = auto_sgb_model[1];
if (strcmp(var.value, "Super Game Boy PAL") == 0) {
new_model = MODEL_SGB_PAL;
}
else if (strcmp(var.value, "Super Game Boy 2") == 0) {
new_model = MODEL_SGB2;
}
else {
new_model = MODEL_SGB_NTSC;
}
auto_sgb_model[1] = new_model;
}
var.key = "sameboy_mono_palette_1"; var.key = "sameboy_mono_palette_1";
var.value = NULL; var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
@ -1079,13 +1180,6 @@ void retro_init(void)
snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", "."); snprintf(retro_system_directory, sizeof(retro_system_directory), "%s", ".");
} }
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir) {
snprintf(retro_save_directory, sizeof(retro_save_directory), "%s", dir);
}
else {
snprintf(retro_save_directory, sizeof(retro_save_directory), "%s", ".");
}
if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) { if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging)) {
log_cb = logging.log; log_cb = logging.log;
} }
@ -1131,7 +1225,7 @@ void retro_get_system_info(struct retro_system_info *info)
#else #else
info->library_version = GB_VERSION; info->library_version = GB_VERSION;
#endif #endif
info->need_fullpath = true; info->need_fullpath = false;
info->valid_extensions = "gb|gbc"; info->valid_extensions = "gb|gbc";
} }
@ -1165,14 +1259,15 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->timing = timing; info->timing = timing;
} }
void retro_set_environment(retro_environment_t cb) void retro_set_environment(retro_environment_t cb)
{ {
bool categories_supported;
environ_cb = cb; environ_cb = cb;
libretro_set_core_options(environ_cb); libretro_set_core_options(environ_cb, &categories_supported);
cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)subsystems); environ_cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)subsystems);
} }
void retro_set_audio_sample(retro_audio_sample_t cb) void retro_set_audio_sample(retro_audio_sample_t cb)
@ -1297,28 +1392,76 @@ void retro_run(void)
initialized = true; initialized = true;
} }
static enum rom_type check_rom_header(const uint8_t *data, size_t size)
{
enum rom_type type;
uint8_t cgb_flag;
uint8_t sgb_flag;
if (!data || (size < 0x146 + 1)) {
return ROM_TYPE_INVALID;
}
type = ROM_TYPE_DMG;
cgb_flag = data[0x143];
sgb_flag = data[0x146];
if ((cgb_flag == 0x80) || (cgb_flag == 0xC0)) {
type = ROM_TYPE_CGB;
}
if ((type == ROM_TYPE_DMG) && (sgb_flag == 0x03)) {
type = ROM_TYPE_SGB;
}
return type;
}
bool retro_load_game(const struct retro_game_info *info) bool retro_load_game(const struct retro_game_info *info)
{ {
enum rom_type content_type = ROM_TYPE_INVALID;
const uint8_t *content_data = NULL;
size_t content_size;
if (info) {
content_data = (const uint8_t *)info->data;
content_size = info->size;
content_type = check_rom_header(content_data, content_size);
}
check_variables(); check_variables();
switch (content_type) {
case ROM_TYPE_DMG:
auto_model[0] = MODEL_DMG_B;
auto_model[1] = MODEL_DMG_B;
break;
case ROM_TYPE_SGB:
auto_model[0] = auto_sgb_enabled[0] ? auto_sgb_model[0] : MODEL_DMG_B;
auto_model[1] = auto_sgb_enabled[1] ? auto_sgb_model[1] : MODEL_DMG_B;
break;
case ROM_TYPE_CGB:
auto_model[0] = MODEL_CGB_E;
auto_model[1] = MODEL_CGB_E;
break;
case ROM_TYPE_INVALID:
default:
log_cb(RETRO_LOG_ERROR, "Invalid content\n");
return false;
}
frame_buf = (uint32_t *)malloc(MAX_VIDEO_PIXELS * emulated_devices * sizeof(uint32_t)); frame_buf = (uint32_t *)malloc(MAX_VIDEO_PIXELS * emulated_devices * sizeof(uint32_t));
memset(frame_buf, 0, MAX_VIDEO_PIXELS * emulated_devices * sizeof(uint32_t)); memset(frame_buf, 0, MAX_VIDEO_PIXELS * emulated_devices * sizeof(uint32_t));
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported\n"); log_cb(RETRO_LOG_ERROR, "XRGB8888 is not supported\n");
return false; return false;
} }
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB_E : MODEL_DMG_B;
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
for (int i = 0; i < emulated_devices; i++) { for (int i = 0; i < emulated_devices; i++) {
init_for_current_model(i); init_for_current_model(i);
if (GB_load_rom(&gameboy[i], info->path)) { GB_load_rom_from_buffer(&gameboy[i], content_data, content_size);
log_cb(RETRO_LOG_INFO, "Failed to load ROM at %s\n", info->path);
return false;
}
} }
bool achievements = true; bool achievements = true;
@ -1353,8 +1496,7 @@ unsigned retro_get_region(void)
bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num_info) bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num_info)
{ {
if ((type == RETRO_GAME_TYPE_GAMEBOY_LINK_2P) && (num_info >= 2)) {
if (type == RETRO_GAME_TYPE_GAMEBOY_LINK_2P) {
emulated_devices = 2; emulated_devices = 2;
} }
else { else {
@ -1371,19 +1513,35 @@ bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
log_cb(RETRO_LOG_INFO, "XRGB8888 is not supported\n"); log_cb(RETRO_LOG_ERROR, "XRGB8888 is not supported\n");
return false; return false;
} }
auto_model = (info->path[strlen(info->path) - 1] & ~0x20) == 'C' ? MODEL_CGB_E : MODEL_DMG_B;
snprintf(retro_game_path, sizeof(retro_game_path), "%s", info->path);
for (int i = 0; i < emulated_devices; i++) { for (int i = 0; i < emulated_devices; i++) {
init_for_current_model(i); enum rom_type content_type = ROM_TYPE_INVALID;
if (GB_load_rom(&gameboy[i], info[i].path)) { const uint8_t *content_data = info[i].data;
log_cb(RETRO_LOG_INFO, "Failed to load ROM\n"); size_t content_size = info[i].size;
return false;
content_type = check_rom_header(content_data, content_size);
switch (content_type) {
case ROM_TYPE_DMG:
auto_model[i] = MODEL_DMG_B;
break;
case ROM_TYPE_SGB:
auto_model[i] = auto_sgb_enabled[i] ? auto_sgb_model[i] : MODEL_DMG_B;
break;
case ROM_TYPE_CGB:
auto_model[i] = MODEL_CGB_E;
break;
case ROM_TYPE_INVALID:
default:
log_cb(RETRO_LOG_ERROR, "Invalid content\n");
return false;
} }
init_for_current_model(i);
GB_load_rom_from_buffer(&gameboy[i], content_data, content_size);
} }
bool achievements = true; bool achievements = true;
@ -1616,4 +1774,3 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
(void)enabled; (void)enabled;
(void)code; (void)code;
} }

View File

@ -1388,6 +1388,363 @@ enum retro_mod
* fastforwarding state will occur in this case). * 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.
*/
#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 69
/* const struct retro_core_options_update_display_callback * --
* Allows a frontend to signal that a core must update
* the visibility of any dynamically hidden core options,
* and enables the frontend to detect visibility changes.
* Used by the frontend to update the menu display status
* of core options without requiring a call of retro_run().
* Must be called in retro_set_environment().
*/
#define RETRO_ENVIRONMENT_SET_VARIABLE 70
/* const struct retro_variable * --
* Allows an implementation to notify the frontend
* that a core option value has changed.
*
* retro_variable::key and retro_variable::value
* must match strings that have been set previously
* via one of the following:
*
* - RETRO_ENVIRONMENT_SET_VARIABLES
* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS
* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL
* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2
* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL
*
* After changing a core option value via this
* callback, RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE
* will return true.
*
* If data is NULL, no changes will be registered
* and the callback will return true; an
* implementation may therefore pass NULL in order
* to test whether the callback is supported.
*/
#define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_throttle_state * --
* Allows an implementation to get details on the actual rate
* the frontend is attempting to call retro_run().
*/
/* VFS functionality */ /* VFS functionality */
/* File paths: /* File paths:
@ -2902,6 +3259,143 @@ struct retro_core_options_intl
struct retro_core_option_definition *local; 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;
};
/* Used by the frontend to monitor changes in core option
* visibility. May be called each time any core option
* value is set via the frontend.
* - On each invocation, the core must update the visibility
* of any dynamically hidden options using the
* RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY environment
* callback.
* - On the first invocation, returns 'true' if the visibility
* of any core option has changed since the last call of
* retro_load_game() or retro_load_game_special().
* - On each subsequent invocation, returns 'true' if the
* visibility of any core option has changed since the last
* time the function was called. */
typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void);
struct retro_core_options_update_display_callback
{
retro_core_options_update_display_callback_t callback;
};
struct retro_game_info struct retro_game_info
{ {
const char *path; /* Path to game, UTF-8 encoded. const char *path; /* Path to game, UTF-8 encoded.

View File

@ -9,9 +9,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 * - 1.3: Move translations to libretro_core_options_intl.h
* - libretro_core_options_intl.h includes BOM and utf-8 * - libretro_core_options_intl.h includes BOM and utf-8
* fix for MSVC 2010-2013 * fix for MSVC 2010-2013
@ -44,16 +45,44 @@ extern "C" {
* - Will be used as a fallback for any missing entries in * - Will be used as a fallback for any missing entries in
* frontend language definition */ * frontend language definition */
struct retro_core_option_definition option_defs_us[] = { struct retro_core_option_v2_category option_cats_us[] = {
{
"system",
"System",
"Configure base hardware selection."
},
{
"video",
"Video",
"Configure display parameters: palette selection, colour correction, screen border."
},
{
"audio",
"Audio",
"Configure audio emulation: highpass filter, electrical interference."
},
{
"input",
"Input",
"Configure input parameters: rumble support."
},
{ NULL, NULL, NULL, NULL },
};
struct retro_core_option_v2_definition option_defs_us[] = {
/* Core options used in single cart mode */ /* Core options used in single cart mode */
{ {
"sameboy_model", "sameboy_model",
"System - Emulated Model (Requires Restart)", "System - Emulated Model (Requires Restart)",
"Emulated Model (Requires Restart)",
"Chooses which system model the content should be started on. Certain games may activate special in-game features when ran on specific models. This option requires a content restart in order to take effect.", "Chooses which system model the content should be started on. Certain games may activate special in-game features when ran on specific models. This option requires a content restart in order to take effect.",
NULL,
"system",
{ {
{ "Auto", "Detect automatically" }, { "Auto", "Auto Detect DMG/CGB" },
{ "Auto (SGB)", "Auto Detect DMG/SGB/CGB" },
{ "Game Boy", "Game Boy (DMG-CPU B)" }, { "Game Boy", "Game Boy (DMG-CPU B)" },
{ "Game Boy Color C", "Game Boy Color (CPU-CGB C) (Experimental)" }, { "Game Boy Color C", "Game Boy Color (CPU-CGB C) (Experimental)" },
{ "Game Boy Color", "Game Boy Color (CPU-CGB E)" }, { "Game Boy Color", "Game Boy Color (CPU-CGB E)" },
@ -65,10 +94,28 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
"Auto" "Auto"
}, },
{
"sameboy_auto_sgb_model",
"System - Auto Detected SGB Model (Requires Restart)",
"Auto Detected SGB Model (Requires Restart)",
"Specifies which model of Super Game Boy hardware to emulate when SGB content is automatically detected. This option requires a content restart in order to take effect.",
NULL,
"system",
{
{ "Super Game Boy", "Super Game Boy NTSC" },
{ "Super Game Boy PAL", NULL },
{ "Super Game Boy 2", NULL },
{ NULL, NULL },
},
"Super Game Boy"
},
{ {
"sameboy_rtc", "sameboy_rtc",
"System - Real Time Clock Emulation", "System - Real Time Clock Emulation",
"Real Time Clock Emulation",
"Specifies how the emulation of the real-time clock feature used in certain Game Boy and Game Boy Color games should function.", "Specifies how the emulation of the real-time clock feature used in certain Game Boy and Game Boy Color games should function.",
NULL,
"system",
{ {
{ "sync to system clock", "Sync to System Clock" }, { "sync to system clock", "Sync to System Clock" },
{ "accurate", "Accurate" }, { "accurate", "Accurate" },
@ -76,11 +123,13 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
"sync to system clock" "sync to system clock"
}, },
{ {
"sameboy_mono_palette", "sameboy_mono_palette",
"Video - GB Mono Palette", "Video - GB Mono Palette",
"GB Mono Palette",
"Selects the color palette that should be used when playing Game Boy games.", "Selects the color palette that should be used when playing Game Boy games.",
NULL,
"video",
{ {
{ "greyscale", "Greyscale" }, { "greyscale", "Greyscale" },
{ "lime", "Lime (Game Boy)" }, { "lime", "Lime (Game Boy)" },
@ -93,7 +142,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_color_correction_mode", "sameboy_color_correction_mode",
"Video - GBC Color Correction", "Video - GBC Color Correction",
"GBC Color Correction",
"Defines which type of color correction should be applied when playing Game Boy Color games.", "Defines which type of color correction should be applied when playing Game Boy Color games.",
NULL,
"video",
{ {
{ "emulate hardware", "Emulate Hardware" }, { "emulate hardware", "Emulate Hardware" },
{ "preserve brightness", "Preserve Brightness" }, { "preserve brightness", "Preserve Brightness" },
@ -108,7 +160,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_light_temperature", "sameboy_light_temperature",
"Video - Ambient Light Temperature", "Video - Ambient Light Temperature",
"Simulates an ambient lights effect on non-backlit Game Boy screens, by setting a user-controlled color temperature. This option has no effect if the content is run on an original Game Boy (DMG) emulated model.", "Ambient Light Temperature",
"Simulates an ambient light's effect on non-backlit Game Boy screens, by setting a user-controlled color temperature. This option has no effect if the content is run on an original Game Boy (DMG) emulated model.",
NULL,
"video",
{ {
{ "1.0", "1000K (Warmest)" }, { "1.0", "1000K (Warmest)" },
{ "0.9", "1550K" }, { "0.9", "1550K" },
@ -130,7 +185,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "-0.7", "10350K" }, { "-0.7", "10350K" },
{ "-0.8", "10900K" }, { "-0.8", "10900K" },
{ "-0.9", "11450K" }, { "-0.9", "11450K" },
{ "-1.0", "12000K (Coolest)" }, { "-1.0", "12000K (Coolest)" },
{ NULL, NULL }, { NULL, NULL },
}, },
"0" "0"
@ -138,7 +193,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_border", "sameboy_border",
"Video - Display Border", "Video - Display Border",
"Display Border",
"Defines when to display an on-screen border around the content.", "Defines when to display an on-screen border around the content.",
NULL,
"video",
{ {
{ "always", "Always" }, { "always", "Always" },
{ "Super Game Boy only", "Only for Super Game Boy" }, { "Super Game Boy only", "Only for Super Game Boy" },
@ -150,7 +208,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_high_pass_filter_mode", "sameboy_high_pass_filter_mode",
"Audio - Highpass Filter", "Audio - Highpass Filter",
"Highpass Filter",
"Applies a filter to the audio output, removing certain pop sounds caused by the DC Offset. If disabled, the sound will be rendered as output by the Game Boy APU, but popping effects will be heard when the emulator is paused or resumed. 'Accurate' will apply a global filter, masking popping sounds while also reducing lower frequencies. 'Preserve Waveform' applies the filter only to the DC Offset.", "Applies a filter to the audio output, removing certain pop sounds caused by the DC Offset. If disabled, the sound will be rendered as output by the Game Boy APU, but popping effects will be heard when the emulator is paused or resumed. 'Accurate' will apply a global filter, masking popping sounds while also reducing lower frequencies. 'Preserve Waveform' applies the filter only to the DC Offset.",
NULL,
"audio",
{ {
{ "accurate", "Accurate" }, { "accurate", "Accurate" },
{ "remove dc offset", "Preserve Waveform" }, { "remove dc offset", "Preserve Waveform" },
@ -162,7 +223,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_audio_interference", "sameboy_audio_interference",
"Audio - Interference Volume", "Audio - Interference Volume",
"Interference Volume",
"Controls the volume of the buzzing effect caused by the electrical interference between the Game Boy SoC and the system speakers.", "Controls the volume of the buzzing effect caused by the electrical interference between the Game Boy SoC and the system speakers.",
NULL,
"audio",
{ {
{ "0", "0%" }, { "0", "0%" },
{ "5", "5%" }, { "5", "5%" },
@ -192,7 +256,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_rumble", "sameboy_rumble",
"Input - Rumble Mode", "Input - Rumble Mode",
"Rumble Mode",
"Defines which type of content should trigger rumble effects.", "Defines which type of content should trigger rumble effects.",
NULL,
"input",
{ {
{ "all games", "Always" }, { "all games", "Always" },
{ "rumble-enabled games", "Only for rumble-enabled games" }, { "rumble-enabled games", "Only for rumble-enabled games" },
@ -207,7 +274,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_link", "sameboy_link",
"System - Link Cable Emulation", "System - Link Cable Emulation",
"Link Cable Emulation",
"Enables the emulation of the link cable, allowing communication and exchange of data between two Game Boy systems.", "Enables the emulation of the link cable, allowing communication and exchange of data between two Game Boy systems.",
NULL,
"system",
{ {
{ "enabled", "Enabled" }, { "enabled", "Enabled" },
{ "disabled", "Disabled" }, { "disabled", "Disabled" },
@ -218,7 +288,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_screen_layout", "sameboy_screen_layout",
"System - Screen Layout", "System - Screen Layout",
"Screen Layout",
"When emulating two systems at once, this option defines the respective position of the two screens.", "When emulating two systems at once, this option defines the respective position of the two screens.",
NULL,
"system",
{ {
{ "top-down", "Top-Down" }, { "top-down", "Top-Down" },
{ "left-right", "Left-Right" }, { "left-right", "Left-Right" },
@ -229,7 +302,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_audio_output", "sameboy_audio_output",
"System - Audio Output", "System - Audio Output",
"Audio Output",
"Selects which of the two emulated Game Boy systems should output audio.", "Selects which of the two emulated Game Boy systems should output audio.",
NULL,
"system",
{ {
{ "Game Boy #1", NULL }, { "Game Boy #1", NULL },
{ "Game Boy #2", NULL }, { "Game Boy #2", NULL },
@ -240,9 +316,13 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_model_1", "sameboy_model_1",
"System - Emulated Model for Game Boy #1 (Requires Restart)", "System - Emulated Model for Game Boy #1 (Requires Restart)",
"Emulated Model for Game Boy #1 (Requires Restart)",
"Chooses which system model the content should be started on for Game Boy #1. Certain games may activate special in-game features when ran on specific models. This option requires a content restart in order to take effect.", "Chooses which system model the content should be started on for Game Boy #1. Certain games may activate special in-game features when ran on specific models. This option requires a content restart in order to take effect.",
NULL,
"system",
{ {
{ "Auto", "Detect automatically" }, { "Auto", "Auto Detect DMG/CGB" },
{ "Auto (SGB)", "Auto Detect DMG/SGB/CGB" },
{ "Game Boy", "Game Boy (DMG-CPU B)" }, { "Game Boy", "Game Boy (DMG-CPU B)" },
{ "Game Boy Color C", "Game Boy Color (CPU-CGB C) (Experimental)" }, { "Game Boy Color C", "Game Boy Color (CPU-CGB C) (Experimental)" },
{ "Game Boy Color", "Game Boy Color (CPU-CGB E)" }, { "Game Boy Color", "Game Boy Color (CPU-CGB E)" },
@ -254,12 +334,31 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
"Auto" "Auto"
}, },
{
"sameboy_auto_sgb_model_1",
"System - Auto Detected SGB Model for Game Boy #1 (Requires Restart)",
"Auto Detected SGB Model for Game Boy #1 (Requires Restart)",
"Specifies which model of Super Game Boy hardware to emulate when SGB content is automatically detected for Game Boy #1. This option requires a content restart in order to take effect.",
NULL,
"system",
{
{ "Super Game Boy", "Super Game Boy NTSC" },
{ "Super Game Boy PAL", NULL },
{ "Super Game Boy 2", NULL },
{ NULL, NULL },
},
"Super Game Boy"
},
{ {
"sameboy_model_2", "sameboy_model_2",
"System - Emulated Model for Game Boy #2 (Requires Restart)", "System - Emulated Model for Game Boy #2 (Requires Restart)",
"Emulated Model for Game Boy #2 (Requires Restart)",
"Chooses which system model the content should be started on for Game Boy #2. Certain games may activate special in-game features when ran on specific models. This option requires a content restart in order to take effect.", "Chooses which system model the content should be started on for Game Boy #2. Certain games may activate special in-game features when ran on specific models. This option requires a content restart in order to take effect.",
NULL,
"system",
{ {
{ "Auto", "Detect automatically" }, { "Auto", "Auto Detect DMG/CGB" },
{ "Auto (SGB)", "Auto Detect DMG/SGB/CGB" },
{ "Game Boy", "Game Boy (DMG-CPU B)" }, { "Game Boy", "Game Boy (DMG-CPU B)" },
{ "Game Boy Color C", "Game Boy Color (CPU-CGB C) (Experimental)" }, { "Game Boy Color C", "Game Boy Color (CPU-CGB C) (Experimental)" },
{ "Game Boy Color", "Game Boy Color (CPU-CGB E)" }, { "Game Boy Color", "Game Boy Color (CPU-CGB E)" },
@ -271,10 +370,28 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
"Auto" "Auto"
}, },
{
"sameboy_auto_sgb_model_2",
"System - Auto Detected SGB Model for Game Boy #2 (Requires Restart)",
"Auto Detected SGB Model for Game Boy #2 (Requires Restart)",
"Specifies which model of Super Game Boy hardware to emulate when SGB content is automatically detected for Game Boy #2. This option requires a content restart in order to take effect.",
NULL,
"system",
{
{ "Super Game Boy", "Super Game Boy NTSC" },
{ "Super Game Boy PAL", NULL },
{ "Super Game Boy 2", NULL },
{ NULL, NULL },
},
"Super Game Boy"
},
{ {
"sameboy_mono_palette_1", "sameboy_mono_palette_1",
"Video - GB Mono Palette for Game Boy #1", "Video - GB Mono Palette for Game Boy #1",
"GB Mono Palette for Game Boy #1",
"Selects the color palette that should be used when playing Game Boy games on Game Boy #1.", "Selects the color palette that should be used when playing Game Boy games on Game Boy #1.",
NULL,
"video",
{ {
{ "greyscale", "Greyscale" }, { "greyscale", "Greyscale" },
{ "lime", "Lime (Game Boy)" }, { "lime", "Lime (Game Boy)" },
@ -287,7 +404,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_mono_palette_2", "sameboy_mono_palette_2",
"Video - GB Mono Palette for Game Boy #2", "Video - GB Mono Palette for Game Boy #2",
"GB Mono Palette for Game Boy #2",
"Selects the color palette that should be used when playing Game Boy games on Game Boy #2.", "Selects the color palette that should be used when playing Game Boy games on Game Boy #2.",
NULL,
"video",
{ {
{ "greyscale", "Greyscale" }, { "greyscale", "Greyscale" },
{ "lime", "Lime (Game Boy)" }, { "lime", "Lime (Game Boy)" },
@ -300,7 +420,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_color_correction_mode_1", "sameboy_color_correction_mode_1",
"Video - GBC Color Correction for Game Boy #1", "Video - GBC Color Correction for Game Boy #1",
"GBC Color Correction for Game Boy #1",
"Defines which type of color correction should be applied when playing Game Boy Color games on Game Boy #1.", "Defines which type of color correction should be applied when playing Game Boy Color games on Game Boy #1.",
NULL,
"video",
{ {
{ "emulate hardware", "Emulate Hardware" }, { "emulate hardware", "Emulate Hardware" },
{ "preserve brightness", "Preserve Brightness" }, { "preserve brightness", "Preserve Brightness" },
@ -315,7 +438,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_color_correction_mode_2", "sameboy_color_correction_mode_2",
"Video - GBC Color Correction for Game Boy #2", "Video - GBC Color Correction for Game Boy #2",
"GBC Color Correction for Game Boy #2",
"Defines which type of color correction should be applied when playing Game Boy Color games on Game Boy #2.", "Defines which type of color correction should be applied when playing Game Boy Color games on Game Boy #2.",
NULL,
"video",
{ {
{ "emulate hardware", "Emulate Hardware" }, { "emulate hardware", "Emulate Hardware" },
{ "preserve brightness", "Preserve Brightness" }, { "preserve brightness", "Preserve Brightness" },
@ -330,7 +456,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_light_temperature_1", "sameboy_light_temperature_1",
"Video - Ambient Light Temperature for Game Boy #1", "Video - Ambient Light Temperature for Game Boy #1",
"Simulates an ambient lights effect on non-backlit Game Boy screens, by setting a user-controlled color temperature applied to the screen of Game Boy #1. This option has no effect if the content is run on an original Game Boy (DMG) emulated model.", "Ambient Light Temperature for Game Boy #1",
"Simulates an ambient light's effect on non-backlit Game Boy screens, by setting a user-controlled color temperature applied to the screen of Game Boy #1. This option has no effect if the content is run on an original Game Boy (DMG) emulated model.",
NULL,
"video",
{ {
{ "1.0", "1000K (Warmest)" }, { "1.0", "1000K (Warmest)" },
{ "0.9", "1550K" }, { "0.9", "1550K" },
@ -352,7 +481,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "-0.7", "10350K" }, { "-0.7", "10350K" },
{ "-0.8", "10900K" }, { "-0.8", "10900K" },
{ "-0.9", "11450K" }, { "-0.9", "11450K" },
{ "-1.0", "12000K (Coolest)" }, { "-1.0", "12000K (Coolest)" },
{ NULL, NULL }, { NULL, NULL },
}, },
"0" "0"
@ -360,7 +489,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_light_temperature_2", "sameboy_light_temperature_2",
"Video - Ambient Light Temperature for Game Boy #2", "Video - Ambient Light Temperature for Game Boy #2",
"Simulates an ambient lights effect on non-backlit Game Boy screens, by setting a user-controlled color temperature applied to the screen of Game Boy #2. This option has no effect if the content is run on an original Game Boy (DMG) emulated model.", "Ambient Light Temperature for Game Boy #2",
"Simulates an ambient light's effect on non-backlit Game Boy screens, by setting a user-controlled color temperature applied to the screen of Game Boy #2. This option has no effect if the content is run on an original Game Boy (DMG) emulated model.",
NULL,
"video",
{ {
{ "1.0", "1000K (Warmest)" }, { "1.0", "1000K (Warmest)" },
{ "0.9", "1550K" }, { "0.9", "1550K" },
@ -382,7 +514,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "-0.7", "10350K" }, { "-0.7", "10350K" },
{ "-0.8", "10900K" }, { "-0.8", "10900K" },
{ "-0.9", "11450K" }, { "-0.9", "11450K" },
{ "-1.0", "12000K (Coolest)" }, { "-1.0", "12000K (Coolest)" },
{ NULL, NULL }, { NULL, NULL },
}, },
"0" "0"
@ -390,7 +522,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_high_pass_filter_mode_1", "sameboy_high_pass_filter_mode_1",
"Audio - Highpass Filter for Game Boy #1", "Audio - Highpass Filter for Game Boy #1",
"Highpass Filter for Game Boy #1",
"Applies a filter to the audio output for Game Boy #1, removing certain pop sounds caused by the DC Offset. If disabled, the sound will be rendered as output by the Game Boy APU, but popping effects will be heard when the emulator is paused or resumed. 'Accurate' will apply a global filter, masking popping sounds while also reducing lower frequencies. 'Preserve Waveform' applies the filter only to the DC Offset.", "Applies a filter to the audio output for Game Boy #1, removing certain pop sounds caused by the DC Offset. If disabled, the sound will be rendered as output by the Game Boy APU, but popping effects will be heard when the emulator is paused or resumed. 'Accurate' will apply a global filter, masking popping sounds while also reducing lower frequencies. 'Preserve Waveform' applies the filter only to the DC Offset.",
NULL,
"audio",
{ {
{ "accurate", "Accurate" }, { "accurate", "Accurate" },
{ "remove dc offset", "Preserve Waveform" }, { "remove dc offset", "Preserve Waveform" },
@ -402,7 +537,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_high_pass_filter_mode_2", "sameboy_high_pass_filter_mode_2",
"Audio - Highpass Filter for Game Boy #2", "Audio - Highpass Filter for Game Boy #2",
"Highpass Filter for Game Boy #2",
"Applies a filter to the audio output for Game Boy #2, removing certain pop sounds caused by the DC Offset. If disabled, the sound will be rendered as output by the Game Boy APU, but popping effects will be heard when the emulator is paused or resumed. 'Accurate' will apply a global filter, masking popping sounds while also reducing lower frequencies. 'Preserve Waveform' applies the filter only to the DC Offset.", "Applies a filter to the audio output for Game Boy #2, removing certain pop sounds caused by the DC Offset. If disabled, the sound will be rendered as output by the Game Boy APU, but popping effects will be heard when the emulator is paused or resumed. 'Accurate' will apply a global filter, masking popping sounds while also reducing lower frequencies. 'Preserve Waveform' applies the filter only to the DC Offset.",
NULL,
"audio",
{ {
{ "accurate", "Accurate" }, { "accurate", "Accurate" },
{ "remove dc offset", "Preserve Waveform" }, { "remove dc offset", "Preserve Waveform" },
@ -414,7 +552,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_audio_interference_1", "sameboy_audio_interference_1",
"Audio - Interference Volume for Game Boy #1", "Audio - Interference Volume for Game Boy #1",
"Interference Volume for Game Boy #1",
"Controls the volume of the buzzing effect caused by the electrical interference between the Game Boy SoC and the system speakers on Game Boy #1.", "Controls the volume of the buzzing effect caused by the electrical interference between the Game Boy SoC and the system speakers on Game Boy #1.",
NULL,
"audio",
{ {
{ "0", "0%" }, { "0", "0%" },
{ "5", "5%" }, { "5", "5%" },
@ -444,7 +585,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_audio_interference_2", "sameboy_audio_interference_2",
"Audio - Interference Volume for Game Boy #2", "Audio - Interference Volume for Game Boy #2",
"Interference Volume for Game Boy #2",
"Controls the volume of the buzzing effect caused by the electrical interference between the Game Boy SoC and the system speakers on Game Boy #2.", "Controls the volume of the buzzing effect caused by the electrical interference between the Game Boy SoC and the system speakers on Game Boy #2.",
NULL,
"audio",
{ {
{ "0", "0%" }, { "0", "0%" },
{ "5", "5%" }, { "5", "5%" },
@ -474,11 +618,14 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_rumble_1", "sameboy_rumble_1",
"Input - Rumble Mode for Game Boy #1", "Input - Rumble Mode for Game Boy #1",
"Rumble Mode for Game Boy #1",
"Defines which type of content should trigger rumble effects when played on Game Boy #1.", "Defines which type of content should trigger rumble effects when played on Game Boy #1.",
NULL,
"input",
{ {
{ "all games", "Always" }, { "all games", "Always" },
{ "rumble-enabled games", "Only for rumble-enabled games" }, { "rumble-enabled games", "Only for rumble-enabled games" },
{ "never", "Never" }, { "never", "Never" },
{ NULL, NULL }, { NULL, NULL },
}, },
"rumble-enabled games" "rumble-enabled games"
@ -486,7 +633,10 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"sameboy_rumble_2", "sameboy_rumble_2",
"Input - Rumble Mode for Game Boy #2", "Input - Rumble Mode for Game Boy #2",
"Rumble Mode for Game Boy #2",
"Defines which type of content should trigger rumble effects when played on Game Boy #2.", "Defines which type of content should trigger rumble effects when played on Game Boy #2.",
NULL,
"input",
{ {
{ "all games", "Always" }, { "all games", "Always" },
{ "rumble-enabled games", "Only for rumble-enabled games" }, { "rumble-enabled games", "Only for rumble-enabled games" },
@ -496,7 +646,12 @@ struct retro_core_option_definition option_defs_us[] = {
"rumble-enabled games" "rumble-enabled games"
}, },
{ 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
}; };
/* /*
@ -506,8 +661,8 @@ struct retro_core_option_definition option_defs_us[] = {
*/ */
#ifndef HAVE_NO_LANGEXTRA #ifndef HAVE_NO_LANGEXTRA
struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = {
option_defs_us, /* RETRO_LANGUAGE_ENGLISH */ &options_us, /* RETRO_LANGUAGE_ENGLISH */
NULL, /* RETRO_LANGUAGE_JAPANESE */ NULL, /* RETRO_LANGUAGE_JAPANESE */
NULL, /* RETRO_LANGUAGE_FRENCH */ NULL, /* RETRO_LANGUAGE_FRENCH */
NULL, /* RETRO_LANGUAGE_SPANISH */ NULL, /* RETRO_LANGUAGE_SPANISH */
@ -531,7 +686,6 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
NULL, /* RETRO_LANGUAGE_HEBREW */ NULL, /* RETRO_LANGUAGE_HEBREW */
NULL, /* RETRO_LANGUAGE_ASTURIAN */ NULL, /* RETRO_LANGUAGE_ASTURIAN */
NULL, /* RETRO_LANGUAGE_FINNISH */ NULL, /* RETRO_LANGUAGE_FINNISH */
}; };
#endif #endif
@ -549,110 +703,220 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
* be as painless as possible for core devs) * 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;
if (!environ_cb) return;
if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1)) {
#ifndef HAVE_NO_LANGEXTRA #ifndef HAVE_NO_LANGEXTRA
struct retro_core_options_intl core_options_intl; unsigned language = 0;
unsigned language = 0; #endif
core_options_intl.us = option_defs_us; if (!environ_cb || !categories_supported) return;
*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_v2_intl core_options_intl;
core_options_intl.us = &options_us;
core_options_intl.local = NULL; core_options_intl.local = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
(language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH)) (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 #else
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us); *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
&options_us);
#endif #endif
} }
else { else {
size_t i; size_t i, j;
size_t option_index = 0;
size_t num_options = 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; struct retro_variable *variables = NULL;
char **values_buf = NULL; char **values_buf = NULL;
/* Determine number of options */ /* Determine total number of options */
while (true) { while (true) {
if (!option_defs_us[num_options].key) break; if (option_defs_us[num_options].key) num_options++;
num_options++; else break;
} }
/* Allocate arrays */ if (version >= 1) {
variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable)); /* Allocate US array */
values_buf = (char **)calloc(num_options, sizeof(char *)); option_v1_defs_us = (struct retro_core_option_definition *) calloc(num_options + 1, sizeof(struct retro_core_option_definition));
if (!variables || !values_buf) goto error; /* Copy parameters from option_defs_us array */
for (i = 0; i < num_options; i++) {
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;
/* Copy parameters from option_defs_us array */ option_v1_def_us->key = option_def_us->key;
for (i = 0; i < num_options; i++) { option_v1_def_us->desc = option_def_us->desc;
const char *key = option_defs_us[i].key; option_v1_def_us->info = option_def_us->info;
const char *desc = option_defs_us[i].desc; option_v1_def_us->default_value = option_def_us->default_value;
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; /* Values must be copied individually... */
while (option_values->value) {
option_v1_values->value = option_values->value;
option_v1_values->label = option_values->label;
if (desc) { option_values++;
size_t num_values = 0; option_v1_values++;
}
}
/* Determine number of 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) { while (true) {
if (!values[num_values].value) break; if (option_defs_intl[num_options_intl].key) num_options_intl++;
else 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 */ /* Allocate intl array */
if (num_values > 0) { option_v1_defs_intl = (struct retro_core_option_definition *)
size_t j; calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition));
buf_len += num_values - 1; /* Copy parameters from option_defs_intl array */
buf_len += strlen(desc); for (i = 0; i < num_options_intl; i++) {
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;
values_buf[i] = (char *)calloc(buf_len, sizeof(char)); option_v1_def_intl->key = option_def_intl->key;
if (!values_buf[i]) goto error; 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;
strcpy(values_buf[i], desc); /* Values must be copied individually... */
strcat(values_buf[i], "; "); while (option_values->value) {
option_v1_values->value = option_values->value;
option_v1_values->label = option_values->label;
/* Default value goes first */ option_values++;
strcat(values_buf[i], values[default_index].value); option_v1_values++;
/* 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; core_options_v1_intl.us = option_v1_defs_us;
variables[i].value = values_buf[i]; 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;
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) {
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 */ error:
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
error:
/* Clean up */ /* 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) { if (values_buf) {
for (i = 0; i < num_options; i++) { for (i = 0; i < num_options; i++) {
if (values_buf[i]) { if (values_buf[i]) {