Annotation of sys/arch/hp300/dev/diofb_mono.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: diofb_mono.c,v 1.3 2006/08/11 18:33:13 miod Exp $ */
2:
3: /*
4: * Copyright (c) 2005, Miodrag Vallat.
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26: * POSSIBILITY OF SUCH DAMAGE.
27: *
28: */
29: /*
30: * Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
31: * Copyright (c) 1991 University of Utah.
32: * Copyright (c) 1990, 1993
33: * The Regents of the University of California. All rights reserved.
34: *
35: * This code is derived from software contributed to Berkeley by
36: * the Systems Programming Group of the University of Utah Computer
37: * Science Department and Mark Davies of the Department of Computer
38: * Science, Victoria University of Wellington, New Zealand.
39: *
40: * Redistribution and use in source and binary forms, with or without
41: * modification, are permitted provided that the following conditions
42: * are met:
43: * 1. Redistributions of source code must retain the above copyright
44: * notice, this list of conditions and the following disclaimer.
45: * 2. Redistributions in binary form must reproduce the above copyright
46: * notice, this list of conditions and the following disclaimer in the
47: * documentation and/or other materials provided with the distribution.
48: * 3. Neither the name of the University nor the names of its contributors
49: * may be used to endorse or promote products derived from this software
50: * without specific prior written permission.
51: *
52: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62: * SUCH DAMAGE.
63: *
64: * from: Utah $Hdr: grf_hy.c 1.2 93/08/13$
65: *
66: * @(#)grf_hy.c 8.4 (Berkeley) 1/12/94
67: */
68:
69: /*
70: * Graphics routines for real 1bpp frame buffers (i.e. pixels not being
71: * byte-addressed)
72: */
73:
74: #include <sys/param.h>
75: #include <sys/systm.h>
76:
77: #include <dev/wscons/wsconsio.h>
78: #include <dev/wscons/wsdisplayvar.h>
79: #include <dev/rasops/rasops.h>
80:
81: #include <hp300/dev/diofbreg.h>
82: #include <hp300/dev/diofbvar.h>
83:
84: #include <dev/rasops/rasops_masks.h>
85: #include <hp300/dev/maskbits.h>
86:
87: int
88: diofb_mono_windowmove(struct diofb *fb, u_int16_t sx, u_int16_t sy,
89: u_int16_t dx, u_int16_t dy, u_int16_t cx, u_int16_t cy, int16_t rop,
90: int16_t planemask /* ignored */)
91: {
92: int width; /* add to get to same position in next line */
93:
94: unsigned int *psrcLine, *pdstLine;
95: /* pointers to line with current src and dst */
96: unsigned int *psrc; /* pointer to current src longword */
97: unsigned int *pdst; /* pointer to current dst longword */
98:
99: /* following used for looping through a line */
100: unsigned int startmask, endmask; /* masks for writing ends of dst */
101: int nlMiddle; /* whole longwords in dst */
102: int nl; /* temp copy of nlMiddle */
103: int xoffSrc; /* offset (>= 0, < 32) from which to
104: fetch whole longwords fetched in src */
105: int nstart; /* number of ragged bits at start of dst */
106: int nend; /* number of ragged bits at end of dst */
107: int srcStartOver; /* pulling nstart bits from src
108: overflows into the next word? */
109:
110: width = fb->fbwidth >> 5;
111:
112: if (sy < dy) { /* start at last scanline of rectangle */
113: psrcLine = ((u_int *)fb->fbkva) + ((sy + cy - 1) * width);
114: pdstLine = ((u_int *)fb->fbkva) + ((dy + cy - 1) * width);
115: width = -width;
116: } else { /* start at first scanline */
117: psrcLine = ((u_int *)fb->fbkva) + (sy * width);
118: pdstLine = ((u_int *)fb->fbkva) + (dy * width);
119: }
120:
121: /* x direction doesn't matter for < 1 longword */
122: if (cx <= 32) {
123: int srcBit, dstBit; /* bit offset of src and dst */
124:
125: pdstLine += (dx >> 5);
126: psrcLine += (sx >> 5);
127: psrc = psrcLine;
128: pdst = pdstLine;
129:
130: srcBit = sx & 0x1f;
131: dstBit = dx & 0x1f;
132:
133: while (cy--) {
134: getandputrop(psrc, srcBit, dstBit, cx, pdst, rop);
135: pdst += width;
136: psrc += width;
137: }
138: } else {
139: maskbits(dx, cx, startmask, endmask, nlMiddle);
140: if (startmask)
141: nstart = 32 - (dx & 0x1f);
142: else
143: nstart = 0;
144: if (endmask)
145: nend = (dx + cx) & 0x1f;
146: else
147: nend = 0;
148:
149: xoffSrc = ((sx & 0x1f) + nstart) & 0x1f;
150: srcStartOver = ((sx & 0x1f) + nstart) > 31;
151:
152: if (sx >= dx) { /* move left to right */
153: pdstLine += (dx >> 5);
154: psrcLine += (sx >> 5);
155:
156: while (cy--) {
157: psrc = psrcLine;
158: pdst = pdstLine;
159:
160: if (startmask) {
161: getandputrop(psrc, (sx & 0x1f),
162: (dx & 0x1f), nstart, pdst, rop);
163: pdst++;
164: if (srcStartOver)
165: psrc++;
166: }
167:
168: /* special case for aligned operations */
169: if (xoffSrc == 0) {
170: nl = nlMiddle;
171: while (nl--) {
172: if (rop == RR_CLEAR)
173: *pdst = 0;
174: else
175: *pdst = *psrc;
176: psrc++;
177: pdst++;
178: }
179: } else {
180: nl = nlMiddle + 1;
181: while (--nl) {
182: if (rop == RR_CLEAR)
183: *pdst = 0;
184: else
185: getunalignedword(psrc,
186: xoffSrc, *pdst);
187: pdst++;
188: psrc++;
189: }
190: }
191:
192: if (endmask) {
193: getandputrop(psrc, xoffSrc, 0, nend,
194: pdst, rop);
195: }
196:
197: pdstLine += width;
198: psrcLine += width;
199: }
200: } else { /* move right to left */
201: pdstLine += ((dx + cx) >> 5);
202: psrcLine += ((sx + cx) >> 5);
203: /*
204: * If fetch of last partial bits from source crosses
205: * a longword boundary, start at the previous longword
206: */
207: if (xoffSrc + nend >= 32)
208: --psrcLine;
209:
210: while (cy--) {
211: psrc = psrcLine;
212: pdst = pdstLine;
213:
214: if (endmask) {
215: getandputrop(psrc, xoffSrc, 0, nend,
216: pdst, rop);
217: }
218:
219: nl = nlMiddle + 1;
220: while (--nl) {
221: --psrc;
222: --pdst;
223: if (rop == RR_CLEAR)
224: *pdst = 0;
225: else
226: getunalignedword(psrc, xoffSrc,
227: *pdst);
228: }
229:
230: if (startmask) {
231: if (srcStartOver)
232: --psrc;
233: --pdst;
234: getandputrop(psrc, (sx & 0x1f),
235: (dx & 0x1f), nstart, pdst, rop);
236: }
237:
238: pdstLine += width;
239: psrcLine += width;
240: }
241: }
242: }
243:
244: return (0);
245: }
CVSweb