diff --git a/Source/Core/Common/Src/ColorUtil.cpp b/Source/Core/Common/Src/ColorUtil.cpp index f338fb3f47..b23da3a05b 100644 --- a/Source/Core/Common/Src/ColorUtil.cpp +++ b/Source/Core/Common/Src/ColorUtil.cpp @@ -40,4 +40,41 @@ u32 Decode5A3(u16 val) return (a << 24) | (r << 16) | (g << 8) | b; } +void decode5A3image(u32* dst, u16* src, int width, int height) +{ + for (int y = 0; y < height; y += 4) + { + for (int x = 0; x < width; x += 4) + { + for (int iy = 0; iy < 4; iy++, src += 4) + { + for (int ix = 0; ix < 4; ix++) + { + u32 RGBA = Decode5A3(Common::swap16(src[ix])); + dst[(y + iy) * width + (x + ix)] = RGBA; + } + } + } + } +} + +void decodeCI8image(u32* dst, u8* src, u16* pal, int width, int height) +{ + for (int y = 0; y < height; y += 4) + { + for (int x = 0; x < width; x += 8) + { + for (int iy = 0; iy < 4; iy++, src += 8) + { + u32 *tdst = dst+(y+iy)*width+x; + for (int ix = 0; ix < 8; ix++) + { + // huh, this seems wrong. CI8, not 5A3, no? + tdst[ix] = ColorUtil::Decode5A3(Common::swap16(pal[src[ix]])); + } + } + } + } +} + } // namespace diff --git a/Source/Core/Common/Src/ColorUtil.h b/Source/Core/Common/Src/ColorUtil.h index 8b666f1f5c..010d8b1a5c 100644 --- a/Source/Core/Common/Src/ColorUtil.h +++ b/Source/Core/Common/Src/ColorUtil.h @@ -8,7 +8,8 @@ namespace ColorUtil { -u32 Decode5A3(u16 val); +void decode5A3image(u32* dst, u16* src, int width, int height); +void decodeCI8image(u32* dst, u8* src, u16* pal, int width, int height); } // namespace diff --git a/Source/Core/Core/Src/HW/GCMemcard.cpp b/Source/Core/Core/Src/HW/GCMemcard.cpp index b4aa9993de..67102bbc8c 100644 --- a/Source/Core/Core/Src/HW/GCMemcard.cpp +++ b/Source/Core/Core/Src/HW/GCMemcard.cpp @@ -11,43 +11,6 @@ static void ByteSwap(u8 *valueA, u8 *valueB) *valueB = tmp; } -void decode5A3image(u32* dst, u16* src, int width, int height) -{ - for (int y = 0; y < height; y += 4) - { - for (int x = 0; x < width; x += 4) - { - for (int iy = 0; iy < 4; iy++, src += 4) - { - for (int ix = 0; ix < 4; ix++) - { - u32 RGBA = ColorUtil::Decode5A3(Common::swap16(src[ix])); - dst[(y + iy) * width + (x + ix)] = RGBA; - } - } - } - } -} - -void decodeCI8image(u32* dst, u8* src, u16* pal, int width, int height) -{ - for (int y = 0; y < height; y += 4) - { - for (int x = 0; x < width; x += 8) - { - for (int iy = 0; iy < 4; iy++, src += 8) - { - u32 *tdst = dst+(y+iy)*width+x; - for (int ix = 0; ix < 8; ix++) - { - // huh, this seems wrong. CI8, not 5A3, no? - tdst[ix] = ColorUtil::Decode5A3(Common::swap16(pal[src[ix]])); - } - } - } - } -} - GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis) : m_valid(false) , m_fileName(filename) @@ -1083,13 +1046,13 @@ bool GCMemcard::ReadBannerRGBA8(u8 index, u32* buffer) const u8 *pxdata = (u8* )(mc_data_blocks[DataBlock].block + DataOffset); u16 *paldata = (u16*)(mc_data_blocks[DataBlock].block + DataOffset + pixels); - decodeCI8image(buffer, pxdata, paldata, 96, 32); + ColorUtil::decodeCI8image(buffer, pxdata, paldata, 96, 32); } else { u16 *pxdata = (u16*)(mc_data_blocks[DataBlock].block + DataOffset); - decode5A3image(buffer, pxdata, 96, 32); + ColorUtil::decode5A3image(buffer, pxdata, 96, 32); } return true; } @@ -1185,16 +1148,16 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8 *delays) const switch (fmts[i]) { case CI8SHARED: // CI8 with shared palette - decodeCI8image(buffer,data[i],sharedPal,32,32); + ColorUtil::decodeCI8image(buffer,data[i],sharedPal,32,32); buffer += 32*32; break; case RGB5A3: // RGB5A3 - decode5A3image(buffer, (u16*)(data[i]), 32, 32); + ColorUtil::decode5A3image(buffer, (u16*)(data[i]), 32, 32); buffer += 32*32; break; case CI8: // CI8 with own palette u16 *paldata = (u16*)(data[i] + 32*32); - decodeCI8image(buffer, data[i], paldata, 32, 32); + ColorUtil::decodeCI8image(buffer, data[i], paldata, 32, 32); buffer += 32*32; break; } @@ -1211,15 +1174,15 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8 *delays) const switch (fmts[j]) { case CI8SHARED: // CI8 with shared palette - decodeCI8image(buffer,data[j],sharedPal,32,32); + ColorUtil::decodeCI8image(buffer,data[j],sharedPal,32,32); break; case RGB5A3: // RGB5A3 - decode5A3image(buffer, (u16*)(data[j]), 32, 32); + ColorUtil::decode5A3image(buffer, (u16*)(data[j]), 32, 32); buffer += 32*32; break; case CI8: // CI8 with own palette u16 *paldata = (u16*)(data[j] + 32*32); - decodeCI8image(buffer, data[j], paldata, 32, 32); + ColorUtil::decodeCI8image(buffer, data[j], paldata, 32, 32); buffer += 32*32; break; } diff --git a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp index a4f07c5fdc..c03af4f86a 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp @@ -55,7 +55,7 @@ std::vector CBannerLoaderGC::GetBanner(int* pWidth, int* pHeight) std::vector Buffer; Buffer.resize(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT); auto const pBanner = (DVDBanner*)m_pBannerFile; - decode5A3image(&Buffer[0], pBanner->image, DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT); + ColorUtil::decode5A3image(&Buffer[0], pBanner->image, DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT); *pWidth = DVD_BANNER_WIDTH; *pHeight = DVD_BANNER_HEIGHT; return Buffer; @@ -163,25 +163,6 @@ std::vector CBannerLoaderGC::GetDescriptions() return descriptions; } - -void CBannerLoaderGC::decode5A3image(u32* dst, u16* src, int width, int height) -{ - for (int y = 0; y < height; y += 4) - { - for (int x = 0; x < width; x += 4) - { - for (int iy = 0; iy < 4; iy++, src += 4) - { - for (int ix = 0; ix < 4; ix++) - { - u32 RGBA = ColorUtil::Decode5A3(Common::swap16(src[ix])); - dst[(y + iy) * width + (x + ix)] = RGBA; - } - } - } - } -} - CBannerLoaderGC::BANNER_TYPE CBannerLoaderGC::getBannerType() { u32 bannerSignature = *(u32*)m_pBannerFile; diff --git a/Source/Core/DiscIO/Src/BannerLoaderGC.h b/Source/Core/DiscIO/Src/BannerLoaderGC.h index e18a2fee82..133ee91978 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderGC.h +++ b/Source/Core/DiscIO/Src/BannerLoaderGC.h @@ -75,9 +75,8 @@ class CBannerLoaderGC bool m_IsValid; BANNER_TYPE m_BNRType; - void decode5A3image(u32* dst, u16* src, int width, int height); BANNER_TYPE getBannerType(); - + DiscIO::IVolume::ECountry const m_country; }; diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index a3b7f56172..777d436df2 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -103,7 +103,7 @@ std::vector CBannerLoaderWii::GetBanner(int* pWidth, int* pHeight) SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; std::vector Buffer; Buffer.resize(192 * 64); - decode5A3image(&Buffer[0], (u16*)pBanner->m_BannerTexture, 192, 64); + ColorUtil::decode5A3image(&Buffer[0], (u16*)pBanner->m_BannerTexture, 192, 64); *pWidth = 192; *pHeight = 64; return Buffer; @@ -153,22 +153,4 @@ std::vector CBannerLoaderWii::GetDescriptions() return result; } -void CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height) -{ - for (int y = 0; y < height; y += 4) - { - for (int x = 0; x < width; x += 4) - { - for (int iy = 0; iy < 4; iy++, src += 4) - { - for (int ix = 0; ix < 4; ix++) - { - u32 RGBA = ColorUtil::Decode5A3(Common::swap16(src[ix])); - dst[(y + iy) * width + (x + ix)] = RGBA; - } - } - } - } -} - } // namespace diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.h b/Source/Core/DiscIO/Src/BannerLoaderWii.h index 455213cbf9..84e106d1ba 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.h +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.h @@ -59,8 +59,6 @@ class CBannerLoaderWii bool m_IsValid; - void decode5A3image(u32* dst, u16* src, int width, int height); - bool GetStringFromComments(const CommentIndex index, std::string& s); }; } // namespace