Skip to content

Commit

Permalink
Cleanups, 80-char limit
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 2, 2014
1 parent d36a4c5 commit 3060d07
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 40 deletions.
2 changes: 1 addition & 1 deletion cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void cheat_manager_save_config(cheat_manager_t *handle,
}

if (*conf_str)
conf_str[strlen(conf_str) - 1] = '\0'; // Remove the trailing ';'
conf_str[strlen(conf_str) - 1] = '\0'; /* Remove the trailing ';' */

config_set_string(conf, sha256, conf_str);

Expand Down
4 changes: 2 additions & 2 deletions core_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ typedef struct
{
char *path;
char *desc;
/* Set once to avoid opening the same file
* several times. */
/* Set missing once to avoid opening
* the same file several times. */
bool missing;
bool optional;
} core_info_firmware_t;
Expand Down
21 changes: 13 additions & 8 deletions driver_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ struct menu_bind_state_port

struct menu_bind_axis_state
{
// Default axis state.
/* Default axis state. */
int16_t rested_axes[MENU_MAX_AXES];
// Locked axis state. If we configured an axis, avoid having the same axis state trigger something again right away.
/* Locked axis state. If we configured an axis,
* avoid having the same axis state trigger something again right away. */
int16_t locked_axes[MENU_MAX_AXES];
};

struct menu_bind_state
{
struct retro_keybind *target;
int64_t timeout_end; // For keyboard binding.
/* For keyboard binding. */
int64_t timeout_end;
unsigned begin;
unsigned last;
unsigned player;
Expand Down Expand Up @@ -91,8 +93,8 @@ typedef struct
bool defer_core;
char deferred_path[PATH_MAX];

// Quick jumping indices with L/R.
// Rebuilt when parsing directory.
/* Quick jumping indices with L/R.
* Rebuilt when parsing directory. */
size_t scroll_indices[2 * (26 + 2) + 1];
unsigned scroll_indices_size;
unsigned scroll_accel;
Expand All @@ -107,10 +109,14 @@ typedef struct
bool load_no_content;

struct gfx_shader *shader;
struct gfx_shader *parameter_shader; // Points to either shader or graphics driver current shader.
/* Points to either shader or
* graphics driver's current shader. */
struct gfx_shader *parameter_shader;
unsigned current_pad;

retro_time_t last_time; // Used to throttle menu in case VSync is broken.
/* Used to throttle menu in case
* VSync is broken. */
retro_time_t last_time;

struct menu_bind_state binds;
struct
Expand Down Expand Up @@ -170,7 +176,6 @@ typedef struct menu_ctx_driver
void (*init_core_info)(void *);

const menu_ctx_driver_backend_t *backend;
// Human readable string.
const char *ident;
} menu_ctx_driver_t;

Expand Down
6 changes: 4 additions & 2 deletions hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
#include "config.h"
#endif

// Hashes sha256 and outputs a human readable string for comparing with the cheat XML values.
/* Hashes sha256 and outputs a human readable string
* for comparing with the cheat XML values. */
void sha256_hash(char *out, const uint8_t *in, size_t size);

#ifdef HAVE_ZLIB
Expand All @@ -61,7 +62,8 @@ static inline uint32_t crc32_calculate(const uint8_t *data, size_t length)

static inline uint32_t crc32_adjust(uint32_t crc, uint8_t data)
{
// zlib and nall have different assumptions on "sign" for this function.
/* zlib and nall have different
* assumptions on "sign" for this function. */
return ~crc32(~crc, &data, 1);
}
#else
Expand Down
35 changes: 23 additions & 12 deletions movie.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ struct bsv_movie
{
FILE *file;

size_t *frame_pos; // A ring buffer keeping track of positions in the file for each frame.
/* A ring buffer keeping track of positions
* in the file for each frame. */
size_t *frame_pos;
size_t frame_mask;
size_t frame_ptr;

Expand Down Expand Up @@ -56,8 +58,10 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
return false;
}

