From c0103d65de610c21ccdc0f825f456332e638d1f1 Mon Sep 17 00:00:00 2001 From: bladeoner Date: Wed, 15 Mar 2023 17:28:20 +0100 Subject: [PATCH] Snes9x - Fix more warnings. (#1055) --- source/snes9x/controls.cpp | 69 +++++++++++++------------------------- source/snes9x/gfx.cpp | 14 +++----- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/source/snes9x/controls.cpp b/source/snes9x/controls.cpp index 09e2779..5e38583 100644 --- a/source/snes9x/controls.cpp +++ b/source/snes9x/controls.cpp @@ -332,14 +332,12 @@ static void DoGunLatch (int x, int y) if (x > 295) x = 295; - else - if (x < 40) + else if (x < 40) x = 40; if (y > PPU.ScreenHeight - 1) y = PPU.ScreenHeight - 1; - else - if (y < 0) + else if (y < 0) y = 0; PPU.GunVLatch = (uint16) (y + 1); @@ -1168,8 +1166,7 @@ s9xcommand_t S9xGetCommandT (const char *name) if (!strcmp(name, "None")) cmd.type = S9xNoMapping; - else - if (!strncmp(name, "Joypad", 6)) + else if (!strncmp(name, "Joypad", 6)) { if (name[6] < '1' || name[6] > '8' || name[7] != ' ') return (cmd); @@ -1180,24 +1177,15 @@ s9xcommand_t S9xGetCommandT (const char *name) s = name + 13; if (!strncmp(s, "Left/Right ", 11)) { j = 0; i = 0; s += 11; } - else - if (!strncmp(s, "Right/Left ", 11)) { j = 0; i = 1; s += 11; } - else - if (!strncmp(s, "Up/Down ", 8)) { j = 1; i = 0; s += 8; } - else - if (!strncmp(s, "Down/Up ", 8)) { j = 1; i = 1; s += 8; } - else - if (!strncmp(s, "Y/A ", 4)) { j = 2; i = 0; s += 4; } - else - if (!strncmp(s, "A/Y ", 4)) { j = 2; i = 1; s += 4; } - else - if (!strncmp(s, "X/B ", 4)) { j = 3; i = 0; s += 4; } - else - if (!strncmp(s, "B/X ", 4)) { j = 3; i = 1; s += 4; } - else - if (!strncmp(s, "L/R ", 4)) { j = 4; i = 0; s += 4; } - else - if (!strncmp(s, "R/L ", 4)) { j = 4; i = 1; s += 4; } + else if (!strncmp(s, "Right/Left ", 11)) { j = 0; i = 1; s += 11; } + else if (!strncmp(s, "Up/Down ", 8)) { j = 1; i = 0; s += 8; } + else if (!strncmp(s, "Down/Up ", 8)) { j = 1; i = 1; s += 8; } + else if (!strncmp(s, "Y/A ", 4)) { j = 2; i = 0; s += 4; } + else if (!strncmp(s, "A/Y ", 4)) { j = 2; i = 1; s += 4; } + else if (!strncmp(s, "X/B ", 4)) { j = 3; i = 0; s += 4; } + else if (!strncmp(s, "B/X ", 4)) { j = 3; i = 1; s += 4; } + else if (!strncmp(s, "L/R ", 4)) { j = 4; i = 0; s += 4; } + else if (!strncmp(s, "R/L ", 4)) { j = 4; i = 1; s += 4; } else return (cmd); @@ -1378,8 +1366,7 @@ s9xcommand_t S9xGetCommandT (const char *name) if (*s == 'h') cmd.axis.pointer.HV = 0; - else - if (*s == 'v') + else if (*s == 'v') cmd.axis.pointer.HV = 1; else return (cmd); @@ -1527,8 +1514,7 @@ s9xcommand_t S9xGetCommandT (const char *name) j = i; } - else - if (name[i] == ',') + else if (name[i] == ',') { free(c); return (cmd); @@ -1541,8 +1527,7 @@ s9xcommand_t S9xGetCommandT (const char *name) { if (name[i] == '+') press = 1; - else - if (name[i] == '-') + else if (name[i] == '-') press = 2; else { @@ -2011,14 +1996,12 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2) uint16 x = r; r = st; st = x; x = s; s = t; t = x; } - else - if (cmd.button.joypad.turbo) + else if (cmd.button.joypad.turbo) { uint16 x = r; r = t; t = x; x = s; s = st; st = x; } - else - if (cmd.button.joypad.sticky) + else if (cmd.button.joypad.sticky) { uint16 x = r; r = s; s = x; x = t; t = st; st = x; @@ -2771,14 +2754,12 @@ static void UpdatePolledMouse (int i) mouse[i - MOUSE0].delta_x = 0xff; mouse[i - MOUSE0].old_x -= 127; } - else - if (j < 0) + else if (j < 0) { mouse[i - MOUSE0].delta_x = 0x80 | -j; mouse[i - MOUSE0].old_x = mouse[i - MOUSE0].cur_x; } - else - if (j > 127) + else if (j > 127) { mouse[i - MOUSE0].delta_x = 0x7f; mouse[i - MOUSE0].old_x += 127; @@ -2796,14 +2777,12 @@ static void UpdatePolledMouse (int i) mouse[i - MOUSE0].delta_y = 0xff; mouse[i - MOUSE0].old_y -= 127; } - else - if (j < 0) + else if (j < 0) { mouse[i - MOUSE0].delta_y = 0x80 | -j; mouse[i - MOUSE0].old_y = mouse[i - MOUSE0].cur_y; } - else - if (j > 127) + else if (j > 127) { mouse[i - MOUSE0].delta_y = 0x7f; mouse[i - MOUSE0].old_y += 127; @@ -3274,8 +3253,7 @@ void S9xControlEOF (void) pseudopointer[n].x += pseudopointer[n].H_adj; if (pseudopointer[n].x < 0) pseudopointer[n].x = 0; - else - if (pseudopointer[n].x > 255) + else if (pseudopointer[n].x > 255) pseudopointer[n].x = 255; if (pseudopointer[n].H_var) @@ -3298,8 +3276,7 @@ void S9xControlEOF (void) pseudopointer[n].y += pseudopointer[n].V_adj; if (pseudopointer[n].y < 0) pseudopointer[n].y = 0; - else - if (pseudopointer[n].y > PPU.ScreenHeight - 1) + else if (pseudopointer[n].y > PPU.ScreenHeight - 1) pseudopointer[n].y = PPU.ScreenHeight - 1; if (pseudopointer[n].V_var) diff --git a/source/snes9x/gfx.cpp b/source/snes9x/gfx.cpp index b8ca0e7..bac4bbb 100644 --- a/source/snes9x/gfx.cpp +++ b/source/snes9x/gfx.cpp @@ -642,8 +642,7 @@ static void SetupOBJ (void) { if (HPos < 0) GFX.OBJVisibleTiles[S] = (GFX.OBJWidths[S] + HPos + 7) >> 3; - else - if (HPos + GFX.OBJWidths[S] > 255) + else if (HPos + GFX.OBJWidths[S] > 255) GFX.OBJVisibleTiles[S] = (256 - HPos + 7) >> 3; else GFX.OBJVisibleTiles[S] = GFX.OBJWidths[S] >> 3; @@ -714,8 +713,7 @@ static void SetupOBJ (void) { if (HPos < 0) GFX.OBJVisibleTiles[S] = (GFX.OBJWidths[S] + HPos + 7) >> 3; - else - if (HPos + GFX.OBJWidths[S] >= 257) + else if (HPos + GFX.OBJWidths[S] >= 257) GFX.OBJVisibleTiles[S] = (257 - HPos + 7) >> 3; else GFX.OBJVisibleTiles[S] = GFX.OBJWidths[S] >> 3; @@ -2019,7 +2017,7 @@ static void DisplayWatchedAddresses (void) break; int32 displayNumber = 0; - char buf[32]; + char buf[64]; for (int r = 0; r < watches[i].size; r++) displayNumber += (Cheat.CWatchRAM[(watches[i].address - 0x7E0000) + r]) << (8 * r); @@ -2033,11 +2031,9 @@ static void DisplayWatchedAddresses (void) { if (watches[i].size == 1) displayNumber = (int32) ((int8) displayNumber); - else - if (watches[i].size == 2) + else if (watches[i].size == 2) displayNumber = (int32) ((int16) displayNumber); - else - if (watches[i].size == 3) + else if (watches[i].size == 3) if (displayNumber >= 8388608) displayNumber -= 16777216;