diff --git a/cheevos.c b/cheevos.c index 102618a1da..a8e20b0186 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1861,6 +1861,14 @@ static unsigned cheevos_find_game_id_nes( } else { + unsigned bytes; + ssize_t num_read; + int i, mapper_no; + int not_power2[] = + { + 53, 198, 228 + }; + bool round = true; RFILE *file = retro_fopen(info->path, RFILE_MODE_READ, 0); uint8_t * data = (uint8_t *) malloc(rom_size << 14); @@ -1871,22 +1879,18 @@ static unsigned cheevos_find_game_id_nes( memset(data, 0xFF, rom_size << 14); /* from fceu core - compute size using the cart mapper */ - int MapperNo = (header.rom_type >> 4); - MapperNo |= (header.rom_type2 & 0xF0); + mapper_no = (header.rom_type >> 4); + mapper_no |= (header.rom_type2 & 0xF0); - int not_power2[] = - { - 53, 198, 228 - }; - bool round = true; - for (int i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) { - //for games not to the power of 2, so we just read enough - //prg rom from it, but we have to keep ROM_size to the power of 2 - //since PRGCartMapping wants ROM_size to be to the power of 2 - //so instead if not to power of 2, we just use head.ROM_size when - //we use FCEU_read - if (not_power2[i] == MapperNo) { + for (i = 0; i != sizeof(not_power2) / sizeof(not_power2[0]); ++i) + { + /* for games not to the power of 2, so we just read enough + * PRG rom from it, but we have to keep ROM_size to the power of 2 + * since PRGCartMapping wants ROM_size to be to the power of 2 + * so instead if not to power of 2, we just use head.ROM_size when + * we use FCEU_read. */ + if (not_power2[i] == mapper_no) { round = false; break; } @@ -1898,8 +1902,8 @@ static unsigned cheevos_find_game_id_nes( if (header.rom_type & 4) retro_fseek(file, sizeof(header), SEEK_CUR); - unsigned bytes = (round) ? rom_size : header.rom_size; - ssize_t num_read = retro_fread(file, (void*) data, 0x4000 * bytes ); + bytes = (round) ? rom_size : header.rom_size; + num_read = retro_fread(file, (void*) data, 0x4000 * bytes ); retro_fclose(file); if (num_read <= 0) diff --git a/configuration.c b/configuration.c index e6c43226a9..5c32045856 100644 --- a/configuration.c +++ b/configuration.c @@ -2522,6 +2522,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user) **/ bool config_save_file(const char *path) { + float msg_color; unsigned i = 0; bool ret = false; config_file_t *conf = config_file_new(path); @@ -2699,7 +2700,6 @@ bool config_save_file(const char *path) config_set_float(conf, "video_font_size", settings->video.font_size); config_set_bool(conf, "video_font_enable", settings->video.font_enable); - float msg_color; msg_color = (((int)(settings->video.msg_color_r * 255.0f) & 0xff) << 16) + (((int)(settings->video.msg_color_g * 255.0f) & 0xff) << 8) + (((int)(settings->video.msg_color_b * 255.0f) & 0xff)); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 13de7e9818..9c6a41a0b4 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2214,15 +2214,15 @@ static void gl_set_nonblock_state(void *data, bool state) static bool resolve_extensions(gl_t *gl, const char *context_ident) { + unsigned major = 0, minor = 0; const char *vendor = (const char*)glGetString(GL_VENDOR); const char *renderer = (const char*)glGetString(GL_RENDERER); const char *version = (const char*)glGetString(GL_VERSION); - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); #if defined(HAVE_GL_SYNC) || defined(HAVE_FBO) settings_t *settings = config_get_ptr(); #endif - unsigned major = 0, minor = 0; + struct retro_hw_render_callback *hwr = NULL; + video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); (void)vendor; (void)renderer; @@ -2477,14 +2477,19 @@ static void gl_init_pbo_readback(gl_t *gl) static const gfx_ctx_driver_t *gl_get_context(gl_t *gl) { + enum gfx_ctx_api api; + unsigned major, minor; + const char *api_name = NULL; struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); - unsigned major = hwr->version_major; - unsigned minor = hwr->version_minor; settings_t *settings = config_get_ptr(); + + video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + + major = hwr->version_major; + minor = hwr->version_minor; #ifdef HAVE_OPENGLES - enum gfx_ctx_api api = GFX_CTX_OPENGL_ES_API; - const char *api_name = "OpenGL ES 2.0"; + api = GFX_CTX_OPENGL_ES_API; + api_name = "OpenGL ES 2.0"; #ifdef HAVE_OPENGLES3 if (hwr->context_type == RETRO_HW_CONTEXT_OPENGLES3) { @@ -2496,8 +2501,8 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl) api_name = "OpenGL ES 3.1+"; #endif #else - enum gfx_ctx_api api = GFX_CTX_OPENGL_API; - const char *api_name = "OpenGL"; + api = GFX_CTX_OPENGL_API; + api_name = "OpenGL"; #endif (void)api_name; diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index c572630e17..8748860a79 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -158,17 +158,21 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, for (; *msg; msg++) { + int glyph_width, glyph_height; + int base_x, base_y, max_width, max_height; + uint32_t *out = NULL; + const uint8_t *src = NULL; const struct font_glyph *glyph = vid->font_driver->get_glyph(vid->font, (uint8_t)*msg); if (!glyph) continue; - int glyph_width = glyph->width; - int glyph_height = glyph->height; + glyph_width = glyph->width; + glyph_height = glyph->height; - int base_x = msg_base_x + glyph->draw_offset_x; - int base_y = msg_base_y + glyph->draw_offset_y; - - const uint8_t *src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; + base_x = msg_base_x + glyph->draw_offset_x; + base_y = msg_base_y + glyph->draw_offset_y; + src = atlas->buffer + glyph->atlas_offset_x + + glyph->atlas_offset_y * atlas->width; if (base_x < 0) { @@ -184,8 +188,8 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, base_y = 0; } - int max_width = width - base_x; - int max_height = height - base_y; + max_width = width - base_x; + max_height = height - base_y; if (max_width <= 0 || max_height <= 0) continue; @@ -195,7 +199,7 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, if (glyph_height > max_height) glyph_height = max_height; - uint32_t *out = (uint32_t*)buffer->pixels + base_y * (buffer->pitch >> 2) + base_x; + out = (uint32_t*)buffer->pixels + base_y * (buffer->pitch >> 2) + base_x; for (y = 0; y < glyph_height; y++, src += atlas->width, out += buffer->pitch >> 2) { @@ -386,7 +390,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, static void sdl_gfx_set_nonblock_state(void *data, bool state) { - (void)data; // Can SDL even do this? + (void)data; /* Can SDL even do this? */ (void)state; } diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index ef1b580f6f..c07ac18470 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -275,6 +275,9 @@ static int16_t sdl_input_state(void *data_, const struct retro_keybind **binds, static void sdl_input_free(void *data) { +#ifndef HAVE_SDL2 + SDL_Event event; +#endif sdl_input_t *sdl = (sdl_input_t*)data; if (!data) @@ -284,7 +287,6 @@ static void sdl_input_free(void *data) #ifdef HAVE_SDL2 SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT); #else - SDL_Event event; while (SDL_PollEvent(&event)); #endif diff --git a/input/input_remapping.c b/input/input_remapping.c index eafa799fad..3afc826fb4 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -138,6 +138,7 @@ bool input_remapping_save_file(const char *path) for (i = 0; i < settings->input.max_users; i++) { + char buf[64] = {0}; char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}}; char key_strings[RARCH_FIRST_CUSTOM_BIND + 4][128] = { "b", "y", "select", "start", @@ -169,7 +170,6 @@ bool input_remapping_save_file(const char *path) } } - char buf[64] = {0}; snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1); config_set_int(conf, buf, settings->input.libretro_device[i]);