Rev 5218 | Rev 5353 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5218 | Rev 5278 | ||
---|---|---|---|
Line 225... | Line 225... | ||
225 | ; Line Clipping algorithm from 'Computer Graphics', Principles and |
225 | ; Line Clipping algorithm from 'Computer Graphics', Principles and |
226 | ; Practice |
226 | ; Practice |
227 | ; tmin,tmax -> &float |
227 | ; tmin,tmax -> &float |
228 | align 4 |
228 | align 4 |
229 | proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword |
229 | proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword |
230 | fldz |
- | |
231 | fcom dword[denom] |
230 | fld dword[denom] |
- | 231 | ftst |
|
232 | fstsw ax |
232 | fstsw ax |
233 | sahf |
233 | sahf |
234 | je .u2 |
- | |
235 | jmp @f |
- | |
236 | .u2: |
- | |
237 | fcom dword[num] |
- | |
238 | fstsw ax |
- | |
239 | sahf |
- | |
240 | jb .r0 ;if (denom==0 && num>0) return 0 |
- | |
241 | jmp .r1 |
- | |
242 | @@: |
- | |
243 | - | ||
244 | fcom dword[denom] |
- | |
245 | fstsw ax |
- | |
246 | sahf |
- | |
247 | ja .els_0 ;if (0 |
234 | jbe .els_0 ;if (denom>0) |
248 | fld dword[num] |
235 | fld dword[num] |
- | 236 | fxch st1 |
|
249 | fdiv dword[denom] |
237 | fdivp ;t=num/denom |
250 | - | ||
251 | mov ebx,[tmax] |
238 | mov ebx,[tmax] |
252 | fcom dword[ebx] |
239 | fcom dword[ebx] |
253 | fstsw ax |
240 | fstsw ax |
254 | sahf |
241 | sahf |
255 | ja .r0_f2 ;if (t>*tmax) return 0 |
242 | ja .r0_f1 ;if (t>*tmax) return 0 |
256 | - | ||
257 | mov ebx,[tmin] |
243 | mov ebx,[tmin] |
258 | fcom dword[ebx] |
244 | fcom dword[ebx] |
259 | fstsw ax |
245 | fstsw ax |
260 | sahf |
246 | sahf |
261 | jbe .r1_f2 |
247 | jbe .r1_f1 ;if (t>*tmin) *tmin=t |
262 | fstp dword[ebx] ;if (t>*tmin) *tmin=t |
248 | fstp dword[ebx] |
263 | jmp .r1 |
249 | jmp .r1 |
264 | - | ||
265 | .els_0: ;else if (0>denom) |
250 | .els_0: ;else if (denom<0) |
- | 251 | jae .els_1 |
|
266 | fld dword[num] |
252 | fld dword[num] |
- | 253 | fxch st1 |
|
267 | fdiv dword[denom] |
254 | fdivp ;t=num/denom |
268 | - | ||
269 | mov ebx,[tmin] |
255 | mov ebx,[tmin] |
270 | fcom dword[ebx] |
256 | fcom dword[ebx] |
271 | fstsw ax |
257 | fstsw ax |
272 | sahf |
258 | sahf |
273 | jb .r0_f2 ;if (t<*tmin) return 0 |
259 | jb .r0_f1 ;if (t<*tmin) return 0 |
274 | - | ||
275 | mov ebx,[tmax] |
260 | mov ebx,[tmax] |
276 | fcom dword[ebx] |
261 | fcom dword[ebx] |
277 | fstsw ax |
262 | fstsw ax |
278 | sahf |
263 | sahf |
279 | jae .r1_f2 |
264 | jae .r1_f1 |
280 | fstp dword[ebx] ;if (t<*tmin) *tmax=t |
265 | fstp dword[ebx] ;if (t<*tmin) *tmax=t |
281 | jmp .r1 |
266 | jmp .r1 |
- | 267 | .els_1: ;else if (num>0) |
|
- | 268 | ffree st0 ;denom |
|
- | 269 | fincstp |
|
- | 270 | fld dword[num] |
|
- | 271 | ftst |
|
- | 272 | fstsw ax |
|
- | 273 | sahf |
|
- | 274 | ja .r0_f1 ;if (num>0) return 0 |
|
- | 275 | jmp .r1_f1 |
|
Line 282... | Line 276... | ||
282 | 276 | ||
283 | .r0_f2: ;return 0 & free st0,st1 |
277 | .r0_f1: ;return 0 & free st0 |
284 | ffree st0 |
278 | ffree st0 |
285 | fincstp |
279 | fincstp |
286 | .r0: ;return 0 & free st0 |
280 | .r0: ;return 0 |
287 | xor eax,eax |
281 | xor eax,eax |
288 | jmp .end_f |
282 | jmp .end_f |
289 | .r1_f2: ;return 1 & free st0,st1 |
283 | .r1_f1: ;return 1 & free st0 |
290 | ffree st0 |
284 | ffree st0 |
291 | fincstp |
285 | fincstp |
292 | .r1: ;return 1 & free st0 |
286 | .r1: ;return 1 |
293 | xor eax,eax |
287 | xor eax,eax |
294 | inc eax |
288 | inc eax |
295 | .end_f: |
- | |
296 | ffree st0 |
- | |
297 | fincstp |
289 | .end_f: |
298 | ret |
290 | ret |
Line 299... | Line 291... | ||
299 | endp |
291 | endp |
300 | 292 |