Subversion Repositories Kolibri OS

Rev

Rev 5175 | Rev 5189 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5175 Rev 5187
Line 17... Line 17...
17
	pp1 dd ? ;PIXEL*
17
	pp1 dd ? ;PIXEL*
18
	part dd ?
18
	part dd ?
19
	update_left dd ?
19
	update_left dd ?
20
	update_right dd ?
20
	update_right dd ?
Line 21... Line 21...
21
 
21
 
22
	nb_lines dd ?
22
	nb_lines dd ? ;число горизонтальных линий в половине треугольника
23
	dx1 dd ?
23
	dx1 dd ?
24
	dy1 dd ?
24
	dy1 dd ?
25
	dx2 dd ?
25
	;dx2 dd ?
Line 26... Line 26...
26
	dy2 dd ?
26
	dy2 dd ?
27
 
27
 
28
	error dd ?
28
	error dd ? ;int
29
	derror dd ?
29
	derror dd ? ;int
30
	x1 dd ?
30
	x1 dd ? ;int
31
	dxdy_min dd ?
31
	dxdy_min dd ? ;int
32
	dxdy_max dd ?
32
	dxdy_max dd ? ;int
33
	; warning: x2 is multiplied by 2^16
33
	; warning: x2 is multiplied by 2^16
Line 34... Line 34...
34
	x2 dd ?
34
	x2 dd ? ;int
35
	dx2dy2 dd ?
35
	dx2dy2 dd ? ;int
36
 
36
 
37
if INTERP_Z eq 1
37
if INTERP_Z eq 1
38
	z1 dd ?
38
	z1 dd ? ;int
39
	dzdx dd ?
39
	dzdx dd ? ;int
40
	dzdy dd ?
40
	dzdy dd ? ;int
41
	dzdl_min dd ?
41
	dzdl_min dd ? ;int
42
	dzdl_max dd ?
42
	dzdl_max dd ? ;int
43
end if
43
end if
44
if INTERP_RGB eq 1
44
if INTERP_RGB eq 1
Line 57... Line 57...
57
	dbdy dd ?
57
	dbdy dd ?
58
	dbdl_min dd ?
58
	dbdl_min dd ?
59
	dbdl_max dd ?
59
	dbdl_max dd ?
60
end if
60
end if
61
if INTERP_ST eq 1
61
if INTERP_ST eq 1
62
	s1 dd ?
62
	s1 dd ? ;int
63
	dsdx dd ?
63
	dsdx dd ? ;int
64
	dsdy dd ?
64
	dsdy dd ? ;int
65
	dsdl_min dd ?
65
	dsdl_min dd ? ;int
66
	dsdl_max dd ?
66
	dsdl_max dd ? ;int
67
	t1 dd ?
67
	t1 dd ? ;int
68
	dtdx dd ?
68
	dtdx dd ? ;int
69
	dtdy dd ?
69
	dtdy dd ? ;int
70
	dtdl_min dd ?
70
	dtdl_min dd ? ;int
71
	dtdl_max dd ?
71
	dtdl_max dd ? ;int
72
end if
72
end if
73
if INTERP_STZ eq 1
73
if INTERP_STZ eq 1
74
	sz1 dd ? ;float
74
	sz1 dd ? ;float
75
	dszdx dd ? ;float
75
	dszdx dd ? ;float
76
	dszdy dd ? ;float
76
	dszdy dd ? ;float
Line 81... Line 81...
81
	dtzdy dd ? ;float
81
	dtzdy dd ? ;float
82
	dtzdl_min dd ? ;float
82
	dtzdl_min dd ? ;float
83
	dtzdl_max dd ? ;float
83
	dtzdl_max dd ? ;float
84
end if
84
end if
Line -... Line 85...
-
 
85
 
85
 
86
 
86
if DRAW_LINE_M eq 1
87
if DRAW_LINE_M eq 1
87
	DRAW_LINE 0 ;переменные делаются в макросе
88
	DRAW_LINE 0 ;переменные делаются в макросе
88
else
-
 
89
	;edi = pp dd ?
89
else
90
	n dd ? ;int
90
	n dd ? ;int - длинна горизонтальной линии в пикселях
91
if INTERP_Z eq 1
91
if INTERP_Z eq 1
92
	pz dd ? ;unsigned short *
92
	pz dd ? ;unsigned short *
93
	z dd ? ;uint
93
	z dd ? ;uint
94
	zz dd ? ;uint
94
	zz dd ? ;uint
Line 107... Line 107...
107
	t_z dd ? ;float
107
	t_z dd ? ;float
108
end if
108
end if
109
end if
109
end if
Line 110... Line 110...
110
 
110
 
-
 
111
endl
-
 
112
pushad
-
 
113
 
-
 
114
if DEBUG ;(1)
-
 
115
stdcall dbg_print,f_fill_tr,m_1
Line 111... Line 116...
111
endl
116
end if
112
 
117
 
113
	; we sort the vertex with increasing y
118
	; 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]
119
	mov ebx,[p0]
-
 
120
	mov ecx,[p1]
-
 
121
	mov edx,[p2]
-
 
122
	mov eax,[edx+offs_zbup_y]
133
		mov ecx,[p1]
123
	cmp [ecx+offs_zbup_y],eax ;(2-1)
134
		mov edx,[p2]
124
	jle @f
