summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/vga256/enhanced/suVHLine.s
blob: 769695f725d6ac7ecc203023d7f37dfaf90e1166 (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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/* $XConsortium: suVHLine.s,v 1.2 94/03/29 11:19:22 dpw Exp $ */
/*******************************************************************************
			Copyright 1992, 1993 by Glenn G. Lai 

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
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 Glenn G. Lai not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  

Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL 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.

Glenn G. Lai
P.O. Box 4314
Austin, Tx 78765
(glenn@cs.utexas.edu)
8/21/92
7/10/93
*******************************************************************************/

#include "assyntax.h"

	FILE("suVHLine.s")
	AS_BEGIN

#include "vgaAsm.h"

/*
	void SpeedUpHLine(dst, fill, len, screen);
	void SpeedUpVLine(dst, fill, len, screen);
*/

#define dst     REGOFF(8,EBP)
#define fill    REGOFF(12,EBP)
#define len	REGOFF(16,EBP)
#define screen  REGOFF(20,EBP)
/****************************************/
	SEG_DATA
copyright:
	STRING("Copyright 1992, 7/10/1993 by Glenn G. Lai")
	ALIGNDATA4
speedUpTop:
	D_LONG	0
lMaskTable:
	D_WORD	0x0f02
	D_WORD	0x0802
	D_WORD	0x0c02
	D_WORD	0x0e02
rMaskTable:
	D_WORD	0x0f02
	D_WORD	0x0102
	D_WORD	0x0302
	D_WORD	0x0702
segment:
	D_BYTE	0
/****************************************/
	SEG_TEXT
	ALIGNTEXT4
	GLOBL GLNAME(SpeedUpVLine)
	GLOBL GLNAME(SpeedUpVLine1)
GLNAME(SpeedUpVLine):
	MOV_L	(REGOFF(12,ESP), ECX)
	OR_L	(ECX, ECX)
	JZ	(return)
GLNAME(SpeedUpVLine1):
	MOV_L	(REGOFF(4,ESP), EAX)
	CMP_L	(VGABASE, EAX)
	JC	(pixmapV)
windowV:
	CMP_L	(CONST(1), ECX)
	JNE	(moreThanOnePoint)
	MOV_L	(EAX, ECX)
	SHR_L	(CONST(16), EAX)
	MOV_L	(CONST(0x3cd), EDX)
	OUT1_B	(DX)
	AND_L	(CONST(0xffff), ECX)
	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)), ECX)
	MOV_L	(REGOFF(8,ESP), EAX)
	MOV_B	(AL, REGIND(ECX))
	RET
/****************************************/
	ALIGNTEXT4
moreThanOnePoint:
	PUSH_L 	(EBP)
	MOV_L 	(ESP, EBP)
	PUSH_L 	(EDI)
	PUSH_L	(ESI)
	PUSH_L	(EBX)

	MOV_L	(screen, ESI)
	MOV_L	(ESI, EBX)
	DEC_L	(EBX)
	ADD_L	(CONTENT(GLNAME(vgaWriteTop)), EBX)
	MOV_L	(EBX, CONTENT(speedUpTop))

	MOV_L	(EAX, EDI)
	SHR_L	(CONST(16), EAX)
	MOV_B	(AL, CONTENT(segment))

	AND_L	(CONST(0xffff), EDI)
	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)), EDI)

	MOV_L	(fill, EBX)
	MOV_L	(len, ECX)
wVLoop:
	MOV_L	(CONST(0x3cd), EDX)
	OUT1_B	(DX)

	XOR_L	(EDX, EDX)
	MOV_L	(CONTENT(speedUpTop), EAX)
	SUB_L	(EDI, EAX)
	DIV_L	(ESI)

	CMP_L	(ECX, EAX)
	JC	(wVLoop1)
	MOV_L	(ECX, EAX)
wVLoop1:
	SUB_L	(EAX, ECX)
wvLoop2:
	MOV_B	(BL, REGIND(EDI))
	ADD_L	(ESI, EDI)
	DEC_L	(EAX)
	JNZ	(wvLoop2)

	OR_L	(ECX, ECX)
	JZ	(npDone)

	SUB_L	(CONST(0x10000), EDI)
	MOV_B	(CONTENT(segment), AL)
	INC_B	(AL)
	MOV_B	(AL, CONTENT(segment))
	JMP	(wVLoop)
/*****************************************/
	ALIGNTEXT4