// Compatibility with old implementation that used incorrect documentation.
if (swap_if_little32(header[MAGIC_INDEX]) != BSV_MAGIC && swap_if_big32(header[MAGIC_INDEX]) != BSV_MAGIC)
/* Compatibility with old implementation that
* used incorrect documentation. */
if (swap_if_little32(header[MAGIC_INDEX]) != BSV_MAGIC
&& swap_if_big32(header[MAGIC_INDEX]) != BSV_MAGIC)
{
RARCH_ERR("Movie file is not a valid BSV1 file.\n");
return false;
Expand Down Expand Up @@ -103,7 +107,7 @@ static bool init_record(bsv_movie_t *handle, const char *path)

uint32_t header[4] = {0};

// This value is supposed to show up as BSV1 in a HEX editor, big-endian.
/* This value is supposed to show up as BSV1 in a HEX editor, big-endian. */
header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC);

header[CRC_INDEX] = swap_if_big32(g_extern.content_crc);
Expand Down Expand Up @@ -170,7 +174,8 @@ bsv_movie_t *bsv_movie_init(const char *path, enum rarch_movie_type type)
else if (!init_record(handle, path))
goto error;

// Just pick something really large :D ~1 million frames rewind should do the trick.
/* Just pick something really large
* ~1 million frames rewind should do the trick. */
if (!(handle->frame_pos = (size_t*)calloc((1 << 20), sizeof(size_t))))
goto error;

