Subversion Repositories Kolibri OS

Rev

Rev 5175 | Rev 5189 | 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
5187 IgorA 173
if DEBUG ;(2)
174
stdcall dbg_print,txt_sp,m_2
175
end if
5175 IgorA 176
	fld1
177
	fdiv dword[fz] ;fz = 1.0 / fz
178
	fst dword[fz]  ;st0 = fz
5153 IgorA 179
 
5175 IgorA 180
	fld dword[fdx1]
181
	fmul st0,st1
182
	fstp dword[fdx1] ;fdx1 *= fz
183
	fld dword[fdy1]
184
	fmul st0,st1
185
	fstp dword[fdy1] ;fdy1 *= fz
186
	fld dword[fdx2]
187
	fmul st0,st1
188
	fstp dword[fdx2] ;fdx2 *= fz
189
	fld dword[fdy2]
190
	fmul st0,st1
191
	fstp dword[fdy2] ;fdy2 *= fz
192
	ffree st0
193
	fincstp
5153 IgorA 194
 
195
if INTERP_Z eq 1
5175 IgorA 196
	mov eax,[ecx+offs_zbup_z]
197
	sub eax,[ebx+offs_zbup_z]
198
	mov [d1],eax
199
	mov eax,[edx+offs_zbup_z]
200
	sub eax,[ebx+offs_zbup_z]
201
	mov [d2],eax
5187 IgorA 202
	fild dword[d1] ;d1 = p1.z - p0.z
203
	fild dword[d2] ;d2 = p2.z - p0.z
5175 IgorA 204
 
5187 IgorA 205
	fld dword[fdy2]
206
	fmul st0,st2
5175 IgorA 207
	fld dword[fdy1]
5187 IgorA 208
	fmul st0,st2
209
	fsubp
210
	fistp dword[dzdx] ;dzdx = (int) (fdy2*d1 - fdy1*d2)
211
	fld dword[fdx1]
5175 IgorA 212
	fmul st0,st1
5187 IgorA 213
	fld dword[fdx2]
5175 IgorA 214
	fmul st0,st3
5187 IgorA 215
	fsubp
5175 IgorA 216
	fistp dword[dzdy] ;dzdy = (int) (fdx1*d2 - fdx2*d1)
5187 IgorA 217
	ffree st0 ;free d2
5175 IgorA 218
	fincstp
5187 IgorA 219
	ffree st0 ;free d1
220
	fincstp
5153 IgorA 221
end if
222
 
223
if INTERP_RGB eq 1
5175 IgorA 224
	mov eax,[ecx+offs_zbup_r]
225
	sub eax,[ebx+offs_zbup_r]
226
	mov [d1],eax
227
	mov eax,[edx+offs_zbup_r]
228
	sub eax,[ebx+offs_zbup_r]
229
	mov [d2],eax
5187 IgorA 230
	fild dword[d1] ;d1 = p1.r - p0.r
231
	fild dword[d2] ;d2 = p2.r - p0.r
5153 IgorA 232
 
5187 IgorA 233
	fld dword[fdy2]
234
	fmul st0,st2
5175 IgorA 235
	fld dword[fdy1]
5187 IgorA 236
	fmul st0,st2
237
	fsubp
238
	fistp dword[drdx] ;drdx = (int) (fdy2*d1 - fdy1*d2)
239
	fld dword[fdx1]
5175 IgorA 240
	fmul st0,st1
5187 IgorA 241
	fld dword[fdx2]
5175 IgorA 242
	fmul st0,st3
5187 IgorA 243
	fsubp
5175 IgorA 244
	fistp dword[drdy] ;drdy = (int) (fdx1*d2 - fdx2*d1)
5187 IgorA 245
	ffree st0 ;free d2
5175 IgorA 246
	fincstp
5187 IgorA 247
	ffree st0 ;free d1
248
	fincstp
5153 IgorA 249
 
5175 IgorA 250
	mov eax,[ecx+offs_zbup_g]
251
	sub eax,[ebx+offs_zbup_g]
252
	mov [d1],eax
253
	mov eax,[edx+offs_zbup_g]
254
	sub eax,[ebx+offs_zbup_g]
255
	mov [d2],eax
5187 IgorA 256
	fild dword[d1] ;d1 = p1.g - p0.g
257
	fild dword[d2] ;d2 = p2.g - p0.g
5153 IgorA 258
 
5187 IgorA 259
	fld dword[fdy2]
