Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.8 KiB

  1. ;----------------------------------------------------------------------------
  2. ;
  3. ; texdiff.inc
  4. ;
  5. ; Assembly macro for TextureDiff.
  6. ;
  7. ; Copyright (C) Microsoft Corporation, 1997.
  8. ;
  9. ;----------------------------------------------------------------------------
  10. IFNDEF __TEXDIFF_INC__
  11. __TEXDIFF_INC__ EQU 1
  12. ;----------------------------------------------------------------------------
  13. ;
  14. ; TEXTURE_DIFF
  15. ;
  16. ; Computes difference of two texture coordinates and returns it on
  17. ; the top of the FP stack.
  18. ;
  19. ; Destroys eax and ecx.
  20. ;
  21. ;----------------------------------------------------------------------------
  22. TEXTURE_DIFF MACRO fTb, fTa, iMode, fTmp
  23. LOCAL L_Exit, L_Ltz, L_Gtz, L_Zero, L_Straight
  24. ; Start initial fTb - fTa computation.
  25. fld fTb
  26. fsub fTa
  27. ; Check for wrapping.
  28. cmp iMode, 0
  29. jz L_Exit
  30. ; Compute smaller of straight or wrapped difference.
  31. fst fTmp
  32. fld st(0)
  33. ; Adjust straight difference according to sign to compute
  34. ; wrapped difference.
  35. mov eax, fTmp
  36. cmp eax, 080000000h
  37. ja L_Ltz
  38. cmp eax, 0
  39. je L_Zero
  40. ; Gtz
  41. fsub _g_fOne
  42. jmp L_Gtz
  43. L_Ltz:
  44. fadd _g_fOne
  45. L_Zero:
  46. and eax, 07fffffffh
  47. L_Gtz:
  48. fst fTmp
  49. mov ecx, fTmp
  50. and ecx, 07fffffffh
  51. ; Pick smaller based on absolute values of differences.
  52. cmp eax, ecx
  53. jle L_Straight
  54. ; Discard straight difference so wrapped difference is
  55. ; returned.
  56. fxch st(1)
  57. L_Straight:
  58. ; Discard wrapped difference so straight difference is
  59. ; returned.
  60. fstp st(0)
  61. L_Exit:
  62. ENDM
  63. ENDIF