summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/vga256/enhanced/fFill.s
blob: 363e0f7598a5cd3457a2723b9772ffbc806265b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/* $XConsortium: fFill.s,v 1.4 95/01/05 20:50:47 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/vga256/enhanced/fFill.s,v 3.2 1994/10/21 11:24:24 dawes Exp $ */
/*
 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of Thomas Roell not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Thomas Roell makes no representations
 * about the suitability of this software for any purpose.  It is provided
 * "as is" without express or implied warranty.
 *
 * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
 *
 * This file was derived from a similar X11R4 file (X386 1.1) for X11R5
 * (X386 1.2) by James Tsillas.  This file was further derived to its current
 * form by David Wexelblat (dwex@goblin.org).
 *
 * /usr/X386/mit/server/ddx/x386/cfb.banked/RCS/fFill.s,v 1.0 92/05/01 16:44:22 root Exp
 */

#include "assyntax.h"

#if __STDC__ && !defined(UNIXCPP)
#define RROP_NAME_CAT(prefix,suffix)    prefix##suffix
#else
#define RROP_NAME_CAT(prefix,suffix)    prefix/**/suffix
#endif

#define GXAnd	1
#define GXCopy	2
#define GXOr	3
#define GXXor	4

#if RROP == GXAnd
	FILE("fFillAnd.s")
#  define RROPB	AND_B
#  define RROPW AND_W
#  define RROPL AND_L
#  define RROP_NAME(pref)	RROP_NAME_CAT(pref,GXand)
#elif RROP == GXOr
	FILE("fFillOr.s")
#  define RROPB	OR_B
#  define RROPW OR_W
#  define RROPL OR_L
#  define RROP_NAME(pref)	RROP_NAME_CAT(pref,GXor)
#elif RROP == GXXor
	FILE("fFillXor.s")
#  define RROPB	XOR_B
#  define RROPW XOR_W
#  define RROPL XOR_L
#  define RROP_NAME(pref)	RROP_NAME_CAT(pref,GXxor)
#elif RROP == GXCopy
	FILE("fFillCopy.s")
#  define RROPB	MOV_B
#  define RROPW MOV_W
#  define RROPL MOV_L
#  define RROP_NAME(pref)	RROP_NAME_CAT(pref,GXcopy)
#endif

	AS_BEGIN

#define GL_RROP_NAME    RROP_NAME(GLNAME(fastFillSolid))

/*
 *
 * This routine implements a fast Solid Fill in GXcopy
 * No segment checking is done.
 *
 * SYNTAX:
 * unchar * fastFillSolid<RROP>(pdst,fill,dummy,hcount,count,width,widthPitch);
 * 
 *  (7/27/90 TR)
 *  (4/92 JT)
 *  (5/92 DW)
 */

#define pdst        EDI
#define fill        EAX
#define fillw       AX
#define fillb       AL
#define count       ESI
#define hcount      ECX
#define width       REGOFF(28,EBP)
#define widthPitch  EBX
#define tmp         EAX


	SEG_DATA
	ALIGNDATA4
countt:	
	D_LONG 0
	SEG_TEXT
	ALIGNTEXT4

#define rrop_name	/**/RROP_NAME(fastFillSolid)

GLOBL	GL_RROP_NAME

GL_RROP_NAME:
	PUSH_L	(EBP)
	MOV_L	(ESP,EBP)
	PUSH_L	(EDI)
	PUSH_L	(ESI)
	PUSH_L	(EBX)
	MOV_L	(REGOFF(8,EBP),pdst)
	MOV_L	(REGOFF(12,EBP),fill)
	MOV_L	(REGOFF(20,EBP),hcount)
	MOV_L	(REGOFF(24,EBP),count)
	MOV_L	(REGOFF(32,EBP),widthPitch)
	OR_L	(hcount,hcount)
	JZ	(.finish)
	OR_L	(count,count)
	JZ	(.finish)
	CMP_L	(CONST(3),count)
	JG	(.startblockloop)
	JE	(.tribbleloop)
	CMP_L	(CONST(2),count)
	JE	(.wordloop)
/*
 * do a fast vertical line
 */
	ALIGNTEXT4ifNOP
.byteloop:
	RROPB	(fillb,REGIND(pdst))
	LEA_L	(REGBID(widthPitch,pdst,1),pdst)
	DEC_L	(ECX)	
	JNZ	(.byteloop)
	JMP	(.finish)

	ALIGNTEXT4
.wordloop:
	RROPW	(fillw,REGIND(pdst))
	LEA_L	(REGBID(widthPitch,pdst,2),pdst)
	DEC_L	(ECX)	
	JNZ	(.wordloop)
	JMP	(.finish)

	ALIGNTEXT4
.tribbleloop:
	RROPW	(fillw,REGIND(pdst))
	RROPB	(fillb,REGOFF(2,pdst))
	LEA_L	(REGBID(widthPitch,pdst,3),pdst)
	DEC_L	(ECX)	
	JNZ	(.tribbleloop)
	JMP	(.finish)

#undef count
#define count ECX
#undef hcount
#define hcount ESI

.startblockloop:
	XCHG_L	(ECX, ESI)
	ALIGNTEXT4ifNOP
.blockloop:
	TEST_L	(CONST(1),pdst)
	JZ	(.alignword)
#if RROP == GXCopy
	STOS_B
#else
	RROPB	(fillb,REGIND(pdst))
	INC_L	(pdst)
#endif
	DEC_L	(count)
.alignword:
	TEST_L	(CONST(2),pdst)
	JZ	(.aligneddword)
#if RROP == GXCopy
	STOS_W
#else
	RROPW	(fillw,REGIND(pdst))
	ADD_L	(CONST(2),pdst)
#endif
	LEA_L	(REGOFF(-2,count),count)
.aligneddword:
	MOV_L	(count, CONTENT(countt))
	AND_L	(CONST(3), CONTENT(countt))
	SHR_L	(CONST(2), count)
#if RROP == GXCopy
	REPZ
	STOS_L
#else
	OR_L	(ECX, ECX)
	JZ	(.endloop)
	ALIGNTEXT4ifNOP
.loop0: RROPL	(fill,REGIND(pdst))
	ADD_L	(CONST(4),pdst)
	DEC_L	(ECX)	
	JNZ	(.loop0)
.endloop:
#endif
	TEST_L	(CONST(2),CONTENT(countt))
	JZ	(.fixupbyte)
#if RROP == GXCopy
	STOS_W
#else
	RROPW	(fillw,REGIND(pdst))
	ADD_L	(CONST(2),pdst)
#endif
.fixupbyte:
	TEST_L	(CONST(1),CONTENT(countt))
	JZ	(.enditeration)
#if RROP == GXCopy
	STOS_B
#else
	RROPB	(fillb,REGIND(pdst))
	INC_L	(pdst)
#endif
.enditeration:
	LEA_L	(REGBI(widthPitch,pdst),pdst)
	MOV_L	(width,count)
	DEC_L	(hcount)
	JNZ	(.blockloop)
.finish:
	MOV_L	(pdst,EAX)
	LEA_L	(REGOFF(-12,EBP),ESP)
	POP_L	(EBX)
	POP_L	(ESI)
	POP_L	(EDI)
	LEAVE
	RET