260
	fmul st0,st2
5175 IgorA 261
	fld dword[fdy1]
5187 IgorA 262
	fmul st0,st2
263
	fsubp
264
	fistp dword[dgdx] ;dgdx = (int) (fdy2*d1 - fdy1*d2)
265
	fld dword[fdx1]
5175 IgorA 266
	fmul st0,st1
5187 IgorA 267
	fld dword[fdx2]
5175 IgorA 268
	fmul st0,st3
5187 IgorA 269
	fsubp
5175 IgorA 270
	fistp dword[dgdy] ;dgdy = (int) (fdx1*d2 - fdx2*d1)
5187 IgorA 271
	ffree st0 ;free d2
5175 IgorA 272
	fincstp
5187 IgorA 273
	ffree st0 ;free d1
274
	fincstp
5175 IgorA 275
 
276
	mov eax,[ecx+offs_zbup_b]
277
	sub eax,[ebx+offs_zbup_b]
278
	mov [d1],eax
279
	mov eax,[edx+offs_zbup_b]
280
	sub eax,[ebx+offs_zbup_b]
281
	mov [d2],eax
5187 IgorA 282
	fild dword[d1] ;d1 = p1.b - p0.b
283
	fild dword[d2] ;d2 = p2.b - p0.b
5175 IgorA 284
 
5187 IgorA 285
	fld dword[fdy2]
286
	fmul st0,st2
5175 IgorA 287
	fld dword[fdy1]
5187 IgorA 288
	fmul st0,st2
289
	fsubp
290
	fistp dword[dbdx] ;dbdx = (int) (fdy2*d1 - fdy1*d2)
291
	fld dword[fdx1]
5175 IgorA 292
	fmul st0,st1
5187 IgorA 293
	fld dword[fdx2]
5175 IgorA 294
	fmul st0,st3
5187 IgorA 295
	fsubp
5175 IgorA 296
	fistp dword[dbdy] ;dbdy = (int) (fdx1*d2 - fdx2*d1)
5187 IgorA 297
	ffree st0 ;free d2
5175 IgorA 298
	fincstp
5187 IgorA 299
	ffree st0 ;free d1
300
	fincstp
5153 IgorA 301
end if
302
 
303
if INTERP_ST eq 1
5175 IgorA 304
	mov eax,[ecx+offs_zbup_s]
305
	sub eax,[ebx+offs_zbup_s]
306
	mov [d1],eax
307
	mov eax,[edx+offs_zbup_s]
308
	sub eax,[ebx+offs_zbup_s]
309
	mov [d2],eax
5187 IgorA 310
	fild dword[d1] ;d1 = p1.s - p0.s
311
	fild dword[d2] ;d2 = p2.s - p0.s
5153 IgorA 312
 
5187 IgorA 313
	fld dword[fdy2]
314
	fmul st0,st2
5175 IgorA 315
	fld dword[fdy1]
5187 IgorA 316
	fmul st0,st2
317
	fsubp
5175 IgorA 318
	fistp dword[dsdx] ;dsdx = (int) (fdy2*d1 - fdy1*d2)
319
	fld dword[fdx2]
320
	fmul st0,st2
321
	fld dword[fdx1]
322
	fmul st0,st2
323
	fsub st0,st1
324
	fistp dword[dsdy] ;dsdy = (int) (fdx1*d2 - fdx2*d1)
325
	ffree st0
326
	fincstp
5187 IgorA 327
	ffree st0 ;free d2
328
	fincstp
329
	ffree st0 ;free d1
330
	fincstp
5175 IgorA 331
 
332
	mov eax,[ecx+offs_zbup_t]
333
	sub eax,[ebx+offs_zbup_t]
334
	mov [d1],eax
335
	mov eax,[edx+offs_zbup_t]
336
	sub eax,[ebx+offs_zbup_t]
337
	mov [d2],eax
5187 IgorA 338
	fild dword[d1] ;d1 = p1.t - p0.t
339
	fild dword[d2] ;d2 = p2.t - p0.t
5175 IgorA 340
 
341
	fld dword[fdy1]
342
	fmul st0,st1
343
	fld dword[fdy2]
344
	fmul st0,st3
345
	fsub st0,st1
346
	fistp dword[dtdx] ;dtdx = (int) (fdy2*d1 - fdy1*d2)
347
	ffree st0
348
	fincstp
349
	fld dword[fdx2]
350
	fmul st0,st2