135
		jmp .end_e0
125
		xchg edx,ecx
136
	@@:
126
	@@:
137
	mov eax,[ecx+offs_zbup_y]
127
	mov eax,[ecx+offs_zbup_y]
-
 
128
	cmp [ebx+offs_zbup_y],eax ;(1-0)
-
 
129
	jle @f
138
	cmp [edx+offs_zbup_y],eax
130
		xchg ecx,ebx
-
 
131
	@@:
-
 
132
	mov eax,[edx+offs_zbup_y]
-
 
133
	cmp [ecx+offs_zbup_y],eax ;(2-1)
-
 
134
	jle @f
139
	jge .end_e0
135
		xchg edx,ecx
140
		;else if (p2.y < p1.y)
136
	@@:
141
		mov [p1],edx
137
	mov [p0],ebx
Line 142... Line 138...
142
		mov [p2],ecx
138
	mov [p1],ecx
143
	.end_e0:
-
 
144
 
139
	mov [p2],edx
145
	; we compute dXdx and dXdy for all interpolated values
140
 
146
 
141
	; we compute dXdx and dXdy for all interpolated values
147
	mov eax,[ecx+offs_zbup_x]
142
	mov eax,[ecx+offs_zbup_x]
148
	sub eax,[ebx+offs_zbup_x]
143
	sub eax,[ebx+offs_zbup_x]
Line 156... Line 151...
156
	mov [fdx2],eax ;p2.x - p0.x
151
	mov [fdx2],eax ;p2.x - p0.x
157
	mov eax,[edx+offs_zbup_y]
152
	mov eax,[edx+offs_zbup_y]
158
	sub eax,[ebx+offs_zbup_y]
153
	sub eax,[ebx+offs_zbup_y]
159
	mov [fdy2],eax ;p2.y - p0.y
154
	mov [fdy2],eax ;p2.y - p0.y
Line 160... Line -...
160
 
-
 
161
	fild dword[fdx2]
-
 
162
	fst dword[fdx2]
-
 
163
	fild dword[fdy1]
-
 
164
	fst dword[fdy1]
-
 
165
	fmulp
155
 
166
	fild dword[fdx1]
156
	fild dword[fdx1]
167
	fst dword[fdx1]
157
	fst dword[fdx1]
168
	fild dword[fdy2]
158
	fild dword[fdy2]
169
	fst dword[fdy2]
159
	fst dword[fdy2]
-
 
160
	fmulp
-
 
161
	fild dword[fdx2]
-
 
162
	fst dword[fdx2]
-
 
163
	fild dword[fdy1]
-
 
164
	fst dword[fdy1]
170
	fmulp
165
	fmulp
171
	fsubp ;st0 = st0-st1
166
	fsubp ;st0 = st1-st0
172
	fst dword[fz] ;fz = fdx1 * fdy2 - fdx2 * fdy1
167
	fst dword[fz] ;fz = fdx1 * fdy2 - fdx2 * fdy1
173
	fldz
168
	fldz
174
	fcompp ;if (fz == 0)
169
	fcompp ;if (fz == 0) return
175
	fstsw ax
170
	fstsw ax
176
	sahf
171
	sahf
-
 
172
	je .end_f
-
 
173
if DEBUG ;(2)
-
 
174
stdcall dbg_print,txt_sp,m_2
177
	je .end_f
175
end if
178
	fld1
176
	fld1
179
	fdiv dword[fz] ;fz = 1.0 / fz
177
	fdiv dword[fz] ;fz = 1.0 / fz
Line 180... Line 178...
180
	fst dword[fz]  ;st0 = fz
178
	fst dword[fz]  ;st0 = fz
Line 199... Line 197...
199
	sub eax,[ebx+offs_zbup_z]
197
	sub eax,[ebx+offs_zbup_z]
200
	mov [d1],eax
198
	mov [d1],eax
201
	mov eax,[edx+offs_zbup_z]
199
	mov eax,[edx+offs_zbup_z]
202
	sub eax,[ebx+offs_zbup_z]
200
	sub eax,[ebx+offs_zbup_z]
203
	mov [d2],eax
201
	mov [d2],eax
204
	fild dword[d1]
-
 
205
	fst dword[d1] ;d1 = p1.z - p0.z
202
	fild dword[d1] ;d1 = p1.z - p0.z
206
	fild dword[d2]
-
 
207
	fst dword[d2] ;d2 = p2.z - p0.z
203
	fild dword[d2] ;d2 = p2.z - p0.z
Line 208... Line -...
208
 
-
 
209
	fld dword[fdy1]
-
 
210
	fmul st0,st1
204
 
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]
205
	fld dword[fdy2]
218
	fmul st0,st2
206
	fmul st0,st2
219
	fld dword[fdx1]
207
	fld dword[fdy1]
-
 
208
	fmul st0,st2
-
 
209
	fsubp
-
 
210
	fistp dword[dzdx] ;dzdx = (int) (fdy2*d1 - fdy1*d2)
220
	fmul st0,st2
211
	fld dword[fdx1]
-
 
212
	fmul st0,st1
-
 
213
	fld dword[fdx2]
-
 
214
	fmul st0,st3
221
	fsub st0,st1
215
	fsubp
-
 
216
	fistp dword[dzdy] ;dzdy = (int) (fdx1*d2 - fdx2*d1)
