From 6138833b2844496b214d82bb680abd9bee7045fe Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Thu, 29 Jul 2021 23:03:36 +0300 Subject: [PATCH] Style fixes --- libretro/libretro.c | 93 ++++++++++++++------------------ libretro/libretro.h | 58 ++++++++++---------- libretro/libretro_core_options.h | 66 +++++++++-------------- libretro/retro_inline.h | 2 +- 4 files changed, 95 insertions(+), 124 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index baca352..fb10245 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -136,7 +136,7 @@ static void GB_update_keys_status(GB_gameboy_t *gb, unsigned port) else { 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)) { joypad_bits |= (1 << j); } @@ -244,65 +244,56 @@ static void set_variable_visibility(void) size_t num_options = 0; // 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_dualcart.visible = false; } - else if (emulated_devices == 2) - { + else if (emulated_devices == 2) { option_display_singlecart.visible = false; option_display_dualcart.visible = true; } // Determine number of options - for (;;) - { - if (!option_defs_us[num_options].key) - break; + while (true) { + if (!option_defs_us[num_options].key) break; num_options++; } // 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; - { - if ((strcmp(key, "sameboy_model") == 0) || - (strcmp(key, "sameboy_rtc") == 0) || - (strcmp(key, "sameboy_scaling_filter") == 0) || - (strcmp(key, "sameboy_mono_palette") == 0) || - (strcmp(key, "sameboy_color_correction_mode") == 0) || - (strcmp(key, "sameboy_light_temperature") == 0) || - (strcmp(key, "sameboy_border") == 0) || - (strcmp(key, "sameboy_high_pass_filter_mode") == 0) || - (strcmp(key, "sameboy_audio_interference") == 0) || - (strcmp(key, "sameboy_rumble") == 0)) - { - 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) || - (strcmp(key, "sameboy_audio_output") == 0) || - (strcmp(key, "sameboy_model_1") == 0) || - (strcmp(key, "sameboy_model_2") == 0) || - (strcmp(key, "sameboy_mono_palette_1") == 0) || - (strcmp(key, "sameboy_mono_palette_2") == 0) || - (strcmp(key, "sameboy_color_correction_mode_1") == 0) || - (strcmp(key, "sameboy_color_correction_mode_2") == 0) || - (strcmp(key, "sameboy_light_temperature_1") == 0) || - (strcmp(key, "sameboy_light_temperature_2") == 0) || - (strcmp(key, "sameboy_high_pass_filter_mode_1") == 0) || - (strcmp(key, "sameboy_high_pass_filter_mode_2") == 0) || - (strcmp(key, "sameboy_audio_interference_1") == 0) || - (strcmp(key, "sameboy_audio_interference_2") == 0) || - (strcmp(key, "sameboy_rumble_1") == 0) || - (strcmp(key, "sameboy_rumble_2") == 0)) - { - option_display_dualcart.key = key; - environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_dualcart); - } + if ((strcmp(key, "sameboy_model") == 0) || + (strcmp(key, "sameboy_rtc") == 0) || + (strcmp(key, "sameboy_scaling_filter") == 0) || + (strcmp(key, "sameboy_mono_palette") == 0) || + (strcmp(key, "sameboy_color_correction_mode") == 0) || + (strcmp(key, "sameboy_light_temperature") == 0) || + (strcmp(key, "sameboy_border") == 0) || + (strcmp(key, "sameboy_high_pass_filter_mode") == 0) || + (strcmp(key, "sameboy_audio_interference") == 0) || + (strcmp(key, "sameboy_rumble") == 0)) { + 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) || + (strcmp(key, "sameboy_audio_output") == 0) || + (strcmp(key, "sameboy_model_1") == 0) || + (strcmp(key, "sameboy_model_2") == 0) || + (strcmp(key, "sameboy_mono_palette_1") == 0) || + (strcmp(key, "sameboy_mono_palette_2") == 0) || + (strcmp(key, "sameboy_color_correction_mode_1") == 0) || + (strcmp(key, "sameboy_color_correction_mode_2") == 0) || + (strcmp(key, "sameboy_light_temperature_1") == 0) || + (strcmp(key, "sameboy_light_temperature_2") == 0) || + (strcmp(key, "sameboy_high_pass_filter_mode_1") == 0) || + (strcmp(key, "sameboy_high_pass_filter_mode_2") == 0) || + (strcmp(key, "sameboy_audio_interference_1") == 0) || + (strcmp(key, "sameboy_audio_interference_2") == 0) || + (strcmp(key, "sameboy_rumble_1") == 0) || + (strcmp(key, "sameboy_rumble_2") == 0)) { + 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) { - const char *model_name = (char *[]){ + const char *model_name = (char *[]) { [GB_BOOT_ROM_DMG0] = "dmg0", [GB_BOOT_ROM_DMG] = "dmg", [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", }[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_DMG] = dmg_boot, [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, }[type]; - unsigned boot_length = (unsigned []){ + unsigned boot_length = (unsigned []) { [GB_BOOT_ROM_DMG0] = dmg_boot_length, // dmg0 not implemented yet [GB_BOOT_ROM_DMG] = dmg_boot_length, [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_INPUT_DESCRIPTORS, descriptors_2p); } - } static void check_variables() diff --git a/libretro/libretro.h b/libretro/libretro.h index bda0b77..e6ee626 100644 --- a/libretro/libretro.h +++ b/libretro/libretro.h @@ -1523,28 +1523,28 @@ typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle * struct retro_vfs_interface { - /* VFS API v1 */ - retro_vfs_get_path_t get_path; - retro_vfs_open_t open; - retro_vfs_close_t close; - retro_vfs_size_t size; - retro_vfs_tell_t tell; - retro_vfs_seek_t seek; - retro_vfs_read_t read; - retro_vfs_write_t write; - retro_vfs_flush_t flush; - retro_vfs_remove_t remove; - retro_vfs_rename_t rename; - /* VFS API v2 */ - retro_vfs_truncate_t truncate; - /* VFS API v3 */ - retro_vfs_stat_t stat; - retro_vfs_mkdir_t mkdir; - retro_vfs_opendir_t opendir; - retro_vfs_readdir_t readdir; - retro_vfs_dirent_get_name_t dirent_get_name; - retro_vfs_dirent_is_dir_t dirent_is_dir; - retro_vfs_closedir_t closedir; + /* VFS API v1 */ + retro_vfs_get_path_t get_path; + retro_vfs_open_t open; + retro_vfs_close_t close; + retro_vfs_size_t size; + retro_vfs_tell_t tell; + retro_vfs_seek_t seek; + retro_vfs_read_t read; + retro_vfs_write_t write; + retro_vfs_flush_t flush; + retro_vfs_remove_t remove; + retro_vfs_rename_t rename; + /* VFS API v2 */ + retro_vfs_truncate_t truncate; + /* VFS API v3 */ + retro_vfs_stat_t stat; + retro_vfs_mkdir_t mkdir; + retro_vfs_opendir_t opendir; + retro_vfs_readdir_t readdir; + retro_vfs_dirent_get_name_t dirent_get_name; + retro_vfs_dirent_is_dir_t dirent_is_dir; + retro_vfs_closedir_t closedir; }; struct retro_vfs_interface_info @@ -1562,13 +1562,13 @@ struct retro_vfs_interface_info enum retro_hw_render_interface_type { - RETRO_HW_RENDER_INTERFACE_VULKAN = 0, - RETRO_HW_RENDER_INTERFACE_D3D9 = 1, - RETRO_HW_RENDER_INTERFACE_D3D10 = 2, - RETRO_HW_RENDER_INTERFACE_D3D11 = 3, - RETRO_HW_RENDER_INTERFACE_D3D12 = 4, - RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5, - RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX + RETRO_HW_RENDER_INTERFACE_VULKAN = 0, + RETRO_HW_RENDER_INTERFACE_D3D9 = 1, + RETRO_HW_RENDER_INTERFACE_D3D10 = 2, + RETRO_HW_RENDER_INTERFACE_D3D11 = 3, + RETRO_HW_RENDER_INTERFACE_D3D12 = 4, + RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5, + RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX }; /* Base struct. All retro_hw_render_interface_* types diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h index 02ffdb6..123853b 100644 --- a/libretro/libretro_core_options.h +++ b/libretro/libretro_core_options.h @@ -557,11 +557,9 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) { unsigned version = 0; - if (!environ_cb) - return; + if (!environ_cb) 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 struct retro_core_options_intl core_options_intl; 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); #endif } - else - { + else { size_t i; size_t num_options = 0; struct retro_variable *variables = NULL; char **values_buf = NULL; /* Determine number of options */ - for (;;) - { - if (!option_defs_us[num_options].key) - break; + while(true) { + if (!option_defs_us[num_options].key) break; 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)); values_buf = (char **)calloc(num_options, sizeof(char *)); - if (!variables || !values_buf) - goto error; + if (!variables || !values_buf) goto error; /* 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 *desc = option_defs_us[i].desc; 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; - if (desc) - { + if (desc) { size_t num_values = 0; /* Determine number of values */ - for (;;) - { - if (!values[num_values].value) - break; + while(true) { + if (!values[num_values].value) break; - /* Check if this is the default value */ - if (default_value) - if (strcmp(values[num_values].value, default_value) == 0) - default_index = num_values; + /* 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++; + buf_len += strlen(values[num_values].value); + num_values++; } /* Build values string */ - if (num_values > 0) - { + 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; + if (!values_buf[i]) goto error; strcpy(values_buf[i], desc); 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); /* Add remaining values */ - for (j = 0; j < num_values; j++) - { - if (j != default_index) - { + for (j = 0; j < num_values; j++) { + if (j != default_index) { strcat(values_buf[i], "|"); strcat(values_buf[i], values[j].value); } @@ -671,12 +657,9 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) error: /* Clean up */ - if (values_buf) - { - for (i = 0; i < num_options; i++) - { - if (values_buf[i]) - { + if (values_buf) { + for (i = 0; i < num_options; i++) { + if (values_buf[i]) { free(values_buf[i]); values_buf[i] = NULL; } @@ -686,8 +669,7 @@ error: values_buf = NULL; } - if (variables) - { + if (variables) { free(variables); variables = NULL; } diff --git a/libretro/retro_inline.h b/libretro/retro_inline.h index b27d6dd..14c038c 100644 --- a/libretro/retro_inline.h +++ b/libretro/retro_inline.h @@ -27,7 +27,7 @@ #if defined(_WIN32) || defined(__INTEL_COMPILER) #define INLINE __inline -#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define INLINE inline #elif defined(__GNUC__) #define INLINE __inline__