351
	fld dword[fdx1]
352
	fmul st0,st2
353
	fsub st0,st1
354
	fistp dword[dtdy] ;dtdy = (int) (fdx1*d2 - fdx2*d1)
355
	ffree st0
356
	fincstp
5187 IgorA 357
	ffree st0 ;free d2
358
	fincstp
359
	ffree st0 ;free d1
360
	fincstp
5153 IgorA 361
end if
362
 
363
if INTERP_STZ eq 1
5175 IgorA 364
	fild dword[ebx+offs_zbup_z]
365
	fild dword[ebx+offs_zbup_s]
366
	fmul st0,st1
367
	fstp dword[ebx+offs_zbup_sz] ;p0.sz = (float) p0.s * p0.z
368
	fild dword[ebx+offs_zbup_t]
5187 IgorA 369
	fmulp
5175 IgorA 370
	fstp dword[ebx+offs_zbup_tz] ;p0.tz = (float) p0.t * p0.z
5153 IgorA 371
 
5175 IgorA 372
	fild dword[ecx+offs_zbup_z]
373
	fild dword[ecx+offs_zbup_s]
374
	fmul st0,st1
375
	fstp dword[ecx+offs_zbup_sz] ;p1.sz = (float) p1.s * p1.z
376
	fild dword[ecx+offs_zbup_t]
5187 IgorA 377
	fmulp
5175 IgorA 378
	fstp dword[ecx+offs_zbup_tz] ;p1.tz = (float) p1.t * p1.z
5153 IgorA 379
 
5175 IgorA 380
	fild dword[edx+offs_zbup_z]
381
	fild dword[edx+offs_zbup_s]
382
	fmul st0,st1
383
	fstp dword[edx+offs_zbup_sz] ;p2.sz = (float) p2.s * p2.z
384
	fild dword[edx+offs_zbup_t]
5187 IgorA 385
	fmulp
5175 IgorA 386
	fstp dword[edx+offs_zbup_tz] ;p2.tz = (float) p2.t * p2.z
387
 
388
	fld dword[ecx+offs_zbup_sz]
5187 IgorA 389
	fsub dword[ebx+offs_zbup_sz] ;d1 = p1.sz - p0.sz
5175 IgorA 390
	fld dword[edx+offs_zbup_sz]
5187 IgorA 391
	fsub dword[ebx+offs_zbup_sz] ;d2 = p2.sz - p0.sz
5175 IgorA 392
 
5187 IgorA 393
	fld dword[fdy2]
394
	fmul st0,st2
5175 IgorA 395
	fld dword[fdy1]
5187 IgorA 396
	fmul st0,st2
397
	fsubp
398
	fstp dword[dszdx] ;dszdx = (fdy2*d1 - fdy1*d2)
5175 IgorA 399
	fld dword[fdx2]
400
	fmul st0,st2
401
	fld dword[fdx1]
402
	fmul st0,st2
403
	fsub st0,st1
5187 IgorA 404
	fstp dword[dszdy] ;dszdy = (fdx1*d2 - fdx2*d1)
5175 IgorA 405
	ffree st0
406
	fincstp
5187 IgorA 407
	ffree st0 ;free d2
408
	fincstp
409
	ffree st0 ;free d1
410
	fincstp
5175 IgorA 411
 
412
	fld dword[ecx+offs_zbup_tz]
5187 IgorA 413
	fsub dword[ebx+offs_zbup_tz] ;d1 = p1.tz - p0.tz
5175 IgorA 414
	fld dword[edx+offs_zbup_tz]
5187 IgorA 415
	fsub dword[ebx+offs_zbup_tz] ;d2 = p2.tz - p0.tz
5175 IgorA 416
 
417
	fld dword[fdy1]
418
	fmul st0,st1
419
	fld dword[fdy2]
420
	fmul st0,st3
421
	fsub st0,st1
5187 IgorA 422
	fstp dword[dtzdx] ;dtzdx = (fdy2*d1 - fdy1*d2)
5175 IgorA 423
	ffree st0
424
	fincstp
425
	fld dword[fdx2]
426
	fmul st0,st2
427
	fld dword[fdx1]
428
	fmul st0,st2
429
	fsub st0,st1
5187 IgorA 430
	fstp dword[dtzdy] ;dtzdy = (fdx1*d2 - fdx2*d1)
5175 IgorA 431
	ffree st0
432
	fincstp