-
 
217
	ffree st0 ;free d2
222
	fistp dword[dzdy] ;dzdy = (int) (fdx1*d2 - fdx2*d1)
218
	fincstp
223
	ffree st0
219
	ffree st0 ;free d1
224
	fincstp
220
	fincstp
Line 225... Line 221...
225
end if
221
end if
226
 
222
 
227
if INTERP_RGB eq 1
223
if INTERP_RGB eq 1
228
	mov eax,[ecx+offs_zbup_r]
224
	mov eax,[ecx+offs_zbup_r]
229
	sub eax,[ebx+offs_zbup_r]
225
	sub eax,[ebx+offs_zbup_r]
230
	mov [d1],eax
226
	mov [d1],eax
231
	mov eax,[edx+offs_zbup_r]
227
	mov eax,[edx+offs_zbup_r]
232
	sub eax,[ebx+offs_zbup_r]
-
 
233
	mov [d2],eax
228
	sub eax,[ebx+offs_zbup_r]
234
	fild dword[d1]
-
 
235
	fst dword[d1] ;d1 = p1.r - p0.r
229
	mov [d2],eax
Line 236... Line -...
236
	fild dword[d2]
-
 
237
	fst dword[d2] ;d2 = p2.r - p0.r
-
 
238
 
230
	fild dword[d1] ;d1 = p1.r - p0.r
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
231
	fild dword[d2] ;d2 = p2.r - p0.r
246
	fincstp
232
 
247
	fld dword[fdx2]
233
	fld dword[fdy2]
-
 
234
	fmul st0,st2
-
 
235
	fld dword[fdy1]
-
 
236
	fmul st0,st2
248
	fmul st0,st2
237
	fsubp
-
 
238
	fistp dword[drdx] ;drdx = (int) (fdy2*d1 - fdy1*d2)
-
 
239
	fld dword[fdx1]
-
 
240
	fmul st0,st1
249
	fld dword[fdx1]
241
	fld dword[fdx2]
-
 
242
	fmul st0,st3
-
 
243
	fsubp
250
	fmul st0,st2
244
	fistp dword[drdy] ;drdy = (int) (fdx1*d2 - fdx2*d1)
251
	fsub st0,st1
245
	ffree st0 ;free d2
Line 252... Line 246...
252
	fistp dword[drdy] ;drdy = (int) (fdx1*d2 - fdx2*d1)
246
	fincstp
253
	ffree st0
247
	ffree st0 ;free d1
254
	fincstp
248
	fincstp
255
 
249
 
256
	mov eax,[ecx+offs_zbup_g]
250
	mov eax,[ecx+offs_zbup_g]
257
	sub eax,[ebx+offs_zbup_g]
251
	sub eax,[ebx+offs_zbup_g]
258
	mov [d1],eax
-
 
259
	mov eax,[edx+offs_zbup_g]
252
	mov [d1],eax
260
	sub eax,[ebx+offs_zbup_g]
-
 
261
	mov [d2],eax
253
	mov eax,[edx+offs_zbup_g]
Line 262... Line -...
262
	fild dword[d1]
-
 
263
	fst dword[d1] ;d1 = p1.g - p0.g
-
 
264
	fild dword[d2]
254
	sub eax,[ebx+offs_zbup_g]
265
	fst dword[d2] ;d2 = p2.g - p0.g
-
 
266
 
-
 
267
	fld dword[fdy1]
-
 
268
	fmul st0,st1
-
 
269
	fld dword[fdy2]
-
 
270
	fmul st0,st3
-
 
271
	fsub st0,st1
255
	mov [d2],eax
272
	fistp dword[dgdx] ;dgdx = (int) (fdy2*d1 - fdy1*d2)
256
	fild dword[d1] ;d1 = p1.g - p0.g
273
	ffree st0
257
	fild dword[d2] ;d2 = p2.g - p0.g
-
 
258
 
-
 
259
	fld dword[fdy2]
-
 
260
	fmul st0,st2
274
	fincstp
261
	fld dword[fdy1]
-
 
262
	fmul st0,st2
-
 
263
	fsubp
-
 
264
	fistp dword[dgdx] ;dgdx = (int) (fdy2*d1 - fdy1*d2)
275
	fld dword[fdx2]
265
	fld dword[fdx1]
-
 
266
	fmul st0,st1
-
 
267
	fld dword[fdx2]
276
	fmul st0,st2
268
	fmul st0,st3
277
	fld dword[fdx1]
269
	fsubp
Line 278... Line 270...
278
	fmul st0,st2
270
	fistp dword[dgdy] ;dgdy = (int) (fdx1*d2 - fdx2*d1)
279
	fsub st0,st1
271
	ffree st0 ;free d2
280
	fistp dword[dgdy] ;dgdy = (int) (fdx1*d2 - fdx2*d1)
272
	fincstp
281
	ffree st0
273
	ffree st0 ;free d1
282
	fincstp
274
	fincstp
283
 
275
 
284
	mov eax,[ecx+offs_zbup_b]
-
 
285
	sub eax,[ebx+offs_zbup_b]
276
	mov eax,[ecx+offs_zbup_b]
286
	mov [d1],eax
-
 
287
	mov eax,[edx+offs_zbup_b]
277
	sub eax,[ebx+offs_zbup_b]
