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

  1. ;
  2. ; $Source: f:/miner/source/vecmat/rcs/vecmat.inc $
  3. ; $Revision: 1.21 $
  4. ; $Author: matt $
  5. ; $Date: 1994/12/13 14:44:21 $
  6. ;
  7. ; Header file for vector/matrix library
  8. ;
  9. ; $Log: vecmat.inc $
  10. ; Revision 1.21  1994/12/13  14:44:21  matt
  11. ; Added vm_vector_2_matrix_norm()
  12. ; Revision 1.20  1994/09/11  19:23:04  matt
  13. ; Added vm_vec_normalized_dir_quick()
  14. ; Revision 1.19  1994/07/19  18:52:55  matt
  15. ; Added vm_vec_normalize_quick() and vm_vec_copy_normalize_quick()
  16. ; Revision 1.18  1994/06/16  18:24:31  matt
  17. ; Added vm_vec_mag_quick()
  18. ; Revision 1.17  1994/05/19  12:07:20  matt
  19. ; Fixed globals and macros and added a constant
  20. ; Revision 1.16  1994/05/18  22:28:55  matt
  21. ; Added function vm_vec_normalized_dir()
  22. ; Added C macros IS_ZERO_VEC(), vm_vec_zero(), and vm_set_identity()
  23. ; Added C global static vars vmd_zero_vector & vmd_identity_matrix
  24. ; Revision 1.15  1994/05/18  21:45:05  matt
  25. ; Added functions:
  26. ;   vm_extract_angles_vector()
  27. ;   vm_extract_angles_vector_normalized()
  28. ;   vm_vec_copy_normalize()
  29. ; Revision 1.14  1994/05/13  12:42:09  matt
  30. ; Added new function, vm_vec_dist_quick(), which does an approximation.
  31. ; Revision 1.13  1994/03/30  15:43:54  matt
  32. ; Added two functions, vm_vec_scale_add() & vm_vec_scale_add2()
  33. ; Revision 1.12  1994/01/31  19:45:24  matt
  34. ; Added function vm_extract_angles_matrix()
  35. ; Revision 1.11  1993/12/21  19:46:29  matt
  36. ; Added function vm_dist_to_plane()
  37. ; Revision 1.10  1993/12/13  17:26:40  matt
  38. ; Added vm_vec_dist()
  39. ; Revision 1.9  1993/12/02  12:44:04  matt
  40. ; New functions: vm_vec_copy_scale(), vm_vec_scale2()
  41. ; Revision 1.8  1993/10/29  22:39:08  matt
  42. ; Changed matrix order, making direction vectors the rows
  43. ; Revision 1.7  1993/10/25  11:49:58  matt
  44. ; Made vm_vec_delta_ang() take optional forward vector to return signed delta
  45. ; Revision 1.6  1993/10/20  01:10:04  matt
  46. ; Added vm_vec_delta_ang(), vm_vec_delta_ang_norm(), and vm_vec_ang_2_matrix()
  47. ; Revision 1.5  1993/09/28  12:16:04  matt
  48. ; Added func vm_vector_2_matrix()
  49. ; Revision 1.4  1993/09/24  21:19:14  matt
  50. ; Added vm_vec_avg() and vm_vec_avg4()
  51. ; Revision 1.3  1993/09/20  14:56:35  matt
  52. ; Added new function, vm_vec_perp()
  53. ; Revision 1.2  1993/09/17  11:09:57  matt
  54. ; Added vm_vec_add2() and vm_vec_sub2(), which take 2 args (dest==src0)
  55. ; Revision 1.1  1993/09/16  20:19:29  matt
  56. ; Initial revision
  57. ;
  58. ;
  59.  
  60. ifndef _VECMAT_INC
  61. _VECMAT_INC equ 1
  62.  
  63.     include    fix.inc
  64.  
  65. ;Structures
  66.  
  67. vms_vector    struct
  68.     union
  69.      struct
  70. x      fix    ?
  71. y      fix    ?
  72. z      fix    ?
  73.      ends
  74. xyz     fix    3 dup (?)
  75.     ends
  76. vms_vector    ends
  77.  
  78.  
  79. vms_svec    struct
  80.     union
  81.      struct
  82. sv_x      dw    ?
  83. sv_y      dw    ?
  84. sv_z      dw    ?
  85.      ends
  86. sv_xyz     dw    3 dup (?)
  87.     ends
  88. vms_svec    ends
  89.  
  90. vms_angvec    struct
  91.     union
  92.     struct
  93. pitch     fixang    ?
  94. bank     fixang    ?
  95. head     fixang    ?
  96.     ends
  97.     struct
  98. ;p     fixang    ?
  99. ;b     fixang    ?
  100. ;h     fixang    ?
  101.     ends
  102.     ends
  103. vms_angvec    ends
  104.  
  105. vms_matrix    struct
  106.     union
  107.      struct
  108. m1      fix    ?
  109. m4      fix    ?
  110. m7      fix    ?
  111. m2      fix    ?
  112. m5      fix    ?
  113. m8      fix    ?
  114. m3      fix    ?
  115. m6      fix    ?
  116. m9      fix    ?
  117.      ends
  118.      struct
  119. rvec      fix    ?,?,?
  120. uvec      fix    ?,?,?
  121. fvec      fix    ?,?,?
  122.      ends
  123. ;;mm     fix    9 dup (?)
  124.     ends
  125. vms_matrix    ends
  126.  
  127.  
  128. ;Macros
  129.  
  130. ;copies one vector to another, using the register specified.  If none
  131. ;specified, uses eax
  132. vm_copy    macro    dest,src,reg:=<eax>
  133.     for    ofs,<x,y,z>
  134.      mov    reg,[src].ofs
  135.      mov    [dest].ofs,reg
  136.     endm
  137.     endm
  138.  
  139. ;copies one angvec to another, using the register specified.  If none
  140. ;specified, uses eax (and ax). Note the trick to get the word part of
  141. ;the register without knowing what the register is.
  142. vm_acopy    macro    dest,src,reg:=<eax>
  143.     mov    reg,fix ptr [src].p    ;copy two at once
  144.     mov    fix ptr [dest].p,reg
  145.     db    66h    ;size override, use short
  146.     mov    reg,fix ptr [src].h ;copy last angle
  147.     db    66h    ;size override, use short
  148.     mov    fix ptr [dest].h,reg
  149.     endm
  150.  
  151. ;Global contants
  152.     extdef    vms_vector,_vmd_zero_vector
  153.     extdef    vms_matrix,_vmd_identity_matrix
  154.  
  155. ;Routines
  156.  
  157. ;register usage appears here, but see VECMAT.H for other info
  158.  
  159.     extn    vm_vec_add    ;eax=dest, esi,edi=srcs
  160.     extn    vm_vec_sub    ;eax=dest, esi,edi=srcs
  161.     extn    vm_vec_add2    ;edi=dest, esi=source
  162.     extn    vm_vec_sub2    ;edi=dest, esi=source
  163.     extn    vm_vec_avg    ;eax=dest, esi,edi=srcs
  164.     extn    vm_vec_avg4    ;eax=dest, esi,edi,ecx,edx=srcs
  165.     extn    vm_vec_scale    ;ebx=vec, ecx=scale
  166.     extn    vm_vec_copy_scale    ;edi=dest, ebx=src, ecx=scale
  167.     extn    vm_vec_scale2    ;edi=vec, ebx=n,edx=d
  168.     extn    vm_vec_mag    ;esi=vec, returns eax=mag
  169.     extn    vm_vec_dist    ;esi,edi=vecs, returns eax=dist
  170.     extn    vm_vec_mag_quick    ;esi=vec, returns eax=approx dist
  171.     extn    vm_vec_dist_quick    ;esi,edi=vecs, returns eax=approx dist
  172.     extn    vm_vec_normalize    ;esi=vec, returns ecx=mag
  173.     extn    vm_vec_normalize_quick    ;esi=vec, returns ecx=mag
  174.     extn    vm_vec_copy_normalize    ;edi=dest, esi=src
  175.     extn    vm_vec_copy_normalize_quick    ;edi=dest, esi=src
  176.     extn    vm_vec_normalized_dir    ;edi=dest, esi=endpoint, ebx=startpoint
  177.     extn    vm_vec_normalized_dir_quick    ;edi=dest, esi=endpoint, ebx=startpoint
  178.     extn    vm_vec_dotprod    ;esi,edi=vecs, ret eax=dotprod
  179.     extn    vm_vec_crossprod    ;eax=dest, esi,edi=srcs
  180.     extn    vm_vec_normal    ;ebx=dest, eax,esi,edi=srcs
  181.     extn    vm_vec_perp    ;ebx=dest, eax,esi,edi=srcs
  182.     extn    vm_vec_delta_ang    ;esi,edi=vecs, eax=(optional) fvec, ret ax=angle
  183.     extn    vm_vec_delta_ang_norm ;esi,edi=vec, ret ax=angle
  184.     extn    vm_angles_2_matrix    ;edi=dest, esi=angvec
  185.     extn    vm_vector_2_matrix    ;edi=dest, esi=fwdvec, eax=upvec, ebx=rightvec
  186.     extn    vm_vector_2_matrix_norm    ;edi=dest, esi=fwdvec, eax=upvec, ebx=rightvec
  187.     extn    vm_vec_rotate    ;eax=dest, esi=src, edi=matrix
  188.     extn    vm_transpose_matrix    ;edi=matrix (transpose in place)
  189.     extn    vm_copy_transpose_matrix ;edi=dest, esi=src
  190.     extn    vm_matrix_x_matrix    ;eax=dest, esi,edi=srcs
  191.     extn    vm_vec_ang_2_matrix    ;esi=vector, eax=angle, edi=matrix
  192.     extn    vm_dist_to_plane    ;ebx=norm, edi=plane pnt, esi=check pnt, ret eax=dist
  193.     extn    vm_extract_angles_matrix    ;edi=angles, esi=matrix
  194.     extn    vm_vec_scale_add    ;edi=dest, ebx=src1, esi=src2, ecx=scale
  195.     extn    vm_vec_scale_add2    ;edi=dest, esi=src, ecx=scale
  196.     extn    vm_extract_angles_vector    ;edi=angvec, esi=vec TRASHES ESI
  197.     extn    vm_extract_angles_vector_normalized    ;edi=angvec, esi=vec
  198.  
  199. endif
  200.  
  201.