Subversion Repositories Kolibri OS

Rev

Rev 5153 | Rev 5187 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5153 IgorA 1
;
2
; We draw a triangle with various interpolations
3
;
4
	t dd ? ;ZBufferPoint*
5
	pr1 dd ? ;ZBufferPoint*
6
	pr2 dd ? ;ZBufferPoint*
7
	l1 dd ? ;ZBufferPoint*
8
	l2 dd ? ;ZBufferPoint*
5175 IgorA 9
	fdx1 dd ? ;float
10
	fdx2 dd ? ;float
11
	fdy1 dd ? ;float
12
	fdy2 dd ? ;float
13
	fz dd ? ;float
14
	d1 dd ? ;float
15
	d2 dd ? ;float
5153 IgorA 16
	pz1 dd ? ;unsigned short*
17
	pp1 dd ? ;PIXEL*
18
	part dd ?
19
	update_left dd ?
20
	update_right dd ?
21
 
22
	nb_lines dd ?
23
	dx1 dd ?
24
	dy1 dd ?
25
	dx2 dd ?
26
	dy2 dd ?
27
 
28
	error dd ?
29
	derror dd ?
30
	x1 dd ?
31
	dxdy_min dd ?
32
	dxdy_max dd ?
33
	; warning: x2 is multiplied by 2^16
34
	x2 dd ?
35
	dx2dy2 dd ?
36
 
37
if INTERP_Z eq 1
38
	z1 dd ?
39
	dzdx dd ?
40
	dzdy dd ?
41
	dzdl_min dd ?
42
	dzdl_max dd ?
43
end if
44
if INTERP_RGB eq 1
45
	r1 dd ? ;int
46
	drdx dd ?
47
	drdy dd ?
48
	drdl_min dd ?
49
	drdl_max dd ?
50
	g1 dd ?
51
	dgdx dd ?
52
	dgdy dd ?
53
	dgdl_min dd ?
54
	dgdl_max dd ?
55
	b1 dd ?
56
	dbdx dd ?
57
	dbdy dd ?
58
	dbdl_min dd ?
59
	dbdl_max dd ?
60
end if
61
if INTERP_ST eq 1
5175 IgorA 62
	s1 dd ?
5153 IgorA 63
	dsdx dd ?
64
	dsdy dd ?
65
	dsdl_min dd ?
66
	dsdl_max dd ?
67
	t1 dd ?
68
	dtdx dd ?
69
	dtdy dd ?
70
	dtdl_min dd ?
71
	dtdl_max dd ?
72
end if
73
if INTERP_STZ eq 1
5175 IgorA 74
	sz1 dd ? ;float
75
	dszdx dd ? ;float
76
	dszdy dd ? ;float
77
	dszdl_min dd ? ;float
78
	dszdl_max dd ? ;float
79
	tz1 dd ? ;float
80
	dtzdx dd ? ;float
81
	dtzdy dd ? ;float
82
	dtzdl_min dd ? ;float
83
	dtzdl_max dd ? ;float
5153 IgorA 84
end if
85
 
5175 IgorA 86
if DRAW_LINE_M eq 1
87
	DRAW_LINE 0 ;переменные делаются в макросе
88
else
89
	;edi = pp dd ?
90
	n dd ? ;int
91
if INTERP_Z eq 1
92
	pz dd ? ;unsigned short *
93
	z dd ? ;uint
94
	zz dd ? ;uint
95
end if
96
if INTERP_RGB eq 1
97
	or1 dd ? ;uint
98
	og1 dd ? ;uint
99
	ob1 dd ? ;uint
100
end if
101
if INTERP_ST eq 1
102
	s dd ? ;uint
103
	t dd ? ;uint
104
end if
105
if INTERP_STZ eq 1
106
	s_z dd ? ;float
107
	t_z dd ? ;float
108
end if
109
end if
110
 
5153 IgorA 111
endl
112
 
5175 IgorA 113
	; we sort the vertex with increasing y
114
	mov ebx,[p0]
115
	mov ecx,[p1]
116
	mov eax,[ebx+offs_zbup_y]
117
	cmp [ecx+offs_zbup_y],eax
118
	jge @f
119
		;if (p1.y < p0.y)
120
		mov [p0],ecx
121
		mov [p1],ebx
122
		xchg ebx,ecx
