Style fixes

This commit is contained in:
Lior Halphon 2021-07-29 23:03:36 +03:00
parent 75ec1c0334
commit 6138833b28
4 changed files with 95 additions and 124 deletions

View File

@ -136,7 +136,7 @@ static void GB_update_keys_status(GB_gameboy_t *gb, unsigned port)
else { else {
unsigned j; unsigned j;
for (j = 0; j < (RETRO_DEVICE_ID_JOYPAD_R3+1); j++) { for (j = 0; j < (RETRO_DEVICE_ID_JOYPAD_R3 + 1); j++) {
if (input_state_cb(port, RETRO_DEVICE_JOYPAD, 0, j)) { if (input_state_cb(port, RETRO_DEVICE_JOYPAD, 0, j)) {
joypad_bits |= (1 << j); joypad_bits |= (1 << j);
} }
@ -244,65 +244,56 @@ static void set_variable_visibility(void)
size_t num_options = 0; size_t num_options = 0;
// Show/hide options depending on the number of emulated devices // Show/hide options depending on the number of emulated devices
if (emulated_devices == 1) if (emulated_devices == 1) {
{
option_display_singlecart.visible = true; option_display_singlecart.visible = true;
option_display_dualcart.visible = false; option_display_dualcart.visible = false;
} }
else if (emulated_devices == 2) else if (emulated_devices == 2) {
{
option_display_singlecart.visible = false; option_display_singlecart.visible = false;
option_display_dualcart.visible = true; option_display_dualcart.visible = true;
} }
// Determine number of options // Determine number of options
for (;;) while (true) {
{ if (!option_defs_us[num_options].key) break;
if (!option_defs_us[num_options].key)
break;
num_options++; num_options++;
} }
// Copy parameters from option_defs_us array // Copy parameters from option_defs_us array
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_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) || (strcmp(key, "sameboy_color_correction_mode") == 0) ||
(strcmp(key, "sameboy_color_correction_mode") == 0) || (strcmp(key, "sameboy_light_temperature") == 0) ||
(strcmp(key, "sameboy_light_temperature") == 0) || (strcmp(key, "sameboy_border") == 0) ||
(strcmp(key, "sameboy_border") == 0) || (strcmp(key, "sameboy_high_pass_filter_mode") == 0) ||
(strcmp(key, "sameboy_high_pass_filter_mode") == 0) || (strcmp(key, "sameboy_audio_interference") == 0) ||
(strcmp(key, "sameboy_audio_interference") == 0) || (strcmp(key, "sameboy_rumble") == 0)) {
(strcmp(key, "sameboy_rumble") == 0)) option_display_singlecart.key = key;
{ environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_singlecart);
option_display_singlecart.key = key; }
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_singlecart); else if ((strcmp(key, "sameboy_link") == 0) ||
} (strcmp(key, "sameboy_screen_layout") == 0) ||
else if ((strcmp(key, "sameboy_link") == 0) || (strcmp(key, "sameboy_audio_output") == 0) ||
(strcmp(key, "sameboy_screen_layout") == 0) || (strcmp(key, "sameboy_model_1") == 0) ||
(strcmp(key, "sameboy_audio_output") == 0) || (strcmp(key, "sameboy_model_2") == 0) ||
(strcmp(key, "sameboy_model_1") == 0) || (strcmp(key, "sameboy_mono_palette_1") == 0) ||
(strcmp(key, "sameboy_model_2") == 0) || (strcmp(key, "sameboy_mono_palette_2") == 0) ||
(strcmp(key, "sameboy_mono_palette_1") == 0) || (strcmp(key, "sameboy_color_correction_mode_1") == 0) ||
(strcmp(key, "sameboy_mono_palette_2") == 0) || (strcmp(key, "sameboy_color_correction_mode_2") == 0) ||
(strcmp(key, "sameboy_color_correction_mode_1") == 0) || (strcmp(key, "sameboy_light_temperature_1") == 0) ||
(strcmp(key, "sameboy_color_correction_mode_2") == 0) || (strcmp(key, "sameboy_light_temperature_2") == 0) ||
(strcmp(key, "sameboy_light_temperature_1") == 0) || (strcmp(key, "sameboy_high_pass_filter_mode_1") == 0) ||
(strcmp(key, "sameboy_light_temperature_2") == 0) || (strcmp(key, "sameboy_high_pass_filter_mode_2") == 0) ||
(strcmp(key, "sameboy_high_pass_filter_mode_1") == 0) || (strcmp(key, "sameboy_audio_interference_1") == 0) ||
(strcmp(key, "sameboy_high_pass_filter_mode_2") == 0) || (strcmp(key, "sameboy_audio_interference_2") == 0) ||
(strcmp(key, "sameboy_audio_interference_1") == 0) || (strcmp(key, "sameboy_rumble_1") == 0) ||
(strcmp(key, "sameboy_audio_interference_2") == 0) || (strcmp(key, "sameboy_rumble_2") == 0)) {
(strcmp(key, "sameboy_rumble_1") == 0) || option_display_dualcart.key = key;
(strcmp(key, "sameboy_rumble_2") == 0)) environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_dualcart);
{
option_display_dualcart.key = key;
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_dualcart);
}
} }
} }
} }
@ -426,7 +417,7 @@ static void set_link_cable_state(bool state)
static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type) static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type)
{ {
const char *model_name = (char *[]){ const char *model_name = (char *[]) {
[GB_BOOT_ROM_DMG0] = "dmg0", [GB_BOOT_ROM_DMG0] = "dmg0",
[GB_BOOT_ROM_DMG] = "dmg", [GB_BOOT_ROM_DMG] = "dmg",
[GB_BOOT_ROM_MGB] = "mgb", [GB_BOOT_ROM_MGB] = "mgb",
@ -437,8 +428,7 @@ static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type)
[GB_BOOT_ROM_AGB] = "agb", [GB_BOOT_ROM_AGB] = "agb",
}[type]; }[type];
const uint8_t *boot_code = (const unsigned char *[]) const uint8_t *boot_code = (const unsigned char *[]) {
{
[GB_BOOT_ROM_DMG0] = dmg_boot, // dmg0 not implemented yet [GB_BOOT_ROM_DMG0] = dmg_boot, // dmg0 not implemented yet
[GB_BOOT_ROM_DMG] = dmg_boot, [GB_BOOT_ROM_DMG] = dmg_boot,
[GB_BOOT_ROM_MGB] = dmg_boot, // mgb not implemented yet [GB_BOOT_ROM_MGB] = dmg_boot, // mgb not implemented yet
@ -449,7 +439,7 @@ static void boot_rom_load(GB_gameboy_t *gb, GB_boot_rom_t type)
[GB_BOOT_ROM_AGB] = agb_boot, [GB_BOOT_ROM_AGB] = agb_boot,
}[type]; }[type];
unsigned boot_length = (unsigned []){ unsigned boot_length = (unsigned []) {
[GB_BOOT_ROM_DMG0] = dmg_boot_length, // dmg0 not implemented yet [GB_BOOT_ROM_DMG0] = dmg_boot_length, // dmg0 not implemented yet
[GB_BOOT_ROM_DMG] = dmg_boot_length, [GB_BOOT_ROM_DMG] = dmg_boot_length,
[GB_BOOT_ROM_MGB] = dmg_boot_length, // mgb not implemented yet [GB_BOOT_ROM_MGB] = dmg_boot_length, // mgb not implemented yet
@ -604,7 +594,6 @@ static void init_for_current_model(unsigned id)
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports); environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descriptors_2p); environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, descriptors_2p);
} }
} }
static void check_variables() static void check_variables()