Line 288... Line -...
288
	sub eax,[ebx+offs_zbup_b]
-
 
289
	mov [d2],eax
-
 
290
	fild dword[d1]
278
	mov [d1],eax
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]
279
	mov eax,[edx+offs_zbup_b]
298
	fmul st0,st3
280
	sub eax,[ebx+offs_zbup_b]
299
	fsub st0,st1
281
	mov [d2],eax
-
 
282
	fild dword[d1] ;d1 = p1.b - p0.b
-
 
283
	fild dword[d2] ;d2 = p2.b - p0.b
-
 
284
 
300
	fistp dword[dbdx] ;dbdx = (int) (fdy2*d1 - fdy1*d2)
285
	fld dword[fdy2]
-
 
286
	fmul st0,st2
-
 
287
	fld dword[fdy1]
-
 
288
	fmul st0,st2
301
	ffree st0
289
	fsubp
-
 
290
	fistp dword[dbdx] ;dbdx = (int) (fdy2*d1 - fdy1*d2)
-
 
291
	fld dword[fdx1]
302
	fincstp
292
	fmul st0,st1
303
	fld dword[fdx2]
293
	fld dword[fdx2]
304
	fmul st0,st2
294
	fmul st0,st3
Line 305... Line 295...
305
	fld dword[fdx1]
295
	fsubp
306
	fmul st0,st2
296
	fistp dword[dbdy] ;dbdy = (int) (fdx1*d2 - fdx2*d1)
307
	fsub st0,st1
297
	ffree st0 ;free d2
308
	fistp dword[dbdy] ;dbdy = (int) (fdx1*d2 - fdx2*d1)
298
	fincstp
309
	ffree st0
299
	ffree st0 ;free d1
310
	fincstp
300
	fincstp
311
end if
301
end if
312
 
-
 
313
if INTERP_ST eq 1
302
 
314
	mov eax,[ecx+offs_zbup_s]
-
 
315
	sub eax,[ebx+offs_zbup_s]
303
if INTERP_ST eq 1
Line 316... Line -...
316
	mov [d1],eax
-
 
317
	mov eax,[edx+offs_zbup_s]
-
 
318
	sub eax,[ebx+offs_zbup_s]
304
	mov eax,[ecx+offs_zbup_s]
319
	mov [d2],eax
305
	sub eax,[ebx+offs_zbup_s]
-
 
306
	mov [d1],eax
320
	fild dword[d1]
307
	mov eax,[edx+offs_zbup_s]
-
 
308
	sub eax,[ebx+offs_zbup_s]
321
	fst dword[d1] ;d1 = p1.s - p0.s
309
	mov [d2],eax
322
	fild dword[d2]
-
 
323
	fst dword[d2] ;d2 = p2.s - p0.s
-
 
324
 
310
	fild dword[d1] ;d1 = p1.s - p0.s
325
	fld dword[fdy1]
311
	fild dword[d2] ;d2 = p2.s - p0.s
326
	fmul st0,st1
312
 
327
	fld dword[fdy2]
313
	fld dword[fdy2]
328
	fmul st0,st3
314
	fmul st0,st2
329
	fsub st0,st1
315
	fld dword[fdy1]
330
	fistp dword[dsdx] ;dsdx = (int) (fdy2*d1 - fdy1*d2)
316
	fmul st0,st2
331
	ffree st0
317
	fsubp
-
 
318
	fistp dword[dsdx] ;dsdx = (int) (fdy2*d1 - fdy1*d2)
-
 
319
	fld dword[fdx2]
-
 
320
	fmul st0,st2
-
 
321
	fld dword[fdx1]
Line 332... Line 322...
332
	fincstp
322
	fmul st0,st2
333
	fld dword[fdx2]
323
	fsub st0,st1
334
	fmul st0,st2
324
	fistp dword[dsdy] ;dsdy = (int) (fdx1*d2 - fdx2*d1)
335
	fld dword[fdx1]
325
	ffree st0
336
	fmul st0,st2
326
	fincstp
337
	fsub st0,st1
327
	ffree st0 ;free d2
338
	fistp dword[dsdy] ;dsdy = (int) (fdx1*d2 - fdx2*d1)
-
 
339
	ffree st0
328
	fincstp
340
	fincstp
-
 
341
 
329
	ffree st0 ;free d1
Line 342... Line 330...
342
	mov eax,[ecx+offs_zbup_t]
330
	fincstp
343
	sub eax,[ebx+offs_zbup_t]
331
 
344
	mov [d1],eax
332
	mov eax,[ecx+offs_zbup_t]
345
	mov eax,[edx+offs_zbup_t]
333
	sub eax,[ebx+offs_zbup_t]
Line 364... Line 352...
364
	fmul st0,st2
352
	fmul st0,st2
365
	fsub st0,st1
353
	fsub st0,st1
366
	fistp dword[dtdy] ;dtdy = (int) (fdx1*d2 - fdx2*d1)
354
	fistp dword[dtdy] ;dtdy = (int) (fdx1*d2 - fdx2*d1)
367
	ffree st0
355
	ffree st0
368
	fincstp
356
	fincstp
-
 
357
	ffree st0 ;free d2
-
 
358
	fincstp
-
 
359
	ffree st0 ;free d1
-
 
360
	fincstp
369
end if
361
end if
Line 370... Line 362...
370
 
362
 