Expand Down Expand Up @@ -201,27 +206,33 @@ void bsv_movie_frame_rewind(bsv_movie_t *handle)
{
handle->did_rewind = true;

// If we're at the beginning ... :)
if ((handle->frame_ptr <= 1) && (handle->frame_pos[0] == handle->min_file_pos))
{
/* If we're at the beginning... */
handle->frame_ptr = 0;
fseek(handle->file, handle->min_file_pos, SEEK_SET);
}
else
{
// First time rewind is performed, the old frame is simply replayed.
// However, playing back that frame caused us to read data, and push data to the ring buffer.
// Sucessively rewinding frames, we need to rewind past the read data, plus another.
handle->frame_ptr = (handle->frame_ptr - (handle->first_rewind ? 1 : 2)) & handle->frame_mask;
/* First time rewind is performed, the old frame is simply replayed.
* However, playing back that frame caused us to read data, and push
* data to the ring buffer.
*
* Sucessively rewinding frames, we need to rewind past the read data,
* plus another. */
handle->frame_ptr = (handle->frame_ptr -
(handle->first_rewind ? 1 : 2)) & handle->frame_mask;
fseek(handle->file, handle->frame_pos[handle->frame_ptr], SEEK_SET);
}

// We rewound past the beginning. :O
if (ftell(handle->file) <= (long)handle->min_file_pos)
{
// If recording, we simply reset the starting point. Nice and easy.
/* We rewound past the beginning. */

if (!handle->playback)
{
/* If recording, we simply reset
* the starting point. Nice and easy. */
fseek(handle->file, 4 * sizeof(uint32_t), SEEK_SET);
pretro_serialize(handle->state, handle->state_size);
fwrite(handle->state, 1, handle->state_size, handle->file);
Expand Down
7 changes: 4 additions & 3 deletions netplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@
static bool netplay_is_alive(netplay_t *handle);

static bool netplay_poll(netplay_t *handle);
static int16_t netplay_input_state(netplay_t *handle, bool port, unsigned device, unsigned index, unsigned id);
static int16_t netplay_input_state(netplay_t *handle, bool port,
unsigned device, unsigned index, unsigned id);

// If we're fast-forward replaying to resync, check if we should actually show frame.
static bool netplay_should_skip(netplay_t *handle);
static bool netplay_can_poll(netplay_t *handle);
static void netplay_set_spectate_input(netplay_t *handle, int16_t input);

static bool netplay_send_cmd(netplay_t *handle, uint32_t cmd, const void *data, size_t size);
static bool netplay_send_cmd(netplay_t *handle, uint32_t cmd,
const void *data, size_t size);
static bool netplay_get_cmd(netplay_t *handle);

#define PREV_PTR(x) ((x) == 0 ? handle->buffer_size - 1 : (x) - 1)
Expand Down Expand Up @@ -1570,4 +1572,3 @@ void freeaddrinfo_rarch__(struct addrinfo *res)
}

#endif

11 changes: 6 additions & 5 deletions netplay_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
#endif

#if defined(_WIN32)
// Woohoo, Winsock has headers from the STONE AGE. :D
/* Woohoo, Winsock has headers
* from the STONE AGE. :D */
#ifndef _XBOX360
#define close(x) closesocket(x)
#endif
Expand All @@ -75,9 +76,9 @@
#endif
#endif

// Compatibility layer for legacy or incomplete BSD socket implementations.
// Only for IPv4. Mostly useful for the consoles which do not support
// anything reasonably modern on the socket API side of things.
/* Compatibility layer for legacy or incomplete BSD socket implementations.
* Only for IPv4. Mostly useful for the consoles which do not support
* anything reasonably modern on the socket API side of things. */

#ifdef HAVE_SOCKET_LEGACY

Expand Down Expand Up @@ -108,7 +109,7 @@ void freeaddrinfo(struct addrinfo *res);
#define AI_PASSIVE 1
#endif

// gai_strerror() not used, so we skip that.
/* gai_strerror() not used, so we skip that. */

#endif
#endif
Expand Down
21 changes: 14 additions & 7 deletions screenshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ static bool write_header_bmp(FILE *file, unsigned width, unsigned height)
/* Generic BMP stuff. */
const uint8_t header[] = {
'B', 'M',
(uint8_t)(size >> 0), (uint8_t)(size >> 8), (uint8_t)(size >> 16), (uint8_t)(size >> 24),
(uint8_t)(size >> 0), (uint8_t)(size >> 8),
(uint8_t)(size >> 16), (uint8_t)(size >> 24),
0, 0, 0, 0,
54, 0, 0, 0,
40, 0, 0, 0,
(uint8_t)(width >> 0), (uint8_t)(width >> 8), (uint8_t)(width >> 16), (uint8_t)(width >> 24),
(uint8_t)(height >> 0), (uint8_t)(height >> 8), (uint8_t)(height >> 16), (uint8_t)(height >> 24),
(uint8_t)(width >> 0), (uint8_t)(width >> 8),
(uint8_t)(width >> 16), (uint8_t)(width >> 24),
(uint8_t)(height >> 0), (uint8_t)(height >> 8),
(uint8_t)(height >> 16), (uint8_t)(height >> 24),
1, 0,
24, 0,
0, 0, 0, 0,
(uint8_t)(size_array >> 0), (uint8_t)(size_array >> 8), (uint8_t)(size_array >> 16), (uint8_t)(size_array >> 24),
(uint8_t)(size_array >> 0), (uint8_t)(size_array >> 8),
(uint8_t)(size_array >> 16), (uint8_t)(size_array >> 24),
19, 11, 0, 0,
19, 11, 0, 0,
0, 0, 0, 0,
Expand All @@ -59,7 +63,8 @@ static bool write_header_bmp(FILE *file, unsigned width, unsigned height)
return fwrite(header, 1, sizeof(header), file) == sizeof(header);
}

static void dump_lines_file(FILE *file, uint8_t **lines, size_t line_size, unsigned height)
static void dump_lines_file(FILE *file, uint8_t **lines,
size_t line_size, unsigned height)
{
unsigned i;
for (i = 0; i < height; i++)
Expand Down Expand Up @@ -187,11 +192,13 @@ bool screenshot_dump(const char *folder, const void *frame,
scaler.in_fmt = SCALER_FMT_RGB565;

scaler_ctx_gen_filter(&scaler);
scaler_ctx_scale(&scaler, out_buffer, (const uint8_t*)frame + ((int)height - 1) * pitch);
scaler_ctx_scale(&scaler, out_buffer,
(const uint8_t*)frame + ((int)height - 1) * pitch);
scaler_ctx_gen_reset(&scaler);

RARCH_LOG("Using RPNG for PNG screenshots.\n");
bool ret = rpng_save_image_bgr24(filename, out_buffer, width, height, width * 3);
bool ret = rpng_save_image_bgr24(filename,
out_buffer, width, height, width * 3);
if (!ret)
RARCH_ERR("Failed to take screenshot.\n");
free(out_buffer);
Expand Down

0 comments on commit 3060d07

Please sign in to comment.