5187 IgorA 433
	ffree st0 ;free d2
434
	fincstp
435
	ffree st0 ;free d1
436
	fincstp
5153 IgorA 437
end if
438
 
439
	; screen coordinates
5175 IgorA 440
	mov eax,[zb]
441
	mov edx,[eax+offs_zbuf_linesize]
442
	imul edx,[ebx+offs_zbup_y]
443
	add edx,[eax+offs_zbuf_pbuf]
444
	mov [pp1],edx ;pp1 = zb.pbuf + zb.linesize * p0.y
445
	mov edx,[eax+offs_zbuf_xsize]
446
	imul edx,[ebx+offs_zbup_y]
447
	shl edx,1
448
	add edx,[eax+offs_zbuf_zbuf]
449
	mov [pz1],edx ;pz1 = zb.zbuf + zb.xsize * p0.y
5153 IgorA 450
 
451
	DRAW_INIT
452
 
5175 IgorA 453
	mov dword[part],0
454
	.cycle_0:
5187 IgorA 455
if DEBUG ;(3)
456
stdcall dbg_print,txt_sp,m_3
457
end if
5175 IgorA 458
		mov ebx,[p0]
459
		mov ecx,[p1]
460
		mov edx,[p2]
5187 IgorA 461
		cmp dword[part],0 ;if (part == 0)
5175 IgorA 462
		jne .els_0
463
			mov dword[update_left],1
464
			mov dword[update_right],1
465
			mov [l1],ebx
466
			mov [pr1],ebx
467
			fldz
468
			fld dword[fz]
469
			fcompp ;if (fz > 0)
470
			fstsw ax
471
			sahf
472
			jbe .els_1
473
				mov [l2],edx
474
				mov [pr2],ecx
475
				jmp .end_1
476
			.els_1:
477
				mov [l2],ecx
478
				mov [pr2],edx
479
			.end_1:
480
			mov eax,[ecx+offs_zbup_y]
481
			sub eax,[ebx+offs_zbup_y]
482
			mov [nb_lines],eax ;nb_lines = p1.y - p0.y
483
			jmp .end_0
484
		.els_0:
485
			; second part
486
			fldz
487
			fld dword[fz]
488
			fcompp ;if (fz > 0)
489
			fstsw ax
490
			sahf
491
			jbe .els_2
5187 IgorA 492
				mov dword[update_left],0
493
				mov dword[update_right],1
5175 IgorA 494
				mov [pr1],ecx
495
				mov [pr2],edx
496
				jmp .end_2
497
			.els_2:
5187 IgorA 498
				mov dword[update_left],1
499
				mov dword[update_right],0
5175 IgorA 500
				mov [l1],ecx
501
				mov [l2],edx
502
			.end_2:
503
			mov eax,[edx+offs_zbup_y]
504
			sub eax,[ecx+offs_zbup_y]
505
			inc eax
506
			mov [nb_lines],eax ;nb_lines = p2.y - p1.y + 1
507
		.end_0:
5153 IgorA 508
 
509
	; compute the values for the left edge
5175 IgorA 510
	cmp dword[update_left],0 ;if (update_left)
511
	je .end_upd_l
512
		mov ebx,[l1]
513
		mov ecx,[l2]
5187 IgorA 514
		mov edx,[ecx+offs_zbup_y]
515
		sub edx,[ebx+offs_zbup_y]
516
		mov [dy1],edx ;dy1 = l2.y - l1.y
5175 IgorA 517
		mov eax,[ecx+offs_zbup_x]
518
		sub eax,[ebx+offs_zbup_x]
519
		mov [dx1],eax ;dx1 = l2.x - l1.x
5187 IgorA 520
		cmp edx,0 ;if (dy1 > 0)
5175 IgorA 521
		jle .els_3
5187 IgorA 522
			xor edx,edx
523
			cmp eax,0
524
			jl .otr_dx1
5175 IgorA 525
			shl eax,16
526
			div dword[dy1] ;eax = (dx1 << 16) / dy1
527
			jmp .end_3
5187 IgorA 528
			.otr_dx1:
529
			neg eax
530
			inc eax
531
			shl eax,16
532
			div dword[dy1] ;eax = (-dx1 << 16) / dy1
533
			neg eax
534
			inc eax
535
			jmp .end_3
5175 IgorA 536
		.els_3:
537
			xor eax,eax
538
		.end_3:
539
		mov edx,[ebx+offs_zbup_x]