View File

@ -1523,28 +1523,28 @@ typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle *
struct retro_vfs_interface struct retro_vfs_interface
{ {
/* VFS API v1 */ /* VFS API v1 */
retro_vfs_get_path_t get_path; retro_vfs_get_path_t get_path;
retro_vfs_open_t open; retro_vfs_open_t open;
retro_vfs_close_t close; retro_vfs_close_t close;
retro_vfs_size_t size; retro_vfs_size_t size;
retro_vfs_tell_t tell; retro_vfs_tell_t tell;
retro_vfs_seek_t seek; retro_vfs_seek_t seek;
retro_vfs_read_t read; retro_vfs_read_t read;
retro_vfs_write_t write; retro_vfs_write_t write;
retro_vfs_flush_t flush; retro_vfs_flush_t flush;
retro_vfs_remove_t remove; retro_vfs_remove_t remove;
retro_vfs_rename_t rename; retro_vfs_rename_t rename;
/* VFS API v2 */ /* VFS API v2 */
retro_vfs_truncate_t truncate; retro_vfs_truncate_t truncate;
/* VFS API v3 */ /* VFS API v3 */
retro_vfs_stat_t stat; retro_vfs_stat_t stat;
retro_vfs_mkdir_t mkdir; retro_vfs_mkdir_t mkdir;
retro_vfs_opendir_t opendir; retro_vfs_opendir_t opendir;
retro_vfs_readdir_t readdir; retro_vfs_readdir_t readdir;
retro_vfs_dirent_get_name_t dirent_get_name; retro_vfs_dirent_get_name_t dirent_get_name;
retro_vfs_dirent_is_dir_t dirent_is_dir; retro_vfs_dirent_is_dir_t dirent_is_dir;
retro_vfs_closedir_t closedir; retro_vfs_closedir_t closedir;
}; };
struct retro_vfs_interface_info struct retro_vfs_interface_info
@ -1562,13 +1562,13 @@ struct retro_vfs_interface_info
enum retro_hw_render_interface_type enum retro_hw_render_interface_type
{ {
RETRO_HW_RENDER_INTERFACE_VULKAN = 0, RETRO_HW_RENDER_INTERFACE_VULKAN = 0,
RETRO_HW_RENDER_INTERFACE_D3D9 = 1, RETRO_HW_RENDER_INTERFACE_D3D9 = 1,
RETRO_HW_RENDER_INTERFACE_D3D10 = 2, RETRO_HW_RENDER_INTERFACE_D3D10 = 2,
RETRO_HW_RENDER_INTERFACE_D3D11 = 3, RETRO_HW_RENDER_INTERFACE_D3D11 = 3,
RETRO_HW_RENDER_INTERFACE_D3D12 = 4, RETRO_HW_RENDER_INTERFACE_D3D12 = 4,
RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5, RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5,
RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX
}; };
/* Base struct. All retro_hw_render_interface_* types /* Base struct. All retro_hw_render_interface_* types

View File

@ -557,11 +557,9 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
{ {
unsigned version = 0; unsigned version = 0;
if (!environ_cb) if (!environ_cb) return;
return;
if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1)) 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; struct retro_core_options_intl core_options_intl;
unsigned language = 0; unsigned language = 0;
@ -578,18 +576,15 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us); environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
#endif #endif
} }
else else {
{
size_t i; size_t i;
size_t num_options = 0; size_t num_options = 0;
struct retro_variable *variables = NULL; struct retro_variable *variables = NULL;
char **values_buf = NULL; char **values_buf = NULL;
/* Determine number of options */ /* Determine number of options */
for (;;) while(true) {
{ if (!option_defs_us[num_options].key) break;
if (!option_defs_us[num_options].key)
break;
num_options++; num_options++;
} }
@ -597,12 +592,10 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable)); variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
values_buf = (char **)calloc(num_options, sizeof(char *)); values_buf = (char **)calloc(num_options, sizeof(char *));
if (!variables || !values_buf) if (!variables || !values_buf) goto error;
goto error;
/* Copy parameters from option_defs_us array */ /* Copy parameters from option_defs_us array */
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;
const char *desc = option_defs_us[i].desc; const char *desc = option_defs_us[i].desc;
const char *default_value = option_defs_us[i].default_value; const char *default_value = option_defs_us[i].default_value;
@ -612,36 +605,31 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
values_buf[i] = NULL; values_buf[i] = NULL;
if (desc) if (desc) {
{
size_t num_values = 0; size_t num_values = 0;
/* Determine number of values */ /* Determine number of values */
for (;;) while(true) {
{ if (!values[num_values].value) break;
if (!values[num_values].value)
break;
/* Check if this is the default value */ /* Check if this is the default value */
if (default_value) if (default_value) {
if (strcmp(values[num_values].value, default_value) == 0) if (strcmp(values[num_values].value, default_value) == 0) default_index = num_values;
default_index = num_values; }
buf_len += strlen(values[num_values].value); buf_len += strlen(values[num_values].value);
num_values++; num_values++;
} }
/* Build values string */ /* Build values string */
if (num_values > 0) if (num_values > 0) {
{
size_t j; size_t j;
buf_len += num_values - 1; buf_len += num_values - 1;
buf_len += strlen(desc); buf_len += strlen(desc);
values_buf[i] = (char *)calloc(buf_len, sizeof(char)); values_buf[i] = (char *)calloc(buf_len, sizeof(char));
if (!values_buf[i]) if (!values_buf[i]) goto error;
goto error;
strcpy(values_buf[i], desc); strcpy(values_buf[i], desc);
strcat(values_buf[i], "; "); strcat(values_buf[i], "; ");
@ -650,10 +638,8 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
strcat(values_buf[i], values[default_index].value); strcat(values_buf[i], values[default_index].value);
/* Add remaining values */ /* Add remaining values */
for (j = 0; j < num_values; j++) for (j = 0; j < num_values; j++) {
{ if (j != default_index) {
if (j != default_index)
{
strcat(values_buf[i], "|"); strcat(values_buf[i], "|");
strcat(values_buf[i], values[j].value); strcat(values_buf[i], values[j].value);
} }
@ -671,12 +657,9 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
error: error:
/* Clean up */ /* Clean up */
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])
{
free(values_buf[i]); free(values_buf[i]);
values_buf[i] = NULL; values_buf[i] = NULL;
} }
@ -686,8 +669,7 @@ error:
values_buf = NULL; values_buf = NULL;
} }
if (variables) if (variables) {
{
free(variables); free(variables);
variables = NULL; variables = NULL;
} }

View File

@ -27,7 +27,7 @@
#if defined(_WIN32) || defined(__INTEL_COMPILER) #if defined(_WIN32) || defined(__INTEL_COMPILER)
#define INLINE __inline #define INLINE __inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define INLINE inline #define INLINE inline
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define INLINE __inline__ #define INLINE __inline__