From 8f175aebe1304fb3af830309ec82f6c1febfe6c6 Mon Sep 17 00:00:00 2001 From: tobid7 Date: Tue, 21 Oct 2025 09:57:20 +0200 Subject: [PATCH] Fix sign compare issues --- source/binutil.cpp | 4 ++-- source/helper.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/binutil.cpp b/source/binutil.cpp index 1eed924..eeeb63a 100644 --- a/source/binutil.cpp +++ b/source/binutil.cpp @@ -21,7 +21,7 @@ void BinUtil::Read(T& v) { // Read data into buffer m_file.read(reinterpret_cast(buf.data()), sizeof(T)); // Loop or in be reverse loop and chift the values - for (int i = 0; i < sizeof(T); i++) { + for (size_t i = 0; i < sizeof(T); i++) { v |= static_cast(buf[m_big ? sizeof(T) - 1 - i : i]) << (8 * i); } } @@ -38,4 +38,4 @@ void BinUtil::Write(const T& v) { // Write buffer into file m_file.write(reinterpret_cast(buf.data()), sizeof(T)); } -} // namespace ctrff \ No newline at end of file +} // namespace ctrff diff --git a/source/helper.cpp b/source/helper.cpp index e3ad894..951d882 100644 --- a/source/helper.cpp +++ b/source/helper.cpp @@ -31,8 +31,8 @@ CTRFF_API void ctrff::RGB565toRGBA(std::vector &img, PD::u16 *icon, img.resize(48 * 48 * 4); img.clear(); } - for (PD::u32 y = 0; y < h; y++) { - for (PD::u32 x = 0; x < w; x++) { + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { auto idx = TileIndex(x, y, w); PD::u32 pos = (y * w + x) * 4; MakePixelRGBA(img[pos + 0], img[pos + 1], img[pos + 2], img[pos + 3], @@ -45,8 +45,8 @@ CTRFF_API void ctrff::RGBA2RGB565(PD::u16 *out, const std::vector &img, const int &w, const int &h) { if (img.size() != size_t(w * h * 4)) return; std::vector px8 = img; - for (PD::u32 y = 0; y < h; y++) { - for (PD::u32 x = 0; x < w; x++) { + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { auto idx = TileIndex(x, y, w); PD::u32 pos = (y * w + x) * 4; out[idx] = MakePixel565(img[pos], img[pos + 1], img[pos + 2]); @@ -148,7 +148,7 @@ CTRFF_API std::string ctrff::U16toU8(PD::u16 *in, size_t max) { result.push_back(static_cast(0x80 | (c & 0x3F))); } else if (c < 0x10000) { result.push_back(static_cast(0xE0 | (c >> 12))); - result.push_back(static_cast(0x80 | ((c >> 6) & 0x3F))); +result.push_back(static_cast(0x80 | ((c >> 6) & 0x3F))); result.push_back(static_cast(0x80 | (c & 0x3F))); } else { continue; @@ -156,4 +156,4 @@ CTRFF_API std::string ctrff::U16toU8(PD::u16 *in, size_t max) { } return result; -} \ No newline at end of file +}