5187 IgorA 540
		mov [x1],edx ;x1 = l1.x
541
		mov dword[error],0 ;error = 0
5175 IgorA 542
		mov dword[derror],eax
5187 IgorA 543
		and dword[derror],0xffff ;derror = eax & 0x0000ffff
5175 IgorA 544
		shr eax,16
5187 IgorA 545
		mov [dxdy_min],eax ;dxdy_min = eax >> 16
5175 IgorA 546
		inc eax
547
		mov [dxdy_max],eax
5153 IgorA 548
 
5187 IgorA 549
if DEBUG ;(4) update_left [dx1], [dy1], [dxdy_min], [dxdy_max]
550
push ecx edi
551
	mov ecx,80
552
	lea edi,[buf_param]
553
	mov eax,[dx1]
554
	stdcall convert_int_to_str,ecx
555
	stdcall str_n_cat,edi,txt_zp_sp,2
556
	stdcall str_len,edi
557
	add edi,eax
558
	sub ecx,eax
559
 
560
	mov eax,[dy1]
561
	stdcall convert_int_to_str,ecx
562
	stdcall str_n_cat,edi,txt_zp_sp,2
563
	stdcall str_len,edi
564
	add edi,eax
565
	sub ecx,eax
566
 
567
	mov eax,[dxdy_min]
568
	stdcall convert_int_to_str,ecx
569
	stdcall str_n_cat,edi,txt_zp_sp,2
570
	stdcall str_len,edi
571
	add edi,eax
572
	sub ecx,eax
573
 
574
	mov eax,[dxdy_max]
575
	stdcall convert_int_to_str,ecx
576
 
577
	stdcall str_n_cat,edi,txt_nl,2
578
	stdcall dbg_print,m_4,buf_param
579
pop edi ecx
580
end if
581
 
5153 IgorA 582
if INTERP_Z eq 1
5175 IgorA 583
	mov eax,[l1]
584
	mov eax,[eax+offs_zbup_z]
585
	mov [z1],eax ;z1 = l1.z
586
	mov eax,[dzdx]
587
	imul eax,[dxdy_min]
588
	add eax,[dzdy]
589
	mov [dzdl_min],eax ;dzdl_min = (dzdy +dzdx*dxdy_min)
590
	add eax,[dzdx]
591
	mov [dzdl_max],eax ;dzdl_max = dzdl_min +dzdx
5153 IgorA 592
end if
593
if INTERP_RGB eq 1
5175 IgorA 594
	mov ebx,[l1]
595
	mov eax,[ebx+offs_zbup_r]
596
	mov [r1],eax ;r1 = l1.r
597
	mov eax,[drdx]
598
	imul eax,[dxdy_min]
599
	add eax,[drdy]
600
	mov [drdl_min],eax ;drdl_min = (drdy +drdx*dxdy_min)
601
	add eax,[drdx]
602
	mov [drdl_max],eax ;drdl_max = drdl_min +drdx
5153 IgorA 603
 
5175 IgorA 604
	mov eax,[ebx+offs_zbup_g]
605
	mov [g1],eax ;g1 = l1.g
606
	mov eax,[dgdx]
607
	imul eax,[dxdy_min]
608
	add eax,[dgdy]
609
	mov [dgdl_min],eax ;dgdl_min = (dgdy +dgdx*dxdy_min)
610
	add eax,[dgdx]
611
	mov [dgdl_max],eax ;dgdl_max = dgdl_min +dgdx
5153 IgorA 612
 
5175 IgorA 613
	mov eax,[ebx+offs_zbup_b]
614
	mov [b1],eax ;b1 = l1.b
615
	mov eax,[dbdx]
616
	imul eax,[dxdy_min]
617
	add eax,[dbdy]
618
	mov [dbdl_min],eax ;dbdl_min = (dbdy +dbdx*dxdy_min)
619
	add eax,[dbdx]
620
	mov [dbdl_max],eax ;dbdl_max = dbdl_min +dbdx
5153 IgorA 621
end if
622
if INTERP_ST eq 1
5175 IgorA 623
	mov ebx,[l1]
624
	mov eax,[ebx+offs_zbup_s]
625
	mov [s1],eax ;s1 = l1.s
626
	mov eax,[dsdx]
627
	imul eax,[dxdy_min]
628
	add eax,[dsdy]
629
	mov [dsdl_min],eax ;dsdl_min = (dsdy +dsdx*dxdy_min)
