openMSX
Main Page
Namespaces
Classes
Files
File List
File Members
video
DisplayMode.hh
Go to the documentation of this file.
1
#ifndef DISPLAYMODE_HH
2
#define DISPLAYMODE_HH
3
4
#include "
openmsx.hh
"
5
6
namespace
openmsx {
7
14
class
DisplayMode
15
{
16
private
:
17
explicit
DisplayMode
(
byte
mode_) : mode(mode_) {}
22
byte
mode;
23
24
public
:
25
enum
{
26
GRAPHIC1
= 0x00,
// Graphic 1
27
TEXT1
= 0x01,
// Text 1
28
MULTICOLOR
= 0x02,
// Multicolor
29
GRAPHIC2
= 0x04,
// Graphic 2
30
TEXT1Q
= 0x05,
// !!
31
MULTIQ
= 0x06,
// !!
32
GRAPHIC3
= 0x08,
// Graphic 3
33
TEXT2
= 0x09,
// Text 2
34
GRAPHIC4
= 0x0C,
// Graphic 4
35
GRAPHIC5
= 0x10,
// Graphic 5
36
GRAPHIC6
= 0x14,
// Graphic 6
37
GRAPHIC7
= 0x1C
// Graphic 7
38
};
39
41
static
const
byte
REG0_MASK
= 0x0E;
42
44
static
const
byte
REG1_MASK
= 0x18;
45
47
static
const
byte
REG25_MASK
= 0x18;
48
50
static
const
byte
YJK
= 0x20;
51
53
static
const
byte
YAE
= 0x40;
54
57
DisplayMode
() {
58
reset
();
59
}
60
67
DisplayMode
(
byte
reg0,
byte
reg1,
byte
reg25) {
68
if
((reg25 & 0x08) == 0) reg25 = 0;
// If YJK is off, ignore YAE.
69
mode = ((reg25 & 0x18) << 2)
// YAE YJK
70
| ((reg0 & 0x0E) << 1)
// M5..M3
71
| ((reg1 & 0x08) >> 2)
// M2
72
| ((reg1 & 0x10) >> 4);
// M1
73
}
74
75
inline
DisplayMode
updateReg25
(
byte
reg25)
const
{
76
if
((reg25 & 0x08) == 0) reg25 = 0;
// If YJK is off, ignore YAE.
77
return
DisplayMode
(
getBase
() | ((reg25 & 0x18) << 2));
78
}
79
82
inline
void
reset
() {
83
mode = 0;
84
}
85
88
inline
DisplayMode
&
operator=
(
const
DisplayMode
& newMode) {
89
mode = newMode.mode;
90
return
*
this
;
91
}
92
95
inline
bool
operator==
(
const
DisplayMode
& otherMode)
const
{
96
return
mode == otherMode.mode;
97
}
98
101
inline
bool
operator!=
(
const
DisplayMode
& otherMode)
const
{
102
return
mode != otherMode.mode;
103
}
104
109
inline
byte
getByte
()
const
{
110
return
mode;
111
}
112
114
inline
void
setByte
(
byte
mode_) {
115
mode = mode_;
116
}
117
123
inline
byte
getBase
()
const
{
124
return
mode & 0x1F;
125
}
126
130
inline
bool
isV9938Mode
()
const
{
131
return
(mode & 0x18) != 0;
132
}
133
138
inline
bool
isTextMode
()
const
{
139
return
(mode ==
TEXT1
) ||
140
(mode ==
TEXT2
) ||
141
(mode ==
TEXT1Q
);
142
}
143
148
inline
bool
isBitmapMode
()
const
{
149
return
getBase
() >= 0x0C;
150
}
151
158
inline
bool
isPlanar
()
const
{
159
// TODO: Is the display mode check OK? Profile undefined modes.
160
return
(mode & 0x14) == 0x14;
161
}
162
165
inline
bool
isSpriteNarrow
()
const
{
166
// TODO: Check what happens to sprites in Graphic5 + YJK/YAE.
167
return
mode ==
GRAPHIC5
;
168
}
169
176
inline
int
getSpriteMode
()
const
{
177
return
isTextMode
() ? 0 : (
isV9938Mode
() ? 2 : 1);
178
}
179
184
inline
unsigned
getLineWidth
()
const
{
185
// Note: Testing "mode" instead of "base mode" ensures that YJK
186
// modes are treated as 256 pixels wide.
187
return
mode ==
TEXT2
|| mode ==
GRAPHIC5
|| mode ==
GRAPHIC6
188
? 512
189
: 256;
190
}
191
};
192
193
}
// namespace openmsx
194
195
#endif
Generated on Sat May 25 2013 11:16:32 for openMSX by
1.8.1.2