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 {
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,30 +244,24 @@ 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) ||
@ -277,8 +271,7 @@ static void set_variable_visibility(void)
(strcmp(key, "sameboy_border") == 0) ||
(strcmp(key, "sameboy_high_pass_filter_mode") == 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);
}
@ -298,13 +291,11 @@ static void set_variable_visibility(void)
(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))
{
(strcmp(key, "sameboy_rumble_2") == 0)) {
option_display_dualcart.key = key;
environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display_dualcart);
}
}
}
}
static const struct retro_subsystem_memory_info gb1_memory[] = {
@ -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()

View File

@ -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;
if (default_value) {
if (strcmp(values[num_values].value, default_value) == 0) default_index = num_values;
}
buf_len += strlen(values[num_values].value);
num_values++;
}
/* Build values string */
if (num_values > 0)
{
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;
}

View File

@ -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__