FIX.INC 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  2. ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  3. ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  4. ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  5. ;IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  6. ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  7. ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  8. ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  9. ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  10. ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. ;
  12. ; $Source: f:/miner/source/fix/rcs/fix.inc $
  13. ; $Revision: 1.7 $
  14. ; $Author: matt $
  15. ; $Date: 1994/01/19 23:12:00 $
  16. ;
  17. ; Header for fixed-point library
  18. ;
  19. ; $Log: fix.inc $
  20. ; Revision 1.7 1994/01/19 23:12:00 matt
  21. ; Made fix_atan2() left-handed, like our coordinate system
  22. ;
  23. ; Revision 1.6 1993/10/20 01:08:49 matt
  24. ; Add fix_asin(), improved fix_atan2()
  25. ;
  26. ; Revision 1.5 1993/10/19 23:53:36 matt
  27. ; Added fix_atan2()
  28. ;
  29. ; Revision 1.4 1993/10/19 22:32:12 matt
  30. ; Added fix_acos()
  31. ;
  32. ; Revision 1.3 1993/09/13 12:09:42 matt
  33. ; Added extf,extfa macros to generate externdef's of fixed-point types
  34. ;
  35. ; Revision 1.2 1993/09/10 11:54:12 matt
  36. ; Added missing 'endif' at end of file
  37. ;
  38. ; Revision 1.1 1993/08/24 12:59:36 matt
  39. ; Initial revision
  40. ;
  41. ;
  42. ;
  43. ifndef fix_inc
  44. fix_inc equ 1
  45. include types.inc
  46. include psmacros.inc
  47. ;Fixed-point types
  48. fix typedef dword
  49. fixang typedef word
  50. ;Externdef macros for fixed-point types
  51. extgen fix,f ;generates extf
  52. extgen fixang,fa ;generates extfa
  53. ;Some handy constants
  54. f0_0 equ 0
  55. f1_0 equ 10000h
  56. f2_0 equ 20000h
  57. f3_0 equ 30000h
  58. f10_0 equ 0a0000h
  59. f0_5 equ 8000h
  60. f0_1 equ 199ah
  61. ;Macros
  62. ;fixed-point multiply. one parm in eax, other passed to macro. result in eax
  63. ;trashes edx
  64. fixmul macro n
  65. imul n
  66. shrd eax,edx,16
  67. endm
  68. ;fixed-point divide. numerator in eax, divisor passed to macro. result in eax
  69. ;trashes edx. made sure parameter is not edx
  70. fixdiv macro n
  71. mov edx,eax
  72. sar edx,16
  73. shl eax,16
  74. idiv n
  75. endm
  76. ;fixed-point multiply and divide. result in eax
  77. ;trashes edx. made sure neither parameter is edx
  78. fixmuldiv macro a,b
  79. imul a
  80. idiv b
  81. endm
  82. ;Functions
  83. extn fix_fastsincos ;ax=ang, ret eax=sin, ebx=cos
  84. extn fix_sincos ;ax=ang, ret eax=sin, ebx=cos
  85. extn fix_asin ;takes eax=sin, ret ax=angle
  86. extn fix_acos ;takes eax=cos, ret ax=angle
  87. extn fix_atan2 ;takes eax,ebx = cos,sin, ret ax=angle
  88. extn long_sqrt ;takes eax, returns ax
  89. extn fix_sqrt ;takes eax, returns eax
  90. extn quad_sqrt ;takes eds:eax, returns eax
  91. endif