371
if INTERP_STZ eq 1
363
if INTERP_STZ eq 1
372
	fild dword[ebx+offs_zbup_z]
364
	fild dword[ebx+offs_zbup_z]
373
	fild dword[ebx+offs_zbup_s]
365
	fild dword[ebx+offs_zbup_s]
374
	fmul st0,st1
366
	fmul st0,st1
375
	fstp dword[ebx+offs_zbup_sz] ;p0.sz = (float) p0.s * p0.z
367
	fstp dword[ebx+offs_zbup_sz] ;p0.sz = (float) p0.s * p0.z
376
	fild dword[ebx+offs_zbup_t]
368
	fild dword[ebx+offs_zbup_t]
377
	fmul st0,st1
369
	fmulp
378
	fstp dword[ebx+offs_zbup_tz] ;p0.tz = (float) p0.t * p0.z
-
 
379
	ffree st0
-
 
Line 380... Line 370...
380
	fincstp
370
	fstp dword[ebx+offs_zbup_tz] ;p0.tz = (float) p0.t * p0.z
381
 
371
 
382
	fild dword[ecx+offs_zbup_z]
372
	fild dword[ecx+offs_zbup_z]
383
	fild dword[ecx+offs_zbup_s]
373
	fild dword[ecx+offs_zbup_s]
384
	fmul st0,st1
374
	fmul st0,st1
385
	fstp dword[ecx+offs_zbup_sz] ;p1.sz = (float) p1.s * p1.z
375
	fstp dword[ecx+offs_zbup_sz] ;p1.sz = (float) p1.s * p1.z
386
	fild dword[ecx+offs_zbup_t]
376
	fild dword[ecx+offs_zbup_t]
387
	fmul st0,st1
-
 
388
	fstp dword[ecx+offs_zbup_tz] ;p1.tz = (float) p1.t * p1.z
-
 
Line 389... Line 377...
389
	ffree st0
377
	fmulp
390
	fincstp
378
	fstp dword[ecx+offs_zbup_tz] ;p1.tz = (float) p1.t * p1.z
391
 
379
 
392
	fild dword[edx+offs_zbup_z]
380
	fild dword[edx+offs_zbup_z]
393
	fild dword[edx+offs_zbup_s]
381
	fild dword[edx+offs_zbup_s]
394
	fmul st0,st1
382
	fmul st0,st1
395
	fstp dword[edx+offs_zbup_sz] ;p2.sz = (float) p2.s * p2.z
383
	fstp dword[edx+offs_zbup_sz] ;p2.sz = (float) p2.s * p2.z
396
	fild dword[edx+offs_zbup_t]
-
 
397
	fmul st0,st1
-
 
Line 398... Line 384...
398
	fstp dword[edx+offs_zbup_tz] ;p2.tz = (float) p2.t * p2.z
384
	fild dword[edx+offs_zbup_t]
399
	ffree st0
-
 
400
	fincstp
385
	fmulp
401
 
386
	fstp dword[edx+offs_zbup_tz] ;p2.tz = (float) p2.t * p2.z
402
	fld dword[ecx+offs_zbup_sz]
-
 
403
	fsub dword[ebx+offs_zbup_sz]
387
 
Line 404... Line -...
404
	fst dword[d1] ;d1 = p1.sz - p0.sz
-
 
405
	fld dword[edx+offs_zbup_sz]
-
 
406
	fsub dword[ebx+offs_zbup_sz]
388
	fld dword[ecx+offs_zbup_sz]
407
	fst dword[d2] ;d2 = p2.sz - p0.sz
389
	fsub dword[ebx+offs_zbup_sz] ;d1 = p1.sz - p0.sz
-
 
390
	fld dword[edx+offs_zbup_sz]
408
 
391
	fsub dword[ebx+offs_zbup_sz] ;d2 = p2.sz - p0.sz
-
 
392
 
409
	fld dword[fdy1]
393
	fld dword[fdy2]
410
	fmul st0,st1
-
 
411
	fld dword[fdy2]
-
 
412
	fmul st0,st3
394
	fmul st0,st2
413
	fsub st0,st1
395
	fld dword[fdy1]
414
	fistp dword[dszdx] ;dszdx = (int) (fdy2*d1 - fdy1*d2)
396
	fmul st0,st2
415
	ffree st0
397
	fsubp
416
	fincstp
398
	fstp dword[dszdx] ;dszdx = (fdy2*d1 - fdy1*d2)
417
	fld dword[fdx2]
399
	fld dword[fdx2]
418
	fmul st0,st2
400
	fmul st0,st2
419
	fld dword[fdx1]
401
	fld dword[fdx1]
-
 
402
	fmul st0,st2
-
 
403
	fsub st0,st1
-
 
404
	fstp dword[dszdy] ;dszdy = (fdx1*d2 - fdx2*d1)
-
 
405
	ffree st0
Line 420... Line 406...
420
	fmul st0,st2
406
	fincstp
421
	fsub st0,st1
-
 
422
	fistp dword[dszdy] ;dszdy = (int) (fdx1*d2 - fdx2*d1)
407
	ffree st0 ;free d2
423
	ffree st0
408
	fincstp
424
	fincstp
-
 
425
 
409
	ffree st0 ;free d1
Line 426... Line 410...
426
	fld dword[ecx+offs_zbup_tz]