630
	add eax,[dsdx]
631
	mov [dsdl_max],eax ;dsdl_max = dsdl_min +dsdx
5153 IgorA 632
 
5175 IgorA 633
	mov eax,[ebx+offs_zbup_t]
634
	mov [t1],eax ;t1 = l1.t
635
	mov eax,[dtdx]
636
	imul eax,[dxdy_min]
637
	add eax,[dtdy]
638
	mov [dtdl_min],eax ;dtdl_min = (dtdy +dtdx*dxdy_min)
639
	add eax,[dtdx]
640
	mov [dtdl_max],eax ;dtdl_max = dtdl_min +dtdx
5153 IgorA 641
end if
642
if INTERP_STZ eq 1
5175 IgorA 643
	mov ebx,[l1]
644
	mov eax,[ebx+offs_zbup_sz]
645
	mov [sz1],eax ;sz1 = l1.sz - преобразований нет, потому без сопроцессора
646
	fild dword[dxdy_min]
647
	fmul dword[dszdx]
648
	fadd dword[dszdy]
649
	fst dword[dszdl_min] ;dszdl_min = (dszdy +dszdx*dxdy_min)
650
	fadd dword[dszdx]
651
	fstp dword[dszdl_max] ;dszdl_max = dszdl_min +dszdx
5153 IgorA 652
 
5175 IgorA 653
	mov eax,[ebx+offs_zbup_tz]
654
	mov [tz1],eax ;tz1 = l1.tz - преобразований нет, потому без сопроцессора
655
	fild dword[dxdy_min]
656
	fmul dword[dtzdx]
657
	fadd dword[dtzdy]
658
	fst dword[dtzdl_min] ;dtzdl_min = (dtzdy +dtzdx*dxdy_min)
659
	fadd dword[dtzdx]
660
	fstp dword[dtzdl_max] ;dtzdl_max = dtzdl_min +dtzdx
5153 IgorA 661
end if
5175 IgorA 662
	.end_upd_l:
5153 IgorA 663
 
5175 IgorA 664
	; compute values for the right edge
5153 IgorA 665
 
5175 IgorA 666
	cmp dword[update_right],0 ;if(update_right)
667
	je .end_upd_r
668
		mov ebx,[pr1]
669
		mov ecx,[pr2]
5187 IgorA 670
		mov edx,[ebx+offs_zbup_x]
5175 IgorA 671
		mov eax,[ecx+offs_zbup_x]
5187 IgorA 672
		sub eax,edx
673
		;mov [dx2],eax ;dx2 = pr2.x - pr1.x
674
		shl edx,16
675
		mov [x2],edx ; x2 = pr1.x << 16
676
		mov edx,[ecx+offs_zbup_y]
677
		sub edx,[ebx+offs_zbup_y]
678
		mov [dy2],edx ;dy2 = pr2.y - pr1.y
679
		cmp edx,0 ;if (dy2 > 0)
5175 IgorA 680
		jle .els_4
5187 IgorA 681
			xor edx,edx
682
			cmp eax,0
683
			jl .otr_dx2
5175 IgorA 684
			shl eax,16
685
			div dword[dy2] ;eax = (dx2 << 16) / dy2
686
			jmp .end_4
5187 IgorA 687
			.otr_dx2:
688
			neg eax
689
			inc eax ;dx2 *= -1
690
			shl eax,16
691
			div dword[dy2] ;eax = (-dx2 << 16) / dy2
692
			neg eax
693
			inc eax
694
			jmp .end_4
5175 IgorA 695
		.els_4:
696
			xor eax,eax
697
		.end_4:
698
		mov [dx2dy2],eax
5187 IgorA 699
 
700
if DEBUG ;(5) update_right [dx2dy2], [dy2], [pr1.x], [pr2.x]
701
push ecx edi
702
	mov eax,[dx2dy2]
703
	shr eax,16
704
	mov ecx,80
705
	lea edi,[buf_param]
706
	stdcall convert_int_to_str,ecx
707
	stdcall str_n_cat,edi,txt_zp_sp,2
708
	stdcall str_len,edi
709
	add edi,eax
710
	sub ecx,eax
711
 
712
	mov eax,[dy2]
713
	stdcall convert_int_to_str,ecx
714
	stdcall str_n_cat,edi,txt_zp_sp,2
715
	stdcall str_len,edi
716
	add edi,eax
717
	sub ecx,eax
718
 
