Rev 5187 | Rev 5208 | 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 |
5175 | IgorA | 539 | shr eax,16 |
5189 | IgorA | 540 | bt eax,15 |
541 | jnc @f |
||
542 | or eax,0xffff0000 |
||
543 | @@: |
||
5187 | IgorA | 544 | mov [dxdy_min],eax ;dxdy_min = eax >> 16 |
5175 | IgorA | 545 | inc eax |
546 | mov [dxdy_max],eax |
||
5153 | IgorA | 547 | |
548 | if INTERP_Z eq 1 |
||
5175 | IgorA | 549 | mov eax,[l1] |
550 | mov eax,[eax+offs_zbup_z] |
||
551 | mov [z1],eax ;z1 = l1.z |
||
552 | mov eax,[dzdx] |
||
553 | imul eax,[dxdy_min] |
||
554 | add eax,[dzdy] |
||
555 | mov [dzdl_min],eax ;dzdl_min = (dzdy +dzdx*dxdy_min) |
||
556 | add eax,[dzdx] |
||
557 | mov [dzdl_max],eax ;dzdl_max = dzdl_min +dzdx |
||
5153 | IgorA | 558 | end if |
559 | if INTERP_RGB eq 1 |
||
5175 | IgorA | 560 | mov ebx,[l1] |
561 | mov eax,[ebx+offs_zbup_r] |
||
562 | mov [r1],eax ;r1 = l1.r |
||
563 | mov eax,[drdx] |
||
564 | imul eax,[dxdy_min] |
||
565 | add eax,[drdy] |
||
566 | mov [drdl_min],eax ;drdl_min = (drdy +drdx*dxdy_min) |
||
567 | add eax,[drdx] |
||
568 | mov [drdl_max],eax ;drdl_max = drdl_min +drdx |
||
5153 | IgorA | 569 | |
5175 | IgorA | 570 | mov eax,[ebx+offs_zbup_g] |
571 | mov [g1],eax ;g1 = l1.g |
||
572 | mov eax,[dgdx] |
||
573 | imul eax,[dxdy_min] |
||
574 | add eax,[dgdy] |
||
575 | mov [dgdl_min],eax ;dgdl_min = (dgdy +dgdx*dxdy_min) |
||
576 | add eax,[dgdx] |
||
577 | mov [dgdl_max],eax ;dgdl_max = dgdl_min +dgdx |
||
5153 | IgorA | 578 | |
5175 | IgorA | 579 | mov eax,[ebx+offs_zbup_b] |
580 | mov [b1],eax ;b1 = l1.b |
||
581 | mov eax,[dbdx] |
||
582 | imul eax,[dxdy_min] |
||
583 | add eax,[dbdy] |
||
584 | mov [dbdl_min],eax ;dbdl_min = (dbdy +dbdx*dxdy_min) |
||
585 | add eax,[dbdx] |
||
586 | mov [dbdl_max],eax ;dbdl_max = dbdl_min +dbdx |
||
5153 | IgorA | 587 | end if |
588 | if INTERP_ST eq 1 |
||
5175 | IgorA | 589 | mov ebx,[l1] |
590 | mov eax,[ebx+offs_zbup_s] |
||
591 | mov [s1],eax ;s1 = l1.s |
||
592 | mov eax,[dsdx] |
||
593 | imul eax,[dxdy_min] |
||
594 | add eax,[dsdy] |
||
595 | mov [dsdl_min],eax ;dsdl_min = (dsdy +dsdx*dxdy_min) |
||
596 | add eax,[dsdx] |
||
597 | mov [dsdl_max],eax ;dsdl_max = dsdl_min +dsdx |
||
5153 | IgorA | 598 | |
5175 | IgorA | 599 | mov eax,[ebx+offs_zbup_t] |
600 | mov [t1],eax ;t1 = l1.t |
||
601 | mov eax,[dtdx] |
||
602 | imul eax,[dxdy_min] |
||
603 | add eax,[dtdy] |
||
604 | mov [dtdl_min],eax ;dtdl_min = (dtdy +dtdx*dxdy_min) |
||
605 | add eax,[dtdx] |
||
606 | mov [dtdl_max],eax ;dtdl_max = dtdl_min +dtdx |
||
5153 | IgorA | 607 | end if |
608 | if INTERP_STZ eq 1 |
||
5175 | IgorA | 609 | mov ebx,[l1] |
610 | mov eax,[ebx+offs_zbup_sz] |
||
611 | mov [sz1],eax ;sz1 = l1.sz - преобразований нет, потому без сопроцессора |
||
612 | fild dword[dxdy_min] |
||
613 | fmul dword[dszdx] |
||
614 | fadd dword[dszdy] |
||
615 | fst dword[dszdl_min] ;dszdl_min = (dszdy +dszdx*dxdy_min) |
||
616 | fadd dword[dszdx] |
||
617 | fstp dword[dszdl_max] ;dszdl_max = dszdl_min +dszdx |
||
5153 | IgorA | 618 | |
5175 | IgorA | 619 | mov eax,[ebx+offs_zbup_tz] |
620 | mov [tz1],eax ;tz1 = l1.tz - преобразований нет, потому без сопроцессора |
||
621 | fild dword[dxdy_min] |
||
622 | fmul dword[dtzdx] |
||
623 | fadd dword[dtzdy] |
||
624 | fst dword[dtzdl_min] ;dtzdl_min = (dtzdy +dtzdx*dxdy_min) |
||
625 | fadd dword[dtzdx] |
||
626 | fstp dword[dtzdl_max] ;dtzdl_max = dtzdl_min +dtzdx |
||
5153 | IgorA | 627 | end if |
5175 | IgorA | 628 | .end_upd_l: |
5153 | IgorA | 629 | |
5175 | IgorA | 630 | ; compute values for the right edge |
5153 | IgorA | 631 | |
5175 | IgorA | 632 | cmp dword[update_right],0 ;if(update_right) |
633 | je .end_upd_r |
||
634 | mov ebx,[pr1] |
||
635 | mov ecx,[pr2] |
||
5187 | IgorA | 636 | mov edx,[ebx+offs_zbup_x] |
5175 | IgorA | 637 | mov eax,[ecx+offs_zbup_x] |
5187 | IgorA | 638 | sub eax,edx |
639 | ;mov [dx2],eax ;dx2 = pr2.x - pr1.x |
||
640 | shl edx,16 |
||
641 | mov [x2],edx ; x2 = pr1.x << 16 |
||
642 | mov edx,[ecx+offs_zbup_y] |
||
643 | sub edx,[ebx+offs_zbup_y] |
||
644 | mov [dy2],edx ;dy2 = pr2.y - pr1.y |
||
645 | cmp edx,0 ;if (dy2 > 0) |
||
5175 | IgorA | 646 | jle .els_4 |
5187 | IgorA | 647 | xor edx,edx |
648 | cmp eax,0 |
||
649 | jl .otr_dx2 |
||
5175 | IgorA | 650 | shl eax,16 |
651 | div dword[dy2] ;eax = (dx2 << 16) / dy2 |
||
652 | jmp .end_4 |
||
5187 | IgorA | 653 | .otr_dx2: |
654 | neg eax |
||
655 | inc eax ;dx2 *= -1 |
||
656 | shl eax,16 |
||
657 | div dword[dy2] ;eax = (-dx2 << 16) / dy2 |
||
658 | neg eax |
||
659 | inc eax |
||
660 | jmp .end_4 |
||
5175 | IgorA | 661 | .els_4: |
662 | xor eax,eax |
||
663 | .end_4: |
||
664 | mov [dx2dy2],eax |
||
665 | .end_upd_r: |
||
5153 | IgorA | 666 | |
5175 | IgorA | 667 | ; we draw all the scan line of the part |
5187 | IgorA | 668 | if DEBUG ;[nb_lines] |
669 | push ecx edi |
||
670 | mov eax,[nb_lines] |
||
671 | mov ecx,80 |
||
672 | lea edi,[buf_param] |
||
673 | stdcall convert_int_to_str,ecx |
||
5153 | IgorA | 674 | |
5187 | IgorA | 675 | stdcall str_n_cat,edi,txt_nl,2 |
676 | stdcall dbg_print,f_fill_tr_nl,buf_param |
||
677 | pop edi ecx |
||
678 | end if |
||
679 | |||
5175 | IgorA | 680 | .beg_w_lin: |
681 | cmp dword[nb_lines],0 ;while (nb_lines>0) |
||
682 | jle .end_w_lin |
||
683 | dec dword[nb_lines] |
||
684 | if DRAW_LINE_M eq 1 |
||
685 | DRAW_LINE 1 |
||
686 | else |
||
687 | ; generic draw line |
||
688 | mov eax,[x2] |
||
689 | shr eax,16 |
||
690 | mov edi,[x1] |
||
691 | sub eax,edi |
||
692 | mov [n],eax ;n = (x2 >> 16) - x1 |
||
693 | imul edi,PSZB |
||
694 | add edi,[pp1] ;pp = pp1 + x1 * PSZB |
||
5187 | IgorA | 695 | |
696 | if DEBUG ;[n], [x1], [x2]>>16 |
||
697 | push ecx edi |
||
698 | mov eax,[n] |
||
699 | mov ecx,80 |
||
700 | lea edi,[buf_param] |
||
701 | stdcall convert_int_to_str,ecx |
||
702 | stdcall str_n_cat,edi,txt_zp_sp,2 |
||
703 | stdcall str_len,edi |
||
704 | add edi,eax |
||
705 | sub ecx,eax |
||
706 | |||
707 | mov eax,[x1] |
||
708 | stdcall convert_int_to_str,ecx |
||
709 | stdcall str_n_cat,edi,txt_zp_sp,2 |
||
710 | stdcall str_len,edi |
||
711 | add edi,eax |
||
712 | sub ecx,eax |
||
713 | |||
714 | mov eax,[x2] |
||
715 | shr eax,16 |
||
716 | stdcall convert_int_to_str,ecx |
||
717 | |||
718 | stdcall str_n_cat,edi,txt_nl,2 |
||
719 | stdcall dbg_print,f_fill_tr_nll,buf_param |
||
720 | pop edi ecx |
||
721 | end if |
||
722 | |||
5153 | IgorA | 723 | if INTERP_Z eq 1 |
5175 | IgorA | 724 | mov eax,[x1] |
725 | shl eax,1 |
||
726 | add eax,[pz1] |
||
727 | mov [pz],eax |
||
728 | mov eax,[z1] |
||
729 | mov [z],eax |
||
5153 | IgorA | 730 | end if |
731 | if INTERP_RGB eq 1 |
||
5175 | IgorA | 732 | mov eax,[r1] |
733 | mov [or1],eax |
||
734 | mov eax,[g1] |
||
735 | mov [og1],eax |
||
736 | mov eax,[b1] |
||
737 | mov [ob1],eax |
||
5153 | IgorA | 738 | end if |
739 | if INTERP_ST eq 1 |
||
5175 | IgorA | 740 | mov eax,[s1] |
741 | mov [s],eax |
||
742 | mov eax,[t1] |
||
743 | mov [t],eax |
||
5153 | IgorA | 744 | end if |
745 | if INTERP_STZ eq 1 |
||
5175 | IgorA | 746 | mov eax,[sz1] |
747 | mov [s_z],eax |
||
748 | mov eax,[tz1] |
||
749 | mov [t_z],eax |
||
5153 | IgorA | 750 | end if |
5187 | IgorA | 751 | |
752 | align 4 |
||
5175 | IgorA | 753 | .cycle_1: ;while (n>=3) |
5187 | IgorA | 754 | cmp dword[n],3 |
755 | jl .cycle_2 |
||
5175 | IgorA | 756 | PUT_PIXEL 0 |
757 | PUT_PIXEL 1 |
||
758 | PUT_PIXEL 2 |
||
759 | PUT_PIXEL 3 |
||
5153 | IgorA | 760 | if INTERP_Z eq 1 |
5175 | IgorA | 761 | add dword[pz],8 ;=4*sizeof(uint) |
5153 | IgorA | 762 | end if |
5175 | IgorA | 763 | add edi,4*PSZB |
764 | sub dword[n],4 |
||
5187 | IgorA | 765 | jmp .cycle_1 |
5175 | IgorA | 766 | .cycle_2: ;while (n>=0) |
5187 | IgorA | 767 | cmp dword[n],0 |
768 | jl .cycle_2_end |
||
5175 | IgorA | 769 | PUT_PIXEL 0 |
5153 | IgorA | 770 | if INTERP_Z eq 1 |
5175 | IgorA | 771 | add dword[pz],2 ;=sizeof(uint) |
5153 | IgorA | 772 | end if |
5175 | IgorA | 773 | add edi,PSZB |
774 | dec dword[n] |
||
5187 | IgorA | 775 | jmp .cycle_2 |
776 | .cycle_2_end: |
||
777 | end if ;проверка от макроса DRAW_LINE |
||
5175 | IgorA | 778 | |
779 | ; left edge |
||
780 | mov eax,[derror] |
||
781 | add [error],eax |
||
5187 | IgorA | 782 | cmp dword[error],0 ;if (error > 0) |
5175 | IgorA | 783 | jle .els_er |
784 | sub dword[error],0x10000 |
||
785 | mov eax,[dxdy_max] |
||
786 | add [x1],eax |
||
5153 | IgorA | 787 | if INTERP_Z eq 1 |
5175 | IgorA | 788 | mov eax,[dzdl_max] |
789 | add [z1],eax |
||
5153 | IgorA | 790 | end if |
791 | if INTERP_RGB eq 1 |
||
5175 | IgorA | 792 | mov eax,[drdl_max] |
793 | add [r1],eax |
||
794 | mov eax,[dgdl_max] |
||
795 | add [g1],eax |
||
796 | mov eax,[dbdl_max] |
||
797 | add [b1],eax |
||
5153 | IgorA | 798 | end if |
799 | if INTERP_ST eq 1 |
||
5175 | IgorA | 800 | mov eax,[dsdl_max] |
801 | add [s1],eax |
||
802 | mov eax,[dtdl_max] |
||
803 | add [t1],eax |
||
5153 | IgorA | 804 | end if |
805 | if INTERP_STZ eq 1 |
||
5175 | IgorA | 806 | fld dword[dszdl_max] |
807 | fadd dword[sz1] |
||
808 | fstp dword[sz1] |
||
809 | fld dword[dtzdl_max] |
||
810 | fadd dword[tz1] |
||
811 | fstp dword[tz1] |
||
5153 | IgorA | 812 | end if |
5175 | IgorA | 813 | jmp .end_er |
814 | .els_er: |
||
815 | mov eax,[dxdy_min] |
||
816 | add [x1],eax |
||
5153 | IgorA | 817 | if INTERP_Z eq 1 |
5175 | IgorA | 818 | mov eax,[dzdl_min] |
819 | add [z1],eax |
||
5153 | IgorA | 820 | end if |
821 | if INTERP_RGB eq 1 |
||
5175 | IgorA | 822 | mov eax,[drdl_min] |
823 | add [r1],eax |
||
824 | mov eax,[dgdl_min] |
||
825 | add [g1],eax |
||
826 | mov eax,[dbdl_min] |
||
827 | add [b1],eax |
||
5153 | IgorA | 828 | end if |
829 | if INTERP_ST eq 1 |
||
5175 | IgorA | 830 | mov eax,[dsdl_min] |
831 | add [s1],eax |
||
832 | mov eax,[dtdl_min] |
||
833 | add [t1],eax |
||
5153 | IgorA | 834 | end if |
835 | if INTERP_STZ eq 1 |
||
5175 | IgorA | 836 | fld dword[dszdl_min] |
837 | fadd dword[sz1] |
||
838 | fstp dword[sz1] |
||
839 | fld dword[dtzdl_min] |
||
840 | fadd dword[tz1] |
||
841 | fstp dword[tz1] |
||
5153 | IgorA | 842 | end if |
5175 | IgorA | 843 | .end_er: |
5153 | IgorA | 844 | |
5175 | IgorA | 845 | ; right edge |
846 | mov eax,[dx2dy2] |
||
847 | add [x2],eax |
||
848 | |||
849 | ; screen coordinates |
||
850 | mov ebx,[zb] |
||
851 | mov eax,[ebx+offs_zbuf_linesize] |
||
852 | add [pp1],eax |
||
853 | mov eax,[ebx+offs_zbuf_xsize] |
||
854 | shl eax,1 |
||
855 | add [pz1],eax |
||
856 | jmp .beg_w_lin |
||
857 | .end_w_lin: |
||
858 | inc dword[part] |
||
859 | cmp dword[part],2 |
||
860 | jl .cycle_0 |
||
861 | .end_f: |
||
5187 | IgorA | 862 | popad |
5175 | IgorA | 863 | ret |
864 | endp |
||
865 | |||
5153 | IgorA | 866 | restore INTERP_Z |
867 | restore INTERP_RGB |
||
868 | restore INTERP_ST |
||
869 | restore INTERP_STZ |
||
5175 | IgorA | 870 | restore DRAW_LINE_M |
5153 | IgorA | 871 | |
872 | purge DRAW_INIT |
||
5175 | IgorA | 873 | purge DRAW_LINE |
5153 | IgorA | 874 | purge PUT_PIXEL><>><>><>><>><> |