410
	fincstp
427
	fsub dword[ebx+offs_zbup_tz]
411
 
428
	fst dword[d1] ;d1 = p1.tz - p0.tz
412
	fld dword[ecx+offs_zbup_tz]
429
	fld dword[edx+offs_zbup_tz]
413
	fsub dword[ebx+offs_zbup_tz] ;d1 = p1.tz - p0.tz
430
	fsub dword[ebx+offs_zbup_tz]
414
	fld dword[edx+offs_zbup_tz]
431
	fst dword[d2] ;d2 = p2.tz - p0.tz
415
	fsub dword[ebx+offs_zbup_tz] ;d2 = p2.tz - p0.tz
432
 
416
 
433
	fld dword[fdy1]
417
	fld dword[fdy1]
434
	fmul st0,st1
418
	fmul st0,st1
435
	fld dword[fdy2]
419
	fld dword[fdy2]
436
	fmul st0,st3
420
	fmul st0,st3
437
	fsub st0,st1
421
	fsub st0,st1
438
	fistp dword[dtzdx] ;dtzdx = (int) (fdy2*d1 - fdy1*d2)
422
	fstp dword[dtzdx] ;dtzdx = (fdy2*d1 - fdy1*d2)
439
	ffree st0
423
	ffree st0
440
	fincstp
424
	fincstp
441
	fld dword[fdx2]
425
	fld dword[fdx2]
-
 
426
	fmul st0,st2
-
 
427
	fld dword[fdx1]
-
 
428
	fmul st0,st2
-
 
429
	fsub st0,st1
442
	fmul st0,st2
430
	fstp dword[dtzdy] ;dtzdy = (fdx1*d2 - fdx2*d1)
Line 443... Line 431...
443
	fld dword[fdx1]
431
	ffree st0
444
	fmul st0,st2
-
 
445
	fsub st0,st1
432
	fincstp
446
	fistp dword[dtzdy] ;dtzdy = (int) (fdx1*d2 - fdx2*d1)
433
	ffree st0 ;free d2
447
	ffree st0
434
	fincstp
448
	fincstp
435
	ffree st0 ;free d1
449
end if
436
	fincstp
Line 463... Line 450...
463
 
450
 
Line 464... Line 451...
464
	DRAW_INIT
451
	DRAW_INIT
465
 
452
 
-
 
453
	mov dword[part],0
-
 
454
	.cycle_0:
-
 
455
if DEBUG ;(3)
466
	mov dword[part],0
456
stdcall dbg_print,txt_sp,m_3
467
	.cycle_0:
457
end if
468
		mov ebx,[p0]
458
		mov ebx,[p0]
469
		mov ecx,[p1]
459
		mov ecx,[p1]
470
		mov edx,[p2]
460
		mov edx,[p2]
471
		cmp dword[part],0
461
		cmp dword[part],0 ;if (part == 0)
472
		jne .els_0
462
		jne .els_0
473
			mov dword[update_left],1
463
			mov dword[update_left],1
474
			mov dword[update_right],1
464
			mov dword[update_right],1
Line 491... Line 481...
491
			sub eax,[ebx+offs_zbup_y]
481
			sub eax,[ebx+offs_zbup_y]
492
			mov [nb_lines],eax ;nb_lines = p1.y - p0.y
482
			mov [nb_lines],eax ;nb_lines = p1.y - p0.y
493
			jmp .end_0
483
			jmp .end_0
494
		.els_0:
484
		.els_0:
495
			; second part
485
			; second part
496
			mov dword[update_left],0
-
 
497
			mov dword[update_right],1
-
 
498
			fldz
486
			fldz
499
			fld dword[fz]
487
			fld dword[fz]
500
			fcompp ;if (fz > 0)
488
			fcompp ;if (fz > 0)
501
			fstsw ax
489
			fstsw ax
502
			sahf
490
			sahf
503
			jbe .els_2
491
			jbe .els_2
-
 
492
				mov dword[update_left],0
-
 
493
				mov dword[update_right],1
504
				mov [pr1],ecx
494
				mov [pr1],ecx
505
				mov [pr2],edx
495
				mov [pr2],edx
506
				jmp .end_2
496
				jmp .end_2
507
			.els_2:
497
			.els_2:
-
 
498
				mov dword[update_left],1
-
 
499
				mov dword[update_right],0
508
				mov [l1],ecx
500
				mov [l1],ecx
509
				mov [l2],edx
501
				mov [l2],edx
510
			.end_2:
502
			.end_2:
511
			mov eax,[edx+offs_zbup_y]
503
			mov eax,[edx+offs_zbup_y]
512
			sub eax,[ecx+offs_zbup_y]
504
			sub eax,[ecx+offs_zbup_y]
513
			inc eax
505
			inc eax
514
			mov [nb_lines],eax ;nb_lines = p2.y - p1.y + 1
506
			mov [nb_lines],eax ;nb_lines = p2.y - p1.y + 1
515
		.end_0:
507
		.end_0:
Line 516... Line 508...
516
 
508
 
517
	; compute the values for the left edge
-
 
518
 
509
	; compute the values for the left edge
519
	cmp dword[update_left],0 ;if (update_left)
510
	cmp dword[update_left],0 ;if (update_left)
520
	je .end_upd_l
511
	je .end_upd_l
521
		mov ebx,[l1]
