summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-02-22 12:43:25 +0000
committerhrydgard <hrydgard@gmail.com>2009-02-22 12:43:25 +0000
commitaff0f1fbe3a8ebe9b2968fe506fdb1f072725c3d (patch)
treed465b6780f39dc9ec195d503da14a0f9da2772df /Source/Core/DiscIO
parent8276ca3b218664201065212c905d6de95d8e4d54 (diff)
Consolidate the three implementations of Decode5A3 found in Core into one. Fix some warnings.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2364 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DiscIO')
-rw-r--r--Source/Core/DiscIO/Src/BannerLoaderGC.cpp46
-rw-r--r--Source/Core/DiscIO/Src/BannerLoaderGC.h16
-rw-r--r--Source/Core/DiscIO/Src/BannerLoaderWii.cpp53
-rw-r--r--Source/Core/DiscIO/Src/BannerLoaderWii.h7
4 files changed, 5 insertions, 117 deletions
diff --git a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp
index b04b1aaa95..9afcb3d119 100644
--- a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp
+++ b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp
@@ -20,6 +20,7 @@
// HyperIris: need clean code
#include "../../Core/Src/ConfigManager.h"
+#include "ColorUtil.h"
#include "BannerLoaderGC.h"
namespace DiscIO
@@ -28,22 +29,6 @@ CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem)
: m_pBannerFile(NULL),
m_IsValid(false)
{
- // build LUT Table
- for (int i = 0; i < 8; i++)
- {
- lut3to8[i] = (i * 255) / 7;
- }
-
- for (int i = 0; i < 16; i++)
- {
- lut4to8[i] = (i * 255) / 15;
- }
-
- for (int i = 0; i < 32; i++)
- {
- lut5to8[i] = (i * 255) / 31;
- }
-
// load the opening.bnr
size_t FileSize = (size_t) _rFileSystem.GetFileSize("opening.bnr");
@@ -216,33 +201,6 @@ CBannerLoaderGC::GetDescription(std::string* _rDescription)
}
-u32
-CBannerLoaderGC::decode5A3(u16 val)
-{
- u32 bannerBGColor = 0x00000000;
-
- int r, g, b, a;
-
- if ((val & 0x8000))
- {
- r = lut5to8[(val >> 10) & 0x1f];
- g = lut5to8[(val >> 5) & 0x1f];
- b = lut5to8[(val) & 0x1f];
- a = 0xFF;
- }
- else
- {
- a = lut3to8[(val >> 12) & 0x7];
- r = (lut4to8[(val >> 8) & 0xf] * a + (bannerBGColor & 0xFF) * (255 - a)) / 255;
- g = (lut4to8[(val >> 4) & 0xf] * a + ((bannerBGColor >> 8) & 0xFF) * (255 - a)) / 255;
- b = (lut4to8[(val) & 0xf] * a + ((bannerBGColor >> 16) & 0xFF) * (255 - a)) / 255;
- a = 0xFF;
- }
-
- return((a << 24) | (r << 16) | (g << 8) | b);
-}
-
-
void
CBannerLoaderGC::decode5A3image(u32* dst, u16* src, int width, int height)
{
@@ -254,7 +212,7 @@ CBannerLoaderGC::decode5A3image(u32* dst, u16* src, int width, int height)
{
for (int ix = 0; ix < 4; ix++)
{
- u32 RGBA = decode5A3(Common::swap16(src[ix]));
+ u32 RGBA = ColorUtil::Decode5A3(Common::swap16(src[ix]));
dst[(y + iy) * width + (x + ix)] = RGBA;
}
}
diff --git a/Source/Core/DiscIO/Src/BannerLoaderGC.h b/Source/Core/DiscIO/Src/BannerLoaderGC.h
index a72830cbab..1c164ff377 100644
--- a/Source/Core/DiscIO/Src/BannerLoaderGC.h
+++ b/Source/Core/DiscIO/Src/BannerLoaderGC.h
@@ -26,24 +26,17 @@ class CBannerLoaderGC
: public IBannerLoader
{
public:
-
CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem);
-
virtual ~CBannerLoaderGC();
virtual bool IsValid();
virtual bool GetBanner(u32* _pBannerImage);
-
virtual bool GetName(std::string* _rName);
-
virtual bool GetCompany(std::string& _rCompany);
-
virtual bool GetDescription(std::string* _rDescription);
-
private:
-
enum
{
DVD_BANNER_WIDTH = 96,
@@ -85,20 +78,13 @@ class CBannerLoaderGC
DVDBannerComment comment[6]; // Comments in six languages
};
-
- // for banner decoding
- int lut3to8[8];
- int lut4to8[16];
- int lut5to8[32];
-
u8* m_pBannerFile;
-
bool m_IsValid;
- u32 decode5A3(u16 val);
void decode5A3image(u32* dst, u16* src, int width, int height);
BANNER_TYPE getBannerType();
};
+
} // namespace
#endif
diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp
index 6989561d7c..eae62f0152 100644
--- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp
+++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp
@@ -20,6 +20,7 @@
#include <stdio.h>
#include "Common.h"
+#include "ColorUtil.h"
#include "BannerLoaderWii.h"
#include "FileUtil.h"
@@ -29,8 +30,6 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem)
: m_pBannerFile(NULL)
, m_IsValid(false)
{
- InitLUTTable();
-
char Filename[260];
char TitleID[4];
@@ -143,54 +142,6 @@ CBannerLoaderWii::GetDescription(std::string* _rDescription)
return false;
}
-
-void
-CBannerLoaderWii::InitLUTTable()
-{
- // build LUT Table
- for (int i = 0; i < 8; i++)
- {
- lut3to8[i] = (i * 255) / 7;
- }
-
- for (int i = 0; i < 16; i++)
- {
- lut4to8[i] = (i * 255) / 15;
- }
-
- for (int i = 0; i < 32; i++)
- {
- lut5to8[i] = (i * 255) / 31;
- }
-}
-
-u32
-CBannerLoaderWii::decode5A3(u16 val)
-{
- u32 bannerBGColor = 0x00000000;
-
- int r, g, b, a;
-
- if ((val & 0x8000))
- {
- r = lut5to8[(val >> 10) & 0x1f];
- g = lut5to8[(val >> 5) & 0x1f];
- b = lut5to8[(val) & 0x1f];
- a = 0xFF;
- }
- else
- {
- a = lut3to8[(val >> 12) & 0x7];
- r = (lut4to8[(val >> 8) & 0xf] * a + (bannerBGColor & 0xFF) * (255 - a)) / 255;
- g = (lut4to8[(val >> 4) & 0xf] * a + ((bannerBGColor >> 8) & 0xFF) * (255 - a)) / 255;
- b = (lut4to8[(val) & 0xf] * a + ((bannerBGColor >> 16) & 0xFF) * (255 - a)) / 255;
- a = 0xFF;
- }
-
- return ((a << 24) | (r << 16) | (g << 8) | b);
-}
-
-
void
CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height)
{
@@ -202,7 +153,7 @@ CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height)
{
for (int ix = 0; ix < 4; ix++)
{
- u32 RGBA = decode5A3(Common::swap16(src[ix]));
+ u32 RGBA = ColorUtil::Decode5A3(Common::swap16(src[ix]));
dst[(y + iy) * width + (x + ix)] = RGBA;
}
}
diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.h b/Source/Core/DiscIO/Src/BannerLoaderWii.h
index 539bf71754..3b5b5110cc 100644
--- a/Source/Core/DiscIO/Src/BannerLoaderWii.h
+++ b/Source/Core/DiscIO/Src/BannerLoaderWii.h
@@ -61,17 +61,10 @@ class CBannerLoaderWii
u8 m_IconTexture[8][WII_BANNER_ICON_SIZE];
} ;
- // for banner decoding
- int lut3to8[8];
- int lut4to8[16];
- int lut5to8[32];
-
u8* m_pBannerFile;
bool m_IsValid;
- void InitLUTTable();
- u32 decode5A3(u16 val);
void decode5A3image(u32* dst, u16* src, int width, int height);
};
} // namespace