|
|
1.1 root 1: /************************************************************
2: Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
3:
4: All Rights Reserved
5:
6: Permission to use, copy, modify, and distribute this
7: software and its documentation for any purpose and without
8: fee is hereby granted, provided that the above copyright no-
9: tice appear in all copies and that both that copyright no-
10: tice and this permission notice appear in supporting docu-
11: mentation, and that the names of Sun or MIT not be used in
12: advertising or publicity pertaining to distribution of the
13: software without specific prior written permission. Sun and
14: M.I.T. make no representations about the suitability of this
15: software for any purpose. It is provided "as is" without any
16: express or implied warranty.
17:
18: SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19: INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
20: NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
21: ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
22: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
23: PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24: OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
25: THE USE OR PERFORMANCE OF THIS SOFTWARE.
26:
27: ********************************************************/
28:
29: /* $Header: cfbmskbits.c,v 4.3 87/09/10 17:53:31 sun Exp $ */
30:
31: /*
32: * ==========================================================================
33: * Converted to Color Frame Buffer by smarks@sun, April-May 1987. The "bit
34: * numbering" in the doc below really means "byte numbering" now.
35: * ==========================================================================
36: */
37:
38: /*
39: these tables are used by several macros in the cfb code.
40:
41: the vax numbers everything left to right, so bit indices on the
42: screen match bit indices in longwords. the pc-rt and Sun number
43: bits on the screen the way they would be written on paper,
44: (i.e. msb to the left), and so a bit index n on the screen is
45: bit index 32-n in a longword
46:
47: see also cfbmskbits.h
48: */
49: #include <X.h>
50: #include <Xmd.h>
51: #include <servermd.h>
52:
53: #if (BITMAP_BIT_ORDER == MSBFirst)
54: /* NOTE:
55: the first element in starttab could be 0xffffffff. making it 0
56: lets us deal with a full first word in the middle loop, rather
57: than having to do the multiple reads and masks that we'd
58: have to do if we thought it was partial.
59: */
60: int cfbstarttab[] =
61: {
62: 0x00000000,
63: 0x00FFFFFF,
64: 0x0000FFFF,
65: 0x000000FF
66: };
67:
68: int cfbendtab[] =
69: {
70: 0x00000000,
71: 0xFF000000,
72: 0xFFFF0000,
73: 0xFFFFFF00
74: };
75:
76: /* a hack, for now, since the entries for 0 need to be all
77: 1 bits, not all zeros.
78: this means the code DOES NOT WORK for segments of length
79: 0 (which is only a problem in the horizontal line code.)
80: */
81: int cfbstartpartial[] =
82: {
83: 0xFFFFFFFF,
84: 0x00FFFFFF,
85: 0x0000FFFF,
86: 0x000000FF
87: };
88:
89: int cfbendpartial[] =
90: {
91: 0xFFFFFFFF,
92: 0xFF000000,
93: 0xFFFF0000,
94: 0xFFFFFF00
95: };
96: #else /* (BITMAP_BIT_ORDER == LSBFirst) */
97: /* NOTE:
98: the first element in starttab could be 0xffffffff. making it 0
99: lets us deal with a full first word in the middle loop, rather
100: than having to do the multiple reads and masks that we'd
101: have to do if we thought it was partial.
102: */
103: int cfbstarttab[] =
104: {
105: 0x00000000,
106: 0xFFFFFF00,
107: 0xFFFF0000,
108: 0xFF000000
109: };
110:
111: int cfbendtab[] =
112: {
113: 0x00000000,
114: 0x000000FF,
115: 0x0000FFFF,
116: 0x00FFFFFF
117: };
118:
119: /* a hack, for now, since the entries for 0 need to be all
120: 1 bits, not all zeros.
121: this means the code DOES NOT WORK for segments of length
122: 0 (which is only a problem in the horizontal line code.)
123: */
124: int cfbstartpartial[] =
125: {
126: 0xFFFFFFFF,
127: 0xFFFFFF00,
128: 0xFFFF0000,
129: 0xFF000000
130: };
131:
132: int cfbendpartial[] =
133: {
134: 0xFFFFFFFF,
135: 0x000000FF,
136: 0x0000FFFF,
137: 0x00FFFFFF
138: };
139: #endif (BITMAP_BIT_ORDER == MSBFirst)
140:
141:
142: /* used for masking bits in bresenham lines
143: mask[n] is used to mask out all but bit n in a longword (n is a
144: screen position).
145: rmask[n] is used to mask out the single bit at position n (n
146: is a screen posiotion.)
147: */
148:
149: #if (BITMAP_BIT_ORDER == MSBFirst)
150: int cfbmask[] =
151: {
152: 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
153: };
154: int cfbrmask[] =
155: {
156: 0x00FFFFFF, 0xFF00FFFF, 0xFFFF00FF, 0xFFFFFF00
157: };
158: #else /* (BITMAP_BIT_ORDER == LSBFirst) */
159: int cfbmask[] =
160: {
161: 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
162: };
163: int cfbrmask[] =
164: {
165: 0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF, 0x00FFFFFF
166: };
167: #endif (BITMAP_BIT_ORDER == MSBFirst)
168:
169: #ifdef vax
170: #undef VAXBYTEORDER
171: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.