512
		mov ebx,[l1]
-
 
513
		mov ecx,[l2]
-
 
514
		mov edx,[ecx+offs_zbup_y]
-
 
515
		sub edx,[ebx+offs_zbup_y]
522
		mov ecx,[l2]
516
		mov [dy1],edx ;dy1 = l2.y - l1.y
523
		mov eax,[ecx+offs_zbup_x]
517
		mov eax,[ecx+offs_zbup_x]
524
		sub eax,[ebx+offs_zbup_x]
518
		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
519
		mov [dx1],eax ;dx1 = l2.x - l1.x
529
		cmp eax,0 ;if (dy1 > 0) 
520
		cmp edx,0 ;if (dy1 > 0) 
530
		jle .els_3
-
 
531
			mov eax,[dx1]
-
 
532
			shl eax,16
521
		jle .els_3
-
 
522
			xor edx,edx
-
 
523
			cmp eax,0
-
 
524
			jl .otr_dx1
533
			xor edx,edx
525
			shl eax,16
534
			div dword[dy1] ;eax = (dx1 << 16) / dy1
526
			div dword[dy1] ;eax = (dx1 << 16) / dy1
-
 
527
			jmp .end_3
-
 
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
535
			jmp .end_3
536
		.els_3:
536
		.els_3:
537
			xor eax,eax
537
			xor eax,eax
538
		.end_3:
538
		.end_3:
539
		mov edx,[ebx+offs_zbup_x]
539
		mov edx,[ebx+offs_zbup_x]
540
		mov [x1],edx
540
		mov [x1],edx ;x1 = l1.x
541
		mov dword[error],0
541
		mov dword[error],0 ;error = 0
542
		mov dword[derror],eax
542
		mov dword[derror],eax
543
		and dword[derror],0xffff
543
		and dword[derror],0xffff ;derror = eax & 0x0000ffff
544
		shr eax,16
544
		shr eax,16
545
		mov [dxdy_min],eax
545
		mov [dxdy_min],eax ;dxdy_min = eax >> 16
546
		inc eax
546
		inc eax
Line -... Line 547...
-
 
547
		mov [dxdy_max],eax
-
 
548
 
-
 
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
547
		mov [dxdy_max],eax
580
end if
548
 
581
 
549
if INTERP_Z eq 1
582
if INTERP_Z eq 1
550
	mov eax,[l1]
583
	mov eax,[l1]
551
	mov eax,[eax+offs_zbup_z]
584
	mov eax,[eax+offs_zbup_z]
Line 583... Line 616...
583
	imul eax,[dxdy_min]
616
	imul eax,[dxdy_min]
584
	add eax,[dbdy]
617
	add eax,[dbdy]
585
	mov [dbdl_min],eax ;dbdl_min = (dbdy +dbdx*dxdy_min)
618
	mov [dbdl_min],eax ;dbdl_min = (dbdy +dbdx*dxdy_min)
586
	add eax,[dbdx]
619
	add eax,[dbdx]
587
	mov [dbdl_max],eax ;dbdl_max = dbdl_min +dbdx
620
	mov [dbdl_max],eax ;dbdl_max = dbdl_min +dbdx
588
 
-
 
589
end if
621
end if
590
if INTERP_ST eq 1
622
if INTERP_ST eq 1
591
	mov ebx,[l1]
623
	mov ebx,[l1]
592
	mov eax,[ebx+offs_zbup_s]
624
	mov eax,[ebx+offs_zbup_s]
593
	mov [s1],eax ;s1 = l1.s
625
	mov [s1],eax ;s1 = l1.s
Line 633... Line 665...
633
 
665
 
634
	cmp dword[update_right],0 ;if(update_right)
666
	cmp dword[update_right],0 ;if(update_right)
635
	je .end_upd_r
667
	je .end_upd_r
636
		mov ebx,[pr1]
668
		mov ebx,[pr1]
-
 
669
		mov ecx,[pr2]
637
		mov ecx,[pr2]
670
		mov edx,[ebx+offs_zbup_x]
638
		mov eax,[ecx+offs_zbup_x]
671
		mov eax,[ecx+offs_zbup_x]
639
		sub eax,[ebx+offs_zbup_x]
672
		sub eax,edx
-
 
673
		;mov [dx2],eax ;dx2 = pr2.x - pr1.x
-
 
674
		shl edx,16
640
		mov [dx2],eax ;dx2 = pr2.x - pr1.x
675
		mov [x2],edx ; x2 = pr1.x << 16
641
		mov eax,[ecx+offs_zbup_y]
676
		mov edx,[ecx+offs_zbup_y]
642
		sub eax,[ebx+offs_zbup_y]
677
		sub edx,[ebx+offs_zbup_y]
643
		mov [dy2],eax ;dy2 = pr2.y - pr1.y
678
		mov [dy2],edx ;dy2 = pr2.y - pr1.y
644
		cmp eax,0 ;if (dy2 > 0) 
679
		cmp edx,0 ;if (dy2 > 0) 
645
		jle .els_4
-
 
646
			mov eax,[dx2]
-
 
647
			shl eax,16
680
		jle .els_4
-
 
681
			xor edx,edx
-
 
682
			cmp eax,0
-
 
683
			jl .otr_dx2
648
			xor edx,edx
684
			shl eax,16
