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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "xf4bpp.h"
#include "OScompiler.h"
#include "wm3.h"
#include "vgaVideo.h"
#include "xf86.h"
/* Ferraro is wrong. GJA */
#define COPY (0 << 3)
#define AND (1 << 3)
#define OR (2 << 3)
#define XOR (3 << 3)
int
wm3_set_regs(pGC)
GC *pGC;
{
#ifndef PC98_EGC
IOADDRESS REGBASE = xf86Screens[pGC->pScreen->myNum]->domainIOBase + 0x300;
int post_invert = 0;
int ALU;
switch(pGC->alu) {
case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */
pGC->fgPixel = 0;
pGC->bgPixel = 0;
ALU = COPY;
break;
case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */
ALU = AND;
break;
case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = OR;
post_invert = 1;
break;
case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */
ALU = COPY;
break;
case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = AND;
break;
default:
case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */
return 0;
case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */
ALU = XOR;
break;
case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */
ALU = OR;
break;
case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/
ALU = OR;
post_invert = 1;
break;
case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = XOR;
break;
case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */
pGC->fgPixel = 0x0F;
pGC->bgPixel = 0x0F;
ALU = XOR;
break;
case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = AND;
post_invert = 1;
break;
case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = COPY;
break;
case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = OR;
break;
case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */
ALU = AND;
post_invert = 1;
break;
case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */
pGC->fgPixel = 0x0F;
pGC->bgPixel = 0x0F;
ALU = COPY;
break;
}
SetVideoSequencer(Mask_MapIndex, (pGC->planemask & VGA_ALLPLANES));
SetVideoGraphics(Enb_Set_ResetIndex, VGA_ALLPLANES);
SetVideoGraphics(Set_ResetIndex, pGC->fgPixel);
SetVideoGraphics(Bit_MaskIndex, 0xFF);
SetVideoGraphics(Graphics_ModeIndex, 3); /* Write Mode 3 */
SetVideoGraphics(Data_RotateIndex, ALU);
return post_invert;
#else
int ALU;
switch(pGC->alu) {
case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */
pGC->fgPixel = 0;
pGC->bgPixel = 0;
ALU = EGC_COPY_MODE;
break;
case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */
ALU = EGC_AND_MODE;
break;
case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = EGC_OR_INV_MODE;
break;
case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */
ALU = EGC_COPY_MODE;
break;
case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = EGC_AND_MODE;
break;
case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */
return 0;
case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */
ALU = EGC_XOR_MODE;
break;
case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */
ALU = EGC_OR_MODE;
break;
case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/
ALU = EGC_OR_INV_MODE;
break;
case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = EGC_XOR_MODE;
break;
case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */
pGC->fgPixel = 0x0F;
pGC->bgPixel = 0x0F;
ALU = EGC_XOR_MODE;
break;
case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = EGC_AND_INV_MODE;
break;
case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = EGC_COPY_MODE;
break;
case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */
pGC->fgPixel = ~pGC->fgPixel;
pGC->bgPixel = ~pGC->bgPixel;
ALU = EGC_OR_MODE;
break;
case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */
ALU = EGC_OR_INV_MODE;
break;
case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */
pGC->fgPixel = 0x0F;
pGC->bgPixel = 0x0F;
ALU = EGC_COPY_MODE;
break;
}
outw(EGC_PLANE, ~(pGC->planemask & VGA_ALLPLANES));
outw(EGC_MODE, ALU);
outw(EGC_FGC, pGC->fgPixel & VGA_ALLPLANES); /* set FGC */
return 0;
#endif
}
/*
Now we will have to set the alu.
Problematic is: How do we handle IsDoubleDash, which draws with both fg
and bg colour?
The answer is: We take care to store the ink colour in one register only.
Then we need set only this register to change the ink.
*/
/* -- MORE NOTES:
We might try to 'wrap' the mfb functions in a 16-colour wrapper that does
all operations once. However, this does not work:
Some operations (esp) CopyArea may for example cause expositions.
Such expositions will cause data to be copied in from backing store,
and this copying in may damage the contents of the VGA registers.
So we must take care to set the VGA registers at each place where they could
be modified.
*/
|