From 46044c068b7aa694e9485344039ce4962abf1376 Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 11 Dec 2021 18:33:28 +0100 Subject: [PATCH] cheats: don't rely on cheat count on load. Fix compile warnings --- core/cfg/option.h | 6 +++--- core/cheats.cpp | 4 +++- core/hw/flashrom/flashrom.h | 4 ++-- core/hw/maple/maple_devs.h | 4 ++-- core/hw/sh4/dyna/ssa.h | 2 +- core/hw/sh4/dyna/ssa_regalloc.h | 2 +- core/hw/sh4/interpr/sh4_interpreter.cpp | 6 +++--- core/hw/sh4/sh4_cache.h | 4 ++-- core/imgread/common.h | 2 +- core/imgread/gdi.cpp | 2 +- core/oslib/audiostream.h | 8 ++++---- core/reios/gdrom_hle.cpp | 4 ++-- core/rend/TexCache.h | 2 +- core/rend/transform_matrix.h | 4 ++-- core/stdclass.h | 10 +++++----- 15 files changed, 33 insertions(+), 31 deletions(-) diff --git a/core/cfg/option.h b/core/cfg/option.h index 548606aba..2d017a725 100644 --- a/core/cfg/option.h +++ b/core/cfg/option.h @@ -198,7 +198,7 @@ protected: if (strValue.empty()) return value; else - return atof(strValue.c_str()); + return (float)atof(strValue.c_str()); } template @@ -382,9 +382,9 @@ public: void calcDbPower() { // dB scaling calculation: https://www.dr-lex.be/info-stuff/volumecontrols.html - logarithmic_volume_scale = fmin(exp(4.605 * float(value) / 100.0) / 100.0, 1.0); + logarithmic_volume_scale = std::min(std::exp(4.605f * float(value) / 100.f) / 100.f, 1.f); if (value < 10) - logarithmic_volume_scale *= value / 10.0; + logarithmic_volume_scale *= value / 10.f; } }; extern AudioVolumeOption AudioVolume; diff --git a/core/cheats.cpp b/core/cheats.cpp index d7427d340..e2e2cf653 100644 --- a/core/cheats.cpp +++ b/core/cheats.cpp @@ -319,12 +319,14 @@ void CheatManager::loadCheatFile(const std::string& filename) int count = cfg.get_int("", "cheats", 0); cheats.clear(); - for (int i = 0; i < count; i++) + for (int i = 0; count == 0 || i < count; i++) { std::string prefix = "cheat" + std::to_string(i) + "_"; Cheat cheat{}; cheat.description = cfg.get("", prefix + "desc", "Cheat " + std::to_string(i + 1)); cheat.address = cfg.get_int("", prefix + "address", -1); + if (count == 0 && cheat.address == (u32)-1) + break; if (cheat.address >= RAM_SIZE) { WARN_LOG(COMMON, "Invalid address %x", cheat.address); diff --git a/core/hw/flashrom/flashrom.h b/core/hw/flashrom/flashrom.h index 6d7f0ac86..d00e448d8 100644 --- a/core/hw/flashrom/flashrom.h +++ b/core/hw/flashrom/flashrom.h @@ -496,11 +496,11 @@ struct DCFlashChip : WritableChip bool valid = true; char sysinfo[16]; - for (size_t i = 0; i < sizeof(sysinfo); i++) + for (u32 i = 0; i < sizeof(sysinfo); i++) sysinfo[i] = Read8(0x1a000 + i); valid = valid && memcmp(&sysinfo[5], "Dreamcast ", 11) == 0; - for (size_t i = 0; i < sizeof(sysinfo); i++) + for (u32 i = 0; i < sizeof(sysinfo); i++) sysinfo[i] = Read8(0x1a0a0 + i); valid = valid && memcmp(&sysinfo[5], "Dreamcast ", 11) == 0; diff --git a/core/hw/maple/maple_devs.h b/core/hw/maple/maple_devs.h index 277ccc496..d290de368 100755 --- a/core/hw/maple/maple_devs.h +++ b/core/hw/maple/maple_devs.h @@ -155,7 +155,7 @@ maple_device* maple_Create(MapleDeviceType type); template void limit_joystick_magnitude(s8& joyx, s8& joyy) { - float mag = joyx * joyx + joyy * joyy; + float mag = (float)joyx * joyx + (float)joyy * joyy; if (mag > (float)Magnitude * Magnitude) { mag = sqrtf(mag) / (float)Magnitude; @@ -195,7 +195,7 @@ struct maple_base: maple_device void wstr(const char* str, u32 len) { - size_t ln = strlen(str); + u32 ln = (u32)strlen(str); verify(len >= ln); len -= ln; while (ln--) diff --git a/core/hw/sh4/dyna/ssa.h b/core/hw/sh4/dyna/ssa.h index 3c06a6714..02f261518 100644 --- a/core/hw/sh4/dyna/ssa.h +++ b/core/hw/sh4/dyna/ssa.h @@ -329,7 +329,7 @@ private: std::set uses; memset(last_versions, -1, sizeof(last_versions)); - for (int opnum = block->oplist.size() - 1; opnum >= 0; opnum--) + for (int opnum = (int)block->oplist.size() - 1; opnum >= 0; opnum--) { shil_opcode& op = block->oplist[opnum]; bool dead_code = false; diff --git a/core/hw/sh4/dyna/ssa_regalloc.h b/core/hw/sh4/dyna/ssa_regalloc.h index ce3bc0bc0..5f2b31bd4 100644 --- a/core/hw/sh4/dyna/ssa_regalloc.h +++ b/core/hw/sh4/dyna/ssa_regalloc.h @@ -491,7 +491,7 @@ private: // Find the first use, but ignore vec ops int first_use = -1; - for (size_t i = opnum + (source ? 0 : 1); i < block->oplist.size(); i++) + for (u32 i = opnum + (source ? 0 : 1); i < (u32)block->oplist.size(); i++) { op = &block->oplist[i]; // Vector ops don't use reg alloc diff --git a/core/hw/sh4/interpr/sh4_interpreter.cpp b/core/hw/sh4/interpr/sh4_interpreter.cpp index 285339ee0..2185c55a4 100644 --- a/core/hw/sh4/interpr/sh4_interpreter.cpp +++ b/core/hw/sh4/interpr/sh4_interpreter.cpp @@ -57,7 +57,7 @@ static void Sh4_int_Run() p_sh4rcb->cntx.cycle_counter -= CPU_RATIO * 5; // an exception requires the instruction pipeline to drain, so approx 5 cycles } } while (sh4_int_bCpuRun); - } catch (const debugger::Stop& e) { + } catch (const debugger::Stop&) { } sh4_int_bCpuRun = false; @@ -79,7 +79,7 @@ static void Sh4_int_Step() } catch (const SH4ThrownException& ex) { Do_Exception(ex.epc, ex.expEvn, ex.callVect); p_sh4rcb->cntx.cycle_counter -= CPU_RATIO * 5; // an exception requires the instruction pipeline to drain, so approx 5 cycles - } catch (const debugger::Stop& e) { + } catch (const debugger::Stop&) { } } @@ -140,7 +140,7 @@ void ExecuteDelayslot_RTE() { try { ExecuteDelayslot(); - } catch (const SH4ThrownException& ex) { + } catch (const SH4ThrownException&) { throw FlycastException("Fatal: SH4 exception in RTE delay slot"); } } diff --git a/core/hw/sh4/sh4_cache.h b/core/hw/sh4/sh4_cache.h index ca3ea93e5..a6a9feed5 100644 --- a/core/hw/sh4/sh4_cache.h +++ b/core/hw/sh4/sh4_cache.h @@ -112,7 +112,7 @@ public: u32 ReadAddressArray(u32 addr) { u32 index = (addr >> 5) & 0xFF; - return lines[index].valid | (lines[index].address << 10); + return (u32)lines[index].valid | (lines[index].address << 10); } void WriteAddressArray(u32 addr, u32 data) @@ -377,7 +377,7 @@ public: u32 ReadAddressArray(u32 addr) { u32 index = (addr >> 5) & 0x1FF; - return lines[index].valid | (lines[index].dirty << 1) | (lines[index].address << 10); + return (u32)lines[index].valid | ((u32)lines[index].dirty << 1) | (lines[index].address << 10); } void WriteAddressArray(u32 addr, u32 data) diff --git a/core/imgread/common.h b/core/imgread/common.h index 166c1a792..5bd33e004 100644 --- a/core/imgread/common.h +++ b/core/imgread/common.h @@ -233,7 +233,7 @@ namespace flycast inline static size_t fsize(FILE *f) { - size_t p = std::ftell(f); + long p = std::ftell(f); std::fseek(f, 0, SEEK_END); size_t size = std::ftell(f); std::fseek(f, p, SEEK_SET); diff --git a/core/imgread/gdi.cpp b/core/imgread/gdi.cpp index 79c798c48..d7d9b9530 100644 --- a/core/imgread/gdi.cpp +++ b/core/imgread/gdi.cpp @@ -3,7 +3,7 @@ #include #include -// On windows, transform / to \\ +// On windows, transform slashes to backslashes std::string normalize_path_separator(std::string path) { diff --git a/core/oslib/audiostream.h b/core/oslib/audiostream.h index 2f9131683..00cc749af 100644 --- a/core/oslib/audiostream.h +++ b/core/oslib/audiostream.h @@ -64,10 +64,10 @@ class RingBuffer std::atomic_int writeCursor { 0 }; u32 readSize() { - return (writeCursor - readCursor + buffer.size()) % buffer.size(); + return (u32)((writeCursor - readCursor + buffer.size()) % buffer.size()); } u32 writeSize() { - return (readCursor - writeCursor + buffer.size() - 1) % buffer.size(); + return (u32)((readCursor - writeCursor + buffer.size() - 1) % buffer.size()); } public: @@ -76,7 +76,7 @@ public: if (size > writeSize()) return false; u32 wc = writeCursor; - u32 chunkSize = std::min(size, buffer.size() - wc); + u32 chunkSize = std::min(size, (u32)buffer.size() - wc); memcpy(&buffer[wc], data, chunkSize); wc = (wc + chunkSize) % buffer.size(); size -= chunkSize; @@ -95,7 +95,7 @@ public: if (size > readSize()) return false; u32 rc = readCursor; - u32 chunkSize = std::min(size, buffer.size() - rc); + u32 chunkSize = std::min(size, (u32)buffer.size() - rc); memcpy(data, &buffer[rc], chunkSize); rc = (rc + chunkSize) % buffer.size(); size -= chunkSize; diff --git a/core/reios/gdrom_hle.cpp b/core/reios/gdrom_hle.cpp index 1691bf84b..ee7e61dfa 100644 --- a/core/reios/gdrom_hle.cpp +++ b/core/reios/gdrom_hle.cpp @@ -567,7 +567,7 @@ void gdrom_hle_op() { try { gd_hle_state.params[i] = r[5] == 0 ? 0 : ReadMem32(r[5] + i * 4); - } catch (SH4ThrownException& ex) { + } catch (SH4ThrownException&) { // Ignore page faults. happens for commands not taking params gd_hle_state.params[i] = 0; } @@ -600,7 +600,7 @@ void gdrom_hle_op() WriteMem32(r[5] + 4, gd_hle_state.result[1]); WriteMem32(r[5] + 8, gd_hle_state.result[2]); WriteMem32(r[5] + 12, gd_hle_state.result[3]); - } catch (SH4ThrownException& ex) { + } catch (SH4ThrownException&) { } if (gd_hle_state.status == BIOS_INACTIVE || gd_hle_state.status == BIOS_ACTIVE) { diff --git a/core/rend/TexCache.h b/core/rend/TexCache.h index 21d8bb81f..4e595e1e2 100644 --- a/core/rend/TexCache.h +++ b/core/rend/TexCache.h @@ -84,7 +84,7 @@ public: void set_mipmap(int level) { - size_t offset = 0; + u32 offset = 0; for (int i = 0; i < level; i++) offset += (1 << (2 * i)); p_current_mipmap = p_current_line = p_current_pixel = p_buffer_start + offset; diff --git a/core/rend/transform_matrix.h b/core/rend/transform_matrix.h index 5dac245cd..7567ad826 100644 --- a/core/rend/transform_matrix.h +++ b/core/rend/transform_matrix.h @@ -87,8 +87,8 @@ public: if (renderingContext->isRTT) { - dcViewport.x = renderingContext->fb_X_CLIP.max - renderingContext->fb_X_CLIP.min + 1; - dcViewport.y = renderingContext->fb_Y_CLIP.max - renderingContext->fb_Y_CLIP.min + 1; + dcViewport.x = (float)(renderingContext->fb_X_CLIP.max - renderingContext->fb_X_CLIP.min + 1); + dcViewport.y = (float)(renderingContext->fb_Y_CLIP.max - renderingContext->fb_Y_CLIP.min + 1); normalMatrix = glm::translate(glm::vec3(-1, -rttFlipY, 0)) * glm::scale(glm::vec3(2.0f / dcViewport.x, 2.0f / dcViewport.y * rttFlipY, 1.f)); scissorMatrix = normalMatrix; diff --git a/core/stdclass.h b/core/stdclass.h index 2b25e293a..eebd96ca5 100644 --- a/core/stdclass.h +++ b/core/stdclass.h @@ -149,7 +149,7 @@ public: MD5_Init(&ctx); } - MD5Sum& add(const void *data, size_t len) { + MD5Sum& add(const void *data, unsigned long len) { MD5_Update(&ctx, data, len); return *this; } @@ -157,21 +157,21 @@ public: MD5Sum& add(std::FILE *file) { std::fseek(file, 0, SEEK_SET); char buf[4096]; - size_t len = 0; - while ((len = std::fread(buf, 1, sizeof(buf), file)) > 0) + unsigned long len = 0; + while ((len = (unsigned long)std::fread(buf, 1, sizeof(buf), file)) > 0) MD5_Update(&ctx, buf, len); return *this; } template MD5Sum& add(const T& v) { - MD5_Update(&ctx, &v, sizeof(T)); + MD5_Update(&ctx, &v, (unsigned long)sizeof(T)); return *this; } template MD5Sum& add(const std::vector& v) { - MD5_Update(&ctx, &v[0], v.size() * sizeof(T)); + MD5_Update(&ctx, &v[0], (unsigned long)(v.size() * sizeof(T))); return *this; }