-
Notifications
You must be signed in to change notification settings - Fork 113
/
OSDManager.cpp
189 lines (182 loc) · 4.77 KB
/
OSDManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "OSDManager.h"
#include "options.h"
extern userOptions *uopt;
extern void saveUserPrefs();
extern void shiftHorizontalRight();
extern void shiftHorizontalLeft();
extern void shiftVerticalDownIF();
extern void shiftVerticalUpIF();
extern void scaleVertical(uint16_t, bool);
extern void scaleHorizontal(uint16_t, bool);
extern OSDManager osdManager;
bool osdBrightness(OSDMenuConfig &config)
{
const int16_t STEP = 8;
int8_t cur = GBS::VDS_Y_OFST::read();
if (config.onChange) {
if (config.inc) {
cur = MIN(cur + STEP, 127);
} else {
cur = MAX(-128, cur - STEP);
}
GBS::VDS_Y_OFST::write(cur);
}
config.barLength = 256 / STEP;
config.barActiveLength = (cur + 128 + 1) / STEP;
return true;
}
bool osdAutoGain(OSDMenuConfig &config)
{
config.barLength = 2;
if (config.onChange) {
uopt->enableAutoGain = config.inc ? 1 : 0;
saveUserPrefs();
}
if (uopt->enableAutoGain == 1) {
config.barActiveLength = 2;
} else {
config.barActiveLength = 0;
}
return true;
}
bool osdScanlines(OSDMenuConfig &config)
{
if (config.onChange) {
if (config.inc) {
if (uopt->scanlineStrength > 0) {
uopt->scanlineStrength -= 0x10;
}
} else {
uopt->scanlineStrength = MIN(uopt->scanlineStrength + 0x10, 0x50);
}
if (uopt->scanlineStrength == 0x50) {
uopt->wantScanlines = 0;
} else {
uopt->wantScanlines = 1;
}
GBS::MADPT_Y_MI_OFFSET::write(uopt->scanlineStrength);
saveUserPrefs();
}
config.barLength = 128;
if (uopt->scanlineStrength == 0) {
config.barActiveLength = 128;
} else {
config.barActiveLength = (5 - uopt->scanlineStrength / 0x10) * 25;
}
return true;
}
bool osdLineFilter(OSDMenuConfig &config)
{
config.barLength = 2;
if (config.onChange) {
uopt->wantVdsLineFilter = config.inc ? 1 : 0;
GBS::VDS_D_RAM_BYPS::write(!uopt->wantVdsLineFilter);
saveUserPrefs();
}
if (uopt->wantVdsLineFilter == 1) {
config.barActiveLength = 2;
} else {
config.barActiveLength = 0;
}
return true;
}
bool osdMoveX(OSDMenuConfig &config)
{
config.barLength = 2;
if (!config.onChange) {
config.barActiveLength = 1;
return true;
}
if (config.inc) {
shiftHorizontalRight();
config.barActiveLength = 2;
} else {
shiftHorizontalLeft();
config.barActiveLength = 0;
}
return false;
}
bool osdMoveY(OSDMenuConfig &config)
{
config.barLength = 2;
if (!config.onChange) {
config.barActiveLength = 1;
return true;
}
if (config.inc) {
shiftVerticalDownIF();
config.barActiveLength = 2;
} else {
shiftVerticalUpIF();
config.barActiveLength = 0;
}
return false;
}
bool osdScaleY(OSDMenuConfig &config)
{
config.barLength = 2;
if (!config.onChange) {
config.barActiveLength = 1;
return true;
}
if (config.inc) {
scaleVertical(2, true);
config.barActiveLength = 2;
} else {
scaleVertical(2, false);
config.barActiveLength = 0;
}
return false;
}
bool osdScaleX(OSDMenuConfig &config)
{
config.barLength = 2;
if (!config.onChange) {
config.barActiveLength = 1;
return true;
}
if (config.inc) {
scaleHorizontal(2, true);
config.barActiveLength = 2;
} else {
scaleHorizontal(2, false);
config.barActiveLength = 0;
}
return false;
}
bool osdContrast(OSDMenuConfig &config)
{
const uint8_t STEP = 8;
int16_t cur = GBS::ADC_RGCTRL::read();
if (config.onChange) {
if (uopt->enableAutoGain == 1) {
uopt->enableAutoGain = 0;
saveUserPrefs();
} else {
uopt->enableAutoGain = 0;
}
if (config.inc) {
cur = MAX(0, cur - STEP);
} else {
cur = MIN(cur + STEP, 255);
}
GBS::ADC_RGCTRL::write(cur);
GBS::ADC_GGCTRL::write(cur);
GBS::ADC_BGCTRL::write(cur);
}
config.barLength = 256 / STEP;
config.barActiveLength = (256 - cur) / STEP;
return true;
}
void initOSD()
{
osdManager.registerIcon(OSDIcon::BRIGHTNESS, osdBrightness);
osdManager.registerIcon(OSDIcon::CONTRAST, osdContrast);
// consufuing, disabled for now
// osdManager.registerIcon(OSDIcon::HUE, osdScanlines);
// osdManager.registerIcon(OSDIcon::VOLUME, osdLineFilter);
osdManager.registerIcon(OSDIcon::MOVE_Y, osdMoveY);
osdManager.registerIcon(OSDIcon::MOVE_X, osdMoveX);
osdManager.registerIcon(OSDIcon::SCALE_Y, osdScaleY);
osdManager.registerIcon(OSDIcon::SCALE_X, osdScaleX);
}