First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xf4bpp / wm3.c
blob3a57221f216858b184ae9052bbbb4feb78610611
1 #ifdef HAVE_XORG_CONFIG_H
2 #include <xorg-config.h>
3 #endif
5 #include "xf4bpp.h"
6 #include "OScompiler.h"
7 #include "wm3.h"
8 #include "vgaVideo.h"
9 #include "xf86.h"
11 /* Ferraro is wrong. GJA */
12 #define COPY (0 << 3)
13 #define AND (1 << 3)
14 #define OR (2 << 3)
15 #define XOR (3 << 3)
17 int
18 wm3_set_regs(pGC)
19 GC *pGC;
21 #ifndef PC98_EGC
22 IOADDRESS REGBASE = xf86Screens[pGC->pScreen->myNum]->domainIOBase + 0x300;
23 int post_invert = 0;
24 int ALU;
26 switch(pGC->alu) {
27 case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */
28 pGC->fgPixel = 0;
29 pGC->bgPixel = 0;
30 ALU = COPY;
31 break;
32 case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */
33 ALU = AND;
34 break;
35 case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */
36 pGC->fgPixel = ~pGC->fgPixel;
37 pGC->bgPixel = ~pGC->bgPixel;
38 ALU = OR;
39 post_invert = 1;
40 break;
41 case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */
42 ALU = COPY;
43 break;
44 case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */
45 pGC->fgPixel = ~pGC->fgPixel;
46 pGC->bgPixel = ~pGC->bgPixel;
47 ALU = AND;
48 break;
49 default:
50 case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */
51 return 0;
52 case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */
53 ALU = XOR;
54 break;
55 case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */
56 ALU = OR;
57 break;
58 case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/
59 ALU = OR;
60 post_invert = 1;
61 break;
62 case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */
63 pGC->fgPixel = ~pGC->fgPixel;
64 pGC->bgPixel = ~pGC->bgPixel;
65 ALU = XOR;
66 break;
67 case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */
68 pGC->fgPixel = 0x0F;
69 pGC->bgPixel = 0x0F;
70 ALU = XOR;
71 break;
72 case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */
73 pGC->fgPixel = ~pGC->fgPixel;
74 pGC->bgPixel = ~pGC->bgPixel;
75 ALU = AND;
76 post_invert = 1;
77 break;
78 case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */
79 pGC->fgPixel = ~pGC->fgPixel;
80 pGC->bgPixel = ~pGC->bgPixel;
81 ALU = COPY;
82 break;
83 case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */
84 pGC->fgPixel = ~pGC->fgPixel;
85 pGC->bgPixel = ~pGC->bgPixel;
86 ALU = OR;
87 break;
88 case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */
89 ALU = AND;
90 post_invert = 1;
91 break;
92 case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */
93 pGC->fgPixel = 0x0F;
94 pGC->bgPixel = 0x0F;
95 ALU = COPY;
96 break;
100 SetVideoSequencer(Mask_MapIndex, (pGC->planemask & VGA_ALLPLANES));
101 SetVideoGraphics(Enb_Set_ResetIndex, VGA_ALLPLANES);
102 SetVideoGraphics(Set_ResetIndex, pGC->fgPixel);
103 SetVideoGraphics(Bit_MaskIndex, 0xFF);
104 SetVideoGraphics(Graphics_ModeIndex, 3); /* Write Mode 3 */
105 SetVideoGraphics(Data_RotateIndex, ALU);
107 return post_invert;
108 #else
109 int ALU;
111 switch(pGC->alu) {
112 case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */
113 pGC->fgPixel = 0;
114 pGC->bgPixel = 0;
115 ALU = EGC_COPY_MODE;
116 break;
117 case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */
118 ALU = EGC_AND_MODE;
119 break;
120 case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */
121 pGC->fgPixel = ~pGC->fgPixel;
122 pGC->bgPixel = ~pGC->bgPixel;
123 ALU = EGC_OR_INV_MODE;
124 break;
125 case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */
126 ALU = EGC_COPY_MODE;
127 break;
128 case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */
129 pGC->fgPixel = ~pGC->fgPixel;
130 pGC->bgPixel = ~pGC->bgPixel;
131 ALU = EGC_AND_MODE;
132 break;
133 case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */
134 return 0;
135 case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */
136 ALU = EGC_XOR_MODE;
137 break;
138 case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */
139 ALU = EGC_OR_MODE;
140 break;
141 case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/
142 ALU = EGC_OR_INV_MODE;
143 break;
144 case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */
145 pGC->fgPixel = ~pGC->fgPixel;
146 pGC->bgPixel = ~pGC->bgPixel;
147 ALU = EGC_XOR_MODE;
148 break;
149 case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */
150 pGC->fgPixel = 0x0F;
151 pGC->bgPixel = 0x0F;
152 ALU = EGC_XOR_MODE;
153 break;
154 case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */
155 pGC->fgPixel = ~pGC->fgPixel;
156 pGC->bgPixel = ~pGC->bgPixel;
157 ALU = EGC_AND_INV_MODE;
158 break;
159 case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */
160 pGC->fgPixel = ~pGC->fgPixel;
161 pGC->bgPixel = ~pGC->bgPixel;
162 ALU = EGC_COPY_MODE;
163 break;
164 case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */
165 pGC->fgPixel = ~pGC->fgPixel;
166 pGC->bgPixel = ~pGC->bgPixel;
167 ALU = EGC_OR_MODE;
168 break;
169 case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */
170 ALU = EGC_OR_INV_MODE;
171 break;
172 case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */
173 pGC->fgPixel = 0x0F;
174 pGC->bgPixel = 0x0F;
175 ALU = EGC_COPY_MODE;
176 break;
179 outw(EGC_PLANE, ~(pGC->planemask & VGA_ALLPLANES));
180 outw(EGC_MODE, ALU);
181 outw(EGC_FGC, pGC->fgPixel & VGA_ALLPLANES); /* set FGC */
183 return 0;
184 #endif
188 Now we will have to set the alu.
189 Problematic is: How do we handle IsDoubleDash, which draws with both fg
190 and bg colour?
191 The answer is: We take care to store the ink colour in one register only.
192 Then we need set only this register to change the ink.
195 /* -- MORE NOTES:
196 We might try to 'wrap' the mfb functions in a 16-colour wrapper that does
197 all operations once. However, this does not work:
198 Some operations (esp) CopyArea may for example cause expositions.
199 Such expositions will cause data to be copied in from backing store,
200 and this copying in may damage the contents of the VGA registers.
201 So we must take care to set the VGA registers at each place where they could
202 be modified.