pixmapV:
	PUSH_L	(EDI)
	PUSH_L	(ESI)
	MOV_L	(REGOFF(16,ESP), EDX)
	MOV_L	(REGOFF(24,ESP), ESI)
	MOV_L	(ECX, EDI)
	AND_L	(CONST(3), EDI)
	MOV_L	(REGDIS(pixmapVTable,EDI,4), EDI)
	SHR_L	(CONST(2), ECX)
	JZ	(pixmapV4)
pixmapV5:
	MOV_B	(DL, REGIND(EAX))
	ADD_L	(ESI, EAX)
	MOV_B	(DL, REGIND(EAX))
	ADD_L	(ESI, EAX)
	MOV_B	(DL, REGIND(EAX))
	ADD_L	(ESI, EAX)
	MOV_B	(DL, REGIND(EAX))
	ADD_L	(ESI, EAX)
	DEC_L	(ECX)
	JNZ	(pixmapV5)
pixmapV4:
	JMP	(CODEPTR(EDI))
/*******************/
	SEG_DATA
	ALIGNDATA4
pixmapVTable:
	D_LONG	pixmapV0, pixmapV1, pixmapV2, pixmapV3
/*******************/
	SEG_TEXT
	ALIGNTEXT4
pixmapV3:
	MOV_B	(DL, REGIND(EAX))
	ADD_L	(ESI, EAX)
pixmapV2:
	MOV_B	(DL, REGIND(EAX))
	ADD_L	(ESI, EAX)
pixmapV1:
	MOV_B	(DL, REGIND(EAX))
pixmapV0:
	POP_L	(ESI)
	POP_L	(EDI)
	RET
/*****************************************/
	GLOBL	GLNAME(SpeedUpHLine)
	GLOBL	GLNAME(SpeedUpHLine1)
	ALIGNTEXT4
GLNAME(SpeedUpHLine):
	MOV_L	(REGOFF(12,ESP), ECX)
	OR_L	(ECX, ECX)
	JZ	(return)
GLNAME(SpeedUpHLine1):
	MOV_L	(REGOFF(4,ESP), EAX)
	SUB_L	(VGABASE, EAX)
	JC	(pixmapH)
windowH:
	CMP_L	(CONST(1), ECX)
	JNE	(windowH1)
	MOV_L	(EAX, ECX)
	SHR_L	(CONST(16), EAX)
	MOV_W	(CONST(0x3cd), DX)
	OUT1_B	(DX)
	AND_L	(CONST(0xffff), ECX)
	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)), ECX)
	MOV_L	(REGOFF(8,ESP), EAX)
	MOV_B	(AL, REGIND(ECX))
	RET
/****************/
	ALIGNTEXT4
windowH1:
/* Change THRESHOLD at YOUR OWN RISK!!! */ 
#define THRESHOLD	CONST(80)
	CMP_L	(THRESHOLD, ECX)
	JNC	(pMode)
windowH8:
	PUSH_L	(EDI)
	MOV_L	(EAX, EDI)
	SHR_L	(CONST(16), EAX)
	MOV_B	(AL, CONTENT(segment))
	MOV_W	(CONST(0x3cd), DX)
	OUT1_B	(DX)

	AND_L	(CONST(0xffff), EDI)
	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)), EDI)
	MOV_L	(CONTENT(GLNAME(vgaWriteTop)), EAX)
	SUB_L	(EDI, EAX)

	XOR_L	(EDX, EDX)
	CMP_L	(ECX, EAX)
	JNC	(windowH7)

	MOV_L	(ECX, EDX)
	MOV_L	(EAX, ECX)
	SUB_L	(EAX, EDX)
windowH7:
	MOV_L	(REGOFF(12,ESP), EAX)
	TEST_L	(CONST(1), EDI)
	JZ	(windowH2)
	STOS_B
	DEC_L	(ECX)
	JZ	(windowH5)
windowH2:
	SHR_L	(CONST(1), ECX)
	JZ	(windowH3)
	REP
	STOS_W
	JNC	(windowH4)
windowH3:
	STOS_B
windowH4:
	OR_L	(EDX, EDX)
	JNZ	(windowH5)
	POP_L	(EDI)
	RET
	ALIGNTEXT4
windowH5:
	MOV_L	(EDX, ECX)
	MOV_B	(CONTENT(segment), AL)
	INC_B	(AL)
	MOV_L	(CONST(0x3cd), EDX)
	OUT1_B	(DX)
	MOV_L	(REGOFF(12,ESP), EAX)
	SUB_L	(CONST(0x10000), EDI)
	SHR_L	(CONST(1), ECX)
	JZ	(windowH6)
	REP
	STOS_W
	JNC	(windowH9)
windowH6:
	STOS_B
