[Common] Abstract out the decode5A3Image and decodeCI8Image functions in BannerLoaderGC, BannerLoaderWii, and GCMemcard into ColorUtil.cpp. Makes for less copied code and remains functionally the same.

This commit is contained in:
Lioncash
2013-10-02 18:18:54 -04:00
parent b1268bfcd2
commit 1ec4894bc5
7 changed files with 50 additions and 89 deletions

View File

@ -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

View File

@ -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