blob: b3279139f1488625ff888e3ee4ae6f1845c0899e (
plain)
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
|
/* $XConsortium: wm3.c,v 1.2 94/10/12 21:06:18 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/vga16/ibm/wm3.c,v 3.0 1994/05/04 15:03:54 dawes Exp $ */
#include <sys/types.h>
#include "compiler.h"
#include "vgaReg.h"
#include "vgaVideo.h"
#include "X.h"
#include "gcstruct.h"
#include "wm3.h"
/* Ferraro is wrong. GJA */
#define COPY (0 << 3)
#define AND (1 << 3)
#define OR (2 << 3)
#define XOR (3 << 3)
wm3_set_regs(pGC)
GC *pGC;
{
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;
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;
}
/*
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.
*/
|