Skip to content

Commit

Permalink
Style nits/conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Feb 9, 2025
1 parent 0be8fe8 commit 91aa803
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 277 deletions.
64 changes: 31 additions & 33 deletions cheat_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,25 +394,24 @@ static void cheat_manager_load_cb_first_pass(char *key, char *value)
}
}

static void cheat_manager_load_cb_second_pass(char *key, char *value)
static void cheat_manager_load_cb_second_pass(char *s, char *value)
{
size_t _len;
char cheat_num_str[20];
unsigned cheat_num;
unsigned cheat_idx;
unsigned cheat_num, cheat_idx;
unsigned idx = 5;
size_t key_length = 0;
cheat_manager_t *cheat_st = &cheat_manager_state;

errno = 0;

if (strncmp(key, "cheat", 5) != 0)
if (strncmp(s, "cheat", 5) != 0)
return;

key_length = strlen((const char*)key);
_len = strlen((const char*)s);

while (idx < key_length && key[idx] >= '0' && key[idx] <= '9' && idx < 24)
while (idx < _len && s[idx] >= '0' && s[idx] <= '9' && idx < 24)
{
cheat_num_str[idx - 5] = key[idx];
cheat_num_str[idx - 5] = s[idx];
idx++;
}

Expand All @@ -423,55 +422,55 @@ static void cheat_manager_load_cb_second_pass(char *key, char *value)
if (cheat_num + cheat_st->loading_cheat_offset >= cheat_st->size)
return;

key = key + idx + 1;
s = s + idx + 1;

cheat_idx = cheat_num + cheat_st->loading_cheat_offset;

if (string_is_equal(key, "address"))
if (string_is_equal(s, "address"))
cheat_st->cheats[cheat_idx].address = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "address_bit_position"))
else if (string_is_equal(s, "address_bit_position"))
cheat_st->cheats[cheat_idx].address_mask = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "big_endian"))
else if (string_is_equal(s, "big_endian"))
cheat_st->cheats[cheat_idx].big_endian = (string_is_equal(value, "true") || string_is_equal(value, "1"));
else if (string_is_equal(key, "cheat_type"))
else if (string_is_equal(s, "cheat_type"))
cheat_st->cheats[cheat_idx].cheat_type = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "code"))
else if (string_is_equal(s, "code"))
cheat_st->cheats[cheat_idx].code = strdup(value);
else if (string_is_equal(key, "desc"))
else if (string_is_equal(s, "desc"))
cheat_st->cheats[cheat_idx].desc = strdup(value);
else if (string_is_equal(key, "enable"))
else if (string_is_equal(s, "enable"))
cheat_st->cheats[cheat_idx].state = (string_is_equal(value, "true") || string_is_equal(value, "1"));
else if (string_is_equal(key, "handler"))
else if (string_is_equal(s, "handler"))
cheat_st->cheats[cheat_idx].handler = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "memory_search_size"))
else if (string_is_equal(s, "memory_search_size"))
cheat_st->cheats[cheat_idx].memory_search_size = (unsigned)strtoul(value, NULL, 0);
else if (string_starts_with_size(key, "repeat_", STRLEN_CONST("repeat_")))
else if (string_starts_with_size(s, "repeat_", STRLEN_CONST("repeat_")))
{
if (string_is_equal(key, "repeat_add_to_address"))
if (string_is_equal(s, "repeat_add_to_address"))
cheat_st->cheats[cheat_idx].repeat_add_to_address = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "repeat_add_to_value"))
else if (string_is_equal(s, "repeat_add_to_value"))
cheat_st->cheats[cheat_idx].repeat_add_to_value = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "repeat_count"))
else if (string_is_equal(s, "repeat_count"))
cheat_st->cheats[cheat_idx].repeat_count = (unsigned)strtoul(value, NULL, 0);
}
else if (string_starts_with_size(key, "rumble", STRLEN_CONST("rumble")))
else if (string_starts_with_size(s, "rumble", STRLEN_CONST("rumble")))
{
if (string_is_equal(key, "rumble_port"))
if (string_is_equal(s, "rumble_port"))
cheat_st->cheats[cheat_idx].rumble_port = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "rumble_primary_duration"))
else if (string_is_equal(s, "rumble_primary_duration"))
cheat_st->cheats[cheat_idx].rumble_primary_duration = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "rumble_primary_strength"))
else if (string_is_equal(s, "rumble_primary_strength"))
cheat_st->cheats[cheat_idx].rumble_primary_strength = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "rumble_secondary_duration"))
else if (string_is_equal(s, "rumble_secondary_duration"))
cheat_st->cheats[cheat_idx].rumble_secondary_duration = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "rumble_secondary_strength"))
else if (string_is_equal(s, "rumble_secondary_strength"))
cheat_st->cheats[cheat_idx].rumble_secondary_strength = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "rumble_type"))
else if (string_is_equal(s, "rumble_type"))
cheat_st->cheats[cheat_idx].rumble_type = (unsigned)strtoul(value, NULL, 0);
else if (string_is_equal(key, "rumble_value"))
else if (string_is_equal(s, "rumble_value"))
cheat_st->cheats[cheat_idx].rumble_value = (unsigned)strtoul(value, NULL, 0);
}
else if (string_is_equal(key, "value"))
else if (string_is_equal(s, "value"))
cheat_st->cheats[cheat_idx].value = (unsigned)strtoul(value, NULL, 0);
}

Expand Down Expand Up @@ -708,8 +707,7 @@ bool cheat_manager_get_code_state(unsigned i)