windowH9:
	POP_L	(EDI)
	RET
/****************************/
	ALIGNTEXT4
pixmapH:
	ADD_L	(VGABASE, EAX)
	CMP_L	(CONST(7), ECX)
	JC	(pixmapH0)

	PUSH_L	(EDI)
	MOV_L	(EAX, EDI)
	MOV_L	(REGOFF(12,ESP), EAX)

	TEST_L	(CONST(1), EDI)
	JZ	(pixmapH1)
	STOS_B
	DEC_L	(ECX)
pixmapH1:
	TEST_L	(CONST(2), EDI)
	JZ	(pixmapH2)
	STOS_W
	SUB_L	(CONST(2), ECX)
pixmapH2:
	MOV_L	(ECX, EDX)
	SHR_L	(CONST(2), ECX)
	REP
	STOS_L
	TEST_L	(CONST(2), EDX)
	JZ	(pixmapH4)
	STOS_W
pixmapH4:
	TEST_L	(CONST(1), EDX)
	JZ	(pixmapH5)
	MOV_B	(AL, REGIND(EDI))
pixmapH5:
	POP_L	(EDI)
	RET
/****************/
	ALIGNTEXT4
pixmapH0:
	MOV_L	(REGOFF(8,ESP), EDX)
pixmapH01:
	MOV_B	(DL, REGIND(EAX))
	INC_L	(EAX)
	DEC_L	(ECX)
	JNZ	(pixmapH01)
	RET
/****************************/
	ALIGNTEXT4
pMode:
	MOV_L	(EAX, EDX)
	AND_L	(CONST(0x3ffff), EDX)
	SUB_L	(CONST(0x40000), EDX)
	NEG_L	(EDX)
	CMP_L	(ECX, EDX)
	JC	(windowH8)

	PUSH_L 	(EBP)
	MOV_L 	(ESP,EBP)
	PUSH_L 	(EDI)
	PUSH_L	(ESI)
	PUSH_L	(EBX)
/***************************/
	MOV_W	(CONST(0x3c4), DX)
	MOV_W	(CONST(0x0604), AX )
	OUT1_W	(DX)
	MOV_W	(CONST(0x3ce), DX)
	MOV_W	(CONST(0x0001), AX)
	OUT1_W	(DX)
	MOV_W	(CONST(0x0003), AX)
	OUT1_W	(DX)
	MOV_W	(CONST(0x4005), AX)
	OUT1_W	(DX)
	MOV_W	(CONST(0xff08), AX)
	OUT1_W	(DX)
/***************************/
	MOV_L	(fill, EBX)
	MOV_L 	(dst, EDI)
	MOV_L	(EDI, EAX)
	SHR_L	(CONST(18), EAX)
	DEC_W	(DX)
	OUT1_B	(DX)
	MOV_W	(CONST(0x3c4), DX)

	AND_L	(CONST(0x3ffff), EDI)
	MOV_L	(EDI, EAX)
	SHR_L	(CONST(2), EDI)
	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)), EDI)

	MOV_L	(EAX, ESI)
	ADD_L	(CONST(3), ESI)
	AND_L	(CONST(0xfffffffc), ESI)
	SUB_L	(EAX, ESI)
	JZ	(pMode1)

	MOV_W	(REGDIS(lMaskTable,ESI,2), AX)
	OUT1_W	(DX)
	SUB_L	(ESI, ECX)
	MOV_B	(BL, REGIND(EDI))
	INC_L	(EDI)
pMode1:
	MOV_W	(CONST(0x0f02), AX)
	OUT1_W	(DX)

	MOV_L	(EBX, EAX)
	MOV_L	(ECX, ESI)
	AND_L	(CONST(3), ESI)
	SHR_L	(CONST(2), ECX)

	TEST_L	(CONST(1), EDI)
	JZ	(pMode2)
	STOS_B
	DEC_L	(ECX)
pMode2:
	SHR_L	(CONST(1), ECX)
	REP
	STOS_W
	JNC	(pMode3)
	STOS_B
pMode3:
	SHL_L	(CONST(1), ESI)
	JZ	(pMode4)
	MOV_W	(rMaskTable(ESI), AX)
	OUT1_W	(DX)
	MOV_B	(BL, REGIND(EDI))
	MOV_W	(CONST(0x0f02), AX)
	OUT1_W	(DX)
pMode4:
	MOV_W	(CONST(0x0c04), AX)
	OUT1_W	(DX)
npDone:
	POP_L 	(EBX)
	POP_L 	(ESI)
	POP_L 	(EDI)
	LEAVE
return:
	RET