649
			div dword[dy2] ;eax = (dx2 << 16) / dy2
685
			div dword[dy2] ;eax = (dx2 << 16) / dy2
-
 
686
			jmp .end_4
-
 
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
650
			jmp .end_4
694
			jmp .end_4
651
		.els_4:
695
		.els_4:
652
			xor eax,eax
696
			xor eax,eax
653
		.end_4:
697
		.end_4:
-
 
698
		mov [dx2dy2],eax
-
 
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
 
654
		mov [dx2dy2],eax
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
655
		mov eax,[ebx+offs_zbup_x]
724
	add edi,eax
-
 
725
	sub ecx,eax
-
 
726
 
656
		shl eax,16
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
657
		mov [x2],eax ; x2 = pr1.x << 16
734
end if
Line 658... Line 735...
658
	.end_upd_r:
735
	.end_upd_r:
-
 
736
 
-
 
737
	; we draw all the scan line of the part
-
 
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
-
 
744
 
-
 
745
	stdcall str_n_cat,edi,txt_nl,2
-
 
746
	stdcall dbg_print,f_fill_tr_nl,buf_param
Line 659... Line 747...
659
 
747
pop edi ecx
660
	; we draw all the scan line of the part
748
end if
661
 
749
 
662
	.beg_w_lin:
750
	.beg_w_lin:
Line 672... Line 760...
672
		mov edi,[x1]
760
		mov edi,[x1]
673
		sub eax,edi
761
		sub eax,edi
674
		mov [n],eax ;n = (x2 >> 16) - x1
762
		mov [n],eax ;n = (x2 >> 16) - x1
675
		imul edi,PSZB
763
		imul edi,PSZB
676
		add edi,[pp1] ;pp = pp1 + x1 * PSZB
764
		add edi,[pp1] ;pp = pp1 + x1 * PSZB
-
 
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
 
677
if INTERP_Z eq 1
793
if INTERP_Z eq 1
678
		mov eax,[x1]
794
		mov eax,[x1]
679
		shl eax,1
795
		shl eax,1
680
		add eax,[pz1]
796
		add eax,[pz1]
681
		mov [pz],eax
797
		mov [pz],eax
Line 700... Line 816...
700
		mov eax,[sz1]
816
		mov eax,[sz1]
701
		mov [s_z],eax
817
		mov [s_z],eax
702
		mov eax,[tz1]
818
		mov eax,[tz1]
703
		mov [t_z],eax
819
		mov [t_z],eax
704
end if
820
end if
-
 
821
 
-
 
822
align 4
705
		.cycle_1: ;while (n>=3)
823
		.cycle_1: ;while (n>=3)
-
 
824
		cmp dword[n],3
-
 
825
		jl .cycle_2
706
			PUT_PIXEL 0
826
			PUT_PIXEL 0
707
			PUT_PIXEL 1
827
			PUT_PIXEL 1
708
			PUT_PIXEL 2
828
			PUT_PIXEL 2
709
			PUT_PIXEL 3
829
			PUT_PIXEL 3
710
if INTERP_Z eq 1
830
if INTERP_Z eq 1
711
			add dword[pz],8 ;=4*sizeof(uint)
831
			add dword[pz],8 ;=4*sizeof(uint)
712
end if
832
end if
713
			add edi,4*PSZB
833
			add edi,4*PSZB
714
			sub dword[n],4
834
			sub dword[n],4
715
			cmp dword[n],3
-
 
716
		jge .cycle_1
835
		jmp .cycle_1
717
		.cycle_2: ;while (n>=0)
836
		.cycle_2: ;while (n>=0)
-
 
837
		cmp dword[n],0
-
 
838
		jl .cycle_2_end
718
			PUT_PIXEL 0
839
			PUT_PIXEL 0
719
if INTERP_Z eq 1
840
if INTERP_Z eq 1
720
			add dword[pz],2 ;=sizeof(uint)
841
			add dword[pz],2 ;=sizeof(uint)
721
end if
842
end if
722
			add edi,PSZB
843
			add edi,PSZB
723
			dec dword[n]
844
			dec dword[n]
724
			cmp dword[n],0
845
		jmp .cycle_2
725
		jge .cycle_2
846
		.cycle_2_end:
726
end if
847
end if ;проверка от макроса DRAW_LINE
Line 727... Line 848...
727
 
848
 
728
	; left edge
849
	; left edge
729
	mov eax,[derror]
850
	mov eax,[derror]
730
	add [error],eax
851
	add [error],eax
731
	cmp eax,0 ;if (error > 0)
852
	cmp dword[error],0 ;if (error > 0)
732
	jle .els_er
853
	jle .els_er
733
		sub dword[error],0x10000
854
		sub dword[error],0x10000
734
		mov eax,[dxdy_max]
855
		mov eax,[dxdy_max]
735
		add [x1],eax
856
		add [x1],eax
Line 806... Line 927...
806
		.end_w_lin:
927
		.end_w_lin:
807
		inc dword[part]
928
		inc dword[part]
808
		cmp dword[part],2
929
		cmp dword[part],2
809
		jl .cycle_0
930
		jl .cycle_0
810
	.end_f:
931
	.end_f:
-
 
932
popad
811
	ret
933
	ret
812
endp
934
endp
Line 813... Line 935...
813
 
935
 
814
restore INTERP_Z
936
restore INTERP_Z