Subversion Repositories Kolibri OS

Rev

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