summaryrefslogtreecommitdiff
path: root/src/core/hw/lcd.h
diff options
context:
space:
mode:
authorGravatar archshift2014-10-12 22:40:26 -0700
committerGravatar archshift2015-03-09 15:51:41 -0700
commit041e99b6132775ff52822060512b8384b735e582 (patch)
treecd8dee92a0b578e512a188cd7e70239b627a5341 /src/core/hw/lcd.h
parentImplement SetLcdForceBlack, move register enum to hw.h (diff)
downloadyuzu-041e99b6132775ff52822060512b8384b735e582.tar.gz
yuzu-041e99b6132775ff52822060512b8384b735e582.tar.xz
yuzu-041e99b6132775ff52822060512b8384b735e582.zip
Added LCD registers, and implementation for color filling in OGL code.
Diffstat (limited to 'src/core/hw/lcd.h')
-rw-r--r--src/core/hw/lcd.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h
new file mode 100644
index 000000000..43893a625
--- /dev/null
+++ b/src/core/hw/lcd.h
@@ -0,0 +1,88 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <cstddef>
8
9#include "common/common_types.h"
10#include "common/bit_field.h"
11
12#define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32))
13
14namespace LCD {
15
16struct Regs {
17
18 union ColorFill {
19 u32 raw;
20
21 BitField<0, 8, u32> color_r;
22 BitField<8, 8, u32> color_g;
23 BitField<16, 8, u32> color_b;
24 BitField<24, 1, u32> is_enabled;
25 };
26
27 INSERT_PADDING_WORDS(0x81);
28 ColorFill color_fill_top;
29 INSERT_PADDING_WORDS(0xE);
30 u32 backlight_top;
31
32 INSERT_PADDING_WORDS(0x1F0);
33
34 ColorFill color_fill_bottom;
35 INSERT_PADDING_WORDS(0xE);
36 u32 backlight_bottom;
37 INSERT_PADDING_WORDS(0x16F);
38
39 static inline size_t NumIds() {
40 return sizeof(Regs) / sizeof(u32);
41 }
42
43 u32& operator [] (int index) const {
44 u32* content = (u32*)this;
45 return content[index];
46 }
47
48 u32& operator [] (int index) {
49 u32* content = (u32*)this;
50 return content[index];
51 }
52
53#undef ASSERT_MEMBER_SIZE
54
55};
56static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout");
57
58// TODO: MSVC does not support using offsetof() on non-static data members even though this
59// is technically allowed since C++11. This macro should be enabled once MSVC adds
60// support for that.
61#ifndef _MSC_VER
62#define ASSERT_REG_POSITION(field_name, position) \
63 static_assert(offsetof(Regs, field_name) == position * 4, \
64 "Field "#field_name" has invalid position")
65
66ASSERT_REG_POSITION(color_fill_top, 0x81);
67ASSERT_REG_POSITION(backlight_top, 0x90);
68ASSERT_REG_POSITION(color_fill_bottom, 0x281);
69ASSERT_REG_POSITION(backlight_bottom, 0x290);
70
71#undef ASSERT_REG_POSITION
72#endif // !defined(_MSC_VER)
73
74extern Regs g_regs;
75
76template <typename T>
77void Read(T &var, const u32 addr);
78
79template <typename T>
80void Write(u32 addr, const T data);
81
82/// Initialize hardware
83void Init();
84
85/// Shutdown hardware
86void Shutdown();
87
88} // namespace