719
	mov ebx,[pr1]
720
	mov eax,[ebx+offs_zbup_x]
721
	stdcall convert_int_to_str,ecx
722
	stdcall str_n_cat,edi,txt_zp_sp,2
723
	stdcall str_len,edi
724
	add edi,eax
725
	sub ecx,eax
726
 
727
	mov ebx,[pr2]
728
	mov eax,[ebx+offs_zbup_x]
729
	stdcall convert_int_to_str,ecx
730
 
731
	stdcall str_n_cat,edi,txt_nl,2
732
	stdcall dbg_print,m_5,buf_param
733
pop edi ecx
734
end if
5175 IgorA 735
	.end_upd_r:
5153 IgorA 736
 
5175 IgorA 737
	; we draw all the scan line of the part
5187 IgorA 738
if DEBUG ;[nb_lines]
739
push ecx edi
740
	mov eax,[nb_lines]
741
	mov ecx,80
742
	lea edi,[buf_param]
743
	stdcall convert_int_to_str,ecx
5153 IgorA 744
 
5187 IgorA 745
	stdcall str_n_cat,edi,txt_nl,2
746
	stdcall dbg_print,f_fill_tr_nl,buf_param
747
pop edi ecx
748
end if
749
 
5175 IgorA 750
	.beg_w_lin:
751
	cmp dword[nb_lines],0 ;while (nb_lines>0)
752
	jle .end_w_lin
753
		dec dword[nb_lines]
754
if DRAW_LINE_M eq 1
755
		DRAW_LINE 1
756
else
757
		; generic draw line
758
		mov eax,[x2]
759
		shr eax,16
760
		mov edi,[x1]
761
		sub eax,edi
762
		mov [n],eax ;n = (x2 >> 16) - x1
763
		imul edi,PSZB
764
		add edi,[pp1] ;pp = pp1 + x1 * PSZB
5187 IgorA 765
 
766
if DEBUG ;[n], [x1], [x2]>>16
767
push ecx edi
768
	mov eax,[n]
769
	mov ecx,80
770
	lea edi,[buf_param]
771
	stdcall convert_int_to_str,ecx
772
	stdcall str_n_cat,edi,txt_zp_sp,2
773
	stdcall str_len,edi
774
	add edi,eax
775
	sub ecx,eax
776
 
777
	mov eax,[x1]
778
	stdcall convert_int_to_str,ecx
779
	stdcall str_n_cat,edi,txt_zp_sp,2
780
	stdcall str_len,edi
781
	add edi,eax
782
	sub ecx,eax
783
 
784
	mov eax,[x2]
785
	shr eax,16
786
	stdcall convert_int_to_str,ecx
787
 
788
	stdcall str_n_cat,edi,txt_nl,2
789
	stdcall dbg_print,f_fill_tr_nll,buf_param
790
pop edi ecx
791
end if
792
 
5153 IgorA 793
if INTERP_Z eq 1
5175 IgorA 794
		mov eax,[x1]
795
		shl eax,1
796
		add eax,[pz1]
797
		mov [pz],eax
798
		mov eax,[z1]
799
		mov [z],eax
5153 IgorA 800
end if
801
if INTERP_RGB eq 1
5175 IgorA 802
		mov eax,[r1]
803
		mov [or1],eax
804
		mov eax,[g1]
805
		mov [og1],eax
806
		mov eax,[b1]
807
		mov [ob1],eax
5153 IgorA 808
end if
809
if INTERP_ST eq 1
5175 IgorA 810
		mov eax,[s1]
811
		mov [s],eax
812
		mov eax,[t1]
813
		mov [t],eax
5153 IgorA 814
end if
815
if INTERP_STZ eq 1
5175 IgorA 816
		mov eax,[sz1]
817
		mov [s_z],eax
818
		mov eax,[tz1]
819
		mov [t_z],eax
5153 IgorA 820
end if
5187 IgorA 821
 
822
align 4
5175 IgorA 823
		.cycle_1: ;while (n>=3)
5187 IgorA 824
		cmp dword[n],3
825
		jl .cycle_2
5175 IgorA 826
			PUT_PIXEL 0
827
			PUT_PIXEL 1
828
			PUT_PIXEL 2
829
			PUT_PIXEL 3
5153 IgorA 830
if INTERP_Z eq 1
5175 IgorA 831
			add dword[pz],8 ;=4*sizeof(uint)
