diff --git a/cheats.c b/cheats.c index f3f9c51c6f..e9425c74a7 100644 --- a/cheats.c +++ b/cheats.c @@ -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); diff --git a/core_info.h b/core_info.h index 631fe60377..a0d8472567 100644 --- a/core_info.h +++ b/core_info.h @@ -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; diff --git a/driver_menu.h b/driver_menu.h index 44287e790a..0a2db438b8 100644 --- a/driver_menu.h +++ b/driver_menu.h @@ -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; @@ -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; @@ -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 @@ -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; diff --git a/hash.h b/hash.h index 6a0a7ea6a7..26572b2dd5 100644 --- a/hash.h +++ b/hash.h @@ -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 @@ -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 diff --git a/movie.c b/movie.c index bcf1c4be4d..4b28c4b570 100644 --- a/movie.c +++ b/movie.c @@ -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; @@ -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; @@ -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); @@ -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; @@ -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); diff --git a/netplay.c b/netplay.c index 3214fd6df1..ac8da29a6e 100644 --- a/netplay.c +++ b/netplay.c @@ -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) @@ -1570,4 +1572,3 @@ void freeaddrinfo_rarch__(struct addrinfo *res) } #endif - diff --git a/netplay_compat.h b/netplay_compat.h index 6b1a6a9412..02c1e35219 100644 --- a/netplay_compat.h +++ b/netplay_compat.h @@ -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 @@ -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 @@ -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 diff --git a/screenshot.c b/screenshot.c index c7ff5eb356..0e9bf7d8f7 100644 --- a/screenshot.c +++ b/screenshot.c @@ -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, @@ -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++) @@ -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);