123
		mov eax,[ebx+offs_zbup_y] ;обновляем p0.y для следующего сравнения
124
	@@:
125
	mov edx,[p2]
126
	cmp [edx+offs_zbup_y],eax
127
	jge @f
128
		;if (p2.y < p0.y)
129
		mov [p0],edx
130
		mov [p1],ebx
131
		mov [p2],ecx
132
		mov ebx,[p0]
133
		mov ecx,[p1]
134
		mov edx,[p2]
135
		jmp .end_e0
136
	@@:
137
	mov eax,[ecx+offs_zbup_y]
138
	cmp [edx+offs_zbup_y],eax
139
	jge .end_e0
140
		;else if (p2.y < p1.y)
141
		mov [p1],edx
142
		mov [p2],ecx
143
	.end_e0:
5153 IgorA 144
 
145
	; we compute dXdx and dXdy for all interpolated values
146
 
5175 IgorA 147
	mov eax,[ecx+offs_zbup_x]
148
	sub eax,[ebx+offs_zbup_x]
149
	mov [fdx1],eax ;p1.x - p0.x
150
	mov eax,[ecx+offs_zbup_y]
151
	sub eax,[ebx+offs_zbup_y]
152
	mov [fdy1],eax ;p1.y - p0.y
5153 IgorA 153
 
5175 IgorA 154
	mov eax,[edx+offs_zbup_x]
155
	sub eax,[ebx+offs_zbup_x]
156
	mov [fdx2],eax ;p2.x - p0.x
157
	mov eax,[edx+offs_zbup_y]
158
	sub eax,[ebx+offs_zbup_y]
159
	mov [fdy2],eax ;p2.y - p0.y
5153 IgorA 160
 
5175 IgorA 161
	fild dword[fdx2]
162
	fst dword[fdx2]
163
	fild dword[fdy1]
164
	fst dword[fdy1]
165
	fmulp
166
	fild dword[fdx1]
167
	fst dword[fdx1]
168
	fild dword[fdy2]
169
	fst dword[fdy2]
170
	fmulp
171
	fsubp ;st0 = st0-st1
172
	fst dword[fz] ;fz = fdx1 * fdy2 - fdx2 * fdy1
173
	fldz
174
	fcompp ;if (fz == 0)
175
	fstsw ax
176
	sahf
177
	je .end_f
178
	fld1
179
	fdiv dword[fz] ;fz = 1.0 / fz
180
	fst dword[fz]  ;st0 = fz
5153 IgorA 181
 
5175 IgorA 182
	fld dword[fdx1]
183
	fmul st0,st1
184
	fstp dword[fdx1] ;fdx1 *= fz
185
	fld dword[fdy1]
186
	fmul st0,st1
187
	fstp dword[fdy1] ;fdy1 *= fz
188
	fld dword[fdx2]
189
	fmul st0,st1
190
	fstp dword[fdx2] ;fdx2 *= fz
191
	fld dword[fdy2]
192
	fmul st0,st1
193
	fstp dword[fdy2] ;fdy2 *= fz
194
	ffree st0
195
	fincstp
5153 IgorA 196
 
197
if INTERP_Z eq 1
5175 IgorA 198
	mov eax,[ecx+offs_zbup_z]
199
	sub eax,[ebx+offs_zbup_z]
200
	mov [d1],eax
201
	mov eax,[edx+offs_zbup_z]
202
	sub eax,[ebx+offs_zbup_z]
203
	mov [d2],eax
204
	fild dword[d1]
205
	fst dword[d1] ;d1 = p1.z - p0.z
206
	fild dword[d2]
207
	fst dword[d2] ;d2 = p2.z - p0.z
208
 
209
	fld dword[fdy1]
210
	fmul st0,st1
211
	fld dword[fdy2]
212
	fmul st0,st3
213
	fsub st0,st1
214
	fistp dword[dzdx] ;dzdx = (int) (fdy2*d1 - fdy1*d2)
215
	ffree st0
216
	fincstp
217
	fld dword[fdx2]
218
	fmul st0,st2
219
	fld dword[fdx1]
220
	fmul st0,st2
221
	fsub st0,st1
222
	fistp dword[dzdy] ;dzdy = (int) (fdx1*d2 - fdx2*d1)
223
	ffree st0
