xref: /csrg-svn/sys/news3400/fb/x.c (revision 63258)
1*63258Sbostic /*
2*63258Sbostic  * Copyright (c) 1992 The Regents of the University of California.
3*63258Sbostic  * All rights reserved.
4*63258Sbostic  *
5*63258Sbostic  * This code is derived from software contributed to Berkeley by
6*63258Sbostic  * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
7*63258Sbostic  *
8*63258Sbostic  * %sccs.include.redist.c%
9*63258Sbostic  *
10*63258Sbostic  * from: $Hdr: fb_mfbs.c,v 4.300 91/06/27 20:42:43 root Rel41 $ SONY
11*63258Sbostic  *
12*63258Sbostic  *	@(#)x.c	5.1 (Berkeley) 06/10/93
13*63258Sbostic  */
14*63258Sbostic 
15*63258Sbostic #include <sys/param.h>
16*63258Sbostic #include <news3400/iop/framebuf.h>
17*63258Sbostic #include <news3400/iop/fbreg.h>
18*63258Sbostic #include <news3400/fb/fbdefs.h>
19*63258Sbostic 
20*63258Sbostic u_short mfbstarttab16[16] =
21*63258Sbostic     {
22*63258Sbostic 	 ( 0x0000 ), ( 0x7FFF ), ( 0x3FFF ), ( 0x1FFF ),
23*63258Sbostic 	 ( 0x0FFF ), ( 0x07FF ), ( 0x03FF ), ( 0x01FF ),
24*63258Sbostic 	 ( 0x00FF ), ( 0x007F ), ( 0x003F ), ( 0x001F ),
25*63258Sbostic 	 ( 0x000F ), ( 0x0007 ), ( 0x0003 ), ( 0x0001 ),
26*63258Sbostic     };
27*63258Sbostic u_short mfbendtab16[16] =
28*63258Sbostic     {
29*63258Sbostic 	 ( 0x0000 ), ( 0x8000 ), ( 0xC000 ), ( 0xE000 ),
30*63258Sbostic 	 ( 0xF000 ), ( 0xF800 ), ( 0xFC00 ), ( 0xFE00 ),
31*63258Sbostic 	 ( 0xFF00 ), ( 0xFF80 ), ( 0xFFC0 ), ( 0xFFE0 ),
32*63258Sbostic 	 ( 0xFFF0 ), ( 0xFFF8 ), ( 0xFFFC ), ( 0xFFFE ),
33*63258Sbostic     };
34*63258Sbostic 
35*63258Sbostic u_short mfbpartmasks16[16][16] = {
36*63258Sbostic      { ( 0xFFFF ),  ( 0x8000 ),  ( 0xC000 ),  ( 0xE000 ),
37*63258Sbostic        ( 0xF000 ),  ( 0xF800 ),  ( 0xFC00 ),  ( 0xFE00 ),
38*63258Sbostic        ( 0xFF00 ),  ( 0xFF80 ),  ( 0xFFC0 ),  ( 0xFFE0 ),
39*63258Sbostic        ( 0xFFF0 ),  ( 0xFFF8 ),  ( 0xFFFC ),  ( 0xFFFE )},
40*63258Sbostic      { ( 0x0000 ),  ( 0x4000 ),  ( 0x6000 ),  ( 0x7000 ),
41*63258Sbostic        ( 0x7800 ),  ( 0x7C00 ),  ( 0x7E00 ),  ( 0x7F00 ),
42*63258Sbostic        ( 0x7F80 ),  ( 0x7FC0 ),  ( 0x7FE0 ),  ( 0x7FF0 ),
43*63258Sbostic        ( 0x7FF8 ),  ( 0x7FFC ),  ( 0x7FFE ),  ( 0x7FFF )},
44*63258Sbostic      { ( 0x0000 ),  ( 0x2000 ),  ( 0x3000 ),  ( 0x3800 ),
45*63258Sbostic        ( 0x3C00 ),  ( 0x3E00 ),  ( 0x3F00 ),  ( 0x3F80 ),
46*63258Sbostic        ( 0x3FC0 ),  ( 0x3FE0 ),  ( 0x3FF0 ),  ( 0x3FF8 ),
47*63258Sbostic        ( 0x3FFC ),  ( 0x3FFE ),  ( 0x3FFF ),  ( 0x0000 )},
48*63258Sbostic      { ( 0x0000 ),  ( 0x1000 ),  ( 0x1800 ),  ( 0x1C00 ),
49*63258Sbostic        ( 0x1E00 ),  ( 0x1F00 ),  ( 0x1F80 ),  ( 0x1FC0 ),
50*63258Sbostic        ( 0x1FE0 ),  ( 0x1FF0 ),  ( 0x1FF8 ),  ( 0x1FFC ),
51*63258Sbostic        ( 0x1FFE ),  ( 0x1FFF ),  ( 0x0000 ),  ( 0x0000 )},
52*63258Sbostic      { ( 0x0000 ),  ( 0x0800 ),  ( 0x0C00 ),  ( 0x0E00 ),
53*63258Sbostic        ( 0x0F00 ),  ( 0x0F80 ),  ( 0x0FC0 ),  ( 0x0FE0 ),
54*63258Sbostic        ( 0x0FF0 ),  ( 0x0FF8 ),  ( 0x0FFC ),  ( 0x0FFE ),
55*63258Sbostic        ( 0x0FFF ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
56*63258Sbostic      { ( 0x0000 ),  ( 0x0400 ),  ( 0x0600 ),  ( 0x0700 ),
57*63258Sbostic        ( 0x0780 ),  ( 0x07C0 ),  ( 0x07E0 ),  ( 0x07F0 ),
58*63258Sbostic        ( 0x07F8 ),  ( 0x07FC ),  ( 0x07FE ),  ( 0x07FF ),
59*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
60*63258Sbostic      { ( 0x0000 ),  ( 0x0200 ),  ( 0x0300 ),  ( 0x0380 ),
61*63258Sbostic        ( 0x03C0 ),  ( 0x03E0 ),  ( 0x03F0 ),  ( 0x03F8 ),
62*63258Sbostic        ( 0x03FC ),  ( 0x03FE ),  ( 0x03FF ),  ( 0x0000 ),
63*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
64*63258Sbostic      { ( 0x0000 ),  ( 0x0100 ),  ( 0x0180 ),  ( 0x01C0 ),
65*63258Sbostic        ( 0x01E0 ),  ( 0x01F0 ),  ( 0x01F8 ),  ( 0x01FC ),
66*63258Sbostic        ( 0x01FE ),  ( 0x01FF ),  ( 0x0000 ),  ( 0x0000 ),
67*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
68*63258Sbostic      { ( 0x0000 ),  ( 0x0080 ),  ( 0x00C0 ),  ( 0x00E0 ),
69*63258Sbostic        ( 0x00F0 ),  ( 0x00F8 ),  ( 0x00FC ),  ( 0x00FE ),
70*63258Sbostic        ( 0x00FF ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
71*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
72*63258Sbostic      { ( 0x0000 ),  ( 0x0040 ),  ( 0x0060 ),  ( 0x0070 ),
73*63258Sbostic        ( 0x0078 ),  ( 0x007C ),  ( 0x007E ),  ( 0x007F ),
74*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
75*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
76*63258Sbostic      { ( 0x0000 ),  ( 0x0020 ),  ( 0x0030 ),  ( 0x0038 ),
77*63258Sbostic        ( 0x003C ),  ( 0x003E ),  ( 0x003F ),  ( 0x0000 ),
78*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
79*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
80*63258Sbostic      { ( 0x0000 ),  ( 0x0010 ),  ( 0x0018 ),  ( 0x001C ),
81*63258Sbostic        ( 0x001E ),  ( 0x001F ),  ( 0x0000 ),  ( 0x0000 ),
82*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
83*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
84*63258Sbostic      { ( 0x0000 ),  ( 0x0008 ),  ( 0x000C ),  ( 0x000E ),
85*63258Sbostic        ( 0x000F ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
86*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
87*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
88*63258Sbostic      { ( 0x0000 ),  ( 0x0004 ),  ( 0x0006 ),  ( 0x0007 ),
89*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
90*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
91*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
92*63258Sbostic      { ( 0x0000 ),  ( 0x0002 ),  ( 0x0003 ),  ( 0x0000 ),
93*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
94*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
95*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
96*63258Sbostic      { ( 0x0000 ),  ( 0x0001 ),  ( 0x0000 ),  ( 0x0000 ),
97*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
98*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),
99*63258Sbostic        ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 ),  ( 0x0000 )},
100*63258Sbostic };
101*63258Sbostic 
102*63258Sbostic u_short mfbmask16[16] =
103*63258Sbostic     {
104*63258Sbostic      ( 1<<15 ),  ( 1<<14 ), ( 1<<13 ),
105*63258Sbostic      ( 1<<12 ),  ( 1<<11 ), ( 1<<10 ),
106*63258Sbostic      ( 1<<9 ),  ( 1<<8 ),  ( 1<<7 ),
107*63258Sbostic      ( 1<<6 ),  ( 1<<5 ),  ( 1<<4 ),
108*63258Sbostic      ( 1<<3 ),  ( 1<<2 ),  ( 1<<1 ),
109*63258Sbostic      ( 1<<0 )
110*63258Sbostic     };
111*63258Sbostic u_short mfbrmask16[16] =
112*63258Sbostic     {
113*63258Sbostic     0xffffffff ^  ( 1<<15 ), 0xffffffff ^  ( 1<<14),
114*63258Sbostic     0xffffffff ^  ( 1<<13 ), 0xffffffff ^  ( 1<<12 ),
115*63258Sbostic     0xffffffff ^  ( 1<<11 ), 0xffffffff ^  ( 1<<10),
116*63258Sbostic     0xffffffff ^  ( 1<<9 ),  0xffffffff ^  ( 1<<8),
117*63258Sbostic     0xffffffff ^  ( 1<<7 ),  0xffffffff ^  ( 1<<6),
118*63258Sbostic     0xffffffff ^  ( 1<<5 ),  0xffffffff ^  ( 1<<4),
119*63258Sbostic     0xffffffff ^  ( 1<<3 ),  0xffffffff ^  ( 1<<2),
120*63258Sbostic     0xffffffff ^  ( 1<<1 ),  0xffffffff ^  ( 1<<0)
121*63258Sbostic     };
122*63258Sbostic 
123*63258Sbostic u_int mfbstarttab32[32] =
124*63258Sbostic     {
125*63258Sbostic 	 ( 0x00000000 ), ( 0x7FFFFFFF ), ( 0x3FFFFFFF ), ( 0x1FFFFFFF ),
126*63258Sbostic 	 ( 0x0FFFFFFF ), ( 0x07FFFFFF ), ( 0x03FFFFFF ), ( 0x01FFFFFF ),
127*63258Sbostic 	 ( 0x00FFFFFF ), ( 0x007FFFFF ), ( 0x003FFFFF ), ( 0x001FFFFF ),
128*63258Sbostic 	 ( 0x000FFFFF ), ( 0x0007FFFF ), ( 0x0003FFFF ), ( 0x0001FFFF ),
129*63258Sbostic 	 ( 0x0000FFFF ), ( 0x00007FFF ), ( 0x00003FFF ), ( 0x00001FFF ),
130*63258Sbostic 	 ( 0x00000FFF ), ( 0x000007FF ), ( 0x000003FF ), ( 0x000001FF ),
131*63258Sbostic 	 ( 0x000000FF ), ( 0x0000007F ), ( 0x0000003F ), ( 0x0000001F ),
132*63258Sbostic 	 ( 0x0000000F ), ( 0x00000007 ), ( 0x00000003 ), ( 0x00000001 )
133*63258Sbostic     };
134*63258Sbostic u_int mfbendtab32[32] =
135*63258Sbostic     {
136*63258Sbostic 	 ( 0x00000000 ), ( 0x80000000 ), ( 0xC0000000 ), ( 0xE0000000 ),
137*63258Sbostic 	 ( 0xF0000000 ), ( 0xF8000000 ), ( 0xFC000000 ), ( 0xFE000000 ),
138*63258Sbostic 	 ( 0xFF000000 ), ( 0xFF800000 ), ( 0xFFC00000 ), ( 0xFFE00000 ),
139*63258Sbostic 	 ( 0xFFF00000 ), ( 0xFFF80000 ), ( 0xFFFC0000 ), ( 0xFFFE0000 ),
140*63258Sbostic 	 ( 0xFFFF0000 ), ( 0xFFFF8000 ), ( 0xFFFFC000 ), ( 0xFFFFE000 ),
141*63258Sbostic 	 ( 0xFFFFF000 ), ( 0xFFFFF800 ), ( 0xFFFFFC00 ), ( 0xFFFFFE00 ),
142*63258Sbostic 	 ( 0xFFFFFF00 ), ( 0xFFFFFF80 ), ( 0xFFFFFFC0 ), ( 0xFFFFFFE0 ),
143*63258Sbostic 	 ( 0xFFFFFFF0 ), ( 0xFFFFFFF8 ), ( 0xFFFFFFFC ), ( 0xFFFFFFFE )
144*63258Sbostic     };
145*63258Sbostic 
146*63258Sbostic u_int mfbpartmasks32[32][32] = {
147*63258Sbostic      { ( 0xFFFFFFFF ),  ( 0x80000000 ),  ( 0xC0000000 ),  ( 0xE0000000 ),
148*63258Sbostic        ( 0xF0000000 ),  ( 0xF8000000 ),  ( 0xFC000000 ),  ( 0xFE000000 ),
149*63258Sbostic        ( 0xFF000000 ),  ( 0xFF800000 ),  ( 0xFFC00000 ),  ( 0xFFE00000 ),
150*63258Sbostic        ( 0xFFF00000 ),  ( 0xFFF80000 ),  ( 0xFFFC0000 ),  ( 0xFFFE0000 ),
151*63258Sbostic        ( 0xFFFF0000 ),  ( 0xFFFF8000 ),  ( 0xFFFFC000 ),  ( 0xFFFFE000 ),
152*63258Sbostic        ( 0xFFFFF000 ),  ( 0xFFFFF800 ),  ( 0xFFFFFC00 ),  ( 0xFFFFFE00 ),
153*63258Sbostic        ( 0xFFFFFF00 ),  ( 0xFFFFFF80 ),  ( 0xFFFFFFC0 ),  ( 0xFFFFFFE0 ),
154*63258Sbostic        ( 0xFFFFFFF0 ),  ( 0xFFFFFFF8 ),  ( 0xFFFFFFFC ),  ( 0xFFFFFFFE )},
155*63258Sbostic      { ( 0x00000000 ),  ( 0x40000000 ),  ( 0x60000000 ),  ( 0x70000000 ),
156*63258Sbostic        ( 0x78000000 ),  ( 0x7C000000 ),  ( 0x7E000000 ),  ( 0x7F000000 ),
157*63258Sbostic        ( 0x7F800000 ),  ( 0x7FC00000 ),  ( 0x7FE00000 ),  ( 0x7FF00000 ),
158*63258Sbostic        ( 0x7FF80000 ),  ( 0x7FFC0000 ),  ( 0x7FFE0000 ),  ( 0x7FFF0000 ),
159*63258Sbostic        ( 0x7FFF8000 ),  ( 0x7FFFC000 ),  ( 0x7FFFE000 ),  ( 0x7FFFF000 ),
160*63258Sbostic        ( 0x7FFFF800 ),  ( 0x7FFFFC00 ),  ( 0x7FFFFE00 ),  ( 0x7FFFFF00 ),
161*63258Sbostic        ( 0x7FFFFF80 ),  ( 0x7FFFFFC0 ),  ( 0x7FFFFFE0 ),  ( 0x7FFFFFF0 ),
162*63258Sbostic        ( 0x7FFFFFF8 ),  ( 0x7FFFFFFC ),  ( 0x7FFFFFFE ),  ( 0x7FFFFFFF )},
163*63258Sbostic      { ( 0x00000000 ),  ( 0x20000000 ),  ( 0x30000000 ),  ( 0x38000000 ),
164*63258Sbostic        ( 0x3C000000 ),  ( 0x3E000000 ),  ( 0x3F000000 ),  ( 0x3F800000 ),
165*63258Sbostic        ( 0x3FC00000 ),  ( 0x3FE00000 ),  ( 0x3FF00000 ),  ( 0x3FF80000 ),
166*63258Sbostic        ( 0x3FFC0000 ),  ( 0x3FFE0000 ),  ( 0x3FFF0000 ),  ( 0x3FFF8000 ),
167*63258Sbostic        ( 0x3FFFC000 ),  ( 0x3FFFE000 ),  ( 0x3FFFF000 ),  ( 0x3FFFF800 ),
168*63258Sbostic        ( 0x3FFFFC00 ),  ( 0x3FFFFE00 ),  ( 0x3FFFFF00 ),  ( 0x3FFFFF80 ),
169*63258Sbostic        ( 0x3FFFFFC0 ),  ( 0x3FFFFFE0 ),  ( 0x3FFFFFF0 ),  ( 0x3FFFFFF8 ),
170*63258Sbostic        ( 0x3FFFFFFC ),  ( 0x3FFFFFFE ),  ( 0x3FFFFFFF ),  ( 0x00000000 )},
171*63258Sbostic      { ( 0x00000000 ),  ( 0x10000000 ),  ( 0x18000000 ),  ( 0x1C000000 ),
172*63258Sbostic        ( 0x1E000000 ),  ( 0x1F000000 ),  ( 0x1F800000 ),  ( 0x1FC00000 ),
173*63258Sbostic        ( 0x1FE00000 ),  ( 0x1FF00000 ),  ( 0x1FF80000 ),  ( 0x1FFC0000 ),
174*63258Sbostic        ( 0x1FFE0000 ),  ( 0x1FFF0000 ),  ( 0x1FFF8000 ),  ( 0x1FFFC000 ),
175*63258Sbostic        ( 0x1FFFE000 ),  ( 0x1FFFF000 ),  ( 0x1FFFF800 ),  ( 0x1FFFFC00 ),
176*63258Sbostic        ( 0x1FFFFE00 ),  ( 0x1FFFFF00 ),  ( 0x1FFFFF80 ),  ( 0x1FFFFFC0 ),
177*63258Sbostic        ( 0x1FFFFFE0 ),  ( 0x1FFFFFF0 ),  ( 0x1FFFFFF8 ),  ( 0x1FFFFFFC ),
178*63258Sbostic        ( 0x1FFFFFFE ),  ( 0x1FFFFFFF ),  ( 0x00000000 ),  ( 0x00000000 )},
179*63258Sbostic      { ( 0x00000000 ),  ( 0x08000000 ),  ( 0x0C000000 ),  ( 0x0E000000 ),
180*63258Sbostic        ( 0x0F000000 ),  ( 0x0F800000 ),  ( 0x0FC00000 ),  ( 0x0FE00000 ),
181*63258Sbostic        ( 0x0FF00000 ),  ( 0x0FF80000 ),  ( 0x0FFC0000 ),  ( 0x0FFE0000 ),
182*63258Sbostic        ( 0x0FFF0000 ),  ( 0x0FFF8000 ),  ( 0x0FFFC000 ),  ( 0x0FFFE000 ),
183*63258Sbostic        ( 0x0FFFF000 ),  ( 0x0FFFF800 ),  ( 0x0FFFFC00 ),  ( 0x0FFFFE00 ),
184*63258Sbostic        ( 0x0FFFFF00 ),  ( 0x0FFFFF80 ),  ( 0x0FFFFFC0 ),  ( 0x0FFFFFE0 ),
185*63258Sbostic        ( 0x0FFFFFF0 ),  ( 0x0FFFFFF8 ),  ( 0x0FFFFFFC ),  ( 0x0FFFFFFE ),
186*63258Sbostic        ( 0x0FFFFFFF ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
187*63258Sbostic      { ( 0x00000000 ),  ( 0x04000000 ),  ( 0x06000000 ),  ( 0x07000000 ),
188*63258Sbostic        ( 0x07800000 ),  ( 0x07C00000 ),  ( 0x07E00000 ),  ( 0x07F00000 ),
189*63258Sbostic        ( 0x07F80000 ),  ( 0x07FC0000 ),  ( 0x07FE0000 ),  ( 0x07FF0000 ),
190*63258Sbostic        ( 0x07FF8000 ),  ( 0x07FFC000 ),  ( 0x07FFE000 ),  ( 0x07FFF000 ),
191*63258Sbostic        ( 0x07FFF800 ),  ( 0x07FFFC00 ),  ( 0x07FFFE00 ),  ( 0x07FFFF00 ),
192*63258Sbostic        ( 0x07FFFF80 ),  ( 0x07FFFFC0 ),  ( 0x07FFFFE0 ),  ( 0x07FFFFF0 ),
193*63258Sbostic        ( 0x07FFFFF8 ),  ( 0x07FFFFFC ),  ( 0x07FFFFFE ),  ( 0x07FFFFFF ),
194*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
195*63258Sbostic      { ( 0x00000000 ),  ( 0x02000000 ),  ( 0x03000000 ),  ( 0x03800000 ),
196*63258Sbostic        ( 0x03C00000 ),  ( 0x03E00000 ),  ( 0x03F00000 ),  ( 0x03F80000 ),
197*63258Sbostic        ( 0x03FC0000 ),  ( 0x03FE0000 ),  ( 0x03FF0000 ),  ( 0x03FF8000 ),
198*63258Sbostic        ( 0x03FFC000 ),  ( 0x03FFE000 ),  ( 0x03FFF000 ),  ( 0x03FFF800 ),
199*63258Sbostic        ( 0x03FFFC00 ),  ( 0x03FFFE00 ),  ( 0x03FFFF00 ),  ( 0x03FFFF80 ),
200*63258Sbostic        ( 0x03FFFFC0 ),  ( 0x03FFFFE0 ),  ( 0x03FFFFF0 ),  ( 0x03FFFFF8 ),
201*63258Sbostic        ( 0x03FFFFFC ),  ( 0x03FFFFFE ),  ( 0x03FFFFFF ),  ( 0x00000000 ),
202*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
203*63258Sbostic      { ( 0x00000000 ),  ( 0x01000000 ),  ( 0x01800000 ),  ( 0x01C00000 ),
204*63258Sbostic        ( 0x01E00000 ),  ( 0x01F00000 ),  ( 0x01F80000 ),  ( 0x01FC0000 ),
205*63258Sbostic        ( 0x01FE0000 ),  ( 0x01FF0000 ),  ( 0x01FF8000 ),  ( 0x01FFC000 ),
206*63258Sbostic        ( 0x01FFE000 ),  ( 0x01FFF000 ),  ( 0x01FFF800 ),  ( 0x01FFFC00 ),
207*63258Sbostic        ( 0x01FFFE00 ),  ( 0x01FFFF00 ),  ( 0x01FFFF80 ),  ( 0x01FFFFC0 ),
208*63258Sbostic        ( 0x01FFFFE0 ),  ( 0x01FFFFF0 ),  ( 0x01FFFFF8 ),  ( 0x01FFFFFC ),
209*63258Sbostic        ( 0x01FFFFFE ),  ( 0x01FFFFFF ),  ( 0x00000000 ),  ( 0x00000000 ),
210*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
211*63258Sbostic      { ( 0x00000000 ),  ( 0x00800000 ),  ( 0x00C00000 ),  ( 0x00E00000 ),
212*63258Sbostic        ( 0x00F00000 ),  ( 0x00F80000 ),  ( 0x00FC0000 ),  ( 0x00FE0000 ),
213*63258Sbostic        ( 0x00FF0000 ),  ( 0x00FF8000 ),  ( 0x00FFC000 ),  ( 0x00FFE000 ),
214*63258Sbostic        ( 0x00FFF000 ),  ( 0x00FFF800 ),  ( 0x00FFFC00 ),  ( 0x00FFFE00 ),
215*63258Sbostic        ( 0x00FFFF00 ),  ( 0x00FFFF80 ),  ( 0x00FFFFC0 ),  ( 0x00FFFFE0 ),
216*63258Sbostic        ( 0x00FFFFF0 ),  ( 0x00FFFFF8 ),  ( 0x00FFFFFC ),  ( 0x00FFFFFE ),
217*63258Sbostic        ( 0x00FFFFFF ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
218*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
219*63258Sbostic      { ( 0x00000000 ),  ( 0x00400000 ),  ( 0x00600000 ),  ( 0x00700000 ),
220*63258Sbostic        ( 0x00780000 ),  ( 0x007C0000 ),  ( 0x007E0000 ),  ( 0x007F0000 ),
221*63258Sbostic        ( 0x007F8000 ),  ( 0x007FC000 ),  ( 0x007FE000 ),  ( 0x007FF000 ),
222*63258Sbostic        ( 0x007FF800 ),  ( 0x007FFC00 ),  ( 0x007FFE00 ),  ( 0x007FFF00 ),
223*63258Sbostic        ( 0x007FFF80 ),  ( 0x007FFFC0 ),  ( 0x007FFFE0 ),  ( 0x007FFFF0 ),
224*63258Sbostic        ( 0x007FFFF8 ),  ( 0x007FFFFC ),  ( 0x007FFFFE ),  ( 0x007FFFFF ),
225*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
226*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
227*63258Sbostic      { ( 0x00000000 ),  ( 0x00200000 ),  ( 0x00300000 ),  ( 0x00380000 ),
228*63258Sbostic        ( 0x003C0000 ),  ( 0x003E0000 ),  ( 0x003F0000 ),  ( 0x003F8000 ),
229*63258Sbostic        ( 0x003FC000 ),  ( 0x003FE000 ),  ( 0x003FF000 ),  ( 0x003FF800 ),
230*63258Sbostic        ( 0x003FFC00 ),  ( 0x003FFE00 ),  ( 0x003FFF00 ),  ( 0x003FFF80 ),
231*63258Sbostic        ( 0x003FFFC0 ),  ( 0x003FFFE0 ),  ( 0x003FFFF0 ),  ( 0x003FFFF8 ),
232*63258Sbostic        ( 0x003FFFFC ),  ( 0x003FFFFE ),  ( 0x003FFFFF ),  ( 0x00000000 ),
233*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
234*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
235*63258Sbostic      { ( 0x00000000 ),  ( 0x00100000 ),  ( 0x00180000 ),  ( 0x001C0000 ),
236*63258Sbostic        ( 0x001E0000 ),  ( 0x001F0000 ),  ( 0x001F8000 ),  ( 0x001FC000 ),
237*63258Sbostic        ( 0x001FE000 ),  ( 0x001FF000 ),  ( 0x001FF800 ),  ( 0x001FFC00 ),
238*63258Sbostic        ( 0x001FFE00 ),  ( 0x001FFF00 ),  ( 0x001FFF80 ),  ( 0x001FFFC0 ),
239*63258Sbostic        ( 0x001FFFE0 ),  ( 0x001FFFF0 ),  ( 0x001FFFF8 ),  ( 0x001FFFFC ),
240*63258Sbostic        ( 0x001FFFFE ),  ( 0x001FFFFF ),  ( 0x00000000 ),  ( 0x00000000 ),
241*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
242*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
243*63258Sbostic      { ( 0x00000000 ),  ( 0x00080000 ),  ( 0x000C0000 ),  ( 0x000E0000 ),
244*63258Sbostic        ( 0x000F0000 ),  ( 0x000F8000 ),  ( 0x000FC000 ),  ( 0x000FE000 ),
245*63258Sbostic        ( 0x000FF000 ),  ( 0x000FF800 ),  ( 0x000FFC00 ),  ( 0x000FFE00 ),
246*63258Sbostic        ( 0x000FFF00 ),  ( 0x000FFF80 ),  ( 0x000FFFC0 ),  ( 0x000FFFE0 ),
247*63258Sbostic        ( 0x000FFFF0 ),  ( 0x000FFFF8 ),  ( 0x000FFFFC ),  ( 0x000FFFFE ),
248*63258Sbostic        ( 0x000FFFFF ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
249*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
250*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
251*63258Sbostic      { ( 0x00000000 ),  ( 0x00040000 ),  ( 0x00060000 ),  ( 0x00070000 ),
252*63258Sbostic        ( 0x00078000 ),  ( 0x0007C000 ),  ( 0x0007E000 ),  ( 0x0007F000 ),
253*63258Sbostic        ( 0x0007F800 ),  ( 0x0007FC00 ),  ( 0x0007FE00 ),  ( 0x0007FF00 ),
254*63258Sbostic        ( 0x0007FF80 ),  ( 0x0007FFC0 ),  ( 0x0007FFE0 ),  ( 0x0007FFF0 ),
255*63258Sbostic        ( 0x0007FFF8 ),  ( 0x0007FFFC ),  ( 0x0007FFFE ),  ( 0x0007FFFF ),
256*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
257*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
258*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
259*63258Sbostic      { ( 0x00000000 ),  ( 0x00020000 ),  ( 0x00030000 ),  ( 0x00038000 ),
260*63258Sbostic        ( 0x0003C000 ),  ( 0x0003E000 ),  ( 0x0003F000 ),  ( 0x0003F800 ),
261*63258Sbostic        ( 0x0003FC00 ),  ( 0x0003FE00 ),  ( 0x0003FF00 ),  ( 0x0003FF80 ),
262*63258Sbostic        ( 0x0003FFC0 ),  ( 0x0003FFE0 ),  ( 0x0003FFF0 ),  ( 0x0003FFF8 ),
263*63258Sbostic        ( 0x0003FFFC ),  ( 0x0003FFFE ),  ( 0x0003FFFF ),  ( 0x00000000 ),
264*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
265*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
266*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
267*63258Sbostic      { ( 0x00000000 ),  ( 0x00010000 ),  ( 0x00018000 ),  ( 0x0001C000 ),
268*63258Sbostic        ( 0x0001E000 ),  ( 0x0001F000 ),  ( 0x0001F800 ),  ( 0x0001FC00 ),
269*63258Sbostic        ( 0x0001FE00 ),  ( 0x0001FF00 ),  ( 0x0001FF80 ),  ( 0x0001FFC0 ),
270*63258Sbostic        ( 0x0001FFE0 ),  ( 0x0001FFF0 ),  ( 0x0001FFF8 ),  ( 0x0001FFFC ),
271*63258Sbostic        ( 0x0001FFFE ),  ( 0x0001FFFF ),  ( 0x00000000 ),  ( 0x00000000 ),
272*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
273*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
274*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
275*63258Sbostic      { ( 0x00000000 ),  ( 0x00008000 ),  ( 0x0000C000 ),  ( 0x0000E000 ),
276*63258Sbostic        ( 0x0000F000 ),  ( 0x0000F800 ),  ( 0x0000FC00 ),  ( 0x0000FE00 ),
277*63258Sbostic        ( 0x0000FF00 ),  ( 0x0000FF80 ),  ( 0x0000FFC0 ),  ( 0x0000FFE0 ),
278*63258Sbostic        ( 0x0000FFF0 ),  ( 0x0000FFF8 ),  ( 0x0000FFFC ),  ( 0x0000FFFE ),
279*63258Sbostic        ( 0x0000FFFF ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
280*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
281*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
282*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
283*63258Sbostic      { ( 0x00000000 ),  ( 0x00004000 ),  ( 0x00006000 ),  ( 0x00007000 ),
284*63258Sbostic        ( 0x00007800 ),  ( 0x00007C00 ),  ( 0x00007E00 ),  ( 0x00007F00 ),
285*63258Sbostic        ( 0x00007F80 ),  ( 0x00007FC0 ),  ( 0x00007FE0 ),  ( 0x00007FF0 ),
286*63258Sbostic        ( 0x00007FF8 ),  ( 0x00007FFC ),  ( 0x00007FFE ),  ( 0x00007FFF ),
287*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
288*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
289*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
290*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
291*63258Sbostic      { ( 0x00000000 ),  ( 0x00002000 ),  ( 0x00003000 ),  ( 0x00003800 ),
292*63258Sbostic        ( 0x00003C00 ),  ( 0x00003E00 ),  ( 0x00003F00 ),  ( 0x00003F80 ),
293*63258Sbostic        ( 0x00003FC0 ),  ( 0x00003FE0 ),  ( 0x00003FF0 ),  ( 0x00003FF8 ),
294*63258Sbostic        ( 0x00003FFC ),  ( 0x00003FFE ),  ( 0x00003FFF ),  ( 0x00000000 ),
295*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
296*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
297*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
298*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
299*63258Sbostic      { ( 0x00000000 ),  ( 0x00001000 ),  ( 0x00001800 ),  ( 0x00001C00 ),
300*63258Sbostic        ( 0x00001E00 ),  ( 0x00001F00 ),  ( 0x00001F80 ),  ( 0x00001FC0 ),
301*63258Sbostic        ( 0x00001FE0 ),  ( 0x00001FF0 ),  ( 0x00001FF8 ),  ( 0x00001FFC ),
302*63258Sbostic        ( 0x00001FFE ),  ( 0x00001FFF ),  ( 0x00000000 ),  ( 0x00000000 ),
303*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
304*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
305*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
306*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
307*63258Sbostic      { ( 0x00000000 ),  ( 0x00000800 ),  ( 0x00000C00 ),  ( 0x00000E00 ),
308*63258Sbostic        ( 0x00000F00 ),  ( 0x00000F80 ),  ( 0x00000FC0 ),  ( 0x00000FE0 ),
309*63258Sbostic        ( 0x00000FF0 ),  ( 0x00000FF8 ),  ( 0x00000FFC ),  ( 0x00000FFE ),
310*63258Sbostic        ( 0x00000FFF ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
311*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
312*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
313*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
314*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
315*63258Sbostic      { ( 0x00000000 ),  ( 0x00000400 ),  ( 0x00000600 ),  ( 0x00000700 ),
316*63258Sbostic        ( 0x00000780 ),  ( 0x000007C0 ),  ( 0x000007E0 ),  ( 0x000007F0 ),
317*63258Sbostic        ( 0x000007F8 ),  ( 0x000007FC ),  ( 0x000007FE ),  ( 0x000007FF ),
318*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
319*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
320*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
321*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
322*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
323*63258Sbostic      { ( 0x00000000 ),  ( 0x00000200 ),  ( 0x00000300 ),  ( 0x00000380 ),
324*63258Sbostic        ( 0x000003C0 ),  ( 0x000003E0 ),  ( 0x000003F0 ),  ( 0x000003F8 ),
325*63258Sbostic        ( 0x000003FC ),  ( 0x000003FE ),  ( 0x000003FF ),  ( 0x00000000 ),
326*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
327*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
328*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
329*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
330*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
331*63258Sbostic      { ( 0x00000000 ),  ( 0x00000100 ),  ( 0x00000180 ),  ( 0x000001C0 ),
332*63258Sbostic        ( 0x000001E0 ),  ( 0x000001F0 ),  ( 0x000001F8 ),  ( 0x000001FC ),
333*63258Sbostic        ( 0x000001FE ),  ( 0x000001FF ),  ( 0x00000000 ),  ( 0x00000000 ),
334*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
335*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
336*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
337*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
338*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
339*63258Sbostic      { ( 0x00000000 ),  ( 0x00000080 ),  ( 0x000000C0 ),  ( 0x000000E0 ),
340*63258Sbostic        ( 0x000000F0 ),  ( 0x000000F8 ),  ( 0x000000FC ),  ( 0x000000FE ),
341*63258Sbostic        ( 0x000000FF ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
342*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
343*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
344*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
345*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
346*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
347*63258Sbostic      { ( 0x00000000 ),  ( 0x00000040 ),  ( 0x00000060 ),  ( 0x00000070 ),
348*63258Sbostic        ( 0x00000078 ),  ( 0x0000007C ),  ( 0x0000007E ),  ( 0x0000007F ),
349*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
350*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
351*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
352*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
353*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
354*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
355*63258Sbostic      { ( 0x00000000 ),  ( 0x00000020 ),  ( 0x00000030 ),  ( 0x00000038 ),
356*63258Sbostic        ( 0x0000003C ),  ( 0x0000003E ),  ( 0x0000003F ),  ( 0x00000000 ),
357*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
358*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
359*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
360*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
361*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
362*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
363*63258Sbostic      { ( 0x00000000 ),  ( 0x00000010 ),  ( 0x00000018 ),  ( 0x0000001C ),
364*63258Sbostic        ( 0x0000001E ),  ( 0x0000001F ),  ( 0x00000000 ),  ( 0x00000000 ),
365*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
366*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
367*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
368*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
369*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
370*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
371*63258Sbostic      { ( 0x00000000 ),  ( 0x00000008 ),  ( 0x0000000C ),  ( 0x0000000E ),
372*63258Sbostic        ( 0x0000000F ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
373*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
374*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
375*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
376*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
377*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
378*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
379*63258Sbostic      { ( 0x00000000 ),  ( 0x00000004 ),  ( 0x00000006 ),  ( 0x00000007 ),
380*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
381*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
382*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
383*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
384*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
385*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
386*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
387*63258Sbostic      { ( 0x00000000 ),  ( 0x00000002 ),  ( 0x00000003 ),  ( 0x00000000 ),
388*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
389*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
390*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
391*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
392*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
393*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
394*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
395*63258Sbostic      { ( 0x00000000 ),  ( 0x00000001 ),  ( 0x00000000 ),  ( 0x00000000 ),
396*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
397*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
398*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
399*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
400*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
401*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),
402*63258Sbostic        ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 ),  ( 0x00000000 )},
403*63258Sbostic };
404*63258Sbostic 
405*63258Sbostic u_int mfbmask32[32] =
406*63258Sbostic     {
407*63258Sbostic      ( 1<<31 ),  ( 1<<30 ),  ( 1<<29 ),
408*63258Sbostic      ( 1<<28 ),  ( 1<<27 ),  ( 1<<26 ),
409*63258Sbostic      ( 1<<25 ),  ( 1<<24 ),  ( 1<<23 ),
410*63258Sbostic      ( 1<<22 ),  ( 1<<21 ),  ( 1<<20 ),
411*63258Sbostic      ( 1<<19 ),  ( 1<<18 ),  ( 1<<17 ),
412*63258Sbostic      ( 1<<16 ),  ( 1<<15 ),  ( 1<<14 ),
413*63258Sbostic      ( 1<<13 ),  ( 1<<12 ),  ( 1<<11 ),
414*63258Sbostic      ( 1<<10 ),  ( 1<<9 ),  ( 1<<8 ),
415*63258Sbostic      ( 1<<7 ),  ( 1<<6 ),  ( 1<<5 ),
416*63258Sbostic      ( 1<<4 ),  ( 1<<3 ),  ( 1<<2 ),
417*63258Sbostic      ( 1<<1 ),  ( 1<<0 )
418*63258Sbostic     };
419*63258Sbostic 
420*63258Sbostic u_int mfbrmask32[32] =
421*63258Sbostic     {
422*63258Sbostic     0xffffffff ^  ( 1<<31 ), 0xffffffff ^  ( 1<<30 ),
423*63258Sbostic     0xffffffff ^  ( 1<<29 ), 0xffffffff ^  ( 1<<28),
424*63258Sbostic     0xffffffff ^  ( 1<<27 ), 0xffffffff ^  ( 1<<26),
425*63258Sbostic     0xffffffff ^  ( 1<<25 ), 0xffffffff ^  ( 1<<24 ),
426*63258Sbostic     0xffffffff ^  ( 1<<23 ), 0xffffffff ^  ( 1<<22),
427*63258Sbostic     0xffffffff ^  ( 1<<21 ), 0xffffffff ^  ( 1<<20),
428*63258Sbostic     0xffffffff ^  ( 1<<19 ), 0xffffffff ^  ( 1<<18 ),
429*63258Sbostic     0xffffffff ^  ( 1<<17 ), 0xffffffff ^  ( 1<<16),
430*63258Sbostic     0xffffffff ^  ( 1<<15 ), 0xffffffff ^  ( 1<<14),
431*63258Sbostic     0xffffffff ^  ( 1<<13 ), 0xffffffff ^  ( 1<<12 ),
432*63258Sbostic     0xffffffff ^  ( 1<<11 ), 0xffffffff ^  ( 1<<10),
433*63258Sbostic     0xffffffff ^  ( 1<<9 ),  0xffffffff ^  ( 1<<8),
434*63258Sbostic     0xffffffff ^  ( 1<<7 ),  0xffffffff ^  ( 1<<6),
435*63258Sbostic     0xffffffff ^  ( 1<<5 ),  0xffffffff ^  ( 1<<4),
436*63258Sbostic     0xffffffff ^  ( 1<<3 ),  0xffffffff ^  ( 1<<2),
437*63258Sbostic     0xffffffff ^  ( 1<<1 ),  0xffffffff ^  ( 1<<0)
438*63258Sbostic     };
439*63258Sbostic 
440*63258Sbostic mergeRopRec mergeRopBits[16] = {
441*63258Sbostic 	 0, 0, 0, 0,		/* BF_0		0 */
442*63258Sbostic 	~0, 0, 0, 0,		/* BF_SDA	src & dst */
443*63258Sbostic 	~0, 0,~0, 0,		/* BF_SDIA	src & ~dst */
444*63258Sbostic 	 0, 0,~0, 0,		/* BF_S		src */
445*63258Sbostic 	~0,~0, 0, 0,		/* BF_SIDA	~src & dst */
446*63258Sbostic 	 0,~0, 0, 0,		/* BF_D		dst */
447*63258Sbostic 	 0,~0,~0, 0,		/* BF_SDX	src ^ dst */
448*63258Sbostic 	~0,~0,~0, 0,		/* BF_SDO	src | dst */
449*63258Sbostic 	~0,~0,~0,~0,		/* BF_SDOI	~(src | dst) */
450*63258Sbostic 	 0,~0,~0,~0,		/* BF_SDXI	~(src ^ dst) */
451*63258Sbostic 	 0,~0, 0,~0,		/* BF_DI	~dst */
452*63258Sbostic 	~0,~0, 0,~0,		/* BF_SDIO	src | ~dst */
453*63258Sbostic 	 0, 0,~0,~0,		/* BF_SI	~src */
454*63258Sbostic 	~0, 0,~0,~0,		/* BF_SIDO	~src | dst */
455*63258Sbostic 	~0, 0, 0,~0,		/* BF_SDAI	~(src & dst) */
456*63258Sbostic 	 0, 0, 0,~0,		/* BF_1		1 */
457*63258Sbostic };
458*63258Sbostic 
459*63258Sbostic #define Duff(counter, block) { \
460*63258Sbostic 	switch (counter & 7) { \
461*63258Sbostic 	case 7: { block; } \
462*63258Sbostic 	case 6: { block; } \
463*63258Sbostic 	case 5: { block; } \
464*63258Sbostic 	case 4: { block; } \
465*63258Sbostic 	case 3: { block; } \
466*63258Sbostic 	case 2: { block; } \
467*63258Sbostic 	case 1: { block; } \
468*63258Sbostic 	case 0:; \
469*63258Sbostic 	} \
470*63258Sbostic 	while ((counter -= 8) >= 0) { \
471*63258Sbostic 		{ block; } \
472*63258Sbostic 		{ block; } \
473*63258Sbostic 		{ block; } \
474*63258Sbostic 		{ block; } \
475*63258Sbostic 		{ block; } \
476*63258Sbostic 		{ block; } \
477*63258Sbostic 		{ block; } \
478*63258Sbostic 		{ block; } \
479*63258Sbostic 	} \
480*63258Sbostic }
481*63258Sbostic 
482*63258Sbostic #ifdef mc68020
483*63258Sbostic #define	Duff_plus(n, dst, src, op) { \
484*63258Sbostic 	switch ((n) & 7) { \
485*63258Sbostic 	case 7: \
486*63258Sbostic 		*(dst)++ op *(src)++; \
487*63258Sbostic 	case 6: \
488*63258Sbostic 		*(dst)++ op *(src)++; \
489*63258Sbostic 	case 5: \
490*63258Sbostic 		*(dst)++ op *(src)++; \
491*63258Sbostic 	case 4: \
492*63258Sbostic 		*(dst)++ op *(src)++; \
493*63258Sbostic 	case 3: \
494*63258Sbostic 		*(dst)++ op *(src)++; \
495*63258Sbostic 	case 2: \
496*63258Sbostic 		*(dst)++ op *(src)++; \
497*63258Sbostic 	case 1: \
498*63258Sbostic 		*(dst)++ op *(src)++; \
499*63258Sbostic 	} \
500*63258Sbostic 	while (((n) -= 8) >= 0) { \
501*63258Sbostic 		*(dst)++ op *(src)++; \
502*63258Sbostic 		*(dst)++ op *(src)++; \
503*63258Sbostic 		*(dst)++ op *(src)++; \
504*63258Sbostic 		*(dst)++ op *(src)++; \
505*63258Sbostic 		*(dst)++ op *(src)++; \
506*63258Sbostic 		*(dst)++ op *(src)++; \
507*63258Sbostic 		*(dst)++ op *(src)++; \
508*63258Sbostic 		*(dst)++ op *(src)++; \
509*63258Sbostic 	} \
510*63258Sbostic } \
511*63258Sbostic 
512*63258Sbostic #define Duff_minus(n, dst, src, op) { \
513*63258Sbostic 	switch ((n) & 7) { \
514*63258Sbostic 	case 7: \
515*63258Sbostic 		*--(dst) op *--(src); \
516*63258Sbostic 	case 6: \
517*63258Sbostic 		*--(dst) op *--(src); \
518*63258Sbostic 	case 5: \
519*63258Sbostic 		*--(dst) op *--(src); \
520*63258Sbostic 	case 4: \
521*63258Sbostic 		*--(dst) op *--(src); \
522*63258Sbostic 	case 3: \
523*63258Sbostic 		*--(dst) op *--(src); \
524*63258Sbostic 	case 2: \
525*63258Sbostic 		*--(dst) op *--(src); \
526*63258Sbostic 	case 1: \
527*63258Sbostic 		*--(dst) op *--(src); \
528*63258Sbostic 	} \
529*63258Sbostic 	while (((n) -= 8) >= 0) { \
530*63258Sbostic 		*--(dst) op *--(src); \
531*63258Sbostic 		*--(dst) op *--(src); \
532*63258Sbostic 		*--(dst) op *--(src); \
533*63258Sbostic 		*--(dst) op *--(src); \
534*63258Sbostic 		*--(dst) op *--(src); \
535*63258Sbostic 		*--(dst) op *--(src); \
536*63258Sbostic 		*--(dst) op *--(src); \
537*63258Sbostic 		*--(dst) op *--(src); \
538*63258Sbostic 	} \
539*63258Sbostic }
540*63258Sbostic 
541*63258Sbostic #define	Duff_shift_plus(n, dst, src, op) { \
542*63258Sbostic 	switch ((n) & 3) { \
543*63258Sbostic 	case 3: \
544*63258Sbostic 		bits = *(src)++; \
545*63258Sbostic 		*(dst)++ op (bits1 << leftShift) | (bits >> rightShift); \
546*63258Sbostic 	case 2: \
547*63258Sbostic 		bits1 = *(src)++; \
548*63258Sbostic 		*(dst)++ op (bits << leftShift) | (bits1 >> rightShift); \
549*63258Sbostic 	case 1: \
550*63258Sbostic 		bits = *(src)++; \
551*63258Sbostic 		*(dst)++ op (bits1 << leftShift) | (bits >> rightShift); \
552*63258Sbostic 	} \
553*63258Sbostic 	while (((n) -= 4) >= 0) { \
554*63258Sbostic 		bits1 = *(src)++; \
555*63258Sbostic 		*(dst)++ op (bits << leftShift) | (bits1 >> rightShift); \
556*63258Sbostic 		bits = *(src)++; \
557*63258Sbostic 		*(dst)++ op (bits1 << leftShift) | (bits >> rightShift); \
558*63258Sbostic 		bits1 = *(src)++; \
559*63258Sbostic 		*(dst)++ op (bits << leftShift) | (bits1 >> rightShift); \
560*63258Sbostic 		bits = *(src)++; \
561*63258Sbostic 		*(dst)++ op (bits1 << leftShift) | (bits >> rightShift); \
562*63258Sbostic 	} \
563*63258Sbostic }
564*63258Sbostic 
565*63258Sbostic #define	Duff_shift_minus(n, dst, src, op) { \
566*63258Sbostic 	switch ((n) & 3) { \
567*63258Sbostic 	case 3: \
568*63258Sbostic 		bits = *--(src); \
569*63258Sbostic 		*--(dst) op ((bits1 >> rightShift) | (bits << leftShift)); \
570*63258Sbostic 	case 2: \
571*63258Sbostic 		bits1 = *--(src); \
572*63258Sbostic 		*--(dst) op ((bits >> rightShift) | (bits1 << leftShift)); \
573*63258Sbostic 	case 1: \
574*63258Sbostic 		bits = *--(src); \
575*63258Sbostic 		*--(dst) op ((bits1 >> rightShift) | (bits << leftShift)); \
576*63258Sbostic 	} \
577*63258Sbostic 	while (((n) -= 4) >= 0) { \
578*63258Sbostic 		bits1 = *--(src); \
579*63258Sbostic 		*--(dst) op ((bits >> rightShift) | (bits1 << leftShift)); \
580*63258Sbostic 		bits = *--(src); \
581*63258Sbostic 		*--(dst) op ((bits1 >> rightShift) | (bits << leftShift)); \
582*63258Sbostic 		bits1 = *--(src); \
583*63258Sbostic 		*--(dst) op ((bits >> rightShift) | (bits1 << leftShift)); \
584*63258Sbostic 		bits = *--(src); \
585*63258Sbostic 		*--(dst) op ((bits1 >> rightShift) | (bits << leftShift)); \
586*63258Sbostic 	} \
587*63258Sbostic }
588*63258Sbostic 
589*63258Sbostic #define	Duff_single(nlw, addr, op) { \
590*63258Sbostic 	switch ((nlw) & 7) { \
591*63258Sbostic 	case 7: \
592*63258Sbostic 		*(addr)++ op ; \
593*63258Sbostic 	case 6: \
594*63258Sbostic 		*(addr)++ op ; \
595*63258Sbostic 	case 5: \
596*63258Sbostic 		*(addr)++ op ; \
597*63258Sbostic 	case 4: \
598*63258Sbostic 		*(addr)++ op ; \
599*63258Sbostic 	case 3: \
600*63258Sbostic 		*(addr)++ op ; \
601*63258Sbostic 	case 2: \
602*63258Sbostic 		*(addr)++ op ; \
603*63258Sbostic 	case 1: \
604*63258Sbostic 		*(addr)++ op ; \
605*63258Sbostic 	} \
606*63258Sbostic 	while (((nlw) -= 8) >= 0) { \
607*63258Sbostic 		*(addr)++ op ; \
608*63258Sbostic 		*(addr)++ op ; \
609*63258Sbostic 		*(addr)++ op ; \
610*63258Sbostic 		*(addr)++ op ; \
611*63258Sbostic 		*(addr)++ op ; \
612*63258Sbostic 		*(addr)++ op ; \
613*63258Sbostic 		*(addr)++ op ; \
614*63258Sbostic 		*(addr)++ op ; \
615*63258Sbostic 	} \
616*63258Sbostic }
617*63258Sbostic #else /* mc68020 */
618*63258Sbostic #define	Duff_plus(n, dst, src, op) { \
619*63258Sbostic 	(src) += (n) & 7; \
620*63258Sbostic 	(dst) += (n) & 7; \
621*63258Sbostic 	switch ((n) & 7) { \
622*63258Sbostic 	case 7: \
623*63258Sbostic 		(dst)[-7] op (src)[-7]; \
624*63258Sbostic 	case 6: \
625*63258Sbostic 		(dst)[-6] op (src)[-6]; \
626*63258Sbostic 	case 5: \
627*63258Sbostic 		(dst)[-5] op (src)[-5]; \
628*63258Sbostic 	case 4: \
629*63258Sbostic 		(dst)[-4] op (src)[-4]; \
630*63258Sbostic 	case 3: \
631*63258Sbostic 		(dst)[-3] op (src)[-3]; \
632*63258Sbostic 	case 2: \
633*63258Sbostic 		(dst)[-2] op (src)[-2]; \
634*63258Sbostic 	case 1: \
635*63258Sbostic 		(dst)[-1] op (src)[-1]; \
636*63258Sbostic 	} \
637*63258Sbostic 	while (((n) -= 8) >= 0) { \
638*63258Sbostic 		(dst) += 8; \
639*63258Sbostic 		(src) += 8; \
640*63258Sbostic 		(dst)[-8] op (src)[-8]; \
641*63258Sbostic 		(dst)[-7] op (src)[-7]; \
642*63258Sbostic 		(dst)[-6] op (src)[-6]; \
643*63258Sbostic 		(dst)[-5] op (src)[-5]; \
644*63258Sbostic 		(dst)[-4] op (src)[-4]; \
645*63258Sbostic 		(dst)[-3] op (src)[-3]; \
646*63258Sbostic 		(dst)[-2] op (src)[-2]; \
647*63258Sbostic 		(dst)[-1] op (src)[-1]; \
648*63258Sbostic 	} \
649*63258Sbostic } \
650*63258Sbostic 
651*63258Sbostic #define Duff_minus(n, dst, src, op) { \
652*63258Sbostic 	(src) -= (n) & 7; \
653*63258Sbostic 	(dst) -= (n) & 7; \
654*63258Sbostic 	switch ((n) & 7) { \
655*63258Sbostic 	case 7: \
656*63258Sbostic 		(dst)[7-1] op (src)[7-1]; \
657*63258Sbostic 	case 6: \
658*63258Sbostic 		(dst)[6-1] op (src)[6-1]; \
659*63258Sbostic 	case 5: \
660*63258Sbostic 		(dst)[5-1] op (src)[5-1]; \
661*63258Sbostic 	case 4: \
662*63258Sbostic 		(dst)[4-1] op (src)[4-1]; \
663*63258Sbostic 	case 3: \
664*63258Sbostic 		(dst)[3-1] op (src)[3-1]; \
665*63258Sbostic 	case 2: \
666*63258Sbostic 		(dst)[2-1] op (src)[2-1]; \
667*63258Sbostic 	case 1: \
668*63258Sbostic 		(dst)[1-1] op (src)[1-1]; \
669*63258Sbostic 	} \
670*63258Sbostic 	while (((n) -= 8) >= 0) { \
671*63258Sbostic 		(dst) -= 8; \
672*63258Sbostic 		(src) -= 8; \
673*63258Sbostic 		(dst)[8-1] op (src)[8-1]; \
674*63258Sbostic 		(dst)[7-1] op (src)[7-1]; \
675*63258Sbostic 		(dst)[6-1] op (src)[6-1]; \
676*63258Sbostic 		(dst)[5-1] op (src)[5-1]; \
677*63258Sbostic 		(dst)[4-1] op (src)[4-1]; \
678*63258Sbostic 		(dst)[3-1] op (src)[3-1]; \
679*63258Sbostic 		(dst)[2-1] op (src)[2-1]; \
680*63258Sbostic 		(dst)[1-1] op (src)[1-1]; \
681*63258Sbostic 	} \
682*63258Sbostic }
683*63258Sbostic 
684*63258Sbostic #define	Duff_shift_plus(n, dst, src, op) { \
685*63258Sbostic 	(src) += (n) & 7; \
686*63258Sbostic 	(dst) += (n) & 7; \
687*63258Sbostic 	switch ((n) & 7) { \
688*63258Sbostic 	case 7: \
689*63258Sbostic 		bits = (src)[-7]; \
690*63258Sbostic 		(dst)[-7] op (bits1 << leftShift) | (bits >> rightShift); \
691*63258Sbostic 	case 6: \
692*63258Sbostic 		bits1 = (src)[-6]; \
693*63258Sbostic 		(dst)[-6] op (bits << leftShift) | (bits1 >> rightShift); \
694*63258Sbostic 	case 5: \
695*63258Sbostic 		bits = (src)[-5]; \
696*63258Sbostic 		(dst)[-5] op (bits1 << leftShift) | (bits >> rightShift); \
697*63258Sbostic 	case 4: \
698*63258Sbostic 		bits1 = (src)[-4]; \
699*63258Sbostic 		(dst)[-4] op (bits << leftShift) | (bits1 >> rightShift); \
700*63258Sbostic 	case 3: \
701*63258Sbostic 		bits = (src)[-3]; \
702*63258Sbostic 		(dst)[-3] op (bits1 << leftShift) | (bits >> rightShift); \
703*63258Sbostic 	case 2: \
704*63258Sbostic 		bits1 = (src)[-2]; \
705*63258Sbostic 		(dst)[-2] op (bits << leftShift) | (bits1 >> rightShift); \
706*63258Sbostic 	case 1: \
707*63258Sbostic 		bits = (src)[-1]; \
708*63258Sbostic 		(dst)[-1] op (bits1 << leftShift) | (bits >> rightShift); \
709*63258Sbostic 	} \
710*63258Sbostic 	while (((n) -= 8) >= 0) { \
711*63258Sbostic 		(dst) += 8; \
712*63258Sbostic 		(src) += 8; \
713*63258Sbostic 		bits1 = (src)[-8]; \
714*63258Sbostic 		(dst)[-8] op (bits << leftShift) | (bits1 >> rightShift); \
715*63258Sbostic 		bits = (src)[-7]; \
716*63258Sbostic 		(dst)[-7] op (bits1 << leftShift) | (bits >> rightShift); \
717*63258Sbostic 		bits1 = (src)[-6]; \
718*63258Sbostic 		(dst)[-6] op (bits << leftShift) | (bits1 >> rightShift); \
719*63258Sbostic 		bits = (src)[-5]; \
720*63258Sbostic 		(dst)[-5] op (bits1 << leftShift) | (bits >> rightShift); \
721*63258Sbostic 		bits1 = (src)[-4]; \
722*63258Sbostic 		(dst)[-4] op (bits << leftShift) | (bits1 >> rightShift); \
723*63258Sbostic 		bits = (src)[-3]; \
724*63258Sbostic 		(dst)[-3] op (bits1 << leftShift) | (bits >> rightShift); \
725*63258Sbostic 		bits1 = (src)[-2]; \
726*63258Sbostic 		(dst)[-2] op (bits << leftShift) | (bits1 >> rightShift); \
727*63258Sbostic 		bits = (src)[-1]; \
728*63258Sbostic 		(dst)[-1] op (bits1 << leftShift) | (bits >> rightShift); \
729*63258Sbostic 	} \
730*63258Sbostic }
731*63258Sbostic 
732*63258Sbostic #define	Duff_shift_minus(n, dst, src, op) { \
733*63258Sbostic 	(src) -= (n) & 7; \
734*63258Sbostic 	(dst) -= (n) & 7; \
735*63258Sbostic 	switch ((n) & 7) { \
736*63258Sbostic 	case 7: \
737*63258Sbostic 		bits = (src)[7-1]; \
738*63258Sbostic 		(dst)[7-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
739*63258Sbostic 	case 6: \
740*63258Sbostic 		bits1 = (src)[6-1]; \
741*63258Sbostic 		(dst)[6-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
742*63258Sbostic 	case 5: \
743*63258Sbostic 		bits = (src)[5-1]; \
744*63258Sbostic 		(dst)[5-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
745*63258Sbostic 	case 4: \
746*63258Sbostic 		bits1 = (src)[4-1]; \
747*63258Sbostic 		(dst)[4-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
748*63258Sbostic 	case 3: \
749*63258Sbostic 		bits = (src)[3-1]; \
750*63258Sbostic 		(dst)[3-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
751*63258Sbostic 	case 2: \
752*63258Sbostic 		bits1 = (src)[2-1]; \
753*63258Sbostic 		(dst)[2-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
754*63258Sbostic 	case 1: \
755*63258Sbostic 		bits = (src)[1-1]; \
756*63258Sbostic 		(dst)[1-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
757*63258Sbostic 	} \
758*63258Sbostic 	while (((n) -= 8) >= 0) { \
759*63258Sbostic 		(dst) -= 8; \
760*63258Sbostic 		(src) -= 8; \
761*63258Sbostic 		bits1 = (src)[8-1]; \
762*63258Sbostic 		(dst)[8-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
763*63258Sbostic 		bits = (src)[7-1]; \
764*63258Sbostic 		(dst)[7-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
765*63258Sbostic 		bits1 = (src)[6-1]; \
766*63258Sbostic 		(dst)[6-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
767*63258Sbostic 		bits = (src)[5-1]; \
768*63258Sbostic 		(dst)[5-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
769*63258Sbostic 		bits1 = (src)[4-1]; \
770*63258Sbostic 		(dst)[4-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
771*63258Sbostic 		bits = (src)[3-1]; \
772*63258Sbostic 		(dst)[3-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
773*63258Sbostic 		bits1 = (src)[2-1]; \
774*63258Sbostic 		(dst)[2-1] op ((bits >> rightShift) | (bits1 << leftShift)); \
775*63258Sbostic 		bits = (src)[1-1]; \
776*63258Sbostic 		(dst)[1-1] op ((bits1 >> rightShift) | (bits << leftShift)); \
777*63258Sbostic 	} \
778*63258Sbostic }
779*63258Sbostic 
780*63258Sbostic #define	Duff_single(nlw, addr, op) { \
781*63258Sbostic 	(addr) += (nlw) & 7; \
782*63258Sbostic 	switch ((nlw) & 7) { \
783*63258Sbostic 	case 7: \
784*63258Sbostic 		(addr)[-7] op; \
785*63258Sbostic 	case 6: \
786*63258Sbostic 		(addr)[-6] op; \
787*63258Sbostic 	case 5: \
788*63258Sbostic 		(addr)[-5] op; \
789*63258Sbostic 	case 4: \
790*63258Sbostic 		(addr)[-4] op; \
791*63258Sbostic 	case 3: \
792*63258Sbostic 		(addr)[-3] op; \
793*63258Sbostic 	case 2: \
794*63258Sbostic 		(addr)[-2] op; \
795*63258Sbostic 	case 1: \
796*63258Sbostic 		(addr)[-1] op; \
797*63258Sbostic 	} \
798*63258Sbostic 	while (((nlw) -= 8) >= 0) { \
799*63258Sbostic 		(addr) += 8; \
800*63258Sbostic 		(addr)[-8] op; \
801*63258Sbostic 		(addr)[-7] op; \
802*63258Sbostic 		(addr)[-6] op; \
803*63258Sbostic 		(addr)[-5] op; \
804*63258Sbostic 		(addr)[-4] op; \
805*63258Sbostic 		(addr)[-3] op; \
806*63258Sbostic 		(addr)[-2] op; \
807*63258Sbostic 		(addr)[-1] op; \
808*63258Sbostic 	} \
809*63258Sbostic }
810*63258Sbostic #endif /* mc68020 */
811*63258Sbostic 
812*63258Sbostic void
mfb_copy_area32(addrSrc,addrDst,widthSrc,widthDst,sr,dp)813*63258Sbostic mfb_copy_area32(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
814*63258Sbostic u_int	*addrSrc;
815*63258Sbostic u_int	*addrDst;
816*63258Sbostic u_int	widthSrc;
817*63258Sbostic u_int	widthDst;
818*63258Sbostic lRectangle	*sr;	/* source rectangle */
819*63258Sbostic lPoint		*dp;	/* destination point */
820*63258Sbostic {
821*63258Sbostic 	register u_int *psrcLine, *psrc;
822*63258Sbostic 	register u_int *pdstLine, *pdst;
823*63258Sbostic 	int w, h;
824*63258Sbostic 	int xdir, ydir;
825*63258Sbostic 	u_int startmask, endmask;
826*63258Sbostic 	register int nlMiddle;
827*63258Sbostic 	int xoffSrc, xoffDst;
828*63258Sbostic 	register int leftShift, rightShift;
829*63258Sbostic 	u_int bits;
830*63258Sbostic 	u_int bits1;
831*63258Sbostic 	register int nl;
832*63258Sbostic 
833*63258Sbostic 	if (sr->origin.y < dp->y) {
834*63258Sbostic 		ydir = -1;
835*63258Sbostic 		widthSrc = -widthSrc;
836*63258Sbostic 		widthDst = -widthDst;
837*63258Sbostic 	} else {
838*63258Sbostic 		ydir = 1;
839*63258Sbostic 	}
840*63258Sbostic 
841*63258Sbostic 	if (sr->origin.x < dp->x) {
842*63258Sbostic 		xdir = -1;
843*63258Sbostic 	} else {
844*63258Sbostic 		xdir = 1;
845*63258Sbostic 	}
846*63258Sbostic 
847*63258Sbostic 	w = sr->extent.x;
848*63258Sbostic 	h = sr->extent.y;
849*63258Sbostic 
850*63258Sbostic 	if (ydir == -1) {
851*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
852*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
853*63258Sbostic 	} else {
854*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
855*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
856*63258Sbostic 	}
857*63258Sbostic 	if ((dp->x & 0x1f) +w <= 32) {
858*63258Sbostic 		startmask = mfbpartmasks32[dp->x & 0x1f][w & 0x1f];
859*63258Sbostic 		endmask = 0;
860*63258Sbostic 		nlMiddle = 0;
861*63258Sbostic 	} else {
862*63258Sbostic 		startmask = mfbstarttab32[dp->x & 0x1f];
863*63258Sbostic 		endmask = mfbendtab32[(dp->x + w) & 0x1f];
864*63258Sbostic 		if (startmask) {
865*63258Sbostic 			nlMiddle = (w - (32 - (dp->x & 0x1f))) >> 5;
866*63258Sbostic 		} else {
867*63258Sbostic 			nlMiddle = w >> 5;
868*63258Sbostic 		}
869*63258Sbostic 	}
870*63258Sbostic 
871*63258Sbostic 	if (xdir == 1) {
872*63258Sbostic 		xoffSrc = sr->origin.x & 0x1f;
873*63258Sbostic 		xoffDst = dp->x & 0x1f;
874*63258Sbostic 		pdstLine += (dp->x >> 5);
875*63258Sbostic 		psrcLine += (sr->origin.x >> 5);
876*63258Sbostic 		if (xoffSrc == xoffDst) {
877*63258Sbostic 			while (h--) {
878*63258Sbostic 				psrc = psrcLine;
879*63258Sbostic 				pdst = pdstLine;
880*63258Sbostic 				pdstLine += widthDst;
881*63258Sbostic 				psrcLine += widthSrc;
882*63258Sbostic 				if (startmask) {
883*63258Sbostic 					*pdst = (*pdst & ~startmask |
884*63258Sbostic 						 *psrc & startmask);
885*63258Sbostic 					psrc++;
886*63258Sbostic 					pdst++;
887*63258Sbostic 				}
888*63258Sbostic 				nl = nlMiddle;
889*63258Sbostic 				Duff_plus(nl, pdst, psrc, =);
890*63258Sbostic 				if (endmask) {
891*63258Sbostic 					*pdst = (*pdst & ~endmask |
892*63258Sbostic 						 *psrc & endmask);
893*63258Sbostic 				}
894*63258Sbostic 			}
895*63258Sbostic 		} else {
896*63258Sbostic 			if (xoffSrc > xoffDst) {
897*63258Sbostic 				leftShift = xoffSrc - xoffDst;
898*63258Sbostic 				rightShift = 32 - leftShift;
899*63258Sbostic 			} else {
900*63258Sbostic 				rightShift = xoffDst - xoffSrc;
901*63258Sbostic 				leftShift = 32 - rightShift;
902*63258Sbostic 			}
903*63258Sbostic 			while (h--) {
904*63258Sbostic 				psrc = psrcLine;
905*63258Sbostic 				pdst = pdstLine;
906*63258Sbostic 				pdstLine += widthDst;
907*63258Sbostic 				psrcLine += widthSrc;
908*63258Sbostic 				bits = 0;
909*63258Sbostic 				if (xoffSrc > xoffDst)
910*63258Sbostic 					bits = *psrc++;
911*63258Sbostic 				if (startmask) {
912*63258Sbostic 					bits1 = bits << leftShift;
913*63258Sbostic 					bits = *psrc++;
914*63258Sbostic 					bits1 |= bits >> rightShift;
915*63258Sbostic 					*pdst = (*pdst & ~startmask |
916*63258Sbostic 						 bits1 & startmask);
917*63258Sbostic 					pdst++;
918*63258Sbostic 				}
919*63258Sbostic 				nl = nlMiddle;
920*63258Sbostic 				bits1 = bits;
921*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, =);
922*63258Sbostic 				if (endmask) {
923*63258Sbostic 					bits1 = bits << leftShift;
924*63258Sbostic 					if (endmask << rightShift) {
925*63258Sbostic 						bits1 |= *psrc >> rightShift;
926*63258Sbostic 					}
927*63258Sbostic 					*pdst = (*pdst & ~endmask |
928*63258Sbostic 						 bits1 & endmask);
929*63258Sbostic 				}
930*63258Sbostic 			}
931*63258Sbostic 		}
932*63258Sbostic 	} else {
933*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0x1f;
934*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0x1f;
935*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 5) + 1;
936*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 5) + 1;
937*63258Sbostic 		if (xoffSrc == xoffDst) {
938*63258Sbostic 			while (h--) {
939*63258Sbostic 				psrc = psrcLine;
940*63258Sbostic 				pdst = pdstLine;
941*63258Sbostic 				pdstLine += widthDst;
942*63258Sbostic 				psrcLine += widthSrc;
943*63258Sbostic 				if (endmask) {
944*63258Sbostic 					pdst--;
945*63258Sbostic 					psrc--;
946*63258Sbostic 					*pdst = (*pdst & ~endmask |
947*63258Sbostic 						 *psrc & endmask);
948*63258Sbostic 				}
949*63258Sbostic 				nl = nlMiddle;
950*63258Sbostic 				Duff_minus(nl, pdst, psrc, =);
951*63258Sbostic 				if (startmask) {
952*63258Sbostic 					--pdst;
953*63258Sbostic 					--psrc;
954*63258Sbostic 					*pdst = (*pdst & ~startmask |
955*63258Sbostic 						 *psrc & startmask);
956*63258Sbostic 				}
957*63258Sbostic 			}
958*63258Sbostic 		} else {
959*63258Sbostic 			if (xoffDst > xoffSrc) {
960*63258Sbostic 				rightShift = xoffDst - xoffSrc;
961*63258Sbostic 				leftShift = 32 - rightShift;
962*63258Sbostic 			} else {
963*63258Sbostic 				leftShift = xoffSrc - xoffDst;
964*63258Sbostic 				rightShift = 32 - leftShift;
965*63258Sbostic 			}
966*63258Sbostic 			while (h--) {
967*63258Sbostic 				psrc = psrcLine;
968*63258Sbostic 				pdst = pdstLine;
969*63258Sbostic 				pdstLine += widthDst;
970*63258Sbostic 				psrcLine += widthSrc;
971*63258Sbostic 				bits = 0;
972*63258Sbostic 				if (xoffDst > xoffSrc)
973*63258Sbostic 					bits = *--psrc;
974*63258Sbostic 				if (endmask) {
975*63258Sbostic 					bits1 = bits >> rightShift;
976*63258Sbostic 					bits = *--psrc;
977*63258Sbostic 					bits1 |= (bits << leftShift);
978*63258Sbostic 					pdst--;
979*63258Sbostic 					*pdst = (*pdst & ~endmask |
980*63258Sbostic 						 bits1 & endmask);
981*63258Sbostic 				}
982*63258Sbostic 				nl = nlMiddle;
983*63258Sbostic 				bits1 = bits;
984*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, =);
985*63258Sbostic 				if (startmask) {
986*63258Sbostic 					bits1 = (bits >> rightShift);
987*63258Sbostic 					if (startmask >> leftShift) {
988*63258Sbostic 						bits1 |= *--psrc << leftShift;
989*63258Sbostic 					}
990*63258Sbostic 					--pdst;
991*63258Sbostic 					*pdst = (*pdst & ~startmask |
992*63258Sbostic 						 bits1 & startmask);
993*63258Sbostic 				}
994*63258Sbostic 			}
995*63258Sbostic 		}
996*63258Sbostic 	}
997*63258Sbostic }
998*63258Sbostic 
999*63258Sbostic void
mfb_copyinv_area32(addrSrc,addrDst,widthSrc,widthDst,sr,dp)1000*63258Sbostic mfb_copyinv_area32(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
1001*63258Sbostic u_int	*addrSrc;
1002*63258Sbostic u_int	*addrDst;
1003*63258Sbostic int	widthSrc;
1004*63258Sbostic int	widthDst;
1005*63258Sbostic lRectangle	*sr;	/* source rectangle */
1006*63258Sbostic lPoint		*dp;	/* destination point */
1007*63258Sbostic {
1008*63258Sbostic 	register u_int *psrcLine, *psrc;
1009*63258Sbostic 	register u_int *pdstLine, *pdst;
1010*63258Sbostic 	int w, h;
1011*63258Sbostic 	int xdir, ydir;
1012*63258Sbostic 	u_int startmask, endmask;
1013*63258Sbostic 	register int nlMiddle;
1014*63258Sbostic 	int xoffSrc, xoffDst;
1015*63258Sbostic 	register int leftShift, rightShift;
1016*63258Sbostic 	u_int bits;
1017*63258Sbostic 	u_int bits1;
1018*63258Sbostic 	register int nl;
1019*63258Sbostic 
1020*63258Sbostic 	if (sr->origin.y < dp->y) {
1021*63258Sbostic 		ydir = -1;
1022*63258Sbostic 		widthSrc = -widthSrc;
1023*63258Sbostic 		widthDst = -widthDst;
1024*63258Sbostic 	} else {
1025*63258Sbostic 		ydir = 1;
1026*63258Sbostic 	}
1027*63258Sbostic 
1028*63258Sbostic 	if (sr->origin.x < dp->x) {
1029*63258Sbostic 		xdir = -1;
1030*63258Sbostic 	} else {
1031*63258Sbostic 		xdir = 1;
1032*63258Sbostic 	}
1033*63258Sbostic 
1034*63258Sbostic 	w = sr->extent.x;
1035*63258Sbostic 	h = sr->extent.y;
1036*63258Sbostic 
1037*63258Sbostic 	if (ydir == -1) {
1038*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
1039*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
1040*63258Sbostic 	} else {
1041*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
1042*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
1043*63258Sbostic 	}
1044*63258Sbostic 	if ((dp->x & 0x1f) +w <= 32) {
1045*63258Sbostic 		startmask = mfbpartmasks32[dp->x & 0x1f][w & 0x1f];
1046*63258Sbostic 		endmask = 0;
1047*63258Sbostic 		nlMiddle = 0;
1048*63258Sbostic 	} else {
1049*63258Sbostic 		startmask = mfbstarttab32[dp->x & 0x1f];
1050*63258Sbostic 		endmask = mfbendtab32[(dp->x + w) & 0x1f];
1051*63258Sbostic 		if (startmask) {
1052*63258Sbostic 			nlMiddle = (w - (32 - (dp->x & 0x1f))) >> 5;
1053*63258Sbostic 		} else {
1054*63258Sbostic 			nlMiddle = w >> 5;
1055*63258Sbostic 		}
1056*63258Sbostic 	}
1057*63258Sbostic 
1058*63258Sbostic 	if (xdir == 1) {
1059*63258Sbostic 		xoffSrc = sr->origin.x & 0x1f;
1060*63258Sbostic 		xoffDst = dp->x & 0x1f;
1061*63258Sbostic 		pdstLine += (dp->x >> 5);
1062*63258Sbostic 		psrcLine += (sr->origin.x >> 5);
1063*63258Sbostic 		if (xoffSrc == xoffDst) {
1064*63258Sbostic 			while (h--) {
1065*63258Sbostic 				psrc = psrcLine;
1066*63258Sbostic 				pdst = pdstLine;
1067*63258Sbostic 				pdstLine += widthDst;
1068*63258Sbostic 				psrcLine += widthSrc;
1069*63258Sbostic 				if (startmask) {
1070*63258Sbostic 					*pdst = (*pdst & ~startmask |
1071*63258Sbostic 						 ~*psrc & startmask);
1072*63258Sbostic 					psrc++;
1073*63258Sbostic 					pdst++;
1074*63258Sbostic 				}
1075*63258Sbostic 				nl = nlMiddle;
1076*63258Sbostic 				Duff_plus(nl, pdst, psrc, = ~);
1077*63258Sbostic 				if (endmask) {
1078*63258Sbostic 					*pdst = (*pdst & ~endmask |
1079*63258Sbostic 						 ~*psrc & endmask);
1080*63258Sbostic 				}
1081*63258Sbostic 			}
1082*63258Sbostic 		} else {
1083*63258Sbostic 			if (xoffSrc > xoffDst) {
1084*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1085*63258Sbostic 				rightShift = 32 - leftShift;
1086*63258Sbostic 			} else {
1087*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1088*63258Sbostic 				leftShift = 32 - rightShift;
1089*63258Sbostic 			}
1090*63258Sbostic 			while (h--) {
1091*63258Sbostic 				psrc = psrcLine;
1092*63258Sbostic 				pdst = pdstLine;
1093*63258Sbostic 				psrcLine += widthSrc;
1094*63258Sbostic 				pdstLine += widthDst;
1095*63258Sbostic 				bits = 0;
1096*63258Sbostic 				if (xoffSrc > xoffDst)
1097*63258Sbostic 					bits = *psrc++;
1098*63258Sbostic 				if (startmask) {
1099*63258Sbostic 					bits1 = bits << leftShift;
1100*63258Sbostic 					bits = *psrc++;
1101*63258Sbostic 					bits1 |= bits >> rightShift;
1102*63258Sbostic 					*pdst = (*pdst & ~startmask |
1103*63258Sbostic 						 ~bits1 & startmask);
1104*63258Sbostic 					pdst++;
1105*63258Sbostic 				}
1106*63258Sbostic 				nl = nlMiddle;
1107*63258Sbostic 				bits1 = bits;
1108*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, = ~);
1109*63258Sbostic 				if (endmask) {
1110*63258Sbostic 					bits1 = bits << leftShift;
1111*63258Sbostic 					if (endmask << rightShift) {
1112*63258Sbostic 						bits1 |= *psrc >> rightShift;
1113*63258Sbostic 					}
1114*63258Sbostic 					*pdst = (*pdst & ~endmask |
1115*63258Sbostic 						 ~bits1 & endmask);
1116*63258Sbostic 				}
1117*63258Sbostic 			}
1118*63258Sbostic 		}
1119*63258Sbostic 	} else {
1120*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0x1f;
1121*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0x1f;
1122*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 5) + 1;
1123*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 5) + 1;
1124*63258Sbostic 		if (xoffSrc == xoffDst) {
1125*63258Sbostic 			while (h--) {
1126*63258Sbostic 				psrc = psrcLine;
1127*63258Sbostic 				pdst = pdstLine;
1128*63258Sbostic 				pdstLine += widthDst;
1129*63258Sbostic 				psrcLine += widthSrc;
1130*63258Sbostic 				if (endmask) {
1131*63258Sbostic 					pdst--;
1132*63258Sbostic 					psrc--;
1133*63258Sbostic 					*pdst = (*pdst & ~endmask |
1134*63258Sbostic 						 ~*psrc & endmask);
1135*63258Sbostic 				}
1136*63258Sbostic 				nl = nlMiddle;
1137*63258Sbostic 				Duff_minus(nl, pdst, psrc, = ~);
1138*63258Sbostic 				if (startmask) {
1139*63258Sbostic 					--pdst;
1140*63258Sbostic 					--psrc;
1141*63258Sbostic 					*pdst = (*pdst & ~startmask |
1142*63258Sbostic 						 ~*psrc & startmask);
1143*63258Sbostic 				}
1144*63258Sbostic 			}
1145*63258Sbostic 		} else {
1146*63258Sbostic 			if (xoffDst > xoffSrc) {
1147*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1148*63258Sbostic 				leftShift = 32 - rightShift;
1149*63258Sbostic 			} else {
1150*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1151*63258Sbostic 				rightShift = 32 - leftShift;
1152*63258Sbostic 			}
1153*63258Sbostic 			while (h--) {
1154*63258Sbostic 				psrc = psrcLine;
1155*63258Sbostic 				pdst = pdstLine;
1156*63258Sbostic 				pdstLine += widthDst;
1157*63258Sbostic 				psrcLine += widthSrc;
1158*63258Sbostic 				bits = 0;
1159*63258Sbostic 				if (xoffDst > xoffSrc)
1160*63258Sbostic 					bits = *--psrc;
1161*63258Sbostic 				if (endmask) {
1162*63258Sbostic 					bits1 = bits >> rightShift;
1163*63258Sbostic 					bits = *--psrc;
1164*63258Sbostic 					bits1 |= (bits << leftShift);
1165*63258Sbostic 					pdst--;
1166*63258Sbostic 					*pdst = (*pdst & ~endmask |
1167*63258Sbostic 						 ~bits1 & endmask);
1168*63258Sbostic 				}
1169*63258Sbostic 				nl = nlMiddle;
1170*63258Sbostic 				bits1 = bits;
1171*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, = ~);
1172*63258Sbostic 				if (startmask) {
1173*63258Sbostic 					bits1 = (bits >> rightShift);
1174*63258Sbostic 					if (startmask >> leftShift) {
1175*63258Sbostic 						bits1 |= *--psrc << leftShift;
1176*63258Sbostic 					}
1177*63258Sbostic 					--pdst;
1178*63258Sbostic 					*pdst = (*pdst & ~startmask |
1179*63258Sbostic 						 ~bits1 & startmask);
1180*63258Sbostic 				}
1181*63258Sbostic 			}
1182*63258Sbostic 		}
1183*63258Sbostic 	}
1184*63258Sbostic }
1185*63258Sbostic 
1186*63258Sbostic void
mfb_or_area32(addrSrc,addrDst,widthSrc,widthDst,sr,dp)1187*63258Sbostic mfb_or_area32(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
1188*63258Sbostic u_int	*addrSrc;
1189*63258Sbostic u_int	*addrDst;
1190*63258Sbostic int	widthSrc;
1191*63258Sbostic int	widthDst;
1192*63258Sbostic lRectangle	*sr;	/* source rectangle */
1193*63258Sbostic lPoint		*dp;	/* destination point */
1194*63258Sbostic {
1195*63258Sbostic 	register u_int *psrcLine, *psrc;
1196*63258Sbostic 	register u_int *pdstLine, *pdst;
1197*63258Sbostic 	int w, h;
1198*63258Sbostic 	int xdir, ydir;
1199*63258Sbostic 	u_int startmask, endmask;
1200*63258Sbostic 	register int nlMiddle;
1201*63258Sbostic 	int xoffSrc, xoffDst;
1202*63258Sbostic 	register int leftShift, rightShift;
1203*63258Sbostic 	u_int bits;
1204*63258Sbostic 	u_int bits1;
1205*63258Sbostic 	register int nl;
1206*63258Sbostic 
1207*63258Sbostic 	if (sr->origin.y < dp->y) {
1208*63258Sbostic 		ydir = -1;
1209*63258Sbostic 		widthSrc = -widthSrc;
1210*63258Sbostic 		widthDst = -widthDst;
1211*63258Sbostic 	} else {
1212*63258Sbostic 		ydir = 1;
1213*63258Sbostic 	}
1214*63258Sbostic 
1215*63258Sbostic 	if (sr->origin.x < dp->x) {
1216*63258Sbostic 		xdir = -1;
1217*63258Sbostic 	} else {
1218*63258Sbostic 		xdir = 1;
1219*63258Sbostic 	}
1220*63258Sbostic 
1221*63258Sbostic 	w = sr->extent.x;
1222*63258Sbostic 	h = sr->extent.y;
1223*63258Sbostic 
1224*63258Sbostic 	if (ydir == -1) {
1225*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
1226*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
1227*63258Sbostic 	} else {
1228*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
1229*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
1230*63258Sbostic 	}
1231*63258Sbostic 	if ((dp->x & 0x1f) +w <= 32) {
1232*63258Sbostic 		startmask = mfbpartmasks32[dp->x & 0x1f][w & 0x1f];
1233*63258Sbostic 		endmask = 0;
1234*63258Sbostic 		nlMiddle = 0;
1235*63258Sbostic 	} else {
1236*63258Sbostic 		startmask = mfbstarttab32[dp->x & 0x1f];
1237*63258Sbostic 		endmask = mfbendtab32[(dp->x + w) & 0x1f];
1238*63258Sbostic 		if (startmask) {
1239*63258Sbostic 			nlMiddle = (w - (32 - (dp->x & 0x1f))) >> 5;
1240*63258Sbostic 		} else {
1241*63258Sbostic 			nlMiddle = w >> 5;
1242*63258Sbostic 		}
1243*63258Sbostic 	}
1244*63258Sbostic 
1245*63258Sbostic 	if (xdir == 1) {
1246*63258Sbostic 		xoffSrc = sr->origin.x & 0x1f;
1247*63258Sbostic 		xoffDst = dp->x & 0x1f;
1248*63258Sbostic 		pdstLine += (dp->x >> 5);
1249*63258Sbostic 		psrcLine += (sr->origin.x >> 5);
1250*63258Sbostic 		if (xoffSrc == xoffDst) {
1251*63258Sbostic 			while (h--) {
1252*63258Sbostic 				psrc = psrcLine;
1253*63258Sbostic 				pdst = pdstLine;
1254*63258Sbostic 				pdstLine += widthDst;
1255*63258Sbostic 				psrcLine += widthSrc;
1256*63258Sbostic 				if (startmask) {
1257*63258Sbostic 					*pdst++ |= *psrc++ & startmask;
1258*63258Sbostic 				}
1259*63258Sbostic 				nl = nlMiddle;
1260*63258Sbostic 				Duff_plus(nl, pdst, psrc, |=);
1261*63258Sbostic 				if (endmask) {
1262*63258Sbostic 					*pdst |= *psrc & endmask;
1263*63258Sbostic 				}
1264*63258Sbostic 			}
1265*63258Sbostic 		} else {
1266*63258Sbostic 			if (xoffSrc > xoffDst) {
1267*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1268*63258Sbostic 				rightShift = 32 - leftShift;
1269*63258Sbostic 			} else {
1270*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1271*63258Sbostic 				leftShift = 32 - rightShift;
1272*63258Sbostic 			}
1273*63258Sbostic 			while (h--) {
1274*63258Sbostic 				psrc = psrcLine;
1275*63258Sbostic 				pdst = pdstLine;
1276*63258Sbostic 				pdstLine += widthDst;
1277*63258Sbostic 				psrcLine += widthSrc;
1278*63258Sbostic 				bits = 0;
1279*63258Sbostic 				if (xoffSrc > xoffDst)
1280*63258Sbostic 					bits = *psrc++;
1281*63258Sbostic 				if (startmask) {
1282*63258Sbostic 					bits1 = bits << leftShift;
1283*63258Sbostic 					bits = *psrc++;
1284*63258Sbostic 					bits1 |= bits >> rightShift;
1285*63258Sbostic 					*pdst++ |= bits1 & startmask;
1286*63258Sbostic 				}
1287*63258Sbostic 				nl = nlMiddle;
1288*63258Sbostic 				bits1 = bits;
1289*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, |=);
1290*63258Sbostic 				if (endmask) {
1291*63258Sbostic 					bits1 = bits << leftShift;
1292*63258Sbostic 					if (endmask << rightShift) {
1293*63258Sbostic 						bits1 |= *psrc >> rightShift;
1294*63258Sbostic 					}
1295*63258Sbostic 					*pdst |= bits1 & endmask;
1296*63258Sbostic 				}
1297*63258Sbostic 			}
1298*63258Sbostic 		}
1299*63258Sbostic 	} else {
1300*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0x1f;
1301*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0x1f;
1302*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 5) + 1;
1303*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 5) + 1;
1304*63258Sbostic 		if (xoffSrc == xoffDst) {
1305*63258Sbostic 			while (h--) {
1306*63258Sbostic 				psrc = psrcLine;
1307*63258Sbostic 				pdst = pdstLine;
1308*63258Sbostic 				pdstLine += widthDst;
1309*63258Sbostic 				psrcLine += widthSrc;
1310*63258Sbostic 				if (endmask) {
1311*63258Sbostic 					*--pdst |= *--psrc & endmask;
1312*63258Sbostic 				}
1313*63258Sbostic 				nl = nlMiddle;
1314*63258Sbostic 				Duff_minus(nl, pdst, psrc, |=);
1315*63258Sbostic 				if (startmask) {
1316*63258Sbostic 					*--pdst |= *--psrc & startmask;
1317*63258Sbostic 				}
1318*63258Sbostic 			}
1319*63258Sbostic 		} else {
1320*63258Sbostic 			if (xoffDst > xoffSrc) {
1321*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1322*63258Sbostic 				leftShift = 32 - rightShift;
1323*63258Sbostic 			} else {
1324*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1325*63258Sbostic 				rightShift = 32 - leftShift;
1326*63258Sbostic 			}
1327*63258Sbostic 			while (h--) {
1328*63258Sbostic 				psrc = psrcLine;
1329*63258Sbostic 				pdst = pdstLine;
1330*63258Sbostic 				pdstLine += widthDst;
1331*63258Sbostic 				psrcLine += widthSrc;
1332*63258Sbostic 				bits = 0;
1333*63258Sbostic 				if (xoffDst > xoffSrc)
1334*63258Sbostic 					bits = *--psrc;
1335*63258Sbostic 				if (endmask) {
1336*63258Sbostic 					bits1 = bits >> rightShift;
1337*63258Sbostic 					bits = *--psrc;
1338*63258Sbostic 					bits1 |= (bits << leftShift);
1339*63258Sbostic 					*--pdst |= bits1 & endmask;
1340*63258Sbostic 				}
1341*63258Sbostic 				nl = nlMiddle;
1342*63258Sbostic 				bits1 = bits;
1343*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, |=);
1344*63258Sbostic 				if (startmask) {
1345*63258Sbostic 					bits1 = (bits >> rightShift);
1346*63258Sbostic 					if (startmask >> leftShift) {
1347*63258Sbostic 						bits1 |= *--psrc << leftShift;
1348*63258Sbostic 					}
1349*63258Sbostic 					*--pdst |= bits1 & startmask;
1350*63258Sbostic 				}
1351*63258Sbostic 			}
1352*63258Sbostic 		}
1353*63258Sbostic 	}
1354*63258Sbostic }
1355*63258Sbostic 
1356*63258Sbostic void
mfb_xor_area32(addrSrc,addrDst,widthSrc,widthDst,sr,dp)1357*63258Sbostic mfb_xor_area32(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
1358*63258Sbostic u_int	*addrSrc;
1359*63258Sbostic u_int	*addrDst;
1360*63258Sbostic int	widthSrc;
1361*63258Sbostic int	widthDst;
1362*63258Sbostic lRectangle	*sr;	/* source rectangle */
1363*63258Sbostic lPoint		*dp;	/* destination point */
1364*63258Sbostic {
1365*63258Sbostic 	register u_int *psrcLine, *psrc;
1366*63258Sbostic 	register u_int *pdstLine, *pdst;
1367*63258Sbostic 	int w, h;
1368*63258Sbostic 	int xdir, ydir;
1369*63258Sbostic 	u_int startmask, endmask;
1370*63258Sbostic 	register int nlMiddle;
1371*63258Sbostic 	int xoffSrc, xoffDst;
1372*63258Sbostic 	register int leftShift, rightShift;
1373*63258Sbostic 	u_int bits;
1374*63258Sbostic 	u_int bits1;
1375*63258Sbostic 	register int nl;
1376*63258Sbostic 
1377*63258Sbostic 	if (sr->origin.y < dp->y) {
1378*63258Sbostic 		ydir = -1;
1379*63258Sbostic 		widthSrc = -widthSrc;
1380*63258Sbostic 		widthDst = -widthDst;
1381*63258Sbostic 	} else {
1382*63258Sbostic 		ydir = 1;
1383*63258Sbostic 	}
1384*63258Sbostic 
1385*63258Sbostic 	if (sr->origin.x < dp->x) {
1386*63258Sbostic 		xdir = -1;
1387*63258Sbostic 	} else {
1388*63258Sbostic 		xdir = 1;
1389*63258Sbostic 	}
1390*63258Sbostic 
1391*63258Sbostic 	w = sr->extent.x;
1392*63258Sbostic 	h = sr->extent.y;
1393*63258Sbostic 
1394*63258Sbostic 	if (ydir == -1) {
1395*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
1396*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
1397*63258Sbostic 	} else {
1398*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
1399*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
1400*63258Sbostic 	}
1401*63258Sbostic 	if ((dp->x & 0x1f) +w <= 32) {
1402*63258Sbostic 		startmask = mfbpartmasks32[dp->x & 0x1f][w & 0x1f];
1403*63258Sbostic 		endmask = 0;
1404*63258Sbostic 		nlMiddle = 0;
1405*63258Sbostic 	} else {
1406*63258Sbostic 		startmask = mfbstarttab32[dp->x & 0x1f];
1407*63258Sbostic 		endmask = mfbendtab32[(dp->x + w) & 0x1f];
1408*63258Sbostic 		if (startmask) {
1409*63258Sbostic 			nlMiddle = (w - (32 - (dp->x & 0x1f))) >> 5;
1410*63258Sbostic 		} else {
1411*63258Sbostic 			nlMiddle = w >> 5;
1412*63258Sbostic 		}
1413*63258Sbostic 	}
1414*63258Sbostic 
1415*63258Sbostic 	if (xdir == 1) {
1416*63258Sbostic 		xoffSrc = sr->origin.x & 0x1f;
1417*63258Sbostic 		xoffDst = dp->x & 0x1f;
1418*63258Sbostic 		pdstLine += (dp->x >> 5);
1419*63258Sbostic 		psrcLine += (sr->origin.x >> 5);
1420*63258Sbostic 		if (xoffSrc == xoffDst) {
1421*63258Sbostic 			while (h--) {
1422*63258Sbostic 				psrc = psrcLine;
1423*63258Sbostic 				pdst = pdstLine;
1424*63258Sbostic 				pdstLine += widthDst;
1425*63258Sbostic 				psrcLine += widthSrc;
1426*63258Sbostic 				if (startmask) {
1427*63258Sbostic 					*pdst++ ^= *psrc++ & startmask;
1428*63258Sbostic 				}
1429*63258Sbostic 				nl = nlMiddle;
1430*63258Sbostic 				Duff_plus(nl, pdst, psrc, ^=);
1431*63258Sbostic 				if (endmask) {
1432*63258Sbostic 					*pdst ^= *psrc & endmask;
1433*63258Sbostic 				}
1434*63258Sbostic 			}
1435*63258Sbostic 		} else {
1436*63258Sbostic 			if (xoffSrc > xoffDst) {
1437*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1438*63258Sbostic 				rightShift = 32 - leftShift;
1439*63258Sbostic 			} else {
1440*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1441*63258Sbostic 				leftShift = 32 - rightShift;
1442*63258Sbostic 			}
1443*63258Sbostic 			while (h--) {
1444*63258Sbostic 				psrc = psrcLine;
1445*63258Sbostic 				pdst = pdstLine;
1446*63258Sbostic 				pdstLine += widthDst;
1447*63258Sbostic 				psrcLine += widthSrc;
1448*63258Sbostic 				bits = 0;
1449*63258Sbostic 				if (xoffSrc > xoffDst)
1450*63258Sbostic 					bits = *psrc++;
1451*63258Sbostic 				if (startmask) {
1452*63258Sbostic 					bits1 = bits << leftShift;
1453*63258Sbostic 					bits = *psrc++;
1454*63258Sbostic 					bits1 |= bits >> rightShift;
1455*63258Sbostic 					*pdst++ ^= bits1 & startmask;
1456*63258Sbostic 				}
1457*63258Sbostic 				nl = nlMiddle;
1458*63258Sbostic 				bits1 = bits;
1459*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, ^=);
1460*63258Sbostic 				if (endmask) {
1461*63258Sbostic 					bits1 = bits << leftShift;
1462*63258Sbostic 					if (endmask << rightShift) {
1463*63258Sbostic 						bits1 |= *psrc >> rightShift;
1464*63258Sbostic 					}
1465*63258Sbostic 					*pdst ^= bits1 & endmask;
1466*63258Sbostic 				}
1467*63258Sbostic 			}
1468*63258Sbostic 		}
1469*63258Sbostic 	} else {
1470*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0x1f;
1471*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0x1f;
1472*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 5) + 1;
1473*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 5) + 1;
1474*63258Sbostic 		if (xoffSrc == xoffDst) {
1475*63258Sbostic 			while (h--) {
1476*63258Sbostic 				psrc = psrcLine;
1477*63258Sbostic 				pdst = pdstLine;
1478*63258Sbostic 				pdstLine += widthDst;
1479*63258Sbostic 				psrcLine += widthSrc;
1480*63258Sbostic 				if (endmask) {
1481*63258Sbostic 					*--pdst ^= *--psrc & endmask;
1482*63258Sbostic 				}
1483*63258Sbostic 				nl = nlMiddle;
1484*63258Sbostic 				Duff_minus(nl, pdst, psrc, ^=);
1485*63258Sbostic 				if (startmask) {
1486*63258Sbostic 					*--pdst ^= *--psrc & startmask;
1487*63258Sbostic 				}
1488*63258Sbostic 			}
1489*63258Sbostic 		} else {
1490*63258Sbostic 			if (xoffDst > xoffSrc) {
1491*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1492*63258Sbostic 				leftShift = 32 - rightShift;
1493*63258Sbostic 			} else {
1494*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1495*63258Sbostic 				rightShift = 32 - leftShift;
1496*63258Sbostic 			}
1497*63258Sbostic 			while (h--) {
1498*63258Sbostic 				psrc = psrcLine;
1499*63258Sbostic 				pdst = pdstLine;
1500*63258Sbostic 				pdstLine += widthDst;
1501*63258Sbostic 				psrcLine += widthSrc;
1502*63258Sbostic 				bits = 0;
1503*63258Sbostic 				if (xoffDst > xoffSrc)
1504*63258Sbostic 					bits = *--psrc;
1505*63258Sbostic 				if (endmask) {
1506*63258Sbostic 					bits1 = bits >> rightShift;
1507*63258Sbostic 					bits = *--psrc;
1508*63258Sbostic 					bits1 |= (bits << leftShift);
1509*63258Sbostic 					*--pdst ^= bits1 & endmask;
1510*63258Sbostic 				}
1511*63258Sbostic 				nl = nlMiddle;
1512*63258Sbostic 				bits1 = bits;
1513*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, ^=);
1514*63258Sbostic 				if (startmask) {
1515*63258Sbostic 					bits1 = (bits >> rightShift);
1516*63258Sbostic 					if (startmask >> leftShift) {
1517*63258Sbostic 						bits1 |= *--psrc << leftShift;
1518*63258Sbostic 					}
1519*63258Sbostic 					*--pdst ^= bits1 & startmask;
1520*63258Sbostic 				}
1521*63258Sbostic 			}
1522*63258Sbostic 		}
1523*63258Sbostic 	}
1524*63258Sbostic }
1525*63258Sbostic 
1526*63258Sbostic void
mfb_general_area32(func,addrSrc,addrDst,widthSrc,widthDst,sr,dp)1527*63258Sbostic mfb_general_area32(func, addrSrc, addrDst, widthSrc, widthDst, sr, dp)
1528*63258Sbostic int		func;
1529*63258Sbostic u_int	*addrSrc;
1530*63258Sbostic u_int	*addrDst;
1531*63258Sbostic int	widthSrc;
1532*63258Sbostic int	widthDst;
1533*63258Sbostic lRectangle	*sr;	/* source rectangle */
1534*63258Sbostic lPoint		*dp;	/* destination point */
1535*63258Sbostic {
1536*63258Sbostic 	register u_int *psrcLine, *psrc;
1537*63258Sbostic 	register u_int *pdstLine, *pdst;
1538*63258Sbostic 	register int leftShift, rightShift;
1539*63258Sbostic 	u_int bits;
1540*63258Sbostic 	u_int bits1;
1541*63258Sbostic 	register int nl;
1542*63258Sbostic 	u_int _ca1, _cx1, _ca2, _cx2;
1543*63258Sbostic 	u_int startmask, endmask;
1544*63258Sbostic 	int w, h;
1545*63258Sbostic 	int xdir, ydir;
1546*63258Sbostic 	register int nlMiddle;
1547*63258Sbostic 	int xoffSrc, xoffDst;
1548*63258Sbostic 
1549*63258Sbostic 	_ca1 = mergeRopBits[func].ca1;
1550*63258Sbostic 	_cx1 = mergeRopBits[func].cx1;
1551*63258Sbostic 	_ca2 = mergeRopBits[func].ca2;
1552*63258Sbostic 	_cx2 = mergeRopBits[func].cx2;
1553*63258Sbostic 
1554*63258Sbostic 	if (sr->origin.y < dp->y) {
1555*63258Sbostic 		ydir = -1;
1556*63258Sbostic 		widthSrc = -widthSrc;
1557*63258Sbostic 		widthDst = -widthDst;
1558*63258Sbostic 	} else {
1559*63258Sbostic 		ydir = 1;
1560*63258Sbostic 	}
1561*63258Sbostic 
1562*63258Sbostic 	if (sr->origin.x < dp->x) {
1563*63258Sbostic 		xdir = -1;
1564*63258Sbostic 	} else {
1565*63258Sbostic 		xdir = 1;
1566*63258Sbostic 	}
1567*63258Sbostic 
1568*63258Sbostic 	w = sr->extent.x;
1569*63258Sbostic 	h = sr->extent.y;
1570*63258Sbostic 
1571*63258Sbostic 	if (ydir == -1) {
1572*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
1573*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
1574*63258Sbostic 	} else {
1575*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
1576*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
1577*63258Sbostic 	}
1578*63258Sbostic 	if ((dp->x & 0x1f) +w <= 32) {
1579*63258Sbostic 		startmask = mfbpartmasks32[dp->x & 0x1f][w & 0x1f];
1580*63258Sbostic 		endmask = 0;
1581*63258Sbostic 		nlMiddle = 0;
1582*63258Sbostic 	} else {
1583*63258Sbostic 		startmask = mfbstarttab32[dp->x & 0x1f];
1584*63258Sbostic 		endmask = mfbendtab32[(dp->x + w) & 0x1f];
1585*63258Sbostic 		if (startmask) {
1586*63258Sbostic 			nlMiddle = (w - (32 - (dp->x & 0x1f))) >> 5;
1587*63258Sbostic 		} else {
1588*63258Sbostic 			nlMiddle = w >> 5;
1589*63258Sbostic 		}
1590*63258Sbostic 	}
1591*63258Sbostic 
1592*63258Sbostic 	if (xdir == 1) {
1593*63258Sbostic 		xoffSrc = sr->origin.x & 0x1f;
1594*63258Sbostic 		xoffDst = dp->x & 0x1f;
1595*63258Sbostic 		pdstLine += (dp->x >> 5);
1596*63258Sbostic 		psrcLine += (sr->origin.x >> 5);
1597*63258Sbostic 		if (xoffSrc == xoffDst) {
1598*63258Sbostic 			while (h--) {
1599*63258Sbostic 				psrc = psrcLine;
1600*63258Sbostic 				pdst = pdstLine;
1601*63258Sbostic 				pdstLine += widthDst;
1602*63258Sbostic 				psrcLine += widthSrc;
1603*63258Sbostic 				if (startmask) {
1604*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
1605*63258Sbostic 							       startmask);
1606*63258Sbostic 					psrc++;
1607*63258Sbostic 					pdst++;
1608*63258Sbostic 				}
1609*63258Sbostic 				nl = nlMiddle;
1610*63258Sbostic #ifdef mc68020
1611*63258Sbostic 				Duff(nl, *pdst = DoMergeRop(*psrc, *pdst);
1612*63258Sbostic 					  psrc++; pdst++);
1613*63258Sbostic #else /* mc68020 */
1614*63258Sbostic 				psrc += nl & 7;
1615*63258Sbostic 				pdst += nl & 7;
1616*63258Sbostic 				switch (nl & 7) {
1617*63258Sbostic 				case 7:
1618*63258Sbostic 					pdst[-7] = DoMergeRop(psrc[-7], pdst[-7]);
1619*63258Sbostic 				case 6:
1620*63258Sbostic 					pdst[-6] = DoMergeRop(psrc[-6], pdst[-6]);
1621*63258Sbostic 				case 5:
1622*63258Sbostic 					pdst[-5] = DoMergeRop(psrc[-5], pdst[-5]);
1623*63258Sbostic 				case 4:
1624*63258Sbostic 					pdst[-4] = DoMergeRop(psrc[-4], pdst[-4]);
1625*63258Sbostic 				case 3:
1626*63258Sbostic 					pdst[-3] = DoMergeRop(psrc[-3], pdst[-3]);
1627*63258Sbostic 				case 2:
1628*63258Sbostic 					pdst[-2] = DoMergeRop(psrc[-2], pdst[-2]);
1629*63258Sbostic 				case 1:
1630*63258Sbostic 					pdst[-1] = DoMergeRop(psrc[-1], pdst[-1]);
1631*63258Sbostic 				}
1632*63258Sbostic 				while ((nl -= 8) >= 0) {
1633*63258Sbostic 					pdst += 8;
1634*63258Sbostic 					psrc += 8;
1635*63258Sbostic 					pdst[-8] = DoMergeRop(psrc[-8], pdst[-8]);
1636*63258Sbostic 					pdst[-7] = DoMergeRop(psrc[-7], pdst[-7]);
1637*63258Sbostic 					pdst[-6] = DoMergeRop(psrc[-6], pdst[-6]);
1638*63258Sbostic 					pdst[-5] = DoMergeRop(psrc[-5], pdst[-5]);
1639*63258Sbostic 					pdst[-4] = DoMergeRop(psrc[-4], pdst[-4]);
1640*63258Sbostic 					pdst[-3] = DoMergeRop(psrc[-3], pdst[-3]);
1641*63258Sbostic 					pdst[-2] = DoMergeRop(psrc[-2], pdst[-2]);
1642*63258Sbostic 					pdst[-1] = DoMergeRop(psrc[-1], pdst[-1]);
1643*63258Sbostic 				}
1644*63258Sbostic #endif /* mc68020 */
1645*63258Sbostic 				if (endmask) {
1646*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
1647*63258Sbostic 							       endmask);
1648*63258Sbostic 				}
1649*63258Sbostic 			}
1650*63258Sbostic 		} else {
1651*63258Sbostic 			if (xoffSrc > xoffDst) {
1652*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1653*63258Sbostic 				rightShift = 32 - leftShift;
1654*63258Sbostic 			} else {
1655*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1656*63258Sbostic 				leftShift = 32 - rightShift;
1657*63258Sbostic 			}
1658*63258Sbostic 			while (h--) {
1659*63258Sbostic 				psrc = psrcLine;
1660*63258Sbostic 				pdst = pdstLine;
1661*63258Sbostic 				pdstLine += widthDst;
1662*63258Sbostic 				psrcLine += widthSrc;
1663*63258Sbostic 				bits = 0;
1664*63258Sbostic 				if (xoffSrc > xoffDst)
1665*63258Sbostic 					bits = *psrc++;
1666*63258Sbostic 				if (startmask) {
1667*63258Sbostic 					bits1 = bits << leftShift;
1668*63258Sbostic 					bits = *psrc++;
1669*63258Sbostic 					bits1 |= bits >> rightShift;
1670*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
1671*63258Sbostic 							       startmask);
1672*63258Sbostic 					pdst++;
1673*63258Sbostic 				}
1674*63258Sbostic 				nl = nlMiddle;
1675*63258Sbostic 				bits1 = bits;
1676*63258Sbostic 				psrc += nl & 7;
1677*63258Sbostic 				pdst += nl & 7;
1678*63258Sbostic 				switch (nl & 7) {
1679*63258Sbostic 				case 7:
1680*63258Sbostic 					bits = psrc[-7];
1681*63258Sbostic 					pdst[-7] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-7]);
1682*63258Sbostic 				case 6:
1683*63258Sbostic 					bits1 = psrc[-6];
1684*63258Sbostic 					pdst[-6] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-6]);
1685*63258Sbostic 				case 5:
1686*63258Sbostic 					bits = psrc[-5];
1687*63258Sbostic 					pdst[-5] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-5]);
1688*63258Sbostic 				case 4:
1689*63258Sbostic 					bits1 = psrc[-4];
1690*63258Sbostic 					pdst[-4] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-4]);
1691*63258Sbostic 				case 3:
1692*63258Sbostic 					bits = psrc[-3];
1693*63258Sbostic 					pdst[-3] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-3]);
1694*63258Sbostic 				case 2:
1695*63258Sbostic 					bits1 = psrc[-2];
1696*63258Sbostic 					pdst[-2] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-2]);
1697*63258Sbostic 				case 1:
1698*63258Sbostic 					bits = psrc[-1];
1699*63258Sbostic 					pdst[-1] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-1]);
1700*63258Sbostic 				}
1701*63258Sbostic 				while ((nl -= 8) >= 0) {
1702*63258Sbostic 					pdst += 8;
1703*63258Sbostic 					psrc += 8;
1704*63258Sbostic 					bits1 = psrc[-8];
1705*63258Sbostic 					pdst[-8] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-8]);
1706*63258Sbostic 					bits = psrc[-7];
1707*63258Sbostic 					pdst[-7] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-7]);
1708*63258Sbostic 					bits1 = psrc[-6];
1709*63258Sbostic 					pdst[-6] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-6]);
1710*63258Sbostic 					bits = psrc[-5];
1711*63258Sbostic 					pdst[-5] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-5]);
1712*63258Sbostic 					bits1 = psrc[-4];
1713*63258Sbostic 					pdst[-4] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-4]);
1714*63258Sbostic 					bits = psrc[-3];
1715*63258Sbostic 					pdst[-3] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-3]);
1716*63258Sbostic 					bits1 = psrc[-2];
1717*63258Sbostic 					pdst[-2] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-2]);
1718*63258Sbostic 					bits = psrc[-1];
1719*63258Sbostic 					pdst[-1] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-1]);
1720*63258Sbostic 				}
1721*63258Sbostic 				if (endmask) {
1722*63258Sbostic 					bits1 = bits << leftShift;
1723*63258Sbostic 					if (endmask << rightShift) {
1724*63258Sbostic 						bits = *psrc;
1725*63258Sbostic 						bits1 |= (bits >> rightShift);
1726*63258Sbostic 					}
1727*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
1728*63258Sbostic 							       endmask);
1729*63258Sbostic 				}
1730*63258Sbostic 			}
1731*63258Sbostic 		}
1732*63258Sbostic 	} else {
1733*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0x1f;
1734*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0x1f;
1735*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 5) + 1;
1736*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 5) + 1;
1737*63258Sbostic 		if (xoffSrc == xoffDst) {
1738*63258Sbostic 			while (h--) {
1739*63258Sbostic 				psrc = psrcLine;
1740*63258Sbostic 				pdst = pdstLine;
1741*63258Sbostic 				pdstLine += widthDst;
1742*63258Sbostic 				psrcLine += widthSrc;
1743*63258Sbostic 				if (endmask) {
1744*63258Sbostic 					pdst--;
1745*63258Sbostic 					psrc--;
1746*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
1747*63258Sbostic 							       endmask);
1748*63258Sbostic 				}
1749*63258Sbostic 				nl = nlMiddle;
1750*63258Sbostic #ifdef mc68020
1751*63258Sbostic 				Duff(nl, pdst--; psrc--;
1752*63258Sbostic 					  *pdst = DoMergeRop(*psrc, *pdst));
1753*63258Sbostic #else /* mc68020 */
1754*63258Sbostic 				psrc -= nl & 7;
1755*63258Sbostic 				pdst -= nl & 7;
1756*63258Sbostic 				switch (nl & 7) {
1757*63258Sbostic 				case 7:
1758*63258Sbostic 					pdst[7-1] = DoMergeRop(psrc[7-1], pdst[7-1]);
1759*63258Sbostic 				case 6:
1760*63258Sbostic 					pdst[6-1] = DoMergeRop(psrc[6-1], pdst[6-1]);
1761*63258Sbostic 				case 5:
1762*63258Sbostic 					pdst[5-1] = DoMergeRop(psrc[5-1], pdst[5-1]);
1763*63258Sbostic 				case 4:
1764*63258Sbostic 					pdst[4-1] = DoMergeRop(psrc[4-1], pdst[4-1]);
1765*63258Sbostic 				case 3:
1766*63258Sbostic 					pdst[3-1] = DoMergeRop(psrc[3-1], pdst[3-1]);
1767*63258Sbostic 				case 2:
1768*63258Sbostic 					pdst[2-1] = DoMergeRop(psrc[2-1], pdst[2-1]);
1769*63258Sbostic 				case 1:
1770*63258Sbostic 					pdst[1-1] = DoMergeRop(psrc[1-1], pdst[1-1]);
1771*63258Sbostic 				}
1772*63258Sbostic 				while ((nl -= 8) >= 0) {
1773*63258Sbostic 					pdst -= 8;
1774*63258Sbostic 					psrc -= 8;
1775*63258Sbostic 					pdst[8-1] = DoMergeRop(psrc[8-1], pdst[8-1]);
1776*63258Sbostic 					pdst[7-1] = DoMergeRop(psrc[7-1], pdst[7-1]);
1777*63258Sbostic 					pdst[6-1] = DoMergeRop(psrc[6-1], pdst[6-1]);
1778*63258Sbostic 					pdst[5-1] = DoMergeRop(psrc[5-1], pdst[5-1]);
1779*63258Sbostic 					pdst[4-1] = DoMergeRop(psrc[4-1], pdst[4-1]);
1780*63258Sbostic 					pdst[3-1] = DoMergeRop(psrc[3-1], pdst[3-1]);
1781*63258Sbostic 					pdst[2-1] = DoMergeRop(psrc[2-1], pdst[2-1]);
1782*63258Sbostic 					pdst[1-1] = DoMergeRop(psrc[1-1], pdst[1-1]);
1783*63258Sbostic 				}
1784*63258Sbostic #endif /* mc68020 */
1785*63258Sbostic 				if (startmask) {
1786*63258Sbostic 					--pdst;
1787*63258Sbostic 					--psrc;
1788*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
1789*63258Sbostic 							       startmask);
1790*63258Sbostic 				}
1791*63258Sbostic 			}
1792*63258Sbostic 		} else {
1793*63258Sbostic 			if (xoffDst > xoffSrc) {
1794*63258Sbostic 				rightShift = xoffDst - xoffSrc;
1795*63258Sbostic 				leftShift = 32 - rightShift;
1796*63258Sbostic 			} else {
1797*63258Sbostic 				leftShift = xoffSrc - xoffDst;
1798*63258Sbostic 				rightShift = 32 - leftShift;
1799*63258Sbostic 			}
1800*63258Sbostic 			while (h--) {
1801*63258Sbostic 				psrc = psrcLine;
1802*63258Sbostic 				pdst = pdstLine;
1803*63258Sbostic 				pdstLine += widthDst;
1804*63258Sbostic 				psrcLine += widthSrc;
1805*63258Sbostic 				bits = 0;
1806*63258Sbostic 				if (xoffDst > xoffSrc)
1807*63258Sbostic 					bits = *--psrc;
1808*63258Sbostic 				if (endmask) {
1809*63258Sbostic 					bits1 = bits >> rightShift;
1810*63258Sbostic 					bits = *--psrc;
1811*63258Sbostic 					bits1 |= (bits << leftShift);
1812*63258Sbostic 					pdst--;
1813*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
1814*63258Sbostic 							       endmask);
1815*63258Sbostic 				}
1816*63258Sbostic 				nl = nlMiddle;
1817*63258Sbostic 				bits1 = bits;
1818*63258Sbostic 				psrc -= nl & 7;
1819*63258Sbostic 				pdst -= nl & 7;
1820*63258Sbostic 				switch (nl & 7) {
1821*63258Sbostic 				case 7:
1822*63258Sbostic 					bits = psrc[7-1];
1823*63258Sbostic 					pdst[7-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[7-1]);
1824*63258Sbostic 				case 6:
1825*63258Sbostic 					bits1 = psrc[6-1];
1826*63258Sbostic 					pdst[6-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[6-1]);
1827*63258Sbostic 				case 5:
1828*63258Sbostic 					bits = psrc[5-1];
1829*63258Sbostic 					pdst[5-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[5-1]);
1830*63258Sbostic 				case 4:
1831*63258Sbostic 					bits1 = psrc[4-1];
1832*63258Sbostic 					pdst[4-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[4-1]);
1833*63258Sbostic 				case 3:
1834*63258Sbostic 					bits = psrc[3-1];
1835*63258Sbostic 					pdst[3-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[3-1]);
1836*63258Sbostic 				case 2:
1837*63258Sbostic 					bits1 = psrc[2-1];
1838*63258Sbostic 					pdst[2-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[2-1]);
1839*63258Sbostic 				case 1:
1840*63258Sbostic 					bits = psrc[1-1];
1841*63258Sbostic 					pdst[1-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[1-1]);
1842*63258Sbostic 				}
1843*63258Sbostic 				while ((nl -= 8) >= 0) {
1844*63258Sbostic 					pdst -= 8;
1845*63258Sbostic 					psrc -= 8;
1846*63258Sbostic 					bits1 = psrc[8-1];
1847*63258Sbostic 					pdst[8-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[8-1]);
1848*63258Sbostic 					bits = psrc[7-1];
1849*63258Sbostic 					pdst[7-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[7-1]);
1850*63258Sbostic 					bits1 = psrc[6-1];
1851*63258Sbostic 					pdst[6-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[6-1]);
1852*63258Sbostic 					bits = psrc[5-1];
1853*63258Sbostic 					pdst[5-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[5-1]);
1854*63258Sbostic 					bits1 = psrc[4-1];
1855*63258Sbostic 					pdst[4-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[4-1]);
1856*63258Sbostic 					bits = psrc[3-1];
1857*63258Sbostic 					pdst[3-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[3-1]);
1858*63258Sbostic 					bits1 = psrc[2-1];
1859*63258Sbostic 					pdst[2-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[2-1]);
1860*63258Sbostic 					bits = psrc[1-1];
1861*63258Sbostic 					pdst[1-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[1-1]);
1862*63258Sbostic 				}
1863*63258Sbostic 				if (startmask) {
1864*63258Sbostic 					bits1 = (bits >> rightShift);
1865*63258Sbostic 					if (startmask >> leftShift) {
1866*63258Sbostic 						bits = *--psrc;
1867*63258Sbostic 						bits1 |= (bits << leftShift);
1868*63258Sbostic 					}
1869*63258Sbostic 					--pdst;
1870*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
1871*63258Sbostic 							       startmask);
1872*63258Sbostic 				}
1873*63258Sbostic 			}
1874*63258Sbostic 		}
1875*63258Sbostic 	}
1876*63258Sbostic }
1877*63258Sbostic 
1878*63258Sbostic void
mfb_clr_area32(x,y,w,h,addr,nlwidth)1879*63258Sbostic mfb_clr_area32(x, y, w, h, addr, nlwidth)
1880*63258Sbostic int x;
1881*63258Sbostic int y;
1882*63258Sbostic int w;
1883*63258Sbostic register int h;
1884*63258Sbostic register u_int *addr;
1885*63258Sbostic int nlwidth;
1886*63258Sbostic {
1887*63258Sbostic 	register u_int startmask;
1888*63258Sbostic 	u_int endmask;
1889*63258Sbostic 	register int nlw, nlwExtra;
1890*63258Sbostic 	int nlwMiddle;
1891*63258Sbostic 	int startoff, endoff;
1892*63258Sbostic 
1893*63258Sbostic 	addr += (y * nlwidth + (x >> 5));
1894*63258Sbostic 
1895*63258Sbostic 	startoff = x & 0x1f;
1896*63258Sbostic 	if (((startoff) + w) < 32) {
1897*63258Sbostic 		startmask = ~mfbpartmasks32[startoff][w & 0x1f];
1898*63258Sbostic 		nlwExtra = nlwidth;
1899*63258Sbostic #ifdef mc68020
1900*63258Sbostic 		asm("	lsl.l	#2,d4");
1901*63258Sbostic 		Duff(h, asm("	and.l	d6,(a5)");
1902*63258Sbostic 			asm("	adda.l	d4,a5"))
1903*63258Sbostic #else /* mc68020 */
1904*63258Sbostic 		Duff(h, *addr &= startmask; addr += nlwExtra)
1905*63258Sbostic #endif /* mc68020 */
1906*63258Sbostic 		return;
1907*63258Sbostic 	}
1908*63258Sbostic 	endoff = (x + w) & 0x1f;
1909*63258Sbostic 	if (startoff) {
1910*63258Sbostic 		startmask = ~mfbstarttab32[startoff];
1911*63258Sbostic 		nlwMiddle = (w - (32 - (startoff))) >> 5;
1912*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle - 1;
1913*63258Sbostic 		if (endoff) {
1914*63258Sbostic 			endmask = ~mfbendtab32[endoff];
1915*63258Sbostic 			while (h--) {
1916*63258Sbostic 				nlw = nlwMiddle;
1917*63258Sbostic 				*addr++ &= startmask;
1918*63258Sbostic 				Duff_single(nlw, addr, = 0);
1919*63258Sbostic 				*addr &= endmask;
1920*63258Sbostic 				addr += nlwExtra;
1921*63258Sbostic 			}
1922*63258Sbostic 		} else {
1923*63258Sbostic 			while (h--) {
1924*63258Sbostic 				nlw = nlwMiddle;
1925*63258Sbostic 				*addr++ &= startmask;
1926*63258Sbostic 				Duff_single(nlw, addr, = 0);
1927*63258Sbostic 				addr += nlwExtra;
1928*63258Sbostic 			}
1929*63258Sbostic 		}
1930*63258Sbostic 	} else {
1931*63258Sbostic 		nlwMiddle = w >> 5;
1932*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle;
1933*63258Sbostic 		if (endoff) {
1934*63258Sbostic 			endmask = ~mfbendtab32[endoff];
1935*63258Sbostic 			while (h--) {
1936*63258Sbostic 				nlw = nlwMiddle;
1937*63258Sbostic 				Duff_single(nlw, addr, = 0);
1938*63258Sbostic 				*addr &= endmask;
1939*63258Sbostic 				addr += nlwExtra;
1940*63258Sbostic 			}
1941*63258Sbostic 		} else {
1942*63258Sbostic 			while (h--) {
1943*63258Sbostic 				nlw = nlwMiddle;
1944*63258Sbostic 				Duff_single(nlw, addr, = 0);
1945*63258Sbostic 				addr += nlwExtra;
1946*63258Sbostic 			}
1947*63258Sbostic 		}
1948*63258Sbostic 	}
1949*63258Sbostic }
1950*63258Sbostic 
1951*63258Sbostic void
mfb_inv_area32(x,y,w,h,addr,nlwidth)1952*63258Sbostic mfb_inv_area32(x, y, w, h, addr, nlwidth)
1953*63258Sbostic int x;
1954*63258Sbostic int y;
1955*63258Sbostic int w;
1956*63258Sbostic register int h;
1957*63258Sbostic register u_int *addr;
1958*63258Sbostic int nlwidth;
1959*63258Sbostic {
1960*63258Sbostic 	register u_int startmask;
1961*63258Sbostic 	u_int endmask;
1962*63258Sbostic 	register int nlw, nlwExtra;
1963*63258Sbostic 	int nlwMiddle;
1964*63258Sbostic 	int startoff, endoff;
1965*63258Sbostic 
1966*63258Sbostic 	addr += (y * nlwidth + (x >> 5));
1967*63258Sbostic 
1968*63258Sbostic 	startoff = x & 0x1f;
1969*63258Sbostic 	if (((startoff) + w) < 32) {
1970*63258Sbostic 		startmask = mfbpartmasks32[startoff][w & 0x1f];
1971*63258Sbostic 		nlwExtra = nlwidth;
1972*63258Sbostic #ifdef mc68020
1973*63258Sbostic 		asm("	lsl.l	#2,d4");
1974*63258Sbostic 		Duff(h, asm("	eor.l	d6,(a5)");
1975*63258Sbostic 			asm("	adda.l	d4,a5"))
1976*63258Sbostic #else /* mc68020 */
1977*63258Sbostic 		Duff(h, *addr ^= startmask; addr += nlwExtra)
1978*63258Sbostic #endif /* mc68020 */
1979*63258Sbostic 		return;
1980*63258Sbostic 	}
1981*63258Sbostic 	endoff = (x + w) & 0x1f;
1982*63258Sbostic 	if (startoff) {
1983*63258Sbostic 		startmask = mfbstarttab32[startoff];
1984*63258Sbostic 		nlwMiddle = (w - (32 - (startoff))) >> 5;
1985*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle - 1;
1986*63258Sbostic 		if (endoff) {
1987*63258Sbostic 			endmask = mfbendtab32[endoff];
1988*63258Sbostic 			while (h--) {
1989*63258Sbostic 				nlw = nlwMiddle;
1990*63258Sbostic 				*addr++ ^= startmask;
1991*63258Sbostic 				Duff_single(nlw, addr, ^= ~0);
1992*63258Sbostic 				*addr ^= endmask;
1993*63258Sbostic 				addr += nlwExtra;
1994*63258Sbostic 			}
1995*63258Sbostic 		} else {
1996*63258Sbostic 			while (h--) {
1997*63258Sbostic 				nlw = nlwMiddle;
1998*63258Sbostic 				*addr++ ^= startmask;
1999*63258Sbostic 				Duff_single(nlw, addr, ^= ~0);
2000*63258Sbostic 				addr += nlwExtra;
2001*63258Sbostic 			}
2002*63258Sbostic 		}
2003*63258Sbostic 	} else {
2004*63258Sbostic 		nlwMiddle = w >> 5;
2005*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle;
2006*63258Sbostic 		if (endoff) {
2007*63258Sbostic 			endmask = mfbendtab32[endoff];
2008*63258Sbostic 			while (h--) {
2009*63258Sbostic 				nlw = nlwMiddle;
2010*63258Sbostic 				Duff_single(nlw, addr, ^= ~0);
2011*63258Sbostic 				*addr ^= endmask;
2012*63258Sbostic 				addr += nlwExtra;
2013*63258Sbostic 			}
2014*63258Sbostic 		} else {
2015*63258Sbostic 			while (h--) {
2016*63258Sbostic 				nlw = nlwMiddle;
2017*63258Sbostic 				Duff_single(nlw, addr, ^= ~0);
2018*63258Sbostic 				addr += nlwExtra;
2019*63258Sbostic 			}
2020*63258Sbostic 		}
2021*63258Sbostic 	}
2022*63258Sbostic }
2023*63258Sbostic 
2024*63258Sbostic void
mfb_set_area32(x,y,w,h,addr,nlwidth)2025*63258Sbostic mfb_set_area32(x, y, w, h, addr, nlwidth)
2026*63258Sbostic int x;
2027*63258Sbostic int y;
2028*63258Sbostic int w;
2029*63258Sbostic register int h;
2030*63258Sbostic register u_int *addr;
2031*63258Sbostic int nlwidth;
2032*63258Sbostic {
2033*63258Sbostic 	register u_int startmask;
2034*63258Sbostic 	u_int endmask;
2035*63258Sbostic 	register int nlw, nlwExtra;
2036*63258Sbostic 	int nlwMiddle;
2037*63258Sbostic 	int startoff, endoff;
2038*63258Sbostic 
2039*63258Sbostic 	addr += (y * nlwidth + (x >> 5));
2040*63258Sbostic 
2041*63258Sbostic 	startoff = x & 0x1f;
2042*63258Sbostic 	if (((startoff) + w) < 32) {
2043*63258Sbostic 		startmask = mfbpartmasks32[startoff][w & 0x1f];
2044*63258Sbostic 		nlwExtra = nlwidth;
2045*63258Sbostic #ifdef mc68020
2046*63258Sbostic 		asm("	lsl.l	#2,d4");
2047*63258Sbostic 		Duff(h, asm("	or.l	d6,(a5)");
2048*63258Sbostic 			asm("	adda.l	d4,a5"))
2049*63258Sbostic #else /* mc68020 */
2050*63258Sbostic 		Duff(h, *addr |= startmask; addr += nlwExtra)
2051*63258Sbostic #endif /* mc68020 */
2052*63258Sbostic 		return;
2053*63258Sbostic 	}
2054*63258Sbostic 	endoff = (x + w) & 0x1f;
2055*63258Sbostic 	if (startoff) {
2056*63258Sbostic 		startmask = mfbstarttab32[startoff];
2057*63258Sbostic 		nlwMiddle = (w - (32 - (startoff))) >> 5;
2058*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle - 1;
2059*63258Sbostic 		if (endoff) {
2060*63258Sbostic 			endmask = mfbendtab32[endoff];
2061*63258Sbostic 			while (h--) {
2062*63258Sbostic 				nlw = nlwMiddle;
2063*63258Sbostic 				*addr++ |= startmask;
2064*63258Sbostic 				Duff_single(nlw, addr, = ~0);
2065*63258Sbostic 				*addr |= endmask;
2066*63258Sbostic 				addr += nlwExtra;
2067*63258Sbostic 			}
2068*63258Sbostic 		} else {
2069*63258Sbostic 			while (h--) {
2070*63258Sbostic 				nlw = nlwMiddle;
2071*63258Sbostic 				*addr++ |= startmask;
2072*63258Sbostic 				Duff_single(nlw, addr, = ~0);
2073*63258Sbostic 				addr += nlwExtra;
2074*63258Sbostic 			}
2075*63258Sbostic 		}
2076*63258Sbostic 	} else {
2077*63258Sbostic 		nlwMiddle = w >> 5;
2078*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle;
2079*63258Sbostic 		if (endoff) {
2080*63258Sbostic 			endmask = mfbendtab32[endoff];
2081*63258Sbostic 			while (h--) {
2082*63258Sbostic 				nlw = nlwMiddle;
2083*63258Sbostic 				Duff_single(nlw, addr, = ~0);
2084*63258Sbostic 				*addr |= endmask;
2085*63258Sbostic 				addr += nlwExtra;
2086*63258Sbostic 			}
2087*63258Sbostic 		} else {
2088*63258Sbostic 			while (h--) {
2089*63258Sbostic 				nlw = nlwMiddle;
2090*63258Sbostic 				Duff_single(nlw, addr, = ~0);
2091*63258Sbostic 				addr += nlwExtra;
2092*63258Sbostic 			}
2093*63258Sbostic 		}
2094*63258Sbostic 	}
2095*63258Sbostic }
2096*63258Sbostic 
2097*63258Sbostic void
mfb_copy_area16(addrSrc,addrDst,widthSrc,widthDst,sr,dp)2098*63258Sbostic mfb_copy_area16(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
2099*63258Sbostic u_short	*addrSrc;
2100*63258Sbostic u_short	*addrDst;
2101*63258Sbostic u_int	widthSrc;
2102*63258Sbostic u_int	widthDst;
2103*63258Sbostic lRectangle	*sr;	/* source rectangle */
2104*63258Sbostic lPoint		*dp;	/* destination point */
2105*63258Sbostic {
2106*63258Sbostic 	register u_short *psrcLine, *psrc;
2107*63258Sbostic 	register u_short *pdstLine, *pdst;
2108*63258Sbostic 	int w, h;
2109*63258Sbostic 	int xdir, ydir;
2110*63258Sbostic 	u_short startmask, endmask;
2111*63258Sbostic 	register int nlMiddle;
2112*63258Sbostic 	int xoffSrc, xoffDst;
2113*63258Sbostic 	register int leftShift, rightShift;
2114*63258Sbostic 	u_short bits;
2115*63258Sbostic 	u_short bits1;
2116*63258Sbostic 	register int nl;
2117*63258Sbostic 
2118*63258Sbostic 	if (sr->origin.y < dp->y) {
2119*63258Sbostic 		ydir = -1;
2120*63258Sbostic 		widthSrc = -widthSrc;
2121*63258Sbostic 		widthDst = -widthDst;
2122*63258Sbostic 	} else {
2123*63258Sbostic 		ydir = 1;
2124*63258Sbostic 	}
2125*63258Sbostic 
2126*63258Sbostic 	if (sr->origin.x < dp->x) {
2127*63258Sbostic 		xdir = -1;
2128*63258Sbostic 	} else {
2129*63258Sbostic 		xdir = 1;
2130*63258Sbostic 	}
2131*63258Sbostic 
2132*63258Sbostic 	w = sr->extent.x;
2133*63258Sbostic 	h = sr->extent.y;
2134*63258Sbostic 
2135*63258Sbostic 	if (ydir == -1) {
2136*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
2137*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
2138*63258Sbostic 	} else {
2139*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
2140*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
2141*63258Sbostic 	}
2142*63258Sbostic 	if ((dp->x & 0xf) +w <= 16) {
2143*63258Sbostic 		startmask = mfbpartmasks16[dp->x & 0xf][w & 0xf];
2144*63258Sbostic 		endmask = 0;
2145*63258Sbostic 		nlMiddle = 0;
2146*63258Sbostic 	} else {
2147*63258Sbostic 		startmask = mfbstarttab16[dp->x & 0xf];
2148*63258Sbostic 		endmask = mfbendtab16[(dp->x + w) & 0xf];
2149*63258Sbostic 		if (startmask) {
2150*63258Sbostic 			nlMiddle = (w - (16 - (dp->x & 0xf))) >> 4;
2151*63258Sbostic 		} else {
2152*63258Sbostic 			nlMiddle = w >> 4;
2153*63258Sbostic 		}
2154*63258Sbostic 	}
2155*63258Sbostic 
2156*63258Sbostic 	if (xdir == 1) {
2157*63258Sbostic 		xoffSrc = sr->origin.x & 0xf;
2158*63258Sbostic 		xoffDst = dp->x & 0xf;
2159*63258Sbostic 		pdstLine += (dp->x >> 4);
2160*63258Sbostic 		psrcLine += (sr->origin.x >> 4);
2161*63258Sbostic 		if (xoffSrc == xoffDst) {
2162*63258Sbostic 			while (h--) {
2163*63258Sbostic 				psrc = psrcLine;
2164*63258Sbostic 				pdst = pdstLine;
2165*63258Sbostic 				psrcLine += widthSrc;
2166*63258Sbostic 				pdstLine += widthDst;
2167*63258Sbostic 				if (startmask) {
2168*63258Sbostic 					*pdst = (*pdst & ~startmask |
2169*63258Sbostic 						 *psrc & startmask);
2170*63258Sbostic 					psrc++;
2171*63258Sbostic 					pdst++;
2172*63258Sbostic 				}
2173*63258Sbostic 				nl = nlMiddle;
2174*63258Sbostic 				Duff_plus(nl, pdst, psrc, =);
2175*63258Sbostic 				if (endmask) {
2176*63258Sbostic 					*pdst = (*pdst & ~endmask |
2177*63258Sbostic 						 *psrc & endmask);
2178*63258Sbostic 				}
2179*63258Sbostic 			}
2180*63258Sbostic 		} else {
2181*63258Sbostic 			if (xoffSrc > xoffDst) {
2182*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2183*63258Sbostic 				rightShift = 16 - leftShift;
2184*63258Sbostic 			} else {
2185*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2186*63258Sbostic 				leftShift = 16 - rightShift;
2187*63258Sbostic 			}
2188*63258Sbostic 			while (h--) {
2189*63258Sbostic 				psrc = psrcLine;
2190*63258Sbostic 				pdst = pdstLine;
2191*63258Sbostic 				psrcLine += widthSrc;
2192*63258Sbostic 				pdstLine += widthDst;
2193*63258Sbostic 				bits = 0;
2194*63258Sbostic 				if (xoffSrc > xoffDst)
2195*63258Sbostic 					bits = *psrc++;
2196*63258Sbostic 				if (startmask) {
2197*63258Sbostic 					bits1 = bits << leftShift;
2198*63258Sbostic 					bits = *psrc++;
2199*63258Sbostic 					bits1 |= bits >> rightShift;
2200*63258Sbostic 					*pdst = (*pdst & ~startmask |
2201*63258Sbostic 						 bits1 & startmask);
2202*63258Sbostic 					pdst++;
2203*63258Sbostic 				}
2204*63258Sbostic 				nl = nlMiddle;
2205*63258Sbostic 				bits1 = bits;
2206*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, =);
2207*63258Sbostic 				if (endmask) {
2208*63258Sbostic 					bits1 = bits << leftShift;
2209*63258Sbostic 					if ((endmask << rightShift) & 0xffff) {
2210*63258Sbostic 						bits1 |= *psrc >> rightShift;
2211*63258Sbostic 					}
2212*63258Sbostic 					*pdst = (*pdst & ~endmask |
2213*63258Sbostic 						 bits1 & endmask);
2214*63258Sbostic 				}
2215*63258Sbostic 			}
2216*63258Sbostic 		}
2217*63258Sbostic 	} else {
2218*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0xf;
2219*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0xf;
2220*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 4) + 1;
2221*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 4) + 1;
2222*63258Sbostic 		if (xoffSrc == xoffDst) {
2223*63258Sbostic 			while (h--) {
2224*63258Sbostic 				psrc = psrcLine;
2225*63258Sbostic 				pdst = pdstLine;
2226*63258Sbostic 				psrcLine += widthSrc;
2227*63258Sbostic 				pdstLine += widthDst;
2228*63258Sbostic 				if (endmask) {
2229*63258Sbostic 					pdst--;
2230*63258Sbostic 					psrc--;
2231*63258Sbostic 					*pdst = (*pdst & ~endmask |
2232*63258Sbostic 						 *psrc & endmask);
2233*63258Sbostic 				}
2234*63258Sbostic 				nl = nlMiddle;
2235*63258Sbostic 				Duff_minus(nl, pdst, psrc, =);
2236*63258Sbostic 				if (startmask) {
2237*63258Sbostic 					--pdst;
2238*63258Sbostic 					--psrc;
2239*63258Sbostic 					*pdst = (*pdst & ~startmask |
2240*63258Sbostic 						 *psrc & startmask);
2241*63258Sbostic 				}
2242*63258Sbostic 			}
2243*63258Sbostic 		} else {
2244*63258Sbostic 			if (xoffDst > xoffSrc) {
2245*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2246*63258Sbostic 				leftShift = 16 - rightShift;
2247*63258Sbostic 			} else {
2248*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2249*63258Sbostic 				rightShift = 16 - leftShift;
2250*63258Sbostic 			}
2251*63258Sbostic 			while (h--) {
2252*63258Sbostic 				psrc = psrcLine;
2253*63258Sbostic 				pdst = pdstLine;
2254*63258Sbostic 				psrcLine += widthSrc;
2255*63258Sbostic 				pdstLine += widthDst;
2256*63258Sbostic 				bits = 0;
2257*63258Sbostic 				if (xoffDst > xoffSrc)
2258*63258Sbostic 					bits = *--psrc;
2259*63258Sbostic 				if (endmask) {
2260*63258Sbostic 					bits1 = bits >> rightShift;
2261*63258Sbostic 					bits = *--psrc;
2262*63258Sbostic 					bits1 |= (bits << leftShift);
2263*63258Sbostic 					pdst--;
2264*63258Sbostic 					*pdst = (*pdst & ~endmask |
2265*63258Sbostic 						 bits1 & endmask);
2266*63258Sbostic 				}
2267*63258Sbostic 				nl = nlMiddle;
2268*63258Sbostic 				bits1 = bits;
2269*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, =);
2270*63258Sbostic 				if (startmask) {
2271*63258Sbostic 					bits1 = (bits >> rightShift);
2272*63258Sbostic 					if (startmask >> leftShift) {
2273*63258Sbostic 						bits1 |= *--psrc << leftShift;
2274*63258Sbostic 					}
2275*63258Sbostic 					--pdst;
2276*63258Sbostic 					*pdst = (*pdst & ~startmask |
2277*63258Sbostic 						 bits1 & startmask);
2278*63258Sbostic 				}
2279*63258Sbostic 			}
2280*63258Sbostic 		}
2281*63258Sbostic 	}
2282*63258Sbostic }
2283*63258Sbostic 
2284*63258Sbostic void
mfb_copyinv_area16(addrSrc,addrDst,widthSrc,widthDst,sr,dp)2285*63258Sbostic mfb_copyinv_area16(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
2286*63258Sbostic u_short	*addrSrc;
2287*63258Sbostic u_short	*addrDst;
2288*63258Sbostic register int	widthSrc;
2289*63258Sbostic register int	widthDst;
2290*63258Sbostic lRectangle	*sr;	/* source rectangle */
2291*63258Sbostic lPoint		*dp;	/* destination point */
2292*63258Sbostic {
2293*63258Sbostic 	register u_short *psrcLine, *psrc;
2294*63258Sbostic 	register u_short *pdstLine, *pdst;
2295*63258Sbostic 	int w, h;
2296*63258Sbostic 	int xdir, ydir;
2297*63258Sbostic 	u_short startmask, endmask;
2298*63258Sbostic 	register int nlMiddle;
2299*63258Sbostic 	int xoffSrc, xoffDst;
2300*63258Sbostic 	register int leftShift, rightShift;
2301*63258Sbostic 	u_short bits;
2302*63258Sbostic 	u_short bits1;
2303*63258Sbostic 	register int nl;
2304*63258Sbostic 
2305*63258Sbostic 	if (sr->origin.y < dp->y) {
2306*63258Sbostic 		ydir = -1;
2307*63258Sbostic 		widthSrc = -widthSrc;
2308*63258Sbostic 		widthDst = -widthDst;
2309*63258Sbostic 	} else {
2310*63258Sbostic 		ydir = 1;
2311*63258Sbostic 	}
2312*63258Sbostic 
2313*63258Sbostic 	if (sr->origin.x < dp->x) {
2314*63258Sbostic 		xdir = -1;
2315*63258Sbostic 	} else {
2316*63258Sbostic 		xdir = 1;
2317*63258Sbostic 	}
2318*63258Sbostic 
2319*63258Sbostic 	w = sr->extent.x;
2320*63258Sbostic 	h = sr->extent.y;
2321*63258Sbostic 
2322*63258Sbostic 	if (ydir == -1) {
2323*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
2324*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
2325*63258Sbostic 	} else {
2326*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
2327*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
2328*63258Sbostic 	}
2329*63258Sbostic 	if ((dp->x & 0xf) +w <= 16) {
2330*63258Sbostic 		startmask = mfbpartmasks16[dp->x & 0xf][w & 0xf];
2331*63258Sbostic 		endmask = 0;
2332*63258Sbostic 		nlMiddle = 0;
2333*63258Sbostic 	} else {
2334*63258Sbostic 		startmask = mfbstarttab16[dp->x & 0xf];
2335*63258Sbostic 		endmask = mfbendtab16[(dp->x + w) & 0xf];
2336*63258Sbostic 		if (startmask) {
2337*63258Sbostic 			nlMiddle = (w - (16 - (dp->x & 0xf))) >> 4;
2338*63258Sbostic 		} else {
2339*63258Sbostic 			nlMiddle = w >> 4;
2340*63258Sbostic 		}
2341*63258Sbostic 	}
2342*63258Sbostic 
2343*63258Sbostic 	if (xdir == 1) {
2344*63258Sbostic 		xoffSrc = sr->origin.x & 0xf;
2345*63258Sbostic 		xoffDst = dp->x & 0xf;
2346*63258Sbostic 		psrcLine += (sr->origin.x >> 4);
2347*63258Sbostic 		pdstLine += (dp->x >> 4);
2348*63258Sbostic 		if (xoffSrc == xoffDst) {
2349*63258Sbostic 			while (h--) {
2350*63258Sbostic 				psrc = psrcLine;
2351*63258Sbostic 				pdst = pdstLine;
2352*63258Sbostic 				psrcLine += widthSrc;
2353*63258Sbostic 				pdstLine += widthDst;
2354*63258Sbostic 				if (startmask) {
2355*63258Sbostic 					*pdst = (*pdst & ~startmask |
2356*63258Sbostic 						 ~*psrc & startmask);
2357*63258Sbostic 					psrc++;
2358*63258Sbostic 					pdst++;
2359*63258Sbostic 				}
2360*63258Sbostic 				nl = nlMiddle;
2361*63258Sbostic 				Duff_plus(nl, pdst, psrc, = ~);
2362*63258Sbostic 				if (endmask) {
2363*63258Sbostic 					*pdst = (*pdst & ~endmask |
2364*63258Sbostic 						 ~*psrc & endmask);
2365*63258Sbostic 				}
2366*63258Sbostic 			}
2367*63258Sbostic 		} else {
2368*63258Sbostic 			if (xoffSrc > xoffDst) {
2369*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2370*63258Sbostic 				rightShift = 16 - leftShift;
2371*63258Sbostic 			} else {
2372*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2373*63258Sbostic 				leftShift = 16 - rightShift;
2374*63258Sbostic 			}
2375*63258Sbostic 			while (h--) {
2376*63258Sbostic 				psrc = psrcLine;
2377*63258Sbostic 				pdst = pdstLine;
2378*63258Sbostic 				psrcLine += widthSrc;
2379*63258Sbostic 				pdstLine += widthDst;
2380*63258Sbostic 				bits = 0;
2381*63258Sbostic 				if (xoffSrc > xoffDst)
2382*63258Sbostic 					bits = *psrc++;
2383*63258Sbostic 				if (startmask) {
2384*63258Sbostic 					bits1 = bits << leftShift;
2385*63258Sbostic 					bits = *psrc++;
2386*63258Sbostic 					bits1 |= bits >> rightShift;
2387*63258Sbostic 					*pdst = (*pdst & ~startmask |
2388*63258Sbostic 						 ~bits1 & startmask);
2389*63258Sbostic 					pdst++;
2390*63258Sbostic 				}
2391*63258Sbostic 				nl = nlMiddle;
2392*63258Sbostic 				bits1 = bits;
2393*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, = ~);
2394*63258Sbostic 				if (endmask) {
2395*63258Sbostic 					bits1 = bits << leftShift;
2396*63258Sbostic 					if ((endmask << rightShift) & 0xffff) {
2397*63258Sbostic 						bits1 |= *psrc >> rightShift;
2398*63258Sbostic 					}
2399*63258Sbostic 					*pdst = (*pdst & ~endmask |
2400*63258Sbostic 						 ~bits1 & endmask);
2401*63258Sbostic 				}
2402*63258Sbostic 			}
2403*63258Sbostic 		}
2404*63258Sbostic 	} else {
2405*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0xf;
2406*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0xf;
2407*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 4) + 1;
2408*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 4) + 1;
2409*63258Sbostic 		if (xoffSrc == xoffDst) {
2410*63258Sbostic 			while (h--) {
2411*63258Sbostic 				psrc = psrcLine;
2412*63258Sbostic 				pdst = pdstLine;
2413*63258Sbostic 				psrcLine += widthSrc;
2414*63258Sbostic 				pdstLine += widthDst;
2415*63258Sbostic 				if (endmask) {
2416*63258Sbostic 					pdst--;
2417*63258Sbostic 					psrc--;
2418*63258Sbostic 					*pdst = (*pdst & ~endmask |
2419*63258Sbostic 						 ~*psrc & endmask);
2420*63258Sbostic 				}
2421*63258Sbostic 				nl = nlMiddle;
2422*63258Sbostic 				Duff_minus(nl, pdst, psrc, = ~);
2423*63258Sbostic 				if (startmask) {
2424*63258Sbostic 					--pdst;
2425*63258Sbostic 					--psrc;
2426*63258Sbostic 					*pdst = (*pdst & ~startmask |
2427*63258Sbostic 						 ~*psrc & startmask);
2428*63258Sbostic 				}
2429*63258Sbostic 			}
2430*63258Sbostic 		} else {
2431*63258Sbostic 			if (xoffDst > xoffSrc) {
2432*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2433*63258Sbostic 				leftShift = 16 - rightShift;
2434*63258Sbostic 			} else {
2435*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2436*63258Sbostic 				rightShift = 16 - leftShift;
2437*63258Sbostic 			}
2438*63258Sbostic 			while (h--) {
2439*63258Sbostic 				psrc = psrcLine;
2440*63258Sbostic 				pdst = pdstLine;
2441*63258Sbostic 				psrcLine += widthSrc;
2442*63258Sbostic 				pdstLine += widthDst;
2443*63258Sbostic 				bits = 0;
2444*63258Sbostic 				if (xoffDst > xoffSrc)
2445*63258Sbostic 					bits = *--psrc;
2446*63258Sbostic 				if (endmask) {
2447*63258Sbostic 					bits1 = bits >> rightShift;
2448*63258Sbostic 					bits = *--psrc;
2449*63258Sbostic 					bits1 |= (bits << leftShift);
2450*63258Sbostic 					pdst--;
2451*63258Sbostic 					*pdst = (*pdst & ~endmask |
2452*63258Sbostic 						 ~bits1 & endmask);
2453*63258Sbostic 				}
2454*63258Sbostic 				nl = nlMiddle;
2455*63258Sbostic 				bits1 = bits;
2456*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, = ~);
2457*63258Sbostic 				if (startmask) {
2458*63258Sbostic 					bits1 = (bits >> rightShift);
2459*63258Sbostic 					if (startmask >> leftShift) {
2460*63258Sbostic 						bits1 |= *--psrc << leftShift;
2461*63258Sbostic 					}
2462*63258Sbostic 					--pdst;
2463*63258Sbostic 					*pdst = (*pdst & ~startmask |
2464*63258Sbostic 						 ~bits1 & startmask);
2465*63258Sbostic 				}
2466*63258Sbostic 			}
2467*63258Sbostic 		}
2468*63258Sbostic 	}
2469*63258Sbostic }
2470*63258Sbostic 
2471*63258Sbostic void
mfb_or_area16(addrSrc,addrDst,widthSrc,widthDst,sr,dp)2472*63258Sbostic mfb_or_area16(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
2473*63258Sbostic u_short	*addrSrc;
2474*63258Sbostic u_short	*addrDst;
2475*63258Sbostic register int	widthSrc;
2476*63258Sbostic register int	widthDst;
2477*63258Sbostic lRectangle	*sr;	/* source rectangle */
2478*63258Sbostic lPoint		*dp;	/* destination point */
2479*63258Sbostic {
2480*63258Sbostic 	register u_short *psrcLine, *psrc;
2481*63258Sbostic 	register u_short *pdstLine, *pdst;
2482*63258Sbostic 	int w, h;
2483*63258Sbostic 	int xdir, ydir;
2484*63258Sbostic 	u_short startmask, endmask;
2485*63258Sbostic 	register int nlMiddle;
2486*63258Sbostic 	int xoffSrc, xoffDst;
2487*63258Sbostic 	register int leftShift, rightShift;
2488*63258Sbostic 	u_short bits;
2489*63258Sbostic 	u_short bits1;
2490*63258Sbostic 	register int nl;
2491*63258Sbostic 
2492*63258Sbostic 	if (sr->origin.y < dp->y) {
2493*63258Sbostic 		ydir = -1;
2494*63258Sbostic 		widthSrc = -widthSrc;
2495*63258Sbostic 		widthDst = -widthDst;
2496*63258Sbostic 	} else {
2497*63258Sbostic 		ydir = 1;
2498*63258Sbostic 	}
2499*63258Sbostic 
2500*63258Sbostic 	if (sr->origin.x < dp->x) {
2501*63258Sbostic 		xdir = -1;
2502*63258Sbostic 	} else {
2503*63258Sbostic 		xdir = 1;
2504*63258Sbostic 	}
2505*63258Sbostic 
2506*63258Sbostic 	w = sr->extent.x;
2507*63258Sbostic 	h = sr->extent.y;
2508*63258Sbostic 
2509*63258Sbostic 	if (ydir == -1) {
2510*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
2511*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
2512*63258Sbostic 	} else {
2513*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
2514*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
2515*63258Sbostic 	}
2516*63258Sbostic 	if ((dp->x & 0xf) +w <= 16) {
2517*63258Sbostic 		startmask = mfbpartmasks16[dp->x & 0xf][w & 0xf];
2518*63258Sbostic 		endmask = 0;
2519*63258Sbostic 		nlMiddle = 0;
2520*63258Sbostic 	} else {
2521*63258Sbostic 		startmask = mfbstarttab16[dp->x & 0xf];
2522*63258Sbostic 		endmask = mfbendtab16[(dp->x + w) & 0xf];
2523*63258Sbostic 		if (startmask) {
2524*63258Sbostic 			nlMiddle = (w - (16 - (dp->x & 0xf))) >> 4;
2525*63258Sbostic 		} else {
2526*63258Sbostic 			nlMiddle = w >> 4;
2527*63258Sbostic 		}
2528*63258Sbostic 	}
2529*63258Sbostic 
2530*63258Sbostic 	if (xdir == 1) {
2531*63258Sbostic 		xoffSrc = sr->origin.x & 0xf;
2532*63258Sbostic 		xoffDst = dp->x & 0xf;
2533*63258Sbostic 		pdstLine += (dp->x >> 4);
2534*63258Sbostic 		psrcLine += (sr->origin.x >> 4);
2535*63258Sbostic 		if (xoffSrc == xoffDst) {
2536*63258Sbostic 			while (h--) {
2537*63258Sbostic 				psrc = psrcLine;
2538*63258Sbostic 				pdst = pdstLine;
2539*63258Sbostic 				psrcLine += widthSrc;
2540*63258Sbostic 				pdstLine += widthDst;
2541*63258Sbostic 				if (startmask) {
2542*63258Sbostic 					*pdst++ |= *psrc++ & startmask;
2543*63258Sbostic 				}
2544*63258Sbostic 				nl = nlMiddle;
2545*63258Sbostic 				Duff_plus(nl, pdst, psrc, |=);
2546*63258Sbostic 				if (endmask) {
2547*63258Sbostic 					*pdst |= *psrc & endmask;
2548*63258Sbostic 				}
2549*63258Sbostic 			}
2550*63258Sbostic 		} else {
2551*63258Sbostic 			if (xoffSrc > xoffDst) {
2552*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2553*63258Sbostic 				rightShift = 16 - leftShift;
2554*63258Sbostic 			} else {
2555*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2556*63258Sbostic 				leftShift = 16 - rightShift;
2557*63258Sbostic 			}
2558*63258Sbostic 			while (h--) {
2559*63258Sbostic 				psrc = psrcLine;
2560*63258Sbostic 				pdst = pdstLine;
2561*63258Sbostic 				psrcLine += widthSrc;
2562*63258Sbostic 				pdstLine += widthDst;
2563*63258Sbostic 				bits = 0;
2564*63258Sbostic 				if (xoffSrc > xoffDst)
2565*63258Sbostic 					bits = *psrc++;
2566*63258Sbostic 				if (startmask) {
2567*63258Sbostic 					bits1 = bits << leftShift;
2568*63258Sbostic 					bits = *psrc++;
2569*63258Sbostic 					bits1 |= bits >> rightShift;
2570*63258Sbostic 					*pdst++ |= bits1 & startmask;
2571*63258Sbostic 				}
2572*63258Sbostic 				nl = nlMiddle;
2573*63258Sbostic 				bits1 = bits;
2574*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, |=);
2575*63258Sbostic 				if (endmask) {
2576*63258Sbostic 					bits1 = bits << leftShift;
2577*63258Sbostic 					if ((endmask << rightShift) & 0xffff) {
2578*63258Sbostic 						bits1 |= *psrc >> rightShift;
2579*63258Sbostic 					}
2580*63258Sbostic 					*pdst |= bits1 & endmask;
2581*63258Sbostic 				}
2582*63258Sbostic 			}
2583*63258Sbostic 		}
2584*63258Sbostic 	} else {
2585*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0xf;
2586*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0xf;
2587*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 4) + 1;
2588*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 4) + 1;
2589*63258Sbostic 		if (xoffSrc == xoffDst) {
2590*63258Sbostic 			while (h--) {
2591*63258Sbostic 				psrc = psrcLine;
2592*63258Sbostic 				pdst = pdstLine;
2593*63258Sbostic 				psrcLine += widthSrc;
2594*63258Sbostic 				pdstLine += widthDst;
2595*63258Sbostic 				if (endmask) {
2596*63258Sbostic 					*--pdst |= *--psrc & endmask;
2597*63258Sbostic 				}
2598*63258Sbostic 				nl = nlMiddle;
2599*63258Sbostic 				Duff_minus(nl, pdst, psrc, |=);
2600*63258Sbostic 				if (startmask) {
2601*63258Sbostic 					*--pdst |= *--psrc & startmask;
2602*63258Sbostic 				}
2603*63258Sbostic 			}
2604*63258Sbostic 		} else {
2605*63258Sbostic 			if (xoffDst > xoffSrc) {
2606*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2607*63258Sbostic 				leftShift = 16 - rightShift;
2608*63258Sbostic 			} else {
2609*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2610*63258Sbostic 				rightShift = 16 - leftShift;
2611*63258Sbostic 			}
2612*63258Sbostic 			while (h--) {
2613*63258Sbostic 				psrc = psrcLine;
2614*63258Sbostic 				pdst = pdstLine;
2615*63258Sbostic 				psrcLine += widthSrc;
2616*63258Sbostic 				pdstLine += widthDst;
2617*63258Sbostic 				bits = 0;
2618*63258Sbostic 				if (xoffDst > xoffSrc)
2619*63258Sbostic 					bits = *--psrc;
2620*63258Sbostic 				if (endmask) {
2621*63258Sbostic 					bits1 = bits >> rightShift;
2622*63258Sbostic 					bits = *--psrc;
2623*63258Sbostic 					bits1 |= (bits << leftShift);
2624*63258Sbostic 					*--pdst |= bits1 & endmask;
2625*63258Sbostic 				}
2626*63258Sbostic 				nl = nlMiddle;
2627*63258Sbostic 				bits1 = bits;
2628*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, |=);
2629*63258Sbostic 				if (startmask) {
2630*63258Sbostic 					bits1 = (bits >> rightShift);
2631*63258Sbostic 					if (startmask >> leftShift) {
2632*63258Sbostic 						bits1 |= *--psrc << leftShift;
2633*63258Sbostic 					}
2634*63258Sbostic 					*--pdst |= bits1 & startmask;
2635*63258Sbostic 				}
2636*63258Sbostic 			}
2637*63258Sbostic 		}
2638*63258Sbostic 	}
2639*63258Sbostic }
2640*63258Sbostic 
2641*63258Sbostic void
mfb_xor_area16(addrSrc,addrDst,widthSrc,widthDst,sr,dp)2642*63258Sbostic mfb_xor_area16(addrSrc, addrDst, widthSrc, widthDst, sr, dp)
2643*63258Sbostic u_short	*addrSrc;
2644*63258Sbostic u_short	*addrDst;
2645*63258Sbostic int	widthSrc;
2646*63258Sbostic int	widthDst;
2647*63258Sbostic lRectangle	*sr;	/* source rectangle */
2648*63258Sbostic lPoint		*dp;	/* destination point */
2649*63258Sbostic {
2650*63258Sbostic 	register u_short *psrcLine, *psrc;
2651*63258Sbostic 	register u_short *pdstLine, *pdst;
2652*63258Sbostic 	int w, h;
2653*63258Sbostic 	int xdir, ydir;
2654*63258Sbostic 	u_short startmask, endmask;
2655*63258Sbostic 	register int nlMiddle;
2656*63258Sbostic 	int xoffSrc, xoffDst;
2657*63258Sbostic 	register int leftShift, rightShift;
2658*63258Sbostic 	u_short bits;
2659*63258Sbostic 	u_short bits1;
2660*63258Sbostic 	register int nl;
2661*63258Sbostic 
2662*63258Sbostic 	if (sr->origin.y < dp->y) {
2663*63258Sbostic 		ydir = -1;
2664*63258Sbostic 		widthSrc = -widthSrc;
2665*63258Sbostic 		widthDst = -widthDst;
2666*63258Sbostic 	} else {
2667*63258Sbostic 		ydir = 1;
2668*63258Sbostic 	}
2669*63258Sbostic 
2670*63258Sbostic 	if (sr->origin.x < dp->x) {
2671*63258Sbostic 		xdir = -1;
2672*63258Sbostic 	} else {
2673*63258Sbostic 		xdir = 1;
2674*63258Sbostic 	}
2675*63258Sbostic 
2676*63258Sbostic 	w = sr->extent.x;
2677*63258Sbostic 	h = sr->extent.y;
2678*63258Sbostic 
2679*63258Sbostic 	if (ydir == -1) {
2680*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
2681*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
2682*63258Sbostic 	} else {
2683*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
2684*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
2685*63258Sbostic 	}
2686*63258Sbostic 	if ((dp->x & 0xf) +w <= 16) {
2687*63258Sbostic 		startmask = mfbpartmasks16[dp->x & 0xf][w & 0xf];
2688*63258Sbostic 		endmask = 0;
2689*63258Sbostic 		nlMiddle = 0;
2690*63258Sbostic 	} else {
2691*63258Sbostic 		startmask = mfbstarttab16[dp->x & 0xf];
2692*63258Sbostic 		endmask = mfbendtab16[(dp->x + w) & 0xf];
2693*63258Sbostic 		if (startmask) {
2694*63258Sbostic 			nlMiddle = (w - (16 - (dp->x & 0xf))) >> 4;
2695*63258Sbostic 		} else {
2696*63258Sbostic 			nlMiddle = w >> 4;
2697*63258Sbostic 		}
2698*63258Sbostic 	}
2699*63258Sbostic 
2700*63258Sbostic 	if (xdir == 1) {
2701*63258Sbostic 		xoffSrc = sr->origin.x & 0xf;
2702*63258Sbostic 		xoffDst = dp->x & 0xf;
2703*63258Sbostic 		pdstLine += (dp->x >> 4);
2704*63258Sbostic 		psrcLine += (sr->origin.x >> 4);
2705*63258Sbostic 		if (xoffSrc == xoffDst) {
2706*63258Sbostic 			while (h--) {
2707*63258Sbostic 				psrc = psrcLine;
2708*63258Sbostic 				pdst = pdstLine;
2709*63258Sbostic 				psrcLine += widthSrc;
2710*63258Sbostic 				pdstLine += widthDst;
2711*63258Sbostic 				if (startmask) {
2712*63258Sbostic 					*pdst++ ^= *psrc++ & startmask;
2713*63258Sbostic 				}
2714*63258Sbostic 				nl = nlMiddle;
2715*63258Sbostic 				Duff_plus(nl, pdst, psrc, ^=);
2716*63258Sbostic 				if (endmask) {
2717*63258Sbostic 					*pdst ^= *psrc & endmask;
2718*63258Sbostic 				}
2719*63258Sbostic 			}
2720*63258Sbostic 		} else {
2721*63258Sbostic 			if (xoffSrc > xoffDst) {
2722*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2723*63258Sbostic 				rightShift = 16 - leftShift;
2724*63258Sbostic 			} else {
2725*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2726*63258Sbostic 				leftShift = 16 - rightShift;
2727*63258Sbostic 			}
2728*63258Sbostic 			while (h--) {
2729*63258Sbostic 				psrc = psrcLine;
2730*63258Sbostic 				pdst = pdstLine;
2731*63258Sbostic 				psrcLine += widthSrc;
2732*63258Sbostic 				pdstLine += widthDst;
2733*63258Sbostic 				bits = 0;
2734*63258Sbostic 				if (xoffSrc > xoffDst)
2735*63258Sbostic 					bits = *psrc++;
2736*63258Sbostic 				if (startmask) {
2737*63258Sbostic 					bits1 = bits << leftShift;
2738*63258Sbostic 					bits = *psrc++;
2739*63258Sbostic 					bits1 |= bits >> rightShift;
2740*63258Sbostic 					*pdst++ ^= bits1 & startmask;
2741*63258Sbostic 				}
2742*63258Sbostic 				nl = nlMiddle;
2743*63258Sbostic 				bits1 = bits;
2744*63258Sbostic 				Duff_shift_plus(nl, pdst, psrc, ^=);
2745*63258Sbostic 				if (endmask) {
2746*63258Sbostic 					bits1 = bits << leftShift;
2747*63258Sbostic 					if ((endmask << rightShift) & 0xffff) {
2748*63258Sbostic 						bits1 |= (*psrc >> rightShift);
2749*63258Sbostic 					}
2750*63258Sbostic 					*pdst ^= bits1 & endmask;
2751*63258Sbostic 				}
2752*63258Sbostic 			}
2753*63258Sbostic 		}
2754*63258Sbostic 	} else {
2755*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0xf;
2756*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0xf;
2757*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 4) + 1;
2758*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 4) + 1;
2759*63258Sbostic 		if (xoffSrc == xoffDst) {
2760*63258Sbostic 			while (h--) {
2761*63258Sbostic 				psrc = psrcLine;
2762*63258Sbostic 				pdst = pdstLine;
2763*63258Sbostic 				psrcLine += widthSrc;
2764*63258Sbostic 				pdstLine += widthDst;
2765*63258Sbostic 				if (endmask) {
2766*63258Sbostic 					*--pdst ^= *--psrc & endmask;
2767*63258Sbostic 				}
2768*63258Sbostic 				nl = nlMiddle;
2769*63258Sbostic 				Duff_minus(nl, pdst, psrc, ^=);
2770*63258Sbostic 				if (startmask) {
2771*63258Sbostic 					*--pdst ^= *--psrc & startmask;
2772*63258Sbostic 				}
2773*63258Sbostic 			}
2774*63258Sbostic 		} else {
2775*63258Sbostic 			if (xoffDst > xoffSrc) {
2776*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2777*63258Sbostic 				leftShift = 16 - rightShift;
2778*63258Sbostic 			} else {
2779*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2780*63258Sbostic 				rightShift = 16 - leftShift;
2781*63258Sbostic 			}
2782*63258Sbostic 			while (h--) {
2783*63258Sbostic 				psrc = psrcLine;
2784*63258Sbostic 				pdst = pdstLine;
2785*63258Sbostic 				psrcLine += widthSrc;
2786*63258Sbostic 				pdstLine += widthDst;
2787*63258Sbostic 				bits = 0;
2788*63258Sbostic 				if (xoffDst > xoffSrc)
2789*63258Sbostic 					bits = *--psrc;
2790*63258Sbostic 				if (endmask) {
2791*63258Sbostic 					bits1 = bits >> rightShift;
2792*63258Sbostic 					bits = *--psrc;
2793*63258Sbostic 					bits1 |= (bits << leftShift);
2794*63258Sbostic 					*--pdst ^= bits1 & endmask;
2795*63258Sbostic 				}
2796*63258Sbostic 				nl = nlMiddle;
2797*63258Sbostic 				bits1 = bits;
2798*63258Sbostic 				Duff_shift_minus(nl, pdst, psrc, ^=);
2799*63258Sbostic 				if (startmask) {
2800*63258Sbostic 					bits1 = (bits >> rightShift);
2801*63258Sbostic 					if (startmask >> leftShift) {
2802*63258Sbostic 						bits1 |= (*--psrc << leftShift);
2803*63258Sbostic 					}
2804*63258Sbostic 					*--pdst ^= bits1 & startmask;
2805*63258Sbostic 				}
2806*63258Sbostic 			}
2807*63258Sbostic 		}
2808*63258Sbostic 	}
2809*63258Sbostic }
2810*63258Sbostic 
2811*63258Sbostic void
mfb_general_area16(func,addrSrc,addrDst,widthSrc,widthDst,sr,dp)2812*63258Sbostic mfb_general_area16(func, addrSrc, addrDst, widthSrc, widthDst, sr, dp)
2813*63258Sbostic int		func;
2814*63258Sbostic u_short	*addrSrc;
2815*63258Sbostic u_short	*addrDst;
2816*63258Sbostic int	widthSrc;
2817*63258Sbostic int	widthDst;
2818*63258Sbostic lRectangle	*sr;	/* source rectangle */
2819*63258Sbostic lPoint		*dp;	/* destination point */
2820*63258Sbostic {
2821*63258Sbostic 	register u_short *psrcLine, *psrc;
2822*63258Sbostic 	register u_short *pdstLine, *pdst;
2823*63258Sbostic 	register int leftShift, rightShift;
2824*63258Sbostic 	u_short bits;
2825*63258Sbostic 	u_short bits1;
2826*63258Sbostic 	register int nl;
2827*63258Sbostic 	u_short _ca1, _cx1, _ca2, _cx2;
2828*63258Sbostic 	u_short startmask, endmask;
2829*63258Sbostic 	int w, h;
2830*63258Sbostic 	int xdir, ydir;
2831*63258Sbostic 	register int nlMiddle;
2832*63258Sbostic 	int xoffSrc, xoffDst;
2833*63258Sbostic 
2834*63258Sbostic 	_ca1 = mergeRopBits[func].ca1;
2835*63258Sbostic 	_cx1 = mergeRopBits[func].cx1;
2836*63258Sbostic 	_ca2 = mergeRopBits[func].ca2;
2837*63258Sbostic 	_cx2 = mergeRopBits[func].cx2;
2838*63258Sbostic 
2839*63258Sbostic 	if (sr->origin.y < dp->y) {
2840*63258Sbostic 		ydir = -1;
2841*63258Sbostic 		widthSrc = -widthSrc;
2842*63258Sbostic 		widthDst = -widthDst;
2843*63258Sbostic 	} else {
2844*63258Sbostic 		ydir = 1;
2845*63258Sbostic 	}
2846*63258Sbostic 
2847*63258Sbostic 	if (sr->origin.x < dp->x) {
2848*63258Sbostic 		xdir = -1;
2849*63258Sbostic 	} else {
2850*63258Sbostic 		xdir = 1;
2851*63258Sbostic 	}
2852*63258Sbostic 
2853*63258Sbostic 	w = sr->extent.x;
2854*63258Sbostic 	h = sr->extent.y;
2855*63258Sbostic 
2856*63258Sbostic 	if (ydir == -1) {
2857*63258Sbostic 		psrcLine = addrSrc + ((sr->origin.y + h - 1) * -widthSrc);
2858*63258Sbostic 		pdstLine = addrDst + ((dp->y + h - 1) * -widthDst);
2859*63258Sbostic 	} else {
2860*63258Sbostic 		psrcLine = addrSrc + (sr->origin.y * widthSrc);
2861*63258Sbostic 		pdstLine = addrDst + (dp->y * widthDst);
2862*63258Sbostic 	}
2863*63258Sbostic 	if ((dp->x & 0xf) +w <= 16) {
2864*63258Sbostic 		startmask = mfbpartmasks16[dp->x & 0xf][w & 0xf];
2865*63258Sbostic 		endmask = 0;
2866*63258Sbostic 		nlMiddle = 0;
2867*63258Sbostic 	} else {
2868*63258Sbostic 		startmask = mfbstarttab16[dp->x & 0xf];
2869*63258Sbostic 		endmask = mfbendtab16[(dp->x + w) & 0xf];
2870*63258Sbostic 		if (startmask) {
2871*63258Sbostic 			nlMiddle = (w - (16 - (dp->x & 0xf))) >> 4;
2872*63258Sbostic 		} else {
2873*63258Sbostic 			nlMiddle = w >> 4;
2874*63258Sbostic 		}
2875*63258Sbostic 	}
2876*63258Sbostic 
2877*63258Sbostic 	if (xdir == 1) {
2878*63258Sbostic 		xoffSrc = sr->origin.x & 0xf;
2879*63258Sbostic 		xoffDst = dp->x & 0xf;
2880*63258Sbostic 		pdstLine += (dp->x >> 4);
2881*63258Sbostic 		psrcLine += (sr->origin.x >> 4);
2882*63258Sbostic 		if (xoffSrc == xoffDst) {
2883*63258Sbostic 			while (h--) {
2884*63258Sbostic 				psrc = psrcLine;
2885*63258Sbostic 				pdst = pdstLine;
2886*63258Sbostic 				psrcLine += widthSrc;
2887*63258Sbostic 				pdstLine += widthDst;
2888*63258Sbostic 				if (startmask) {
2889*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
2890*63258Sbostic 							       startmask);
2891*63258Sbostic 					psrc++;
2892*63258Sbostic 					pdst++;
2893*63258Sbostic 				}
2894*63258Sbostic 				nl = nlMiddle;
2895*63258Sbostic 				psrc += nl & 7;
2896*63258Sbostic 				pdst += nl & 7;
2897*63258Sbostic 				switch (nl & 7) {
2898*63258Sbostic 				case 7:
2899*63258Sbostic 					pdst[-7] = DoMergeRop(psrc[-7], pdst[-7]);
2900*63258Sbostic 				case 6:
2901*63258Sbostic 					pdst[-6] = DoMergeRop(psrc[-6], pdst[-6]);
2902*63258Sbostic 				case 5:
2903*63258Sbostic 					pdst[-5] = DoMergeRop(psrc[-5], pdst[-5]);
2904*63258Sbostic 				case 4:
2905*63258Sbostic 					pdst[-4] = DoMergeRop(psrc[-4], pdst[-4]);
2906*63258Sbostic 				case 3:
2907*63258Sbostic 					pdst[-3] = DoMergeRop(psrc[-3], pdst[-3]);
2908*63258Sbostic 				case 2:
2909*63258Sbostic 					pdst[-2] = DoMergeRop(psrc[-2], pdst[-2]);
2910*63258Sbostic 				case 1:
2911*63258Sbostic 					pdst[-1] = DoMergeRop(psrc[-1], pdst[-1]);
2912*63258Sbostic 				}
2913*63258Sbostic 				while ((nl -= 8) >= 0) {
2914*63258Sbostic 					pdst += 8;
2915*63258Sbostic 					psrc += 8;
2916*63258Sbostic 					pdst[-8] = DoMergeRop(psrc[-8], pdst[-8]);
2917*63258Sbostic 					pdst[-7] = DoMergeRop(psrc[-7], pdst[-7]);
2918*63258Sbostic 					pdst[-6] = DoMergeRop(psrc[-6], pdst[-6]);
2919*63258Sbostic 					pdst[-5] = DoMergeRop(psrc[-5], pdst[-5]);
2920*63258Sbostic 					pdst[-4] = DoMergeRop(psrc[-4], pdst[-4]);
2921*63258Sbostic 					pdst[-3] = DoMergeRop(psrc[-3], pdst[-3]);
2922*63258Sbostic 					pdst[-2] = DoMergeRop(psrc[-2], pdst[-2]);
2923*63258Sbostic 					pdst[-1] = DoMergeRop(psrc[-1], pdst[-1]);
2924*63258Sbostic 				}
2925*63258Sbostic 				if (endmask) {
2926*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
2927*63258Sbostic 							       endmask);
2928*63258Sbostic 				}
2929*63258Sbostic 			}
2930*63258Sbostic 		} else {
2931*63258Sbostic 			if (xoffSrc > xoffDst) {
2932*63258Sbostic 				leftShift = xoffSrc - xoffDst;
2933*63258Sbostic 				rightShift = 16 - leftShift;
2934*63258Sbostic 			} else {
2935*63258Sbostic 				rightShift = xoffDst - xoffSrc;
2936*63258Sbostic 				leftShift = 16 - rightShift;
2937*63258Sbostic 			}
2938*63258Sbostic 			while (h--) {
2939*63258Sbostic 				psrc = psrcLine;
2940*63258Sbostic 				pdst = pdstLine;
2941*63258Sbostic 				psrcLine += widthSrc;
2942*63258Sbostic 				pdstLine += widthDst;
2943*63258Sbostic 				bits = 0;
2944*63258Sbostic 				if (xoffSrc > xoffDst)
2945*63258Sbostic 					bits = *psrc++;
2946*63258Sbostic 				if (startmask) {
2947*63258Sbostic 					bits1 = bits << leftShift;
2948*63258Sbostic 					bits = *psrc++;
2949*63258Sbostic 					bits1 |= bits >> rightShift;
2950*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
2951*63258Sbostic 							       startmask);
2952*63258Sbostic 					pdst++;
2953*63258Sbostic 				}
2954*63258Sbostic 				nl = nlMiddle;
2955*63258Sbostic 				bits1 = bits;
2956*63258Sbostic 				psrc += nl & 7;
2957*63258Sbostic 				pdst += nl & 7;
2958*63258Sbostic 				switch (nl & 7) {
2959*63258Sbostic 				case 7:
2960*63258Sbostic 					bits = psrc[-7];
2961*63258Sbostic 					pdst[-7] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-7]);
2962*63258Sbostic 				case 6:
2963*63258Sbostic 					bits1 = psrc[-6];
2964*63258Sbostic 					pdst[-6] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-6]);
2965*63258Sbostic 				case 5:
2966*63258Sbostic 					bits = psrc[-5];
2967*63258Sbostic 					pdst[-5] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-5]);
2968*63258Sbostic 				case 4:
2969*63258Sbostic 					bits1 = psrc[-4];
2970*63258Sbostic 					pdst[-4] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-4]);
2971*63258Sbostic 				case 3:
2972*63258Sbostic 					bits = psrc[-3];
2973*63258Sbostic 					pdst[-3] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-3]);
2974*63258Sbostic 				case 2:
2975*63258Sbostic 					bits1 = psrc[-2];
2976*63258Sbostic 					pdst[-2] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-2]);
2977*63258Sbostic 				case 1:
2978*63258Sbostic 					bits = psrc[-1];
2979*63258Sbostic 					pdst[-1] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-1]);
2980*63258Sbostic 				}
2981*63258Sbostic 				while ((nl -= 8) >= 0) {
2982*63258Sbostic 					pdst += 8;
2983*63258Sbostic 					psrc += 8;
2984*63258Sbostic 					bits1 = psrc[-8];
2985*63258Sbostic 					pdst[-8] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-8]);
2986*63258Sbostic 					bits = psrc[-7];
2987*63258Sbostic 					pdst[-7] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-7]);
2988*63258Sbostic 					bits1 = psrc[-6];
2989*63258Sbostic 					pdst[-6] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-6]);
2990*63258Sbostic 					bits = psrc[-5];
2991*63258Sbostic 					pdst[-5] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-5]);
2992*63258Sbostic 					bits1 = psrc[-4];
2993*63258Sbostic 					pdst[-4] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-4]);
2994*63258Sbostic 					bits = psrc[-3];
2995*63258Sbostic 					pdst[-3] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-3]);
2996*63258Sbostic 					bits1 = psrc[-2];
2997*63258Sbostic 					pdst[-2] = DoMergeRop(((bits << leftShift) | (bits1 >> rightShift)), pdst[-2]);
2998*63258Sbostic 					bits = psrc[-1];
2999*63258Sbostic 					pdst[-1] = DoMergeRop(((bits1 << leftShift) | (bits >> rightShift)), pdst[-1]);
3000*63258Sbostic 				}
3001*63258Sbostic 				if (endmask) {
3002*63258Sbostic 					bits1 = bits << leftShift;
3003*63258Sbostic 					if ((endmask << rightShift) & 0xffff) {
3004*63258Sbostic 						bits = *psrc;
3005*63258Sbostic 						bits1 |= (bits >> rightShift);
3006*63258Sbostic 					}
3007*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
3008*63258Sbostic 							       endmask);
3009*63258Sbostic 				}
3010*63258Sbostic 			}
3011*63258Sbostic 		}
3012*63258Sbostic 	} else {
3013*63258Sbostic 		xoffSrc = (sr->origin.x + w - 1) & 0xf;
3014*63258Sbostic 		xoffDst = (dp->x + w - 1) & 0xf;
3015*63258Sbostic 		pdstLine += ((dp->x + w - 1) >> 4) + 1;
3016*63258Sbostic 		psrcLine += ((sr->origin.x + w - 1) >> 4) + 1;
3017*63258Sbostic 		if (xoffSrc == xoffDst) {
3018*63258Sbostic 			while (h--) {
3019*63258Sbostic 				psrc = psrcLine;
3020*63258Sbostic 				pdst = pdstLine;
3021*63258Sbostic 				psrcLine += widthSrc;
3022*63258Sbostic 				pdstLine += widthDst;
3023*63258Sbostic 				if (endmask) {
3024*63258Sbostic 					pdst--;
3025*63258Sbostic 					psrc--;
3026*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
3027*63258Sbostic 							       endmask);
3028*63258Sbostic 				}
3029*63258Sbostic 				nl = nlMiddle;
3030*63258Sbostic 				psrc -= nl & 7;
3031*63258Sbostic 				pdst -= nl & 7;
3032*63258Sbostic 				switch (nl & 7) {
3033*63258Sbostic 				case 7:
3034*63258Sbostic 					pdst[7-1] = DoMergeRop(psrc[7-1], pdst[7-1]);
3035*63258Sbostic 				case 6:
3036*63258Sbostic 					pdst[6-1] = DoMergeRop(psrc[6-1], pdst[6-1]);
3037*63258Sbostic 				case 5:
3038*63258Sbostic 					pdst[5-1] = DoMergeRop(psrc[5-1], pdst[5-1]);
3039*63258Sbostic 				case 4:
3040*63258Sbostic 					pdst[4-1] = DoMergeRop(psrc[4-1], pdst[4-1]);
3041*63258Sbostic 				case 3:
3042*63258Sbostic 					pdst[3-1] = DoMergeRop(psrc[3-1], pdst[3-1]);
3043*63258Sbostic 				case 2:
3044*63258Sbostic 					pdst[2-1] = DoMergeRop(psrc[2-1], pdst[2-1]);
3045*63258Sbostic 				case 1:
3046*63258Sbostic 					pdst[1-1] = DoMergeRop(psrc[1-1], pdst[1-1]);
3047*63258Sbostic 				}
3048*63258Sbostic 				while ((nl -= 8) >= 0) {
3049*63258Sbostic 					pdst -= 8;
3050*63258Sbostic 					psrc -= 8;
3051*63258Sbostic 					pdst[8-1] = DoMergeRop(psrc[8-1], pdst[8-1]);
3052*63258Sbostic 					pdst[7-1] = DoMergeRop(psrc[7-1], pdst[7-1]);
3053*63258Sbostic 					pdst[6-1] = DoMergeRop(psrc[6-1], pdst[6-1]);
3054*63258Sbostic 					pdst[5-1] = DoMergeRop(psrc[5-1], pdst[5-1]);
3055*63258Sbostic 					pdst[4-1] = DoMergeRop(psrc[4-1], pdst[4-1]);
3056*63258Sbostic 					pdst[3-1] = DoMergeRop(psrc[3-1], pdst[3-1]);
3057*63258Sbostic 					pdst[2-1] = DoMergeRop(psrc[2-1], pdst[2-1]);
3058*63258Sbostic 					pdst[1-1] = DoMergeRop(psrc[1-1], pdst[1-1]);
3059*63258Sbostic 				}
3060*63258Sbostic 				if (startmask) {
3061*63258Sbostic 					--pdst;
3062*63258Sbostic 					--psrc;
3063*63258Sbostic 					*pdst = DoMergeRopMask(*psrc, *pdst,
3064*63258Sbostic 							       startmask);
3065*63258Sbostic 				}
3066*63258Sbostic 			}
3067*63258Sbostic 		} else {
3068*63258Sbostic 			if (xoffDst > xoffSrc) {
3069*63258Sbostic 				rightShift = xoffDst - xoffSrc;
3070*63258Sbostic 				leftShift = 16 - rightShift;
3071*63258Sbostic 			} else {
3072*63258Sbostic 				leftShift = xoffSrc - xoffDst;
3073*63258Sbostic 				rightShift = 16 - leftShift;
3074*63258Sbostic 			}
3075*63258Sbostic 			while (h--) {
3076*63258Sbostic 				psrc = psrcLine;
3077*63258Sbostic 				pdst = pdstLine;
3078*63258Sbostic 				psrcLine += widthSrc;
3079*63258Sbostic 				pdstLine += widthDst;
3080*63258Sbostic 				bits = 0;
3081*63258Sbostic 				if (xoffDst > xoffSrc)
3082*63258Sbostic 					bits = *--psrc;
3083*63258Sbostic 				if (endmask) {
3084*63258Sbostic 					bits1 = bits >> rightShift;
3085*63258Sbostic 					bits = *--psrc;
3086*63258Sbostic 					bits1 |= (bits << leftShift);
3087*63258Sbostic 					pdst--;
3088*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
3089*63258Sbostic 							       endmask);
3090*63258Sbostic 				}
3091*63258Sbostic 				nl = nlMiddle;
3092*63258Sbostic 				bits1 = bits;
3093*63258Sbostic 				psrc -= nl & 7;
3094*63258Sbostic 				pdst -= nl & 7;
3095*63258Sbostic 				switch (nl & 7) {
3096*63258Sbostic 				case 7:
3097*63258Sbostic 					bits = psrc[7-1];
3098*63258Sbostic 					pdst[7-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[7-1]);
3099*63258Sbostic 				case 6:
3100*63258Sbostic 					bits1 = psrc[6-1];
3101*63258Sbostic 					pdst[6-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[6-1]);
3102*63258Sbostic 				case 5:
3103*63258Sbostic 					bits = psrc[5-1];
3104*63258Sbostic 					pdst[5-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[5-1]);
3105*63258Sbostic 				case 4:
3106*63258Sbostic 					bits1 = psrc[4-1];
3107*63258Sbostic 					pdst[4-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[4-1]);
3108*63258Sbostic 				case 3:
3109*63258Sbostic 					bits = psrc[3-1];
3110*63258Sbostic 					pdst[3-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[3-1]);
3111*63258Sbostic 				case 2:
3112*63258Sbostic 					bits1 = psrc[2-1];
3113*63258Sbostic 					pdst[2-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[2-1]);
3114*63258Sbostic 				case 1:
3115*63258Sbostic 					bits = psrc[1-1];
3116*63258Sbostic 					pdst[1-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[1-1]);
3117*63258Sbostic 				}
3118*63258Sbostic 				while ((nl -= 8) >= 0) {
3119*63258Sbostic 					pdst -= 8;
3120*63258Sbostic 					psrc -= 8;
3121*63258Sbostic 					bits1 = psrc[8-1];
3122*63258Sbostic 					pdst[8-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[8-1]);
3123*63258Sbostic 					bits = psrc[7-1];
3124*63258Sbostic 					pdst[7-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[7-1]);
3125*63258Sbostic 					bits1 = psrc[6-1];
3126*63258Sbostic 					pdst[6-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[6-1]);
3127*63258Sbostic 					bits = psrc[5-1];
3128*63258Sbostic 					pdst[5-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[5-1]);
3129*63258Sbostic 					bits1 = psrc[4-1];
3130*63258Sbostic 					pdst[4-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[4-1]);
3131*63258Sbostic 					bits = psrc[3-1];
3132*63258Sbostic 					pdst[3-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[3-1]);
3133*63258Sbostic 					bits1 = psrc[2-1];
3134*63258Sbostic 					pdst[2-1] = DoMergeRop(((bits >> rightShift) | (bits1 << leftShift)), pdst[2-1]);
3135*63258Sbostic 					bits = psrc[1-1];
3136*63258Sbostic 					pdst[1-1] = DoMergeRop(((bits1 >> rightShift) | (bits << leftShift)), pdst[1-1]);
3137*63258Sbostic 				}
3138*63258Sbostic 				if (startmask) {
3139*63258Sbostic 					bits1 = (bits >> rightShift);
3140*63258Sbostic 					if (startmask >> leftShift) {
3141*63258Sbostic 						bits = *--psrc;
3142*63258Sbostic 						bits1 |= (bits << leftShift);
3143*63258Sbostic 					}
3144*63258Sbostic 					--pdst;
3145*63258Sbostic 					*pdst = DoMergeRopMask(bits1, *pdst,
3146*63258Sbostic 							       startmask);
3147*63258Sbostic 				}
3148*63258Sbostic 			}
3149*63258Sbostic 		}
3150*63258Sbostic 	}
3151*63258Sbostic }
3152*63258Sbostic 
3153*63258Sbostic void
mfb_clr_area16(x,y,w,h,addr,nlwidth)3154*63258Sbostic mfb_clr_area16(x, y, w, h, addr, nlwidth)
3155*63258Sbostic int x;
3156*63258Sbostic int y;
3157*63258Sbostic int w;
3158*63258Sbostic register int h;
3159*63258Sbostic register u_short *addr;
3160*63258Sbostic int nlwidth;
3161*63258Sbostic {
3162*63258Sbostic 	register u_short startmask;
3163*63258Sbostic 	u_short endmask;
3164*63258Sbostic 	register int nlw, nlwExtra;
3165*63258Sbostic 	int nlwMiddle;
3166*63258Sbostic 
3167*63258Sbostic 	addr += (y * nlwidth + (x >> 4));
3168*63258Sbostic 
3169*63258Sbostic 	if (((x & 0xf) + w) < 16) {
3170*63258Sbostic 		startmask = mfbpartmasks16[x & 0xf][w & 0xf];
3171*63258Sbostic 		nlwExtra = nlwidth;
3172*63258Sbostic 		Duff(h, *addr &= ~startmask; addr += nlwExtra)
3173*63258Sbostic 	} else {
3174*63258Sbostic 		startmask = mfbstarttab16[x & 0xf];
3175*63258Sbostic 		endmask = mfbendtab16[(x + w) & 0xf];
3176*63258Sbostic 		if (startmask) {
3177*63258Sbostic 			nlwMiddle = (w - (16 - (x & 0xf))) >> 4;
3178*63258Sbostic 		} else {
3179*63258Sbostic 			nlwMiddle = w >> 4;
3180*63258Sbostic 		}
3181*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle;
3182*63258Sbostic 		if (startmask && endmask) {
3183*63258Sbostic 			startmask ^= ~0;
3184*63258Sbostic 			endmask ^= ~0;
3185*63258Sbostic 			nlwExtra -= 1;
3186*63258Sbostic 			while (h--) {
3187*63258Sbostic 				nlw = nlwMiddle;
3188*63258Sbostic 				*addr++ &= startmask;
3189*63258Sbostic 				Duff_single(nlw, addr, = 0)
3190*63258Sbostic 				*addr &= endmask;
3191*63258Sbostic 				addr += nlwExtra;
3192*63258Sbostic 			}
3193*63258Sbostic 		} else if (startmask && !endmask) {
3194*63258Sbostic 			startmask ^= ~0;
3195*63258Sbostic 			nlwExtra -= 1;
3196*63258Sbostic 			while (h--) {
3197*63258Sbostic 				nlw = nlwMiddle;
3198*63258Sbostic 				*addr++ &= startmask;
3199*63258Sbostic 				Duff_single(nlw, addr, = 0)
3200*63258Sbostic 				addr += nlwExtra;
3201*63258Sbostic 			}
3202*63258Sbostic 		} else if (!startmask && endmask) {
3203*63258Sbostic 			endmask ^= ~0;
3204*63258Sbostic 			while (h--) {
3205*63258Sbostic 				nlw = nlwMiddle;
3206*63258Sbostic 				Duff_single(nlw, addr, = 0)
3207*63258Sbostic 				*addr &= endmask;
3208*63258Sbostic 				addr += nlwExtra;
3209*63258Sbostic 			}
3210*63258Sbostic 		} else {
3211*63258Sbostic 			while (h--) {
3212*63258Sbostic 				nlw = nlwMiddle;
3213*63258Sbostic 				Duff_single(nlw, addr, = 0)
3214*63258Sbostic 				addr += nlwExtra;
3215*63258Sbostic 			}
3216*63258Sbostic 		}
3217*63258Sbostic 	}
3218*63258Sbostic }
3219*63258Sbostic 
3220*63258Sbostic void
mfb_inv_area16(x,y,w,h,addr,nlwidth)3221*63258Sbostic mfb_inv_area16(x, y, w, h, addr, nlwidth)
3222*63258Sbostic int x;
3223*63258Sbostic int y;
3224*63258Sbostic int w;
3225*63258Sbostic register int h;
3226*63258Sbostic register u_short *addr;
3227*63258Sbostic int nlwidth;
3228*63258Sbostic {
3229*63258Sbostic 	register u_short startmask;
3230*63258Sbostic 	u_short endmask;
3231*63258Sbostic 	register int nlw, nlwExtra;
3232*63258Sbostic 	int nlwMiddle;
3233*63258Sbostic 
3234*63258Sbostic 	addr += (y * nlwidth + (x >> 4));
3235*63258Sbostic 
3236*63258Sbostic 	if (((x & 0xf) + w) < 16) {
3237*63258Sbostic 		startmask = mfbpartmasks16[x & 0xf][w & 0xf];
3238*63258Sbostic 		nlwExtra = nlwidth;
3239*63258Sbostic 		Duff(h, *addr ^= startmask; addr += nlwExtra)
3240*63258Sbostic 	} else {
3241*63258Sbostic 		startmask = mfbstarttab16[x & 0xf];
3242*63258Sbostic 		endmask = mfbendtab16[(x + w) & 0xf];
3243*63258Sbostic 		if (startmask) {
3244*63258Sbostic 			nlwMiddle = (w - (16 - (x & 0xf))) >> 4;
3245*63258Sbostic 		} else {
3246*63258Sbostic 			nlwMiddle = w >> 4;
3247*63258Sbostic 		}
3248*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle;
3249*63258Sbostic 		if (startmask && endmask) {
3250*63258Sbostic 			nlwExtra -= 1;
3251*63258Sbostic 			while (h--) {
3252*63258Sbostic 				nlw = nlwMiddle;
3253*63258Sbostic 				*addr++ ^= startmask;
3254*63258Sbostic 				Duff_single(nlw, addr, ^= ~0)
3255*63258Sbostic 				*addr ^= endmask;
3256*63258Sbostic 				addr += nlwExtra;
3257*63258Sbostic 			}
3258*63258Sbostic 		} else if (startmask && !endmask) {
3259*63258Sbostic 			nlwExtra -= 1;
3260*63258Sbostic 			while (h--) {
3261*63258Sbostic 				nlw = nlwMiddle;
3262*63258Sbostic 				*addr++ ^= startmask;
3263*63258Sbostic 				Duff_single(nlw, addr, ^= ~0)
3264*63258Sbostic 				addr += nlwExtra;
3265*63258Sbostic 			}
3266*63258Sbostic 		} else if (!startmask && endmask) {
3267*63258Sbostic 			while (h--) {
3268*63258Sbostic 				nlw = nlwMiddle;
3269*63258Sbostic 				Duff_single(nlw, addr, ^= ~0)
3270*63258Sbostic 				*addr ^= endmask;
3271*63258Sbostic 				addr += nlwExtra;
3272*63258Sbostic 			}
3273*63258Sbostic 		} else {
3274*63258Sbostic 			while (h--) {
3275*63258Sbostic 				nlw = nlwMiddle;
3276*63258Sbostic 				Duff_single(nlw, addr, ^= ~0)
3277*63258Sbostic 				addr += nlwExtra;
3278*63258Sbostic 			}
3279*63258Sbostic 		}
3280*63258Sbostic 	}
3281*63258Sbostic }
3282*63258Sbostic 
3283*63258Sbostic void
mfb_set_area16(x,y,w,h,addr,nlwidth)3284*63258Sbostic mfb_set_area16(x, y, w, h, addr, nlwidth)
3285*63258Sbostic int x;
3286*63258Sbostic int y;
3287*63258Sbostic int w;
3288*63258Sbostic register int h;
3289*63258Sbostic register u_short *addr;
3290*63258Sbostic int nlwidth;
3291*63258Sbostic {
3292*63258Sbostic 	register u_short startmask;
3293*63258Sbostic 	u_short endmask;
3294*63258Sbostic 	register int nlw, nlwExtra;
3295*63258Sbostic 	int nlwMiddle;
3296*63258Sbostic 
3297*63258Sbostic 	addr += (y * nlwidth + (x >> 4));
3298*63258Sbostic 
3299*63258Sbostic 	if (((x & 0xf) + w) < 16) {
3300*63258Sbostic 		startmask = mfbpartmasks16[x & 0xf][w & 0xf];
3301*63258Sbostic 		nlwExtra = nlwidth;
3302*63258Sbostic 		Duff(h, *addr |= startmask; addr += nlwExtra)
3303*63258Sbostic 	} else {
3304*63258Sbostic 		startmask = mfbstarttab16[x & 0xf];
3305*63258Sbostic 		endmask = mfbendtab16[(x + w) & 0xf];
3306*63258Sbostic 		if (startmask) {
3307*63258Sbostic 			nlwMiddle = (w - (16 - (x & 0xf))) >> 4;
3308*63258Sbostic 		} else {
3309*63258Sbostic 			nlwMiddle = w >> 4;
3310*63258Sbostic 		}
3311*63258Sbostic 		nlwExtra = nlwidth - nlwMiddle;
3312*63258Sbostic 		if (startmask && endmask) {
3313*63258Sbostic 			nlwExtra -= 1;
3314*63258Sbostic 			while (h--) {
3315*63258Sbostic 				nlw = nlwMiddle;
3316*63258Sbostic 				*addr++ |= startmask;
3317*63258Sbostic #ifdef mc68020
3318*63258Sbostic 				asm(" move.w #-1,d3");
3319*63258Sbostic 				Duff(nlw, asm(" move.w d3,(a5)+"))
3320*63258Sbostic #else /* mc68020 */
3321*63258Sbostic 				Duff_single(nlw, addr, = ~0)
3322*63258Sbostic #endif /* mc68020 */
3323*63258Sbostic 				*addr |= endmask;
3324*63258Sbostic 				addr += nlwExtra;
3325*63258Sbostic 			}
3326*63258Sbostic 		} else if (startmask && !endmask) {
3327*63258Sbostic 			nlwExtra -= 1;
3328*63258Sbostic 			while (h--) {
3329*63258Sbostic 				nlw = nlwMiddle;
3330*63258Sbostic 				*addr++ |= startmask;
3331*63258Sbostic #ifdef mc68020
3332*63258Sbostic 				asm(" move.w #-1,d3");
3333*63258Sbostic 				Duff(nlw, asm(" move.w d3,(a5)+"));
3334*63258Sbostic #else /* mc68020 */
3335*63258Sbostic 				Duff_single(nlw, addr, = ~0)
3336*63258Sbostic #endif /* mc68020 */
3337*63258Sbostic 				addr += nlwExtra;
3338*63258Sbostic 			}
3339*63258Sbostic 		} else if (!startmask && endmask) {
3340*63258Sbostic 			while (h--) {
3341*63258Sbostic 				nlw = nlwMiddle;
3342*63258Sbostic #ifdef mc68020
3343*63258Sbostic 				asm(" move.w #-1,d3");
3344*63258Sbostic 				Duff(nlw, asm(" move.w d3,(a5)+"));
3345*63258Sbostic #else /* mc68020 */
3346*63258Sbostic 				Duff_single(nlw, addr, = ~0)
3347*63258Sbostic #endif /* mc68020 */
3348*63258Sbostic 				*addr |= endmask;
3349*63258Sbostic 				addr += nlwExtra;
3350*63258Sbostic 			}
3351*63258Sbostic 		} else {
3352*63258Sbostic 			while (h--) {
3353*63258Sbostic 				nlw = nlwMiddle;
3354*63258Sbostic #ifdef mc68020
3355*63258Sbostic 				asm(" move.w #-1,d3");
3356*63258Sbostic 				Duff(nlw, asm(" move.w d3,(a5)+"));
3357*63258Sbostic #else /* mc68020 */
3358*63258Sbostic 				Duff_single(nlw, addr, = ~0)
3359*63258Sbostic #endif /* mc68020 */
3360*63258Sbostic 				addr += nlwExtra;
3361*63258Sbostic 			}
3362*63258Sbostic 		}
3363*63258Sbostic 	}
3364*63258Sbostic }
3365*63258Sbostic 
3366*63258Sbostic void
mfb_clrvvector32(addr,nlwidth,x,len,lpf)3367*63258Sbostic mfb_clrvvector32(addr, nlwidth, x, len, lpf)
3368*63258Sbostic register u_int *addr;
3369*63258Sbostic register int nlwidth;
3370*63258Sbostic register int x;
3371*63258Sbostic register int len;
3372*63258Sbostic {
3373*63258Sbostic 	register u_int bitmask;
3374*63258Sbostic 
3375*63258Sbostic 	if (len < 0) {
3376*63258Sbostic 		nlwidth = -nlwidth;
3377*63258Sbostic 		len = -len;
3378*63258Sbostic 	}
3379*63258Sbostic 	if (lpf)
3380*63258Sbostic 		len++;
3381*63258Sbostic 	addr += (x >> 5);
3382*63258Sbostic 
3383*63258Sbostic 	bitmask = mfbrmask32[x & 0x1f];
3384*63258Sbostic 
3385*63258Sbostic 	Duff(len, *addr &= bitmask; addr += nlwidth)
3386*63258Sbostic }
3387*63258Sbostic 
3388*63258Sbostic void
mfb_clrhvector32(addr,x,len,lpf)3389*63258Sbostic mfb_clrhvector32(addr, x, len, lpf)
3390*63258Sbostic register u_int *addr;
3391*63258Sbostic int x;
3392*63258Sbostic int len;
3393*63258Sbostic int lpf;
3394*63258Sbostic {
3395*63258Sbostic 	register u_int	startmask;
3396*63258Sbostic 	register u_int 	endmask;
3397*63258Sbostic 	register int	nl, off;
3398*63258Sbostic 
3399*63258Sbostic 	if (len < 0) {
3400*63258Sbostic 		x += len;
3401*63258Sbostic 		len = -len;
3402*63258Sbostic 		if (lpf) {
3403*63258Sbostic 			len++;
3404*63258Sbostic 		} else {
3405*63258Sbostic 			x++;
3406*63258Sbostic 		}
3407*63258Sbostic 	} else {
3408*63258Sbostic 		if (lpf) {
3409*63258Sbostic 			len++;
3410*63258Sbostic 		}
3411*63258Sbostic 	}
3412*63258Sbostic 	addr += (x >> 5);
3413*63258Sbostic 
3414*63258Sbostic 	off = x & 0x1f;
3415*63258Sbostic 	if (off + len < 32) {
3416*63258Sbostic 		*addr &= ~mfbpartmasks32[off][len & 0x1f];
3417*63258Sbostic 	} else {
3418*63258Sbostic 		startmask = mfbstarttab32[off];
3419*63258Sbostic 		endmask = mfbendtab32[(x + len) & 0x1f];
3420*63258Sbostic 		if (startmask) {
3421*63258Sbostic 			nl = (len - (32 - off)) >> 5;
3422*63258Sbostic 			*addr++ &= ~startmask;
3423*63258Sbostic 		} else
3424*63258Sbostic 			nl = len >> 5;
3425*63258Sbostic 		Duff_single(nl, addr, = 0);
3426*63258Sbostic 		if (endmask)
3427*63258Sbostic 			*addr &= ~endmask;
3428*63258Sbostic 	}
3429*63258Sbostic }
3430*63258Sbostic 
3431*63258Sbostic void
mfb_clrvector32(fb,addr,ddy,p0,p1,lpf)3432*63258Sbostic mfb_clrvector32(fb, addr, ddy, p0, p1, lpf)
3433*63258Sbostic struct fbdev	*fb;
3434*63258Sbostic register u_int *addr;
3435*63258Sbostic register int ddy;
3436*63258Sbostic register lPoint *p0, *p1;
3437*63258Sbostic int lpf;		/* if 0, don't draw last point */
3438*63258Sbostic {
3439*63258Sbostic 	register int i;
3440*63258Sbostic 	register int lim;
3441*63258Sbostic #ifdef mc68020
3442*63258Sbostic 	register int x = p0->x;
3443*63258Sbostic #else /* mc68020 */
3444*63258Sbostic 	register u_int bit, leftbit, rightbit;
3445*63258Sbostic #endif /* mc68020 */
3446*63258Sbostic 	int ddx;
3447*63258Sbostic 	int dx = p1->x - p0->x;
3448*63258Sbostic 	int dy = p1->y - p0->y;
3449*63258Sbostic 	int s, d, c;
3450*63258Sbostic 
3451*63258Sbostic 	addr += (p0->y * ddy);
3452*63258Sbostic 
3453*63258Sbostic 	if (dx == 0) {
3454*63258Sbostic 		mfb_clrvvector32(addr, ddy, p0->x, dy, lpf);
3455*63258Sbostic 		return;
3456*63258Sbostic 	}
3457*63258Sbostic 	if (dy == 0) {
3458*63258Sbostic 		mfb_clrhvector32(addr, p0->x, dx, lpf);
3459*63258Sbostic 		return;
3460*63258Sbostic 	}
3461*63258Sbostic 
3462*63258Sbostic 	if (dx < 0) {
3463*63258Sbostic 		ddx = -1;
3464*63258Sbostic 		dx = -dx;
3465*63258Sbostic 	} else {
3466*63258Sbostic 		ddx = 1;
3467*63258Sbostic 	}
3468*63258Sbostic 	if (dy < 0) {
3469*63258Sbostic 		dy = -dy;
3470*63258Sbostic 		ddy = -ddy;
3471*63258Sbostic 	}
3472*63258Sbostic 
3473*63258Sbostic #ifndef mc68020
3474*63258Sbostic 	bit = mfbmask32[p0->x & 0x1f];
3475*63258Sbostic 	leftbit = mfbmask32[0];
3476*63258Sbostic 	rightbit = mfbmask32[31];
3477*63258Sbostic 	addr += (p0->x >> 5);
3478*63258Sbostic #endif /* mc68020 */
3479*63258Sbostic 	if (dx > dy) {	/* case x */
3480*63258Sbostic 		lim = dx;
3481*63258Sbostic 		if (lpf)
3482*63258Sbostic 			lim++;
3483*63258Sbostic 
3484*63258Sbostic 		s = -dx;
3485*63258Sbostic 		d = dx << 1;
3486*63258Sbostic 		c = dy << 1;
3487*63258Sbostic 
3488*63258Sbostic 		if (ddx > 0) {
3489*63258Sbostic 			for (i = lim; i > 0; i--) {
3490*63258Sbostic #ifdef mc68020
3491*63258Sbostic 				asm("	bfclr	(a5){d4:1}");
3492*63258Sbostic 				x++;
3493*63258Sbostic #else /* mc68020 */
3494*63258Sbostic 				*addr &= ~bit;
3495*63258Sbostic 				bit >>= 1;
3496*63258Sbostic 				if (!bit) {
3497*63258Sbostic 					bit = leftbit;
3498*63258Sbostic 					addr++;
3499*63258Sbostic 				}
3500*63258Sbostic #endif /* mc68020 */
3501*63258Sbostic 				if ((s += c) >= 0) {
3502*63258Sbostic 					s -= d;
3503*63258Sbostic 					addr += ddy;
3504*63258Sbostic 				}
3505*63258Sbostic 			}
3506*63258Sbostic 		} else {
3507*63258Sbostic 			for (i = lim; i > 0; i--) {
3508*63258Sbostic #ifdef mc68020
3509*63258Sbostic 				asm("	bfclr	(a5){d4:1}");
3510*63258Sbostic 				x--;
3511*63258Sbostic #else /* mc68020 */
3512*63258Sbostic 				*addr &= ~bit;
3513*63258Sbostic 				bit <<= 1;
3514*63258Sbostic 				if (!bit) {
3515*63258Sbostic 					bit = rightbit;
3516*63258Sbostic 					addr--;
3517*63258Sbostic 				}
3518*63258Sbostic #endif /* mc68020 */
3519*63258Sbostic 				if ((s += c) >= 0) {
3520*63258Sbostic 					s -= d;
3521*63258Sbostic 					addr += ddy;
3522*63258Sbostic 				}
3523*63258Sbostic 			}
3524*63258Sbostic 		}
3525*63258Sbostic 	} else {			/* case y */
3526*63258Sbostic 		lim = dy;
3527*63258Sbostic 		if (lpf)
3528*63258Sbostic 			lim++;
3529*63258Sbostic 		s = -dy;
3530*63258Sbostic 		d = dy << 1;
3531*63258Sbostic 		c = dx << 1;
3532*63258Sbostic 
3533*63258Sbostic 		if (ddx > 0) {
3534*63258Sbostic 			for (i = lim; i > 0; i--) {
3535*63258Sbostic #ifdef mc68020
3536*63258Sbostic 				asm("	bfclr	(a5){d4:1}");
3537*63258Sbostic 				if ((s += c) >= 0) {
3538*63258Sbostic 					s -= d;
3539*63258Sbostic 					x++;
3540*63258Sbostic 				}
3541*63258Sbostic #else /* mc68020 */
3542*63258Sbostic 				*addr &= ~bit;
3543*63258Sbostic 				if ((s += c) >= 0) {
3544*63258Sbostic 					s -= d;
3545*63258Sbostic 					bit >>= 1;
3546*63258Sbostic 					if (!bit) {
3547*63258Sbostic 						bit = leftbit;
3548*63258Sbostic 						addr++;
3549*63258Sbostic 					}
3550*63258Sbostic 				}
3551*63258Sbostic #endif /* mc68020 */
3552*63258Sbostic 				addr += ddy;
3553*63258Sbostic 			}
3554*63258Sbostic 		} else {
3555*63258Sbostic 			for (i = lim; i > 0; i--) {
3556*63258Sbostic #ifdef mc68020
3557*63258Sbostic 				asm("	bfclr	(a5){d4:1}");
3558*63258Sbostic 				if ((s += c) >= 0) {
3559*63258Sbostic 					s -= d;
3560*63258Sbostic 					x--;
3561*63258Sbostic 				}
3562*63258Sbostic #else /* mc68020 */
3563*63258Sbostic 				*addr &= ~bit;
3564*63258Sbostic 				if ((s += c) >= 0) {
3565*63258Sbostic 					s -= d;
3566*63258Sbostic 					bit <<= 1;
3567*63258Sbostic 					if (!bit) {
3568*63258Sbostic 						bit = rightbit;
3569*63258Sbostic 						addr--;
3570*63258Sbostic 					}
3571*63258Sbostic 				}
3572*63258Sbostic #endif /* mc68020 */
3573*63258Sbostic 				addr += ddy;
3574*63258Sbostic 			}
3575*63258Sbostic 		}
3576*63258Sbostic 	}
3577*63258Sbostic }
3578*63258Sbostic 
3579*63258Sbostic void
mfb_invvvector32(addr,nlwidth,x,len,lpf)3580*63258Sbostic mfb_invvvector32(addr, nlwidth, x, len, lpf)
3581*63258Sbostic register u_int *addr;
3582*63258Sbostic register int nlwidth;
3583*63258Sbostic register int x;
3584*63258Sbostic register int len;
3585*63258Sbostic {
3586*63258Sbostic 	register u_int bitmask;
3587*63258Sbostic 
3588*63258Sbostic 	if (len < 0) {
3589*63258Sbostic 		nlwidth = -nlwidth;
3590*63258Sbostic 		len = -len;
3591*63258Sbostic 	}
3592*63258Sbostic 	if (lpf)
3593*63258Sbostic 		len++;
3594*63258Sbostic 	addr += (x >> 5);
3595*63258Sbostic 
3596*63258Sbostic 	bitmask = mfbmask32[x & 0x1f];
3597*63258Sbostic 
3598*63258Sbostic 	Duff(len, *addr ^= bitmask; addr += nlwidth)
3599*63258Sbostic }
3600*63258Sbostic 
3601*63258Sbostic void
mfb_invhvector32(addr,x,len,lpf)3602*63258Sbostic mfb_invhvector32(addr, x, len, lpf)
3603*63258Sbostic register u_int *addr;
3604*63258Sbostic int x;
3605*63258Sbostic int len;
3606*63258Sbostic int lpf;
3607*63258Sbostic {
3608*63258Sbostic 	register u_int	startmask;
3609*63258Sbostic 	register u_int 	endmask;
3610*63258Sbostic 	register int nl, off;
3611*63258Sbostic 
3612*63258Sbostic 	if (len < 0) {
3613*63258Sbostic 		x += len;
3614*63258Sbostic 		len = -len;
3615*63258Sbostic 		if (lpf) {
3616*63258Sbostic 			len++;
3617*63258Sbostic 		} else {
3618*63258Sbostic 			x++;
3619*63258Sbostic 		}
3620*63258Sbostic 	} else {
3621*63258Sbostic 		if (lpf) {
3622*63258Sbostic 			len++;
3623*63258Sbostic 		}
3624*63258Sbostic 	}
3625*63258Sbostic 	addr += (x >> 5);
3626*63258Sbostic 
3627*63258Sbostic 	off = x & 0x1f;
3628*63258Sbostic 	if (off + len < 32) {
3629*63258Sbostic 		*addr ^= mfbpartmasks32[off][len & 0x1f];
3630*63258Sbostic 	} else {
3631*63258Sbostic 		startmask = mfbstarttab32[off];
3632*63258Sbostic 		endmask = mfbendtab32[(x + len) & 0x1f];
3633*63258Sbostic 		if (startmask) {
3634*63258Sbostic 			nl = (len - (32 - off)) >> 5;
3635*63258Sbostic 			*addr++ ^= startmask;
3636*63258Sbostic 		} else
3637*63258Sbostic 			nl = len >> 5;
3638*63258Sbostic 		Duff_single(nl, addr, ^= ~0);
3639*63258Sbostic 		if (endmask)
3640*63258Sbostic 			*addr ^= endmask;
3641*63258Sbostic 	}
3642*63258Sbostic }
3643*63258Sbostic 
3644*63258Sbostic void
mfb_invvector32(fb,addr,ddy,p0,p1,lpf)3645*63258Sbostic mfb_invvector32(fb, addr, ddy, p0, p1, lpf)
3646*63258Sbostic struct fbdev	*fb;
3647*63258Sbostic register u_int *addr;
3648*63258Sbostic register int	ddy;
3649*63258Sbostic register lPoint *p0, *p1;
3650*63258Sbostic int lpf;		/* if 0, don't draw last point */
3651*63258Sbostic {
3652*63258Sbostic 	register int i;
3653*63258Sbostic 	register int lim;
3654*63258Sbostic #ifdef mc68020
3655*63258Sbostic 	register int x = p0->x;
3656*63258Sbostic #else /* mc68020 */
3657*63258Sbostic 	register u_int bit, leftbit, rightbit;
3658*63258Sbostic #endif /* mc68020 */
3659*63258Sbostic 	int ddx;
3660*63258Sbostic 	int dx = p1->x - p0->x;
3661*63258Sbostic 	int dy = p1->y - p0->y;
3662*63258Sbostic 	int s, d, c;
3663*63258Sbostic 
3664*63258Sbostic 	addr += (p0->y * ddy);
3665*63258Sbostic 
3666*63258Sbostic 	if (dx == 0) {
3667*63258Sbostic 		mfb_invvvector32(addr, ddy, p0->x, dy, lpf);
3668*63258Sbostic 		return;
3669*63258Sbostic 	}
3670*63258Sbostic 	if (dy == 0) {
3671*63258Sbostic 		mfb_invhvector32(addr, p0->x, dx, lpf);
3672*63258Sbostic 		return;
3673*63258Sbostic 	}
3674*63258Sbostic 
3675*63258Sbostic 	if (dx < 0) {
3676*63258Sbostic 		dx = -dx;
3677*63258Sbostic 		ddx = -1;
3678*63258Sbostic 	} else {
3679*63258Sbostic 		ddx = 1;
3680*63258Sbostic 	}
3681*63258Sbostic 	if (dy < 0) {
3682*63258Sbostic 		dy = -dy;
3683*63258Sbostic 		ddy = -ddy;
3684*63258Sbostic 	}
3685*63258Sbostic 
3686*63258Sbostic #ifndef mc68020
3687*63258Sbostic 	bit = mfbmask32[p0->x & 0x1f];
3688*63258Sbostic 	leftbit = mfbmask32[0];
3689*63258Sbostic 	rightbit = mfbmask32[31];
3690*63258Sbostic 	addr += (p0->x >> 5);
3691*63258Sbostic #endif /* mc68020 */
3692*63258Sbostic 	if (dx > dy) {	/* case x */
3693*63258Sbostic 		lim = dx;
3694*63258Sbostic 		if (lpf)
3695*63258Sbostic 			lim++;
3696*63258Sbostic 
3697*63258Sbostic 		s = -dx;
3698*63258Sbostic 		d = dx << 1;
3699*63258Sbostic 		c = dy << 1;
3700*63258Sbostic 
3701*63258Sbostic 		if (ddx > 0) {
3702*63258Sbostic 			for (i = lim; i > 0; i--) {
3703*63258Sbostic #ifdef mc68020
3704*63258Sbostic 				asm("	bfchg	(a5){d4:1}");
3705*63258Sbostic 				x++;
3706*63258Sbostic #else /* mc68020 */
3707*63258Sbostic 				*addr ^= bit;
3708*63258Sbostic 				bit >>= 1;
3709*63258Sbostic 				if (!bit) {
3710*63258Sbostic 					bit = leftbit;
3711*63258Sbostic 					addr++;
3712*63258Sbostic 				}
3713*63258Sbostic #endif /* mc68020 */
3714*63258Sbostic 				if ((s += c) >= 0) {
3715*63258Sbostic 					s -= d;
3716*63258Sbostic 					addr += ddy;
3717*63258Sbostic 				}
3718*63258Sbostic 			}
3719*63258Sbostic 		} else {
3720*63258Sbostic 			for (i = lim; i > 0; i--) {
3721*63258Sbostic #ifdef mc68020
3722*63258Sbostic 				asm("	bfchg	(a5){d4:1}");
3723*63258Sbostic 				x--;
3724*63258Sbostic #else /* mc68020 */
3725*63258Sbostic 				*addr ^= bit;
3726*63258Sbostic 				bit <<= 1;
3727*63258Sbostic 				if (!bit) {
3728*63258Sbostic 					bit = rightbit;
3729*63258Sbostic 					addr--;
3730*63258Sbostic 				}
3731*63258Sbostic #endif /* mc68020 */
3732*63258Sbostic 				if ((s += c) >= 0) {
3733*63258Sbostic 					s -= d;
3734*63258Sbostic 					addr += ddy;
3735*63258Sbostic 				}
3736*63258Sbostic 			}
3737*63258Sbostic 		}
3738*63258Sbostic 	} else {			/* case y */
3739*63258Sbostic 		lim = dy;
3740*63258Sbostic 		if (lpf)
3741*63258Sbostic 			lim++;
3742*63258Sbostic 		s = -dy;
3743*63258Sbostic 		d = dy << 1;
3744*63258Sbostic 		c = dx << 1;
3745*63258Sbostic 
3746*63258Sbostic 		if (ddx > 0) {
3747*63258Sbostic 			for (i = lim; i > 0; i--) {
3748*63258Sbostic #ifdef mc68020
3749*63258Sbostic 				asm("	bfchg	(a5){d4:1}");
3750*63258Sbostic 				if ((s += c) >= 0) {
3751*63258Sbostic 					s -= d;
3752*63258Sbostic 					x++;
3753*63258Sbostic 				}
3754*63258Sbostic #else /* mc68020 */
3755*63258Sbostic 				*addr ^= bit;
3756*63258Sbostic 				if ((s += c) >= 0) {
3757*63258Sbostic 					s -= d;
3758*63258Sbostic 					bit >>= 1;
3759*63258Sbostic 					if (!bit) {
3760*63258Sbostic 						bit = leftbit;
3761*63258Sbostic 						addr++;
3762*63258Sbostic 					}
3763*63258Sbostic 				}
3764*63258Sbostic #endif /* mc68020 */
3765*63258Sbostic 				addr += ddy;
3766*63258Sbostic 			}
3767*63258Sbostic 		} else {
3768*63258Sbostic 			for (i = lim; i > 0; i--) {
3769*63258Sbostic #ifdef mc68020
3770*63258Sbostic 				asm("	bfchg	(a5){d4:1}");
3771*63258Sbostic 				if ((s += c) >= 0) {
3772*63258Sbostic 					s -= d;
3773*63258Sbostic 					x--;
3774*63258Sbostic 				}
3775*63258Sbostic #else /* mc68020 */
3776*63258Sbostic 				*addr ^= bit;
3777*63258Sbostic 				if ((s += c) >= 0) {
3778*63258Sbostic 					s -= d;
3779*63258Sbostic 					bit <<= 1;
3780*63258Sbostic 					if (!bit) {
3781*63258Sbostic 						bit = rightbit;
3782*63258Sbostic 						addr--;
3783*63258Sbostic 					}
3784*63258Sbostic 				}
3785*63258Sbostic #endif /* mc68020 */
3786*63258Sbostic 				addr += ddy;
3787*63258Sbostic 			}
3788*63258Sbostic 		}
3789*63258Sbostic 	}
3790*63258Sbostic }
3791*63258Sbostic 
3792*63258Sbostic void
mfb_setvvector32(addr,nlwidth,x,len,lpf)3793*63258Sbostic mfb_setvvector32(addr, nlwidth, x, len, lpf)
3794*63258Sbostic register u_int *addr;
3795*63258Sbostic register int nlwidth;
3796*63258Sbostic register int x;
3797*63258Sbostic register int len;
3798*63258Sbostic {
3799*63258Sbostic 	register u_int bitmask;
3800*63258Sbostic 
3801*63258Sbostic 	if (len < 0) {
3802*63258Sbostic 		nlwidth = -nlwidth;
3803*63258Sbostic 		len = -len;
3804*63258Sbostic 	}
3805*63258Sbostic 	if (lpf)
3806*63258Sbostic 		len++;
3807*63258Sbostic 	addr += (x >> 5);
3808*63258Sbostic 
3809*63258Sbostic 	bitmask = mfbmask32[x & 0x1f];
3810*63258Sbostic 
3811*63258Sbostic 	Duff(len, *addr |= bitmask; addr += nlwidth)
3812*63258Sbostic }
3813*63258Sbostic 
3814*63258Sbostic void
mfb_sethvector32(addr,x,len,lpf)3815*63258Sbostic mfb_sethvector32(addr, x, len, lpf)
3816*63258Sbostic register u_int *addr;
3817*63258Sbostic int x;
3818*63258Sbostic int len;
3819*63258Sbostic int lpf;
3820*63258Sbostic {
3821*63258Sbostic 	register u_int startmask;
3822*63258Sbostic 	register u_int endmask;
3823*63258Sbostic 	register int nl, off;
3824*63258Sbostic 
3825*63258Sbostic 	if (len < 0) {
3826*63258Sbostic 		x += len;
3827*63258Sbostic 		len = -len;
3828*63258Sbostic 		if (lpf) {
3829*63258Sbostic 			len++;
3830*63258Sbostic 		} else {
3831*63258Sbostic 			x++;
3832*63258Sbostic 		}
3833*63258Sbostic 	} else {
3834*63258Sbostic 		if (lpf) {
3835*63258Sbostic 			len++;
3836*63258Sbostic 		}
3837*63258Sbostic 	}
3838*63258Sbostic 	addr += (x >> 5);
3839*63258Sbostic 
3840*63258Sbostic 	off = x & 0x1f;
3841*63258Sbostic 	if (off + len < 32) {
3842*63258Sbostic 		*addr |= mfbpartmasks32[off][len & 0x1f];
3843*63258Sbostic 	} else {
3844*63258Sbostic 		startmask = mfbstarttab32[off];
3845*63258Sbostic 		endmask = mfbendtab32[(x + len) & 0x1f];
3846*63258Sbostic 		if (startmask) {
3847*63258Sbostic 			nl = (len - (32 - off)) >> 5;
3848*63258Sbostic 			*addr++ |= startmask;
3849*63258Sbostic 		} else
3850*63258Sbostic 			nl = len >> 5;
3851*63258Sbostic #ifdef mc68020
3852*63258Sbostic 		;
3853*63258Sbostic 		asm(" move.l #-1,d3");
3854*63258Sbostic 		Duff(nl, asm(" move.l d3,(a5)+"))
3855*63258Sbostic #else /* mc68020 */
3856*63258Sbostic 		Duff_single(nl, addr, = ~0);
3857*63258Sbostic #endif /* mc68020 */
3858*63258Sbostic 		if (endmask)
3859*63258Sbostic 			*addr |= endmask;
3860*63258Sbostic 	}
3861*63258Sbostic }
3862*63258Sbostic 
3863*63258Sbostic void
mfb_setvector32(fb,addr,ddy,p0,p1,lpf)3864*63258Sbostic mfb_setvector32(fb, addr, ddy, p0, p1, lpf)
3865*63258Sbostic struct fbdev	*fb;
3866*63258Sbostic register u_int *addr;
3867*63258Sbostic register int ddy;
3868*63258Sbostic register lPoint *p0, *p1;
3869*63258Sbostic int lpf;		/* if 0, don't draw last point */
3870*63258Sbostic {
3871*63258Sbostic 	register int i;
3872*63258Sbostic 	register int lim;
3873*63258Sbostic #ifdef mc68020
3874*63258Sbostic 	register int x = p0->x;
3875*63258Sbostic #else /* mc68020 */
3876*63258Sbostic 	register u_int bit, leftbit, rightbit;
3877*63258Sbostic #endif /* mc68020 */
3878*63258Sbostic 	int ddx;
3879*63258Sbostic 	int dx = p1->x - p0->x;
3880*63258Sbostic 	int dy = p1->y - p0->y;
3881*63258Sbostic 	int s, d, c;
3882*63258Sbostic 
3883*63258Sbostic 	ddx = 1;
3884*63258Sbostic 	addr += (p0->y * ddy);
3885*63258Sbostic 
3886*63258Sbostic 	if (dx == 0) {
3887*63258Sbostic 		mfb_setvvector32(addr, ddy, p0->x, dy, lpf);
3888*63258Sbostic 		return;
3889*63258Sbostic 	}
3890*63258Sbostic 	if (dy == 0) {
3891*63258Sbostic 		mfb_sethvector32(addr, p0->x, dx, lpf);
3892*63258Sbostic 		return;
3893*63258Sbostic 	}
3894*63258Sbostic 
3895*63258Sbostic 	if (dx < 0) {
3896*63258Sbostic 		dx = -dx;
3897*63258Sbostic 		ddx = -ddx;
3898*63258Sbostic 	}
3899*63258Sbostic 	if (dy < 0) {
3900*63258Sbostic 		dy = -dy;
3901*63258Sbostic 		ddy = -ddy;
3902*63258Sbostic 	}
3903*63258Sbostic 
3904*63258Sbostic #ifndef mc68020
3905*63258Sbostic 	bit = mfbmask32[p0->x & 0x1f];
3906*63258Sbostic 	leftbit = mfbmask32[0];
3907*63258Sbostic 	rightbit = mfbmask32[31];
3908*63258Sbostic 	addr += (p0->x >> 5);
3909*63258Sbostic #endif /* mc68020 */
3910*63258Sbostic 	if (dx > dy) {	/* case x */
3911*63258Sbostic 		lim = dx;
3912*63258Sbostic 		if (lpf)
3913*63258Sbostic 			lim++;
3914*63258Sbostic 
3915*63258Sbostic 		s = -dx;
3916*63258Sbostic 		d = dx << 1;
3917*63258Sbostic 		c = dy << 1;
3918*63258Sbostic 
3919*63258Sbostic 		if (ddx > 0) {
3920*63258Sbostic 			for (i = lim; i > 0; i--) {
3921*63258Sbostic #ifdef mc68020
3922*63258Sbostic 				asm("	bfset	(a5){d4:1}");
3923*63258Sbostic 				x++;
3924*63258Sbostic #else /* mc68020 */
3925*63258Sbostic 				*addr |= bit;
3926*63258Sbostic 				bit >>= 1;
3927*63258Sbostic 				if (!bit) {
3928*63258Sbostic 					bit = leftbit;
3929*63258Sbostic 					addr++;
3930*63258Sbostic 				}
3931*63258Sbostic #endif /* mc68020 */
3932*63258Sbostic 				if ((s += c) >= 0) {
3933*63258Sbostic 					s -= d;
3934*63258Sbostic 					addr += ddy;
3935*63258Sbostic 				}
3936*63258Sbostic 			}
3937*63258Sbostic 		} else {
3938*63258Sbostic 			for (i = lim; i > 0; i--) {
3939*63258Sbostic #ifdef mc68020
3940*63258Sbostic 				asm("	bfset	(a5){d4:1}");
3941*63258Sbostic 				x--;
3942*63258Sbostic #else /* mc68020 */
3943*63258Sbostic 				*addr |= bit;
3944*63258Sbostic 				bit <<= 1;
3945*63258Sbostic 				if (!bit) {
3946*63258Sbostic 					bit = rightbit;
3947*63258Sbostic 					addr--;
3948*63258Sbostic 				}
3949*63258Sbostic #endif /* mc68020 */
3950*63258Sbostic 				if ((s += c) >= 0) {
3951*63258Sbostic 					s -= d;
3952*63258Sbostic 					addr += ddy;
3953*63258Sbostic 				}
3954*63258Sbostic 			}
3955*63258Sbostic 		}
3956*63258Sbostic 	} else {			/* case y */
3957*63258Sbostic 		lim = dy;
3958*63258Sbostic 		if (lpf)
3959*63258Sbostic 			lim++;
3960*63258Sbostic 		s = -dy;
3961*63258Sbostic 		d = dy << 1;
3962*63258Sbostic 		c = dx << 1;
3963*63258Sbostic 
3964*63258Sbostic 		if (ddx > 0) {
3965*63258Sbostic 			for (i = lim; i > 0; i--) {
3966*63258Sbostic #ifdef mc68020
3967*63258Sbostic 				asm("	bfset	(a5){d4:1}");
3968*63258Sbostic 				if ((s += c) >= 0) {
3969*63258Sbostic 					s -= d;
3970*63258Sbostic 					x++;
3971*63258Sbostic 				}
3972*63258Sbostic #else /* mc68020 */
3973*63258Sbostic 				*addr |= bit;
3974*63258Sbostic 				if ((s += c) >= 0) {
3975*63258Sbostic 					s -= d;
3976*63258Sbostic 					bit >>= 1;
3977*63258Sbostic 					if (!bit) {
3978*63258Sbostic 						bit = leftbit;
3979*63258Sbostic 						addr++;
3980*63258Sbostic 					}
3981*63258Sbostic 				}
3982*63258Sbostic #endif /* mc68020 */
3983*63258Sbostic 				addr += ddy;
3984*63258Sbostic 			}
3985*63258Sbostic 		} else {
3986*63258Sbostic 			for (i = lim; i > 0; i--) {
3987*63258Sbostic #ifdef mc68020
3988*63258Sbostic 				asm("	bfset	(a5){d4:1}");
3989*63258Sbostic 				if ((s += c) >= 0) {
3990*63258Sbostic 					s -= d;
3991*63258Sbostic 					x--;
3992*63258Sbostic 				}
3993*63258Sbostic #else /* mc68020 */
3994*63258Sbostic 				*addr |= bit;
3995*63258Sbostic 				if ((s += c) >= 0) {
3996*63258Sbostic 					s -= d;
3997*63258Sbostic 					bit <<= 1;
3998*63258Sbostic 					if (!bit) {
3999*63258Sbostic 						bit = rightbit;
4000*63258Sbostic 						addr--;
4001*63258Sbostic 					}
4002*63258Sbostic 				}
4003*63258Sbostic #endif /* mc68020 */
4004*63258Sbostic 				addr += ddy;
4005*63258Sbostic 			}
4006*63258Sbostic 		}
4007*63258Sbostic 	}
4008*63258Sbostic }
4009*63258Sbostic 
4010*63258Sbostic void
mfb_point(p,x,s,f)4011*63258Sbostic mfb_point(p, x, s, f)
4012*63258Sbostic register u_int *p;
4013*63258Sbostic register int x;
4014*63258Sbostic register u_int s;
4015*63258Sbostic register char *f;
4016*63258Sbostic {
4017*63258Sbostic #ifdef mc68020
4018*63258Sbostic 	asm("	andi.l	#31, d7");
4019*63258Sbostic 	asm("	move.l	d7,d0");
4020*63258Sbostic 	asm("	neg.l	d7");
4021*63258Sbostic 	asm("	addi.l	#31, d7");
4022*63258Sbostic 
4023*63258Sbostic 	asm("	move.l	(a5), d1");
4024*63258Sbostic 	asm("	lsr.l	d7, d1");
4025*63258Sbostic 	asm("	andi.l	#1, d1");
4026*63258Sbostic 
4027*63258Sbostic 	asm("	andi.l	#1, d6");
4028*63258Sbostic 	asm("	lsl.l	#1, d6");
4029*63258Sbostic 	asm("	or.l	d6, d1");
4030*63258Sbostic 	asm("	neg.l	d1");
4031*63258Sbostic 	asm("	addq.l	#3, d1");
4032*63258Sbostic 
4033*63258Sbostic 	asm("	btst.b	d1, (a4)");
4034*63258Sbostic 	asm("	beq	bcl");
4035*63258Sbostic 	asm("	bfset	(a5){d0:1}");
4036*63258Sbostic 	asm("	bra	bend");
4037*63258Sbostic 	asm("bcl:	bfclr	(a5){d0:1}");
4038*63258Sbostic 	asm("bend:	");
4039*63258Sbostic #else /* mc68020 */
4040*63258Sbostic 	x = 31 - (x & 31);
4041*63258Sbostic 	if ((1 << (3 - (((s & 1) << 1) | ((*p >> x) & 1)))) & *f)
4042*63258Sbostic 		*p |= (1 << x);
4043*63258Sbostic 	else
4044*63258Sbostic 		*p &= ~(1 << x);
4045*63258Sbostic #endif /* mc68020 */
4046*63258Sbostic }
4047*63258Sbostic 
4048*63258Sbostic void
mfb_vector32(fb,addr,ddy,p0,p1,lpf)4049*63258Sbostic mfb_vector32(fb, addr, ddy, p0, p1, lpf)
4050*63258Sbostic struct fbdev	*fb;
4051*63258Sbostic register u_int *addr;
4052*63258Sbostic int	ddy;
4053*63258Sbostic register lPoint *p0, *p1;
4054*63258Sbostic int lpf;		/* if 0, don't draw last point */
4055*63258Sbostic {
4056*63258Sbostic 	register char *fp = fb->funcvec;
4057*63258Sbostic 	register int x = p0->x;
4058*63258Sbostic 	register u_int pat = fb->pat;
4059*63258Sbostic 	int lim;
4060*63258Sbostic 	register int i;
4061*63258Sbostic 	register int ddx;
4062*63258Sbostic 	int s, d, c;
4063*63258Sbostic 	int dx = p1->x - x;
4064*63258Sbostic 	int dy = p1->y - p0->y;
4065*63258Sbostic 
4066*63258Sbostic 	ddx = 1;
4067*63258Sbostic 	addr += (p0->y * ddy);
4068*63258Sbostic 
4069*63258Sbostic 	if (dx == 0) {
4070*63258Sbostic 		ddx = 0;
4071*63258Sbostic 	} else if (dx < 0) {
4072*63258Sbostic 		dx = -dx;
4073*63258Sbostic 		ddx = -ddx;
4074*63258Sbostic 	}
4075*63258Sbostic 
4076*63258Sbostic 	if (dy == 0)
4077*63258Sbostic 		ddy = 0;
4078*63258Sbostic 	else if (dy < 0) {
4079*63258Sbostic 		dy = -dy;
4080*63258Sbostic 		ddy = -ddy;
4081*63258Sbostic 	}
4082*63258Sbostic 
4083*63258Sbostic 	if (dx > dy) {			/* case x */
4084*63258Sbostic 		lim = dx;
4085*63258Sbostic 		if (lpf)
4086*63258Sbostic 			lim++;
4087*63258Sbostic 
4088*63258Sbostic 		s = -dx;
4089*63258Sbostic 		d = dx << 1;
4090*63258Sbostic 		c = dy << 1;
4091*63258Sbostic 
4092*63258Sbostic 		for (i = lim; i > 0; i--) {
4093*63258Sbostic #ifdef mc68020
4094*63258Sbostic 			asm(" rol.l	#1, d6 ");
4095*63258Sbostic #else /* mc68020 */
4096*63258Sbostic 			pat = (pat << 1) | ((pat & 0x80000000) ? 1: 0);
4097*63258Sbostic #endif /* mc68020 */
4098*63258Sbostic 			mfb_point(addr + (x >> 5), x, pat, fp);
4099*63258Sbostic 
4100*63258Sbostic 			if ((s += c) >= 0) {
4101*63258Sbostic 				s -= d;
4102*63258Sbostic 				addr += ddy;
4103*63258Sbostic 			}
4104*63258Sbostic 
4105*63258Sbostic 			x += ddx;
4106*63258Sbostic 		}
4107*63258Sbostic 	} else {			/* case y */
4108*63258Sbostic 		lim = dy;
4109*63258Sbostic 		if (lpf)
4110*63258Sbostic 			lim++;
4111*63258Sbostic 		s = -dy;
4112*63258Sbostic 		d = dy << 1;
4113*63258Sbostic 		c = dx << 1;
4114*63258Sbostic 
4115*63258Sbostic 		for (i = lim; i > 0; i--) {
4116*63258Sbostic #ifdef mc68020
4117*63258Sbostic 			asm(" rol.l	#1, d6 ");
4118*63258Sbostic #else /* mc68020 */
4119*63258Sbostic 			pat = (pat << 1) | ((pat & 0x80000000) ? 1: 0);
4120*63258Sbostic #endif /* mc68020 */
4121*63258Sbostic 			mfb_point(addr + (x >> 5), x, pat, fp);
4122*63258Sbostic 
4123*63258Sbostic 			if ((s += c) >= 0) {
4124*63258Sbostic 				s -= d;
4125*63258Sbostic 				x += ddx;
4126*63258Sbostic 			}
4127*63258Sbostic 
4128*63258Sbostic 			addr += ddy;
4129*63258Sbostic 		}
4130*63258Sbostic 	}
4131*63258Sbostic 
4132*63258Sbostic 	/* rotate pattern */
4133*63258Sbostic 	pat = fb->pat;
4134*63258Sbostic 
4135*63258Sbostic #ifdef mc68020
4136*63258Sbostic 	asm("	move.l	(-8, fp), d0");
4137*63258Sbostic 	asm("	andi.l	#31, d0");
4138*63258Sbostic 	asm("	rol.l	d0, d6");
4139*63258Sbostic #else /* mc68020 */
4140*63258Sbostic 	{
4141*63258Sbostic 		register int tmp;
4142*63258Sbostic 
4143*63258Sbostic 		tmp = lim & 31;
4144*63258Sbostic 		pat = (pat << tmp) | (pat >> (32 - tmp));
4145*63258Sbostic 	}
4146*63258Sbostic #endif /* mc68020 */
4147*63258Sbostic 
4148*63258Sbostic 	fb->pat = pat;
4149*63258Sbostic }
4150*63258Sbostic 
4151*63258Sbostic void
mem_to_mem(func,mapSrc,offSrc,widthSrc,mapDst,offDst,widthDst,sr,dp)4152*63258Sbostic mem_to_mem(func, mapSrc, offSrc, widthSrc, mapDst, offDst, widthDst, sr, dp)
4153*63258Sbostic int		func;
4154*63258Sbostic struct fb_map	*mapSrc;
4155*63258Sbostic int		offSrc;
4156*63258Sbostic u_int		widthSrc;
4157*63258Sbostic struct fb_map	*mapDst;
4158*63258Sbostic int		offDst;
4159*63258Sbostic u_int		widthDst;
4160*63258Sbostic register lRectangle *sr;	/* source rectangle */
4161*63258Sbostic register lPoint	 *dp;	/* destination point */
4162*63258Sbostic {
4163*63258Sbostic 	register u_short *addrSrc;
4164*63258Sbostic 	register u_short *addrDst;
4165*63258Sbostic 
4166*63258Sbostic 	addrSrc = (u_short *)TypeAt(mapSrc, offSrc);
4167*63258Sbostic 	addrDst = (u_short *)TypeAt(mapDst, offDst);
4168*63258Sbostic 
4169*63258Sbostic 	if ((!((u_int)addrSrc & 3) && !(widthSrc & 1)) &&
4170*63258Sbostic 	    (!((u_int)addrDst & 3) && !(widthDst & 1))) {
4171*63258Sbostic 		switch (func) {
4172*63258Sbostic 
4173*63258Sbostic 		case BF_0:
4174*63258Sbostic 			mfb_clr_area32(dp->x, dp->y,
4175*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, widthDst / 2);
4176*63258Sbostic 			break;
4177*63258Sbostic 		case BF_S:
4178*63258Sbostic 			mfb_copy_area32(addrSrc, addrDst,
4179*63258Sbostic 			    widthSrc / 2, widthDst / 2, sr, dp);
4180*63258Sbostic 			break;
4181*63258Sbostic 		case BF_D:
4182*63258Sbostic 			break;
4183*63258Sbostic 		case BF_SDX:
4184*63258Sbostic 			mfb_xor_area32(addrSrc, addrDst,
4185*63258Sbostic 			    widthSrc / 2, widthDst / 2, sr, dp);
4186*63258Sbostic 			break;
4187*63258Sbostic 		case BF_SDO:
4188*63258Sbostic 			mfb_or_area32(addrSrc, addrDst,
4189*63258Sbostic 			    widthSrc / 2, widthDst / 2, sr, dp);
4190*63258Sbostic 			break;
4191*63258Sbostic 		case BF_DI:
4192*63258Sbostic 			mfb_inv_area32(dp->x, dp->y,
4193*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, widthDst / 2);
4194*63258Sbostic 			break;
4195*63258Sbostic 		case BF_SI:
4196*63258Sbostic 			mfb_copyinv_area32(addrSrc, addrDst,
4197*63258Sbostic 			    widthSrc / 2, widthDst / 2, sr, dp);
4198*63258Sbostic 			break;
4199*63258Sbostic 		case BF_1:
4200*63258Sbostic 			mfb_set_area32(dp->x, dp->y,
4201*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, widthDst / 2);
4202*63258Sbostic 			break;
4203*63258Sbostic 		default:
4204*63258Sbostic 			mfb_general_area32(func, addrSrc, addrDst,
4205*63258Sbostic 			    widthSrc / 2, widthDst / 2, sr, dp);
4206*63258Sbostic 			break;
4207*63258Sbostic 		}
4208*63258Sbostic 	} else {
4209*63258Sbostic 		switch (func) {
4210*63258Sbostic 
4211*63258Sbostic 		case BF_0:
4212*63258Sbostic 			mfb_clr_area16(dp->x, dp->y,
4213*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, widthDst);
4214*63258Sbostic 			break;
4215*63258Sbostic 		case BF_S:
4216*63258Sbostic 			mfb_copy_area16(addrSrc, addrDst,
4217*63258Sbostic 			    widthSrc, widthDst, sr, dp);
4218*63258Sbostic 			break;
4219*63258Sbostic 		case BF_D:
4220*63258Sbostic 			break;
4221*63258Sbostic 		case BF_SDX:
4222*63258Sbostic 			mfb_xor_area16(addrSrc, addrDst,
4223*63258Sbostic 			    widthSrc, widthDst, sr, dp);
4224*63258Sbostic 			break;
4225*63258Sbostic 		case BF_SDO:
4226*63258Sbostic 			mfb_or_area16(addrSrc, addrDst,
4227*63258Sbostic 			    widthSrc, widthDst, sr, dp);
4228*63258Sbostic 			break;
4229*63258Sbostic 		case BF_DI:
4230*63258Sbostic 			mfb_inv_area16(dp->x, dp->y,
4231*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, widthDst);
4232*63258Sbostic 			break;
4233*63258Sbostic 		case BF_SI:
4234*63258Sbostic 			mfb_copyinv_area16(addrSrc, addrDst,
4235*63258Sbostic 			    widthSrc, widthDst, sr, dp);
4236*63258Sbostic 			break;
4237*63258Sbostic 		case BF_1:
4238*63258Sbostic 			mfb_set_area16(dp->x, dp->y,
4239*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, widthDst);
4240*63258Sbostic 			break;
4241*63258Sbostic 		default:
4242*63258Sbostic 			mfb_general_area16(func, addrSrc, addrDst,
4243*63258Sbostic 			    widthSrc, widthDst, sr, dp);
4244*63258Sbostic 			break;
4245*63258Sbostic 		}
4246*63258Sbostic 	}
4247*63258Sbostic }
4248*63258Sbostic 
4249*63258Sbostic void
mem_clear(func,map,offset,width,dr,mode)4250*63258Sbostic mem_clear(func, map, offset, width, dr, mode)
4251*63258Sbostic register int	func;
4252*63258Sbostic struct fb_map	*map;
4253*63258Sbostic int		offset;
4254*63258Sbostic u_int		width;
4255*63258Sbostic register lRectangle *dr;
4256*63258Sbostic int		mode;
4257*63258Sbostic {
4258*63258Sbostic 	u_short *addr;
4259*63258Sbostic 
4260*63258Sbostic 	if (!mode)
4261*63258Sbostic 		func >>= 2;
4262*63258Sbostic 	func &= 0x3;
4263*63258Sbostic 
4264*63258Sbostic 	addr = (u_short *)TypeAt(map, offset);
4265*63258Sbostic 
4266*63258Sbostic 	if (!((u_int)addr & 3) && !(width & 1)) {
4267*63258Sbostic 		switch (func) {
4268*63258Sbostic 
4269*63258Sbostic 		case 0:
4270*63258Sbostic 			mfb_clr_area32(dr->origin.x, dr->origin.y,
4271*63258Sbostic 			    dr->extent.x, dr->extent.y, addr, width / 2);
4272*63258Sbostic 			break;
4273*63258Sbostic 		case 2:
4274*63258Sbostic 			mfb_inv_area32(dr->origin.x, dr->origin.y,
4275*63258Sbostic 			    dr->extent.x, dr->extent.y, addr, width / 2);
4276*63258Sbostic 			break;
4277*63258Sbostic 		case 3:
4278*63258Sbostic 			mfb_set_area32(dr->origin.x, dr->origin.y,
4279*63258Sbostic 			    dr->extent.x, dr->extent.y, addr, width / 2);
4280*63258Sbostic 			break;
4281*63258Sbostic 		}
4282*63258Sbostic 	} else {
4283*63258Sbostic 		switch (func) {
4284*63258Sbostic 
4285*63258Sbostic 		case 0:
4286*63258Sbostic 			mfb_clr_area16(dr->origin.x, dr->origin.y,
4287*63258Sbostic 			    dr->extent.x, dr->extent.y, addr, width);
4288*63258Sbostic 			break;
4289*63258Sbostic 		case 2:
4290*63258Sbostic 			mfb_inv_area16(dr->origin.x, dr->origin.y,
4291*63258Sbostic 			    dr->extent.x, dr->extent.y, addr, width);
4292*63258Sbostic 			break;
4293*63258Sbostic 		case 3:
4294*63258Sbostic 			mfb_set_area16(dr->origin.x, dr->origin.y,
4295*63258Sbostic 			    dr->extent.x, dr->extent.y, addr, width);
4296*63258Sbostic 			break;
4297*63258Sbostic 		}
4298*63258Sbostic 	}
4299*63258Sbostic }
4300*63258Sbostic 
4301*63258Sbostic #ifdef CPU_SINGLE
4302*63258Sbostic #define	VRAM_START(fb)		(((struct mfbdev *)(fb)->private)->vram_start)
4303*63258Sbostic #define	VRAM_WIDTH(fb)		(((struct mfbdev *)(fb)->private)->vram_width)
4304*63258Sbostic 
4305*63258Sbostic fbmem_rop_init(fb, func)
4306*63258Sbostic struct fbdev	*fb;
4307*63258Sbostic char	*func;
4308*63258Sbostic {
4309*63258Sbostic 	fb->func = *func;
4310*63258Sbostic }
4311*63258Sbostic 
4312*63258Sbostic void
fbmem_rop_winit(fb)4313*63258Sbostic fbmem_rop_winit(fb)
4314*63258Sbostic struct fbdev	*fb;
4315*63258Sbostic {
4316*63258Sbostic }
4317*63258Sbostic 
4318*63258Sbostic void
fbmem_rop_copy(fb,sr,dp,mode,wmask)4319*63258Sbostic fbmem_rop_copy(fb, sr, dp, mode, wmask)
4320*63258Sbostic register struct fbdev	*fb;
4321*63258Sbostic register lRectangle	*sr;	/* source rectangle */
4322*63258Sbostic register lPoint		*dp;	/* destination point */
4323*63258Sbostic {
4324*63258Sbostic 	if (!(wmask & 1)) {
4325*63258Sbostic 		return;
4326*63258Sbostic 	}
4327*63258Sbostic 
4328*63258Sbostic 	switch (fb->func) {
4329*63258Sbostic 	case BF_0:
4330*63258Sbostic 		mfb_clr_area32(dp->x, dp->y,
4331*63258Sbostic 		    sr->extent.x, sr->extent.y, VRAM_START(fb), VRAM_WIDTH(fb));
4332*63258Sbostic 		break;
4333*63258Sbostic 	case BF_S:
4334*63258Sbostic 		mfb_copy_area32(VRAM_START(fb), VRAM_START(fb),
4335*63258Sbostic 		    VRAM_WIDTH(fb), VRAM_WIDTH(fb), sr, dp);
4336*63258Sbostic 		break;
4337*63258Sbostic 	case BF_D:
4338*63258Sbostic 		break;
4339*63258Sbostic 	case BF_SDX:
4340*63258Sbostic 		mfb_xor_area32(VRAM_START(fb), VRAM_START(fb),
4341*63258Sbostic 		    VRAM_WIDTH(fb), VRAM_WIDTH(fb), sr, dp);
4342*63258Sbostic 		break;
4343*63258Sbostic 	case BF_SDO:
4344*63258Sbostic 		mfb_or_area32(VRAM_START(fb), VRAM_START(fb),
4345*63258Sbostic 		    VRAM_WIDTH(fb), VRAM_WIDTH(fb), sr, dp);
4346*63258Sbostic 		break;
4347*63258Sbostic 	case BF_DI:
4348*63258Sbostic 		mfb_inv_area32(dp->x, dp->y,
4349*63258Sbostic 		    sr->extent.x, sr->extent.y, VRAM_START(fb), VRAM_WIDTH(fb));
4350*63258Sbostic 		break;
4351*63258Sbostic 	case BF_SI:
4352*63258Sbostic 		mfb_copyinv_area32(VRAM_START(fb), VRAM_START(fb),
4353*63258Sbostic 		    VRAM_WIDTH(fb), VRAM_WIDTH(fb), sr, dp);
4354*63258Sbostic 		break;
4355*63258Sbostic 	case BF_1:
4356*63258Sbostic 		mfb_set_area32(dp->x, dp->y,
4357*63258Sbostic 		    sr->extent.x, sr->extent.y, VRAM_START(fb), VRAM_WIDTH(fb));
4358*63258Sbostic 		break;
4359*63258Sbostic 	default:
4360*63258Sbostic 		mfb_general_area32(fb->func, VRAM_START(fb), VRAM_START(fb),
4361*63258Sbostic 		    VRAM_WIDTH(fb), VRAM_WIDTH(fb), sr, dp);
4362*63258Sbostic 		break;
4363*63258Sbostic 	}
4364*63258Sbostic }
4365*63258Sbostic 
4366*63258Sbostic void
fbmem_rop_read(fb,map,offset,width,sr,dp,rplane,wplane)4367*63258Sbostic fbmem_rop_read(fb, map, offset, width, sr, dp, rplane, wplane)
4368*63258Sbostic register struct fbdev	*fb;
4369*63258Sbostic struct fb_map	*map;
4370*63258Sbostic u_int		offset;
4371*63258Sbostic u_int		width;
4372*63258Sbostic register lRectangle *sr;	/* source rectangle */
4373*63258Sbostic register lPoint	*dp;	/* destination point */
4374*63258Sbostic int		rplane;
4375*63258Sbostic int		wplane;
4376*63258Sbostic {
4377*63258Sbostic 	register u_short *addrDst;
4378*63258Sbostic 
4379*63258Sbostic 	addrDst = (u_short *)TypeAt(map, offset);
4380*63258Sbostic 
4381*63258Sbostic 	if (!((u_int)addrDst & 3) && !(width & 1)) {
4382*63258Sbostic 		switch (fb->funcvec[wplane]) {
4383*63258Sbostic 		case BF_0:
4384*63258Sbostic 			mfb_clr_area32(dp->x, dp->y,
4385*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, width / 2);
4386*63258Sbostic 			break;
4387*63258Sbostic 		case BF_S:
4388*63258Sbostic 			mfb_copy_area32(VRAM_START(fb), addrDst,
4389*63258Sbostic 			    VRAM_WIDTH(fb), width / 2, sr, dp);
4390*63258Sbostic 			break;
4391*63258Sbostic 		case BF_D:
4392*63258Sbostic 			break;
4393*63258Sbostic 		case BF_SDX:
4394*63258Sbostic 			mfb_xor_area32(VRAM_START(fb), addrDst,
4395*63258Sbostic 			    VRAM_WIDTH(fb), width / 2, sr, dp);
4396*63258Sbostic 			break;
4397*63258Sbostic 		case BF_SDO:
4398*63258Sbostic 			mfb_or_area32(VRAM_START(fb), addrDst,
4399*63258Sbostic 			    VRAM_WIDTH(fb), width / 2, sr, dp);
4400*63258Sbostic 			break;
4401*63258Sbostic 		case BF_DI:
4402*63258Sbostic 			mfb_inv_area32(dp->x, dp->y,
4403*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, width / 2);
4404*63258Sbostic 			break;
4405*63258Sbostic 		case BF_SI:
4406*63258Sbostic 			mfb_copyinv_area32(VRAM_START(fb), addrDst,
4407*63258Sbostic 			    VRAM_WIDTH(fb), width / 2, sr, dp);
4408*63258Sbostic 			break;
4409*63258Sbostic 		case BF_1:
4410*63258Sbostic 			mfb_set_area32(dp->x, dp->y,
4411*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, width / 2);
4412*63258Sbostic 			break;
4413*63258Sbostic 		default:
4414*63258Sbostic 			mfb_general_area32(fb->funcvec[wplane], VRAM_START(fb),
4415*63258Sbostic 			    addrDst, VRAM_WIDTH(fb), width/2, sr, dp);
4416*63258Sbostic 			break;
4417*63258Sbostic 		}
4418*63258Sbostic 	} else {
4419*63258Sbostic 		switch (fb->funcvec[wplane]) {
4420*63258Sbostic 		case BF_0:
4421*63258Sbostic 			mfb_clr_area16(dp->x, dp->y,
4422*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, width);
4423*63258Sbostic 			break;
4424*63258Sbostic 		case BF_S:
4425*63258Sbostic 			mfb_copy_area16(VRAM_START(fb), addrDst,
4426*63258Sbostic 			    VRAM_WIDTH(fb) * 2, width, sr, dp);
4427*63258Sbostic 			break;
4428*63258Sbostic 		case BF_D:
4429*63258Sbostic 			break;
4430*63258Sbostic 		case BF_SDX:
4431*63258Sbostic 			mfb_xor_area16(VRAM_START(fb), addrDst,
4432*63258Sbostic 			    VRAM_WIDTH(fb) * 2, width, sr, dp);
4433*63258Sbostic 			break;
4434*63258Sbostic 		case BF_SDO:
4435*63258Sbostic 			mfb_or_area16(VRAM_START(fb), addrDst,
4436*63258Sbostic 			    VRAM_WIDTH(fb) * 2, width, sr, dp);
4437*63258Sbostic 			break;
4438*63258Sbostic 		case BF_DI:
4439*63258Sbostic 			mfb_inv_area16(dp->x, dp->y,
4440*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, width);
4441*63258Sbostic 			break;
4442*63258Sbostic 		case BF_SI:
4443*63258Sbostic 			mfb_copyinv_area16(VRAM_START(fb), addrDst,
4444*63258Sbostic 			    VRAM_WIDTH(fb) * 2, width, sr, dp);
4445*63258Sbostic 			break;
4446*63258Sbostic 		case BF_1:
4447*63258Sbostic 			mfb_set_area16(dp->x, dp->y,
4448*63258Sbostic 			    sr->extent.x, sr->extent.y, addrDst, width);
4449*63258Sbostic 			break;
4450*63258Sbostic 		default:
4451*63258Sbostic 			mfb_general_area16(fb->funcvec[wplane], VRAM_START(fb),
4452*63258Sbostic 			    addrDst, VRAM_WIDTH(fb)*2, width, sr, dp);
4453*63258Sbostic 			break;
4454*63258Sbostic 		}
4455*63258Sbostic 	}
4456*63258Sbostic }
4457*63258Sbostic 
4458*63258Sbostic void
fbmem_rop_write(fb,map,offset,width,sr,dp,wmask)4459*63258Sbostic fbmem_rop_write(fb, map, offset, width, sr, dp, wmask)
4460*63258Sbostic register struct fbdev *fb;
4461*63258Sbostic struct fb_map	*map;
4462*63258Sbostic int		offset;
4463*63258Sbostic u_int		width;
4464*63258Sbostic register lRectangle *sr;	/* source rectangle */
4465*63258Sbostic register lPoint	*dp;	/* destination point */
4466*63258Sbostic int		wmask;
4467*63258Sbostic {
4468*63258Sbostic 	register u_short *addrSrc;
4469*63258Sbostic 
4470*63258Sbostic 	addrSrc = (u_short *)TypeAt(map, offset);
4471*63258Sbostic 
4472*63258Sbostic 	if (!(wmask & 1)) {
4473*63258Sbostic 		return;
4474*63258Sbostic 	}
4475*63258Sbostic 
4476*63258Sbostic 	if (!((u_int)addrSrc & 3) && !(width & 1)) {
4477*63258Sbostic 		switch (fb->funcvec[0]) {
4478*63258Sbostic 
4479*63258Sbostic 		case BF_0:
4480*63258Sbostic 			mfb_clr_area32(dp->x, dp->y,
4481*63258Sbostic 			    sr->extent.x, sr->extent.y,
4482*63258Sbostic 			    VRAM_START(fb), VRAM_WIDTH(fb));
4483*63258Sbostic 			break;
4484*63258Sbostic 		case BF_S:
4485*63258Sbostic 			mfb_copy_area32(addrSrc, VRAM_START(fb),
4486*63258Sbostic 			    width / 2, VRAM_WIDTH(fb), sr, dp);
4487*63258Sbostic 			break;
4488*63258Sbostic 		case BF_D:
4489*63258Sbostic 			break;
4490*63258Sbostic 		case BF_SDX:
4491*63258Sbostic 			mfb_xor_area32(addrSrc, VRAM_START(fb),
4492*63258Sbostic 			    width / 2, VRAM_WIDTH(fb), sr, dp);
4493*63258Sbostic 			break;
4494*63258Sbostic 		case BF_SDO:
4495*63258Sbostic 			mfb_or_area32(addrSrc, VRAM_START(fb),
4496*63258Sbostic 			    width / 2, VRAM_WIDTH(fb), sr, dp);
4497*63258Sbostic 			break;
4498*63258Sbostic 		case BF_DI:
4499*63258Sbostic 			mfb_inv_area32(dp->x, dp->y,
4500*63258Sbostic 			    sr->extent.x, sr->extent.y,
4501*63258Sbostic 			    VRAM_START(fb), VRAM_WIDTH(fb));
4502*63258Sbostic 			break;
4503*63258Sbostic 		case BF_SI:
4504*63258Sbostic 			mfb_copyinv_area32(addrSrc, VRAM_START(fb),
4505*63258Sbostic 			    width / 2, VRAM_WIDTH(fb), sr, dp);
4506*63258Sbostic 			break;
4507*63258Sbostic 		case BF_1:
4508*63258Sbostic 			mfb_set_area32(dp->x, dp->y,
4509*63258Sbostic 			    sr->extent.x, sr->extent.y,
4510*63258Sbostic 			    VRAM_START(fb), VRAM_WIDTH(fb));
4511*63258Sbostic 			break;
4512*63258Sbostic 		default:
4513*63258Sbostic 			mfb_general_area32(fb->funcvec[0], addrSrc,
4514*63258Sbostic 			    VRAM_START(fb), width / 2, VRAM_WIDTH(fb), sr, dp);
4515*63258Sbostic 			break;
4516*63258Sbostic 		}
4517*63258Sbostic 	} else {
4518*63258Sbostic 		switch (fb->funcvec[0]) {
4519*63258Sbostic 		case BF_0:
4520*63258Sbostic 			mfb_clr_area32(dp->x, dp->y,
4521*63258Sbostic 			    sr->extent.x, sr->extent.y,
4522*63258Sbostic 			    VRAM_START(fb), VRAM_WIDTH(fb));
4523*63258Sbostic 			break;
4524*63258Sbostic 		case BF_S:
4525*63258Sbostic 			mfb_copy_area16(addrSrc, VRAM_START(fb),
4526*63258Sbostic 			    width, VRAM_WIDTH(fb) * 2, sr, dp);
4527*63258Sbostic 			break;
4528*63258Sbostic 		case BF_D:
4529*63258Sbostic 			break;
4530*63258Sbostic 		case BF_SDX:
4531*63258Sbostic 			mfb_xor_area16(addrSrc, VRAM_START(fb),
4532*63258Sbostic 			    width, VRAM_WIDTH(fb) * 2, sr, dp);
4533*63258Sbostic 			break;
4534*63258Sbostic 		case BF_SDO:
4535*63258Sbostic 			mfb_or_area16(addrSrc, VRAM_START(fb),
4536*63258Sbostic 			    width, VRAM_WIDTH(fb) * 2, sr, dp);
4537*63258Sbostic 			break;
4538*63258Sbostic 		case BF_DI:
4539*63258Sbostic 			mfb_inv_area32(dp->x, dp->y,
4540*63258Sbostic 			    sr->extent.x, sr->extent.y,
4541*63258Sbostic 			    VRAM_START(fb), VRAM_WIDTH(fb));
4542*63258Sbostic 			break;
4543*63258Sbostic 		case BF_SI:
4544*63258Sbostic 			mfb_copyinv_area16(addrSrc, VRAM_START(fb),
4545*63258Sbostic 			    width, VRAM_WIDTH(fb) * 2, sr, dp);
4546*63258Sbostic 			break;
4547*63258Sbostic 		case BF_1:
4548*63258Sbostic 			mfb_set_area32(dp->x, dp->y,
4549*63258Sbostic 			    sr->extent.x, sr->extent.y,
4550*63258Sbostic 			    VRAM_START(fb), VRAM_WIDTH(fb));
4551*63258Sbostic 			break;
4552*63258Sbostic 		default:
4553*63258Sbostic 			mfb_general_area16(fb->funcvec[0], addrSrc,
4554*63258Sbostic 			    VRAM_START(fb), width, VRAM_WIDTH(fb) * 2, sr, dp);
4555*63258Sbostic 			break;
4556*63258Sbostic 		}
4557*63258Sbostic 	}
4558*63258Sbostic }
4559*63258Sbostic 
4560*63258Sbostic void
fbmem_rop_cinit(fb,wplane,sw)4561*63258Sbostic fbmem_rop_cinit(fb, wplane, sw)
4562*63258Sbostic struct fbdev	*fb;
4563*63258Sbostic {
4564*63258Sbostic 	fb->Pmask = wplane;
4565*63258Sbostic 	fb->Mode = sw;
4566*63258Sbostic }
4567*63258Sbostic 
4568*63258Sbostic void
fbmem_rop_clear(fb,dr)4569*63258Sbostic fbmem_rop_clear(fb, dr)
4570*63258Sbostic register struct fbdev *fb;
4571*63258Sbostic register lRectangle *dr;
4572*63258Sbostic {
4573*63258Sbostic 	register int func;
4574*63258Sbostic 
4575*63258Sbostic 	if (!(fb->Pmask & 1)) {
4576*63258Sbostic 		return;
4577*63258Sbostic 	}
4578*63258Sbostic 	func = fb->funcvec[0];
4579*63258Sbostic 	if (!fb->Mode)
4580*63258Sbostic 		func >>= 2;
4581*63258Sbostic 	func &= 3;
4582*63258Sbostic 
4583*63258Sbostic 	switch (func) {
4584*63258Sbostic 	case 0:
4585*63258Sbostic 		mfb_clr_area32(dr->origin.x, dr->origin.y,
4586*63258Sbostic 		    dr->extent.x, dr->extent.y, VRAM_START(fb), VRAM_WIDTH(fb));
4587*63258Sbostic 		break;
4588*63258Sbostic 	case 2:
4589*63258Sbostic 		mfb_inv_area32(dr->origin.x, dr->origin.y,
4590*63258Sbostic 		    dr->extent.x, dr->extent.y, VRAM_START(fb), VRAM_WIDTH(fb));
4591*63258Sbostic 		break;
4592*63258Sbostic 	case 3:
4593*63258Sbostic 		mfb_set_area32(dr->origin.x, dr->origin.y,
4594*63258Sbostic 		    dr->extent.x, dr->extent.y, VRAM_START(fb), VRAM_WIDTH(fb));
4595*63258Sbostic 		break;
4596*63258Sbostic 	}
4597*63258Sbostic }
4598*63258Sbostic 
4599*63258Sbostic void
fbmem_rop_vect(fb,clip,ropf,forc,auxc,transp,wplane,np,ps,lptn,lpf,joint)4600*63258Sbostic fbmem_rop_vect(fb, clip, ropf, forc, auxc, transp, wplane,
4601*63258Sbostic 						np, ps, lptn, lpf, joint)
4602*63258Sbostic register struct fbdev *fb;
4603*63258Sbostic register lRectangle *clip;
4604*63258Sbostic int ropf, forc, auxc, transp;
4605*63258Sbostic register int np;
4606*63258Sbostic register lPoint *ps;
4607*63258Sbostic register u_int lptn;
4608*63258Sbostic {
4609*63258Sbostic 	lPoint p0, p1;
4610*63258Sbostic 	register void (*line_func)();
4611*63258Sbostic 	register int func;
4612*63258Sbostic 
4613*63258Sbostic 	if (!(wplane & 1))
4614*63258Sbostic 		return;
4615*63258Sbostic 	linerop(fb, ropf, forc, auxc, transp);
4616*63258Sbostic 	func = fb->funcvec[0];
4617*63258Sbostic 	if (lptn == 0xffffffff || lptn == 0) {
4618*63258Sbostic 		if (!lptn)
4619*63258Sbostic 			func >>= 2;
4620*63258Sbostic 		switch (func & 3) {
4621*63258Sbostic 		case 0:
4622*63258Sbostic 			line_func = mfb_clrvector32;
4623*63258Sbostic 			break;
4624*63258Sbostic 		case 1:
4625*63258Sbostic 			return;
4626*63258Sbostic 		case 2:
4627*63258Sbostic 			line_func = mfb_invvector32;
4628*63258Sbostic 			break;
4629*63258Sbostic 		default:
4630*63258Sbostic 			line_func = mfb_setvector32;
4631*63258Sbostic 			break;
4632*63258Sbostic 		}
4633*63258Sbostic 	} else
4634*63258Sbostic 		line_func = mfb_vector32;
4635*63258Sbostic 	if (joint) {
4636*63258Sbostic 		fb->pat = lptn;
4637*63258Sbostic 		p0 = *ps++;
4638*63258Sbostic 		np--;
4639*63258Sbostic 		if (clip) {
4640*63258Sbostic 			while (--np > 0) {
4641*63258Sbostic 				p1 = *ps;
4642*63258Sbostic 				if (lineclip(&p0, &p1, clip)) {
4643*63258Sbostic 					(*line_func)(fb,
4644*63258Sbostic 						VRAM_START(fb), VRAM_WIDTH(fb),
4645*63258Sbostic 						&p0, &p1,
4646*63258Sbostic 						ps->x != p1.x || ps->y != p1.y);
4647*63258Sbostic 				}
4648*63258Sbostic 				p0 = *ps++;
4649*63258Sbostic 			}
4650*63258Sbostic 			p1 = *ps;
4651*63258Sbostic 			if (lineclip(&p0, &p1, clip)) {
4652*63258Sbostic 				(*line_func)(fb, VRAM_START(fb), VRAM_WIDTH(fb),
4653*63258Sbostic 					&p0, &p1,
4654*63258Sbostic 					ps->x != p1.x || ps->y != p1.y || lpf);
4655*63258Sbostic 			}
4656*63258Sbostic 		} else {
4657*63258Sbostic 			while (--np > 0) {
4658*63258Sbostic 				p1 = *ps;
4659*63258Sbostic 				(*line_func)(fb, VRAM_START(fb), VRAM_WIDTH(fb),
4660*63258Sbostic 					&p0, &p1, 0);
4661*63258Sbostic 				p0 = *ps++;
4662*63258Sbostic 			}
4663*63258Sbostic 			p1 = *ps;
4664*63258Sbostic 			(*line_func)(fb, VRAM_START(fb), VRAM_WIDTH(fb),
4665*63258Sbostic 				&p0, &p1, lpf);
4666*63258Sbostic 		}
4667*63258Sbostic 	} else {
4668*63258Sbostic 		np >>= 1;
4669*63258Sbostic 		if (lpf) {
4670*63258Sbostic 			if (clip) {
4671*63258Sbostic 				while (--np >= 0) {
4672*63258Sbostic 					p0 = *ps++;
4673*63258Sbostic 					p1 = *ps++;
4674*63258Sbostic 					fb->pat = lptn;
4675*63258Sbostic 					if (lineclip(&p0, &p1, clip)) {
4676*63258Sbostic 						(*line_func)(fb,
4677*63258Sbostic 							VRAM_START(fb),
4678*63258Sbostic 							VRAM_WIDTH(fb),
4679*63258Sbostic 							&p0, &p1, 1);
4680*63258Sbostic 					}
4681*63258Sbostic 				}
4682*63258Sbostic 			} else {
4683*63258Sbostic 				while (--np >= 0) {
4684*63258Sbostic 					p0 = *ps++;
4685*63258Sbostic 					p1 = *ps++;
4686*63258Sbostic 					fb->pat = lptn;
4687*63258Sbostic 					(*line_func)(fb,
4688*63258Sbostic 						VRAM_START(fb), VRAM_WIDTH(fb),
4689*63258Sbostic 						&p0, &p1, 1);
4690*63258Sbostic 				}
4691*63258Sbostic 			}
4692*63258Sbostic 		} else {
4693*63258Sbostic 			if (clip) {
4694*63258Sbostic 				while (--np >= 0) {
4695*63258Sbostic 					p0 = *ps++;
4696*63258Sbostic 					p1 = *ps;
4697*63258Sbostic 					fb->pat = lptn;
4698*63258Sbostic 					if (lineclip(&p0, &p1, clip)) {
4699*63258Sbostic 						(*line_func)(fb,
4700*63258Sbostic 							VRAM_START(fb),
4701*63258Sbostic 							VRAM_WIDTH(fb),
4702*63258Sbostic 							&p0, &p1,
4703*63258Sbostic 							ps->x != p1.x ||
4704*63258Sbostic 							ps->y != p1.y);
4705*63258Sbostic 					}
4706*63258Sbostic 					ps++;
4707*63258Sbostic 				}
4708*63258Sbostic 			} else {
4709*63258Sbostic 				while (--np >= 0) {
4710*63258Sbostic 					p0 = *ps++;
4711*63258Sbostic 					p1 = *ps++;
4712*63258Sbostic 					fb->pat = lptn;
4713*63258Sbostic 					(*line_func)(fb,
4714*63258Sbostic 						VRAM_START(fb), VRAM_WIDTH(fb),
4715*63258Sbostic 						&p0, &p1, 0);
4716*63258Sbostic 				}
4717*63258Sbostic 			}
4718*63258Sbostic 		}
4719*63258Sbostic 	}
4720*63258Sbostic }
4721*63258Sbostic 
4722*63258Sbostic #define	mfb_clrdot32(fb, addr, ddy, p) \
4723*63258Sbostic { *((u_int *)addr + (p->y * ddy) + (p->x >> 5)) &= mfbrmask32[p->x & 0x1f]; }
4724*63258Sbostic 
4725*63258Sbostic #define	mfb_invdot32(fb, addr, ddy, p) \
4726*63258Sbostic { *((u_int *)addr + (p->y * ddy) + (p->x >> 5)) ^= mfbmask32[p->x & 0x1f]; }
4727*63258Sbostic 
4728*63258Sbostic #define	mfb_setdot32(fb, addr, ddy, p) \
4729*63258Sbostic { *((u_int *)addr + (p->y * ddy) + (p->x >> 5)) |= mfbmask32[p->x & 0x1f]; }
4730*63258Sbostic 
4731*63258Sbostic void
fbmem_rop_dot_BF_clr(fb,clip,np,ps)4732*63258Sbostic fbmem_rop_dot_BF_clr(fb, clip, np, ps)
4733*63258Sbostic register struct fbdev *fb;
4734*63258Sbostic lRectangle *clip;
4735*63258Sbostic register int np;
4736*63258Sbostic register lPoint *ps;
4737*63258Sbostic {
4738*63258Sbostic 	register int x0, y0, x1, y1;
4739*63258Sbostic 
4740*63258Sbostic 	if (clip) {
4741*63258Sbostic 		x0 = clip->origin.x;
4742*63258Sbostic 		y0 = clip->origin.y;
4743*63258Sbostic 		x1 = x0 + clip->extent.x - 1;
4744*63258Sbostic 		y1 = y0 + clip->extent.y - 1;
4745*63258Sbostic 		if (x1 <= 0 || y1 <= 0) return;
4746*63258Sbostic 
4747*63258Sbostic 		while (np-- > 0) {
4748*63258Sbostic 			if ((ps->x >= x0) && (ps->y >= y0)
4749*63258Sbostic 			 && (ps->x <= x1) && (ps->y <= y1))
4750*63258Sbostic 				mfb_clrdot32(fb, VRAM_START(fb), VRAM_WIDTH(fb), ps);
4751*63258Sbostic 			ps++;
4752*63258Sbostic 		}
4753*63258Sbostic 	} else {
4754*63258Sbostic 		while (np-- > 0) {
4755*63258Sbostic 			mfb_clrdot32(fb, VRAM_START(fb), VRAM_WIDTH(fb), ps);
4756*63258Sbostic 			ps++;
4757*63258Sbostic 		}
4758*63258Sbostic 	}
4759*63258Sbostic }
4760*63258Sbostic 
4761*63258Sbostic void
fbmem_rop_dot_BF_inv(fb,clip,np,ps)4762*63258Sbostic fbmem_rop_dot_BF_inv(fb, clip, np, ps)
4763*63258Sbostic register struct fbdev *fb;
4764*63258Sbostic lRectangle *clip;
4765*63258Sbostic register int np;
4766*63258Sbostic register lPoint *ps;
4767*63258Sbostic {
4768*63258Sbostic 	register int x0, y0, x1, y1;
4769*63258Sbostic 
4770*63258Sbostic 	if (clip) {
4771*63258Sbostic 		x0 = clip->origin.x;
4772*63258Sbostic 		y0 = clip->origin.y;
4773*63258Sbostic 		x1 = x0 + clip->extent.x - 1;
4774*63258Sbostic 		y1 = y0 + clip->extent.y - 1;
4775*63258Sbostic 		if (x1 <= 0 || y1 <= 0) return;
4776*63258Sbostic 
4777*63258Sbostic 		while (np-- > 0) {
4778*63258Sbostic 			if ((ps->x >= x0) && (ps->y >= y0)
4779*63258Sbostic 			 && (ps->x <= x1) && (ps->y <= y1))
4780*63258Sbostic 				mfb_invdot32(fb, VRAM_START(fb), VRAM_WIDTH(fb), ps);
4781*63258Sbostic 			ps++;
4782*63258Sbostic 		}
4783*63258Sbostic 	} else {
4784*63258Sbostic 		while (np-- > 0) {
4785*63258Sbostic 			mfb_invdot32(fb, VRAM_START(fb), VRAM_WIDTH(fb), ps);
4786*63258Sbostic 			ps++;
4787*63258Sbostic 		}
4788*63258Sbostic 	}
4789*63258Sbostic }
4790*63258Sbostic 
4791*63258Sbostic void
fbmem_rop_dot(fb,clip,ropf,forc,auxc,transp,wplane,np,ps)4792*63258Sbostic fbmem_rop_dot(fb, clip, ropf, forc, auxc, transp, wplane, np, ps)
4793*63258Sbostic register struct fbdev *fb;
4794*63258Sbostic lRectangle *clip;
4795*63258Sbostic int ropf, forc, auxc, transp;
4796*63258Sbostic register int np;
4797*63258Sbostic register lPoint *ps;
4798*63258Sbostic {
4799*63258Sbostic 	register int x0, y0, x1, y1;
4800*63258Sbostic 
4801*63258Sbostic 	if (!(wplane & 1))
4802*63258Sbostic 		return;
4803*63258Sbostic 
4804*63258Sbostic 	linerop(fb, ropf, forc, auxc, transp);
4805*63258Sbostic 
4806*63258Sbostic 	switch (fb->funcvec[0] & 3) {
4807*63258Sbostic 	case 1:
4808*63258Sbostic 		break;
4809*63258Sbostic 
4810*63258Sbostic 	case 0:
4811*63258Sbostic 		fbmem_rop_dot_BF_clr(fb, clip, np, ps);
4812*63258Sbostic 		break;
4813*63258Sbostic 	case 2:
4814*63258Sbostic 		fbmem_rop_dot_BF_inv(fb, clip, np, ps);
4815*63258Sbostic 		break;
4816*63258Sbostic 
4817*63258Sbostic 	default:
4818*63258Sbostic 		if (clip) {
4819*63258Sbostic 			x0 = clip->origin.x;
4820*63258Sbostic 			y0 = clip->origin.y;
4821*63258Sbostic 			x1 = x0 + clip->extent.x - 1;
4822*63258Sbostic 			y1 = y0 + clip->extent.y - 1;
4823*63258Sbostic 			if (x1 <= 0 || y1 <= 0) return;
4824*63258Sbostic 
4825*63258Sbostic 			while (np-- > 0) {
4826*63258Sbostic 				if ((ps->x >= x0) && (ps->y >= y0)
4827*63258Sbostic 				 && (ps->x <= x1) && (ps->y <= y1))
4828*63258Sbostic 					mfb_setdot32(fb,
4829*63258Sbostic 					    VRAM_START(fb), VRAM_WIDTH(fb), ps);
4830*63258Sbostic 				ps++;
4831*63258Sbostic 			}
4832*63258Sbostic 		} else {
4833*63258Sbostic 			while (np-- > 0) {
4834*63258Sbostic 				mfb_setdot32(fb,
4835*63258Sbostic 				    VRAM_START(fb), VRAM_WIDTH(fb), ps);
4836*63258Sbostic 				ps++;
4837*63258Sbostic 			}
4838*63258Sbostic 		}
4839*63258Sbostic 	}
4840*63258Sbostic }
4841*63258Sbostic 
4842*63258Sbostic #ifdef notdef
4843*63258Sbostic 
4844*63258Sbostic #ifndef mfb_clrdot32
4845*63258Sbostic void
mfb_clrdot32(fb,addr,ddy,p)4846*63258Sbostic mfb_clrdot32(fb, addr, ddy, p)
4847*63258Sbostic struct fbdev	*fb;
4848*63258Sbostic register unsigned int *addr;
4849*63258Sbostic register int ddy;
4850*63258Sbostic register lPoint *p;
4851*63258Sbostic {
4852*63258Sbostic 	addr += (p->y * ddy) + (p->x >> 5);
4853*63258Sbostic 	*addr &= mfbrmask32[p->x & 0x1f];
4854*63258Sbostic }
4855*63258Sbostic #endif /* ! mfb_clrdot32 */
4856*63258Sbostic 
4857*63258Sbostic #ifndef mfb_invdot32
4858*63258Sbostic void
mfb_invdot32(fb,addr,ddy,p)4859*63258Sbostic mfb_invdot32(fb, addr, ddy, p)
4860*63258Sbostic struct fbdev	*fb;
4861*63258Sbostic register unsigned int *addr;
4862*63258Sbostic register int	ddy;
4863*63258Sbostic register lPoint *p;
4864*63258Sbostic {
4865*63258Sbostic 	addr += (p->y * ddy) + (p->x >> 5);
4866*63258Sbostic 	*addr ^= mfbmask32[p->x & 0x1f];
4867*63258Sbostic }
4868*63258Sbostic #endif /* ! mfb_invdot32 */
4869*63258Sbostic 
4870*63258Sbostic #ifndef mfb_setdot32
4871*63258Sbostic void
mfb_setdot32(fb,addr,ddy,p)4872*63258Sbostic mfb_setdot32(fb, addr, ddy, p)
4873*63258Sbostic struct fbdev	*fb;
4874*63258Sbostic register unsigned int *addr;
4875*63258Sbostic register int ddy;
4876*63258Sbostic register lPoint *p;
4877*63258Sbostic {
4878*63258Sbostic 	addr += (p->y * ddy) + (p->x >> 5);
4879*63258Sbostic 	*addr |= mfbmask32[p->x & 0x1f];
4880*63258Sbostic }
4881*63258Sbostic #endif /* ! mfb_setdot32 */
4882*63258Sbostic #endif
4883*63258Sbostic 
4884*63258Sbostic #endif /* CPU_SINGLE */
4885