summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2014-12-31 15:17:07 +0100
committerTony Wasserka <NeoBrainX@gmail.com>2014-12-31 16:32:55 +0100
commit47543d62cf9e982598f58438ad24769c2b36ec77 (patch)
tree856ccab2a9165d0a50def92f958851566bb93b2b /src/video_core
parentVideoCore: Remove some unused functions. (diff)
downloadyuzu-47543d62cf9e982598f58438ad24769c2b36ec77.tar
yuzu-47543d62cf9e982598f58438ad24769c2b36ec77.tar.gz
yuzu-47543d62cf9e982598f58438ad24769c2b36ec77.tar.bz2
yuzu-47543d62cf9e982598f58438ad24769c2b36ec77.tar.lz
yuzu-47543d62cf9e982598f58438ad24769c2b36ec77.tar.xz
yuzu-47543d62cf9e982598f58438ad24769c2b36ec77.tar.zst
yuzu-47543d62cf9e982598f58438ad24769c2b36ec77.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/color.h32
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp32
2 files changed, 46 insertions, 18 deletions
diff --git a/src/video_core/color.h b/src/video_core/color.h
new file mode 100644
index 000000000..e86ac1265
--- /dev/null
+++ b/src/video_core/color.h
@@ -0,0 +1,32 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include "common/common_types.h"
+
+namespace Color {
+
+/// Convert a 1-bit color component to 8 bit
+static inline u8 Convert1To8(u8 value) {
+ return value * 255;
+}
+
+/// Convert a 4-bit color component to 8 bit
+static inline u8 Convert4To8(u8 value) {
+ return (value << 4) | value;
+}
+
+/// Convert a 5-bit color component to 8 bit
+static inline u8 Convert5To8(u8 value) {
+ return (value << 3) | (value >> 2);
+}
+
+/// Convert a 6-bit color component to 8 bit
+static inline u8 Convert6To8(u8 value) {
+ return (value << 2) | (value >> 4);
+}
+
+
+} // namespace
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 83d585d16..a494465b9 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -19,6 +19,7 @@
#include "common/log.h"
#include "common/file_util.h"
+#include "video_core/color.h"
#include "video_core/math.h"
#include "video_core/pica.h"
@@ -359,29 +360,26 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
u8 g = ((source_ptr) >> 6) & 0x1F;
u8 b = (source_ptr >> 1) & 0x1F;
u8 a = source_ptr & 1;
- return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), disable_alpha ? 255 : (a * 255));
+ return Math::MakeVec<u8>(Color::Convert5To8(r), Color::Convert5To8(g),
+ Color::Convert5To8(b), disable_alpha ? 255 : Color::Convert1To8(a));
}
case Regs::TextureFormat::RGB565:
{
const u16 source_ptr = *(const u16*)(source + offset * 2);
- u8 r = (source_ptr >> 11) & 0x1F;
- u8 g = ((source_ptr) >> 5) & 0x3F;
- u8 b = (source_ptr) & 0x1F;
- return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), 255);
+ u8 r = Color::Convert5To8((source_ptr >> 11) & 0x1F);
+ u8 g = Color::Convert6To8(((source_ptr) >> 5) & 0x3F);
+ u8 b = Color::Convert5To8((source_ptr) & 0x1F);
+ return Math::MakeVec<u8>(r, g, b, 255);
}
case Regs::TextureFormat::RGBA4:
{
const u8* source_ptr = source + offset * 2;
- u8 r = source_ptr[1] >> 4;
- u8 g = source_ptr[1] & 0xF;
- u8 b = source_ptr[0] >> 4;
- u8 a = source_ptr[0] & 0xF;
- r = (r << 4) | r;
- g = (g << 4) | g;
- b = (b << 4) | b;
- a = (a << 4) | a;
+ u8 r = Color::Convert4To8(source_ptr[1] >> 4);
+ u8 g = Color::Convert4To8(source_ptr[1] & 0xF);
+ u8 b = Color::Convert4To8(source_ptr[0] >> 4);
+ u8 a = Color::Convert4To8(source_ptr[0] & 0xF);
return { r, g, b, disable_alpha ? (u8)255 : a };
}
@@ -418,10 +416,8 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
{
const u8* source_ptr = source + offset;
- u8 i = ((*source_ptr) & 0xF0) >> 4;
- u8 a = (*source_ptr) & 0xF;
- a |= a << 4;
- i |= i << 4;
+ u8 i = Color::Convert4To8(((*source_ptr) & 0xF0) >> 4);
+ u8 a = Color::Convert4To8((*source_ptr) & 0xF);
if (disable_alpha) {
// Show intensity as red, alpha as green
@@ -436,7 +432,7 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
const u8* source_ptr = source + offset / 2;
u8 a = (coarse_x % 2) ? ((*source_ptr)&0xF) : (((*source_ptr) & 0xF0) >> 4);
- a |= a << 4;
+ a = Color::Convert4To8(a);
if (disable_alpha) {
return { a, a, a, 255 };