static size_t cheat_manager_get_game_specific_filename(
char *s, size_t len,
const char *path_cheat_database,
bool saving)
const char *path_cheat_database, bool saving)
{
char s1[PATH_MAX_LENGTH];
struct retro_system_info sysinfo;
Expand Down
44 changes: 22 additions & 22 deletions libretro-common/audio/audio_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,43 @@
#include <audio/conversion/float_to_s16.h>
#include <audio/conversion/s16_to_float.h>

void audio_mix_volume_C(float *out, const float *in, float vol, size_t samples)
void audio_mix_volume_C(float *s, const float *in, float vol, size_t len)
{
size_t i;
for (i = 0; i < samples; i++)
out[i] += in[i] * vol;
for (i = 0; i < len; i++)
s[i] += in[i] * vol;
}

#ifdef __SSE2__
void audio_mix_volume_SSE2(float *out, const float *in, float vol, size_t samples)
void audio_mix_volume_SSE2(float *s, const float *in, float vol, size_t len)
{
size_t i, remaining_samples;
__m128 volume = _mm_set1_ps(vol);

for (i = 0; i + 16 <= samples; i += 16, out += 16, in += 16)
for (i = 0; i + 16 <= len; i += 16, s += 16, in += 16)
{
unsigned j;
__m128 input[4];
__m128 additive[4];

input[0] = _mm_loadu_ps(out + 0);
input[1] = _mm_loadu_ps(out + 4);
input[2] = _mm_loadu_ps(out + 8);
input[3] = _mm_loadu_ps(out + 12);
input[0] = _mm_loadu_ps(s + 0);
input[1] = _mm_loadu_ps(s + 4);
input[2] = _mm_loadu_ps(s + 8);
input[3] = _mm_loadu_ps(s + 12);

additive[0] = _mm_mul_ps(volume, _mm_loadu_ps(in + 0));
additive[1] = _mm_mul_ps(volume, _mm_loadu_ps(in + 4));
additive[2] = _mm_mul_ps(volume, _mm_loadu_ps(in + 8));
additive[3] = _mm_mul_ps(volume, _mm_loadu_ps(in + 12));

for (j = 0; j < 4; j++)
_mm_storeu_ps(out + 4 * j, _mm_add_ps(input[j], additive[j]));
_mm_storeu_ps(s + 4 * j, _mm_add_ps(input[j], additive[j]));
}

remaining_samples = samples - i;
remaining_samples = len - i;

for (i = 0; i < remaining_samples; i++)
out[i] += in[i] * vol;
s[i] += in[i] * vol;
}
#endif

Expand Down Expand Up @@ -176,9 +176,9 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
uint8_t *sample = (
(uint8_t*)chunk->rwav->samples) + i;

chunk->upsample_buf[i * 2] =
chunk->upsample_buf[i * 2] =
(int16_t)((sample[0] - 128) << 8);
chunk->upsample_buf[(i * 2) + 1] =
chunk->upsample_buf[(i * 2) + 1] =
(int16_t)((sample[0] - 128) << 8);
}
}
Expand All @@ -190,9 +190,9 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
(uint8_t*)chunk->rwav->samples) +
(i * 2);

chunk->upsample_buf[i * 2] =
chunk->upsample_buf[i * 2] =
(int16_t)((sample[0] - 128) << 8);
chunk->upsample_buf[(i * 2) + 1] =
chunk->upsample_buf[(i * 2) + 1] =
(int16_t)((sample[1] - 128) << 8);
}
}
Expand Down Expand Up @@ -238,13 +238,13 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
struct resampler_data info;

chunk->float_buf = (float*)memalign_alloc(128,
chunk->rwav->numsamples * 2 *
chunk->rwav->numsamples * 2 *
chunk->ratio * sizeof(float));

/* why is *3 needed instead of just *2? Does the
/* why is *3 needed instead of just *2? Does the
* sinc driver require more space than we know about? */
chunk->float_resample_buf = (float*)memalign_alloc(128,
chunk->rwav->numsamples * 3 *
chunk->rwav->numsamples * 3 *
chunk->ratio * sizeof(float));

convert_s16_to_float(chunk->float_buf,
Expand All @@ -260,7 +260,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,

chunk->resampler->process(chunk->resampler_data, &info);

/* number of output_frames does not increase with
/* number of output_frames does not increase with
* multiple channels, but assume we need space for 2 */
chunk->resample_buf = (int16_t*)memalign_alloc(128,
info.output_frames * 2 * sizeof(int16_t));
Expand Down Expand Up @@ -323,11 +323,11 @@ int16_t audio_mix_get_chunk_sample(audio_chunk_t *chunk,

if (chunk->resample)
sample = (uint8_t*)chunk->resample_buf +
(sample_size * index * chunk->rwav->numchannels)
(sample_size * index * chunk->rwav->numchannels)
+ (channel * sample_size);
else
sample = (uint8_t*)chunk->upsample_buf +
(sample_size * index * chunk->rwav->numchannels)
(sample_size * index * chunk->rwav->numchannels)
+ (channel * sample_size);

sample_out = (int16_t)*sample;
Expand Down
4 changes: 2 additions & 2 deletions libretro-common/audio/audio_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ static unsigned s_rate = 0;
static void audio_mixer_release(audio_mixer_voice_t* voice);

#ifdef HAVE_RWAV
static bool wav_to_float(const rwav_t* wav, float** pcm, size_t samples_out)
static bool wav_to_float(const rwav_t* wav, float** pcm, size_t len)
{
size_t i;
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes */
float *f = (float*)memalign_alloc(16,
((samples_out + 15) & ~15) * sizeof(float));
((len + 15) & ~15) * sizeof(float));

if (!f)
return false;
Expand Down
Loading

0 comments on commit 91aa803

Please sign in to comment.