home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / lib / fix.inc < prev    next >
Text File  |  1998-06-08  |  3KB  |  106 lines

  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. ; Revision 1.6  1993/10/20  01:08:49  matt
  23. ; Add fix_asin(), improved fix_atan2()
  24. ; Revision 1.5  1993/10/19  23:53:36  matt
  25. ; Added fix_atan2()
  26. ; Revision 1.4  1993/10/19  22:32:12  matt
  27. ; Added fix_acos()
  28. ; Revision 1.3  1993/09/13  12:09:42  matt
  29. ; Added extf,extfa macros to generate externdef's of fixed-point types
  30. ; Revision 1.2  1993/09/10  11:54:12  matt
  31. ; Added missing 'endif' at end of file
  32. ; Revision 1.1  1993/08/24  12:59:36  matt
  33. ; Initial revision
  34. ;
  35. ;
  36.  
  37. ifndef    fix_inc
  38. fix_inc equ 1
  39.  
  40.     include    types.inc
  41.     include    psmacros.inc
  42.  
  43. ;Fixed-point types
  44.  
  45. fix    typedef    dword
  46. fixang    typedef    word
  47.  
  48. ;Externdef macros for fixed-point types
  49.  
  50.     extgen    fix,f    ;generates extf
  51.     extgen    fixang,fa    ;generates extfa
  52.  
  53. ;Some handy constants
  54.  
  55. f0_0    equ 0
  56. f1_0    equ 10000h
  57. f2_0    equ 20000h
  58. f3_0    equ 30000h
  59. f10_0    equ 0a0000h
  60. f0_5    equ 8000h
  61. f0_1    equ 199ah
  62.  
  63. ;Macros
  64.  
  65. ;fixed-point multiply. one parm in eax, other passed to macro. result in eax
  66. ;trashes edx
  67. fixmul    macro    n
  68.     imul    n
  69.     shrd    eax,edx,16
  70.     endm
  71.  
  72. ;fixed-point divide. numerator in eax, divisor passed to macro. result in eax
  73. ;trashes edx. made sure parameter is not edx
  74. fixdiv    macro    n
  75.     mov    edx,eax
  76.     sar    edx,16
  77.     shl    eax,16
  78.     idiv    n
  79.     endm
  80.  
  81. ;fixed-point multiply and divide. result in eax
  82. ;trashes edx. made sure neither parameter is edx
  83. fixmuldiv    macro    a,b
  84.     imul    a
  85.     idiv    b
  86.     endm
  87.  
  88.  
  89. ;Functions
  90.     extn    fix_fastsincos    ;ax=ang, ret eax=sin, ebx=cos
  91.     extn    fix_sincos    ;ax=ang, ret eax=sin, ebx=cos
  92.     extn    fix_asin    ;takes eax=sin, ret ax=angle
  93.     extn    fix_acos    ;takes eax=cos, ret ax=angle
  94.     extn    fix_atan2    ;takes eax,ebx = cos,sin, ret ax=angle
  95.     extn    long_sqrt    ;takes eax, returns ax
  96.     extn    fix_sqrt    ;takes eax, returns eax    
  97.     extn    quad_sqrt    ;takes eds:eax, returns eax
  98. endif
  99.