224
	fincstp
5153 IgorA 225
end if
226
 
227
if INTERP_RGB eq 1
5175 IgorA 228
	mov eax,[ecx+offs_zbup_r]
229
	sub eax,[ebx+offs_zbup_r]
230
	mov [d1],eax
231
	mov eax,[edx+offs_zbup_r]
232
	sub eax,[ebx+offs_zbup_r]
233
	mov [d2],eax
234
	fild dword[d1]
235
	fst dword[d1] ;d1 = p1.r - p0.r
236
	fild dword[d2]
237
	fst dword[d2] ;d2 = p2.r - p0.r
5153 IgorA 238
 
5175 IgorA 239
	fld dword[fdy1]
240
	fmul st0,st1
241
	fld dword[fdy2]
242
	fmul st0,st3
243
	fsub st0,st1
244
	fistp dword[drdx] ;drdx = (int) (fdy2*d1 - fdy1*d2)
245
	ffree st0
246
	fincstp
247
	fld dword[fdx2]
248
	fmul st0,st2
249
	fld dword[fdx1]
250
	fmul st0,st2
251
	fsub st0,st1
252
	fistp dword[drdy] ;drdy = (int) (fdx1*d2 - fdx2*d1)
253
	ffree st0
254
	fincstp
5153 IgorA 255
 
5175 IgorA 256
	mov eax,[ecx+offs_zbup_g]
257
	sub eax,[ebx+offs_zbup_g]
258
	mov [d1],eax
259
	mov eax,[edx+offs_zbup_g]
260
	sub eax,[ebx+offs_zbup_g]
261
	mov [d2],eax
262
	fild dword[d1]
263
	fst dword[d1] ;d1 = p1.g - p0.g
264
	fild dword[d2]
265
	fst dword[d2] ;d2 = p2.g - p0.g
5153 IgorA 266
 
5175 IgorA 267
	fld dword[fdy1]
268
	fmul st0,st1
269
	fld dword[fdy2]
270
	fmul st0,st3
271
	fsub st0,st1
272
	fistp dword[dgdx] ;dgdx = (int) (fdy2*d1 - fdy1*d2)
273
	ffree st0
274
	fincstp
275
	fld dword[fdx2]
276
	fmul st0,st2
277
	fld dword[fdx1]
278
	fmul st0,st2
279
	fsub st0,st1
280
	fistp dword[dgdy] ;dgdy = (int) (fdx1*d2 - fdx2*d1)
281
	ffree st0
282
	fincstp
283
 
284
	mov eax,[ecx+offs_zbup_b]
285
	sub eax,[ebx+offs_zbup_b]
286
	mov [d1],eax
287
	mov eax,[edx+offs_zbup_b]
288
	sub eax,[ebx+offs_zbup_b]
289
	mov [d2],eax
290
	fild dword[d1]
291
	fst dword[d1] ;d1 = p1.b - p0.b
292
	fild dword[d2]
293
	fst dword[d2] ;d2 = p2.b - p0.b
294
 
295
	fld dword[fdy1]
296
	fmul st0,st1
297
	fld dword[fdy2]
298
	fmul st0,st3
299
	fsub st0,st1
300
	fistp dword[dbdx] ;dbdx = (int) (fdy2*d1 - fdy1*d2)
301
	ffree st0
302
	fincstp
303
	fld dword[fdx2]
304
	fmul st0,st2
305
	fld dword[fdx1]
306
	fmul st0,st2
307
	fsub st0,st1
308
	fistp dword[dbdy] ;dbdy = (int) (fdx1*d2 - fdx2*d1)
309
	ffree st0
310
	fincstp
5153 IgorA 311
end if
312
 
313
if INTERP_ST eq 1
5175 IgorA 314
	mov eax,[ecx+offs_zbup_s]
315
	sub eax,[ebx+offs_zbup_s]
316
	mov [d1],eax
317
	mov eax,[edx+offs_zbup_s]
318
	sub eax,[ebx+offs_zbup_s]
319
	mov [d2],eax
320
	fild dword[d1]
321
	fst dword[d1] ;d1 = p1.s - p0.s
322
	fild dword[d2]
323
	fst dword[d2] ;d2 = p2.s - p0.s
5153 IgorA 324
 
5175 IgorA 325
	fld dword[fdy1]