5153 IgorA 832
end if
5175 IgorA 833
			add edi,4*PSZB
834
			sub dword[n],4
5187 IgorA 835
		jmp .cycle_1
5175 IgorA 836
		.cycle_2: ;while (n>=0)
5187 IgorA 837
		cmp dword[n],0
838
		jl .cycle_2_end
5175 IgorA 839
			PUT_PIXEL 0
5153 IgorA 840
if INTERP_Z eq 1
5175 IgorA 841
			add dword[pz],2 ;=sizeof(uint)
5153 IgorA 842
end if
5175 IgorA 843
			add edi,PSZB
844
			dec dword[n]
5187 IgorA 845
		jmp .cycle_2
846
		.cycle_2_end:
847
end if ;проверка от макроса DRAW_LINE
5175 IgorA 848
 
849
	; left edge
850
	mov eax,[derror]
851
	add [error],eax
5187 IgorA 852
	cmp dword[error],0 ;if (error > 0)
5175 IgorA 853
	jle .els_er
854
		sub dword[error],0x10000
855
		mov eax,[dxdy_max]
856
		add [x1],eax
5153 IgorA 857
if INTERP_Z eq 1
5175 IgorA 858
		mov eax,[dzdl_max]
859
		add [z1],eax
5153 IgorA 860
end if
861
if INTERP_RGB eq 1
5175 IgorA 862
		mov eax,[drdl_max]
863
		add [r1],eax
864
		mov eax,[dgdl_max]
865
		add [g1],eax
866
		mov eax,[dbdl_max]
867
		add [b1],eax
5153 IgorA 868
end if
869
if INTERP_ST eq 1
5175 IgorA 870
		mov eax,[dsdl_max]
871
		add [s1],eax
872
		mov eax,[dtdl_max]
873
		add [t1],eax
5153 IgorA 874
end if
875
if INTERP_STZ eq 1
5175 IgorA 876
		fld dword[dszdl_max]
877
		fadd dword[sz1]
878
		fstp dword[sz1]
879
		fld dword[dtzdl_max]
880
		fadd dword[tz1]
881
		fstp dword[tz1]
5153 IgorA 882
end if
5175 IgorA 883
		jmp .end_er
884
	.els_er:
885
		mov eax,[dxdy_min]
886
		add [x1],eax
5153 IgorA 887
if INTERP_Z eq 1
5175 IgorA 888
		mov eax,[dzdl_min]
889
		add [z1],eax
5153 IgorA 890
end if
891
if INTERP_RGB eq 1
5175 IgorA 892
		mov eax,[drdl_min]
893
		add [r1],eax
894
		mov eax,[dgdl_min]
895
		add [g1],eax
896
		mov eax,[dbdl_min]
897
		add [b1],eax
5153 IgorA 898
end if
899
if INTERP_ST eq 1
5175 IgorA 900
		mov eax,[dsdl_min]
901
		add [s1],eax
902
		mov eax,[dtdl_min]
903
		add [t1],eax
5153 IgorA 904
end if
905
if INTERP_STZ eq 1
5175 IgorA 906
		fld dword[dszdl_min]
907
		fadd dword[sz1]
908
		fstp dword[sz1]
909
		fld dword[dtzdl_min]
910
		fadd dword[tz1]
911
		fstp dword[tz1]
5153 IgorA 912
end if
5175 IgorA 913
	.end_er:
5153 IgorA 914
 
5175 IgorA 915
			; right edge
916
			mov eax,[dx2dy2]
917
			add [x2],eax
918
 
919
			; screen coordinates
920
			mov ebx,[zb]
921
			mov eax,[ebx+offs_zbuf_linesize]
922
			add [pp1],eax
923
			mov eax,[ebx+offs_zbuf_xsize]
924
			shl eax,1
925
			add [pz1],eax
926
			jmp .beg_w_lin
927
		.end_w_lin:
928
		inc dword[part]
929
		cmp dword[part],2
930
		jl .cycle_0
931
	.end_f:
5187 IgorA 932
popad
5175 IgorA 933
	ret
934
endp
935
 
5153 IgorA 936
restore INTERP_Z
937
restore INTERP_RGB
938
restore INTERP_ST
939
restore INTERP_STZ
5175 IgorA 940
restore DRAW_LINE_M
5153 IgorA 941
 
942
purge DRAW_INIT
5175 IgorA 943
purge DRAW_LINE
5153 IgorA 944
purge PUT_PIXEL