326
	fmul st0,st1
327
	fld dword[fdy2]
328
	fmul st0,st3
329
	fsub st0,st1
330
	fistp dword[dsdx] ;dsdx = (int) (fdy2*d1 - fdy1*d2)
331
	ffree st0
332
	fincstp
333
	fld dword[fdx2]
334
	fmul st0,st2
335
	fld dword[fdx1]
336
	fmul st0,st2
337
	fsub st0,st1
338
	fistp dword[dsdy] ;dsdy = (int) (fdx1*d2 - fdx2*d1)
339
	ffree st0
340
	fincstp
341
 
342
	mov eax,[ecx+offs_zbup_t]
343
	sub eax,[ebx+offs_zbup_t]
344
	mov [d1],eax
345
	mov eax,[edx+offs_zbup_t]
346
	sub eax,[ebx+offs_zbup_t]
347
	mov [d2],eax
348
	fild dword[d1]
349
	fst dword[d1] ;d1 = p1.t - p0.t
350
	fild dword[d2]
351
	fst dword[d2] ;d2 = p2.t - p0.t
352
 
353
	fld dword[fdy1]
354
	fmul st0,st1
355
	fld dword[fdy2]
356
	fmul st0,st3
357
	fsub st0,st1
358
	fistp dword[dtdx] ;dtdx = (int) (fdy2*d1 - fdy1*d2)
359
	ffree st0
360
	fincstp
361
	fld dword[fdx2]
362
	fmul st0,st2
363
	fld dword[fdx1]
364
	fmul st0,st2
365
	fsub st0,st1
366
	fistp dword[dtdy] ;dtdy = (int) (fdx1*d2 - fdx2*d1)
367
	ffree st0
368
	fincstp
5153 IgorA 369
end if
370
 
371
if INTERP_STZ eq 1
5175 IgorA 372
	fild dword[ebx+offs_zbup_z]
373
	fild dword[ebx+offs_zbup_s]
374
	fmul st0,st1
375
	fstp dword[ebx+offs_zbup_sz] ;p0.sz = (float) p0.s * p0.z
376
	fild dword[ebx+offs_zbup_t]
377
	fmul st0,st1
378
	fstp dword[ebx+offs_zbup_tz] ;p0.tz = (float) p0.t * p0.z
379
	ffree st0
380
	fincstp
5153 IgorA 381
 
5175 IgorA 382
	fild dword[ecx+offs_zbup_z]
383
	fild dword[ecx+offs_zbup_s]
384
	fmul st0,st1
385
	fstp dword[ecx+offs_zbup_sz] ;p1.sz = (float) p1.s * p1.z
386
	fild dword[ecx+offs_zbup_t]
387
	fmul st0,st1
388
	fstp dword[ecx+offs_zbup_tz] ;p1.tz = (float) p1.t * p1.z
389
	ffree st0
390
	fincstp
5153 IgorA 391
 
5175 IgorA 392
	fild dword[edx+offs_zbup_z]
393
	fild dword[edx+offs_zbup_s]
394
	fmul st0,st1
395
	fstp dword[edx+offs_zbup_sz] ;p2.sz = (float) p2.s * p2.z
396
	fild dword[edx+offs_zbup_t]
397
	fmul st0,st1
398
	fstp dword[edx+offs_zbup_tz] ;p2.tz = (float) p2.t * p2.z
399
	ffree st0
400
	fincstp
401
 
402
	fld dword[ecx+offs_zbup_sz]
403
	fsub dword[ebx+offs_zbup_sz]
404
	fst dword[d1] ;d1 = p1.sz - p0.sz
405
	fld dword[edx+offs_zbup_sz]
406
	fsub dword[ebx+offs_zbup_sz]
407
	fst dword[d2] ;d2 = p2.sz - p0.sz
408
 
409
	fld dword[fdy1]
410
	fmul st0,st1
411
	fld dword[fdy2]
412
	fmul st0,st3
413
	fsub st0,st1
414
	fistp dword[dszdx] ;dszdx = (int) (fdy2*d1 - fdy1*d2)
415
	ffree st0
416
	fincstp
417
	fld dword[fdx2]
418
	fmul st0,st2
419
	fld dword[fdx1]
420
	fmul st0,st2
421
	fsub st0,st1
422
	fistp dword[dszdy] ;dszdy = (int) (fdx1*d2 - fdx2*d1)
423
	ffree st0
424
	fincstp
425
 
426
	fld dword[ecx+offs_zbup_tz]
427
	fsub dword[ebx+offs_zbup_tz]
428
	fst dword[d1] ;d1 = p1.tz - p0.tz
429
	fld dword[edx+offs_zbup_tz]
430
	fsub dword[ebx+offs_zbup_tz]
431
	fst dword[d2] ;d2 = p2.tz - p0.tz
432
 
433
	fld dword[fdy1]
434
	fmul st0,st1
435
	fld dword[fdy2]
436
	fmul st0,st3
437
	fsub st0,st1
438
	fistp dword[dtzdx] ;dtzdx = (int) (fdy2*d1 - fdy1*d2)
439
	ffree st0
440
	fincstp
441
	fld dword[fdx2]
442
	fmul st0,st2
443
	fld dword[fdx1]
444
	fmul st0,st2
445
	fsub st0,st1
446
	fistp dword[dtzdy] ;dtzdy = (int) (fdx1*d2 - fdx2*d1)
447
	ffree st0
448
	fincstp
5153 IgorA 449
end if
450
 
451
	; screen coordinates
452
 
5175 IgorA 453
	mov eax,[zb]
454
	mov edx,[eax+offs_zbuf_linesize]
455
	imul edx,[ebx+offs_zbup_y]
456
	add edx,[eax+offs_zbuf_pbuf]
457
	mov [pp1],edx ;pp1 = zb.pbuf + zb.linesize * p0.y
458
	mov edx,[eax+offs_zbuf_xsize]
459
	imul edx,[ebx+offs_zbup_y]
460
	shl edx,1
461
	add edx,[eax+offs_zbuf_zbuf]
462
	mov [pz1],edx ;pz1 = zb.zbuf + zb.xsize * p0.y
5153 IgorA 463
 
464
	DRAW_INIT
465
 
5175 IgorA 466
	mov dword[part],0
467
	.cycle_0:
468
		mov ebx,[p0]
469
		mov ecx,[p1]
470
		mov edx,[p2]
471
		cmp dword[part],0
472
		jne .els_0
473
			mov dword[update_left],1
474
			mov dword[update_right],1
475
			mov [l1],ebx
476
			mov [pr1],ebx
477
			fldz
478
			fld dword[fz]
479
			fcompp ;if (fz > 0)
480
			fstsw ax
481
			sahf
482
			jbe .els_1
483
				mov [l2],edx
484
				mov [pr2],ecx
485
				jmp .end_1
486
			.els_1:
487
				mov [l2],ecx
488
				mov [pr2],edx
489
			.end_1:
490
			mov eax,[ecx+offs_zbup_y]
491
			sub eax,[ebx+offs_zbup_y]
492
			mov [nb_lines],eax ;nb_lines = p1.y - p0.y
493
			jmp .end_0
494
		.els_0:
495
			; second part
496
			mov dword[update_left],0
497
			mov dword[update_right],1
498
			fldz
499
			fld dword[fz]
500
			fcompp ;if (fz > 0)
501
			fstsw ax
502
			sahf
503
			jbe .els_2
504
				mov [pr1],ecx
505
				mov [pr2],edx
506
				jmp .end_2
507
			.els_2:
508
				mov [l1],ecx
509
				mov [l2],edx
510
			.end_2:
511
			mov eax,[edx+offs_zbup_y]
512
			sub eax,[ecx+offs_zbup_y]
513
			inc eax
514
			mov [nb_lines],eax ;nb_lines = p2.y - p1.y + 1
515
		.end_0:
5153 IgorA 516
 
517
	; compute the values for the left edge
518
 
5175 IgorA 519
	cmp dword[update_left],0 ;if (update_left)
520
	je .end_upd_l
521
		mov ebx,[l1]
522
		mov ecx,[l2]
523
		mov eax,[ecx+offs_zbup_x]
524
		sub eax,[ebx+offs_zbup_x]
525
		mov [dx1],eax ;dx1 = l2.x - l1.x
526
		mov eax,[ecx+offs_zbup_y]
527
		sub eax,[ebx+offs_zbup_y]
528
		mov [dy1],eax ;dy1 = l2.y - l1.y
529
		cmp eax,0 ;if (dy1 > 0)
530
		jle .els_3
531
			mov eax,[dx1]
532
			shl eax,16
533
			xor edx,edx
534
			div dword[dy1] ;eax = (dx1 << 16) / dy1
535
			jmp .end_3
536
		.els_3:
537
			xor eax,eax
538
		.end_3:
539
		mov edx,[ebx+offs_zbup_x]
540
		mov [x1],edx
541
		mov dword[error],0
542
		mov dword[derror],eax
543
		and dword[derror],0xffff
544
		shr eax,16
545
		mov [dxdy_min],eax
546
		inc eax
547
		mov [dxdy_max],eax
5153 IgorA 548
 
549
if INTERP_Z eq 1
5175 IgorA 550
	mov eax,[l1]
551
	mov eax,[eax+offs_zbup_z]
552
	mov [z1],eax ;z1 = l1.z
553
	mov eax,[dzdx]
554
	imul eax,[dxdy_min]
555
	add eax,[dzdy]
556
	mov [dzdl_min],eax ;dzdl_min = (dzdy +dzdx*dxdy_min)
557
	add eax,[dzdx]
558
	mov [dzdl_max],eax ;dzdl_max = dzdl_min +dzdx
5153 IgorA 559
end if
560
if INTERP_RGB eq 1
5175 IgorA 561
	mov ebx,[l1]
562
	mov eax,[ebx+offs_zbup_r]
563
	mov [r1],eax ;r1 = l1.r
564
	mov eax,[drdx]
565
	imul eax,[dxdy_min]
566
	add eax,[drdy]
567
	mov [drdl_min],eax ;drdl_min = (drdy +drdx*dxdy_min)
568
	add eax,[drdx]
569
	mov [drdl_max],eax ;drdl_max = drdl_min +drdx
5153 IgorA 570
 
5175 IgorA 571
	mov eax,[ebx+offs_zbup_g]
572
	mov [g1],eax ;g1 = l1.g
573
	mov eax,[dgdx]
574
	imul eax,[dxdy_min]
575
	add eax,[dgdy]
576
	mov [dgdl_min],eax ;dgdl_min = (dgdy +dgdx*dxdy_min)
577
	add eax,[dgdx]
578
	mov [dgdl_max],eax ;dgdl_max = dgdl_min +dgdx
5153 IgorA 579
 
5175 IgorA 580
	mov eax,[ebx+offs_zbup_b]
581
	mov [b1],eax ;b1 = l1.b
582
	mov eax,[dbdx]
583
	imul eax,[dxdy_min]
584
	add eax,[dbdy]
585
	mov [dbdl_min],eax ;dbdl_min = (dbdy +dbdx*dxdy_min)
586
	add eax,[dbdx]
587
	mov [dbdl_max],eax ;dbdl_max = dbdl_min +dbdx
588
 
5153 IgorA 589
end if
590
if INTERP_ST eq 1
5175 IgorA 591
	mov ebx,[l1]
592
	mov eax,[ebx+offs_zbup_s]
593
	mov [s1],eax ;s1 = l1.s
594
	mov eax,[dsdx]
595
	imul eax,[dxdy_min]
596
	add eax,[dsdy]
597
	mov [dsdl_min],eax ;dsdl_min = (dsdy +dsdx*dxdy_min)
598
	add eax,[dsdx]
599
	mov [dsdl_max],eax ;dsdl_max = dsdl_min +dsdx
5153 IgorA 600
 
5175 IgorA 601
	mov eax,[ebx+offs_zbup_t]
602
	mov [t1],eax ;t1 = l1.t
603
	mov eax,[dtdx]
604
	imul eax,[dxdy_min]
605
	add eax,[dtdy]
606
	mov [dtdl_min],eax ;dtdl_min = (dtdy +dtdx*dxdy_min)
607
	add eax,[dtdx]
608
	mov [dtdl_max],eax ;dtdl_max = dtdl_min +dtdx
5153 IgorA 609
end if
610
if INTERP_STZ eq 1
5175 IgorA 611
	mov ebx,[l1]
612
	mov eax,[ebx+offs_zbup_sz]
613
	mov [sz1],eax ;sz1 = l1.sz - преобразований нет, потому без сопроцессора
614
	fild dword[dxdy_min]
615
	fmul dword[dszdx]
616
	fadd dword[dszdy]
617
	fst dword[dszdl_min] ;dszdl_min = (dszdy +dszdx*dxdy_min)
618
	fadd dword[dszdx]
619
	fstp dword[dszdl_max] ;dszdl_max = dszdl_min +dszdx
5153 IgorA 620
 
5175 IgorA 621
	mov eax,[ebx+offs_zbup_tz]
622
	mov [tz1],eax ;tz1 = l1.tz - преобразований нет, потому без сопроцессора
623
	fild dword[dxdy_min]
624
	fmul dword[dtzdx]
625
	fadd dword[dtzdy]
626
	fst dword[dtzdl_min] ;dtzdl_min = (dtzdy +dtzdx*dxdy_min)
627
	fadd dword[dtzdx]
628
	fstp dword[dtzdl_max] ;dtzdl_max = dtzdl_min +dtzdx
5153 IgorA 629
end if
5175 IgorA 630
	.end_upd_l:
5153 IgorA 631
 
5175 IgorA 632
	; compute values for the right edge
5153 IgorA 633
 
5175 IgorA 634
	cmp dword[update_right],0 ;if(update_right)
635
	je .end_upd_r
636
		mov ebx,[pr1]
637
		mov ecx,[pr2]
638
		mov eax,[ecx+offs_zbup_x]
639
		sub eax,[ebx+offs_zbup_x]
640
		mov [dx2],eax ;dx2 = pr2.x - pr1.x
641
		mov eax,[ecx+offs_zbup_y]
642
		sub eax,[ebx+offs_zbup_y]
643
		mov [dy2],eax ;dy2 = pr2.y - pr1.y
644
		cmp eax,0 ;if (dy2 > 0)
645
		jle .els_4
646
			mov eax,[dx2]
647
			shl eax,16
648
			xor edx,edx
649
			div dword[dy2] ;eax = (dx2 << 16) / dy2
650
			jmp .end_4
651
		.els_4:
652
			xor eax,eax
653
		.end_4:
654
		mov [dx2dy2],eax
655
		mov eax,[ebx+offs_zbup_x]
656
		shl eax,16
657
		mov [x2],eax ; x2 = pr1.x << 16
658
	.end_upd_r:
5153 IgorA 659
 
5175 IgorA 660
	; we draw all the scan line of the part
5153 IgorA 661
 
5175 IgorA 662
	.beg_w_lin:
663
	cmp dword[nb_lines],0 ;while (nb_lines>0)
664
	jle .end_w_lin
665
		dec dword[nb_lines]
666
if DRAW_LINE_M eq 1
667
		DRAW_LINE 1
668
else
669
		; generic draw line
670
		mov eax,[x2]
671
		shr eax,16
672
		mov edi,[x1]
673
		sub eax,edi
674
		mov [n],eax ;n = (x2 >> 16) - x1
675
		imul edi,PSZB
676
		add edi,[pp1] ;pp = pp1 + x1 * PSZB
5153 IgorA 677
if INTERP_Z eq 1
5175 IgorA 678
		mov eax,[x1]
679
		shl eax,1
680
		add eax,[pz1]
681
		mov [pz],eax
682
		mov eax,[z1]
683
		mov [z],eax
5153 IgorA 684
end if
685
if INTERP_RGB eq 1
5175 IgorA 686
		mov eax,[r1]
687
		mov [or1],eax
688
		mov eax,[g1]
689
		mov [og1],eax
690
		mov eax,[b1]
691
		mov [ob1],eax
5153 IgorA 692
end if
693
if INTERP_ST eq 1
5175 IgorA 694
		mov eax,[s1]
695
		mov [s],eax
696
		mov eax,[t1]
697
		mov [t],eax
5153 IgorA 698
end if
699
if INTERP_STZ eq 1
5175 IgorA 700
		mov eax,[sz1]
701
		mov [s_z],eax
702
		mov eax,[tz1]
703
		mov [t_z],eax
5153 IgorA 704
end if
5175 IgorA 705
		.cycle_1: ;while (n>=3)
706
			PUT_PIXEL 0
707
			PUT_PIXEL 1
708
			PUT_PIXEL 2
709
			PUT_PIXEL 3
5153 IgorA 710
if INTERP_Z eq 1
5175 IgorA 711
			add dword[pz],8 ;=4*sizeof(uint)
5153 IgorA 712
end if
5175 IgorA 713
			add edi,4*PSZB
714
			sub dword[n],4
715
			cmp dword[n],3
716
		jge .cycle_1
717
		.cycle_2: ;while (n>=0)
718
			PUT_PIXEL 0
5153 IgorA 719
if INTERP_Z eq 1
5175 IgorA 720
			add dword[pz],2 ;=sizeof(uint)
5153 IgorA 721
end if
5175 IgorA 722
			add edi,PSZB
723
			dec dword[n]
724
			cmp dword[n],0
725
		jge .cycle_2
5153 IgorA 726
end if
5175 IgorA 727
 
728
	; left edge
729
	mov eax,[derror]
730
	add [error],eax
731
	cmp eax,0 ;if (error > 0)
732
	jle .els_er
733
		sub dword[error],0x10000
734
		mov eax,[dxdy_max]
735
		add [x1],eax
5153 IgorA 736
if INTERP_Z eq 1
5175 IgorA 737
		mov eax,[dzdl_max]
738
		add [z1],eax
5153 IgorA 739
end if
740
if INTERP_RGB eq 1
5175 IgorA 741
		mov eax,[drdl_max]
742
		add [r1],eax
743
		mov eax,[dgdl_max]
744
		add [g1],eax
745
		mov eax,[dbdl_max]
746
		add [b1],eax
5153 IgorA 747
end if
748
if INTERP_ST eq 1
5175 IgorA 749
		mov eax,[dsdl_max]
750
		add [s1],eax
751
		mov eax,[dtdl_max]
752
		add [t1],eax
5153 IgorA 753
end if
754
if INTERP_STZ eq 1
5175 IgorA 755
		fld dword[dszdl_max]
756
		fadd dword[sz1]
757
		fstp dword[sz1]
758
		fld dword[dtzdl_max]
759
		fadd dword[tz1]
760
		fstp dword[tz1]
5153 IgorA 761
end if
5175 IgorA 762
		jmp .end_er
763
	.els_er:
764
		mov eax,[dxdy_min]
765
		add [x1],eax
5153 IgorA 766
if INTERP_Z eq 1
5175 IgorA 767
		mov eax,[dzdl_min]
768
		add [z1],eax
5153 IgorA 769
end if
770
if INTERP_RGB eq 1
5175 IgorA 771
		mov eax,[drdl_min]
772
		add [r1],eax
773
		mov eax,[dgdl_min]
774
		add [g1],eax
775
		mov eax,[dbdl_min]
776
		add [b1],eax
5153 IgorA 777
end if
778
if INTERP_ST eq 1
5175 IgorA 779
		mov eax,[dsdl_min]
780
		add [s1],eax
781
		mov eax,[dtdl_min]
782
		add [t1],eax
5153 IgorA 783
end if
784
if INTERP_STZ eq 1
5175 IgorA 785
		fld dword[dszdl_min]
786
		fadd dword[sz1]
787
		fstp dword[sz1]
788
		fld dword[dtzdl_min]
789
		fadd dword[tz1]
790
		fstp dword[tz1]
5153 IgorA 791
end if
5175 IgorA 792
	.end_er:
5153 IgorA 793
 
5175 IgorA 794
			; right edge
795
			mov eax,[dx2dy2]
796
			add [x2],eax
797
 
798
			; screen coordinates
799
			mov ebx,[zb]
800
			mov eax,[ebx+offs_zbuf_linesize]
801
			add [pp1],eax
802
			mov eax,[ebx+offs_zbuf_xsize]
803
			shl eax,1
804
			add [pz1],eax
805
			jmp .beg_w_lin
806
		.end_w_lin:
807
		inc dword[part]
808
		cmp dword[part],2
809
		jl .cycle_0
810
	.end_f:
811
	ret
812
endp
813
 
5153 IgorA 814
restore INTERP_Z
815
restore INTERP_RGB
816
restore INTERP_ST
817
restore INTERP_STZ
5175 IgorA 818
restore DRAW_LINE_M
5153 IgorA 819
 
820
purge DRAW_INIT
5175 IgorA 821
purge DRAW_LINE
5153 IgorA 822
purge PUT_PIXEL