r_aclipa.s 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. //
  16. // r_aliasa.s
  17. // x86 assembly-language Alias model transform and project code.
  18. //
  19. #include "asm_i386.h"
  20. #include "quakeasm.h"
  21. #include "asm_draw.h"
  22. #include "d_ifacea.h"
  23. #if id386
  24. .data
  25. Ltemp0: .long 0
  26. Ltemp1: .long 0
  27. .text
  28. #define pfv0 8+4
  29. #define pfv1 8+8
  30. #define out 8+12
  31. .globl C(R_Alias_clip_bottom)
  32. C(R_Alias_clip_bottom):
  33. pushl %esi
  34. pushl %edi
  35. movl pfv0(%esp),%esi
  36. movl pfv1(%esp),%edi
  37. movl C(r_refdef)+rd_aliasvrectbottom,%eax
  38. LDoForwardOrBackward:
  39. movl fv_v+4(%esi),%edx
  40. movl fv_v+4(%edi),%ecx
  41. cmpl %ecx,%edx
  42. jl LDoForward
  43. movl fv_v+4(%esi),%ecx
  44. movl fv_v+4(%edi),%edx
  45. movl pfv0(%esp),%edi
  46. movl pfv1(%esp),%esi
  47. LDoForward:
  48. subl %edx,%ecx
  49. subl %edx,%eax
  50. movl %ecx,Ltemp1
  51. movl %eax,Ltemp0
  52. fildl Ltemp1
  53. fildl Ltemp0
  54. movl out(%esp),%edx
  55. movl $2,%eax
  56. fdivp %st(0),%st(1) // scale
  57. LDo3Forward:
  58. fildl fv_v+0(%esi) // fv0v0 | scale
  59. fildl fv_v+0(%edi) // fv1v0 | fv0v0 | scale
  60. fildl fv_v+4(%esi) // fv0v1 | fv1v0 | fv0v0 | scale
  61. fildl fv_v+4(%edi) // fv1v1 | fv0v1 | fv1v0 | fv0v0 | scale
  62. fildl fv_v+8(%esi) // fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv0v0 | scale
  63. fildl fv_v+8(%edi) // fv1v2 | fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv0v0 |
  64. // scale
  65. fxch %st(5) // fv0v0 | fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv1v2 |
  66. // scale
  67. fsubr %st(0),%st(4) // fv0v0 | fv0v2 | fv1v1 | fv0v1 | fv1v0-fv0v0 |
  68. // fv1v2 | scale
  69. fxch %st(3) // fv0v1 | fv0v2 | fv1v1 | fv0v0 | fv1v0-fv0v0 |
  70. // fv1v2 | scale
  71. fsubr %st(0),%st(2) // fv0v1 | fv0v2 | fv1v1-fv0v1 | fv0v0 |
  72. // fv1v0-fv0v0 | fv1v2 | scale
  73. fxch %st(1) // fv0v2 | fv0v1 | fv1v1-fv0v1 | fv0v0 |
  74. // fv1v0-fv0v0 | fv1v2 | scale
  75. fsubr %st(0),%st(5) // fv0v2 | fv0v1 | fv1v1-fv0v1 | fv0v0 |
  76. // fv1v0-fv0v0 | fv1v2-fv0v2 | scale
  77. fxch %st(6) // scale | fv0v1 | fv1v1-fv0v1 | fv0v0 |
  78. // fv1v0-fv0v0 | fv1v2-fv0v2 | fv0v2
  79. fmul %st(0),%st(4) // scale | fv0v1 | fv1v1-fv0v1 | fv0v0 |
  80. // (fv1v0-fv0v0)*scale | fv1v2-fv0v2 | fv0v2
  81. addl $12,%edi
  82. fmul %st(0),%st(2) // scale | fv0v1 | (fv1v1-fv0v1)*scale | fv0v0 |
  83. // (fv1v0-fv0v0)*scale | fv1v2-fv0v2 | fv0v2
  84. addl $12,%esi
  85. addl $12,%edx
  86. fmul %st(0),%st(5) // scale | fv0v1 | (fv1v1-fv0v1)*scale | fv0v0 |
  87. // (fv1v0-fv0v0)*scale | (fv1v2-fv0v2)*scale |
  88. // fv0v2
  89. fxch %st(3) // fv0v0 | fv0v1 | (fv1v1-fv0v1)*scale | scale |
  90. // (fv1v0-fv0v0)*scale | (fv1v2-fv0v2)*scale |
  91. // fv0v2
  92. faddp %st(0),%st(4) // fv0v1 | (fv1v1-fv0v1)*scale | scale |
  93. // fv0v0+(fv1v0-fv0v0)*scale |
  94. // (fv1v2-fv0v2)*scale | fv0v2
  95. faddp %st(0),%st(1) // fv0v1+(fv1v1-fv0v1)*scale | scale |
  96. // fv0v0+(fv1v0-fv0v0)*scale |
  97. // (fv1v2-fv0v2)*scale | fv0v2
  98. fxch %st(4) // fv0v2 | scale | fv0v0+(fv1v0-fv0v0)*scale |
  99. // (fv1v2-fv0v2)*scale | fv0v1+(fv1v1-fv0v1)*scale
  100. faddp %st(0),%st(3) // scale | fv0v0+(fv1v0-fv0v0)*scale |
  101. // fv0v2+(fv1v2-fv0v2)*scale |
  102. // fv0v1+(fv1v1-fv0v1)*scale
  103. fxch %st(1) // fv0v0+(fv1v0-fv0v0)*scale | scale |
  104. // fv0v2+(fv1v2-fv0v2)*scale |
  105. // fv0v1+(fv1v1-fv0v1)*scale
  106. fadds float_point5
  107. fxch %st(3) // fv0v1+(fv1v1-fv0v1)*scale | scale |
  108. // fv0v2+(fv1v2-fv0v2)*scale |
  109. // fv0v0+(fv1v0-fv0v0)*scale
  110. fadds float_point5
  111. fxch %st(2) // fv0v2+(fv1v2-fv0v2)*scale | scale |
  112. // fv0v1+(fv1v1-fv0v1)*scale |
  113. // fv0v0+(fv1v0-fv0v0)*scale
  114. fadds float_point5
  115. fxch %st(3) // fv0v0+(fv1v0-fv0v0)*scale | scale |
  116. // fv0v1+(fv1v1-fv0v1)*scale |
  117. // fv0v2+(fv1v2-fv0v2)*scale
  118. fistpl fv_v+0-12(%edx) // scale | fv0v1+(fv1v1-fv0v1)*scale |
  119. // fv0v2+(fv1v2-fv0v2)*scale
  120. fxch %st(1) // fv0v1+(fv1v1-fv0v1)*scale | scale |
  121. // fv0v2+(fv1v2-fv0v2)*scale | scale
  122. fistpl fv_v+4-12(%edx) // scale | fv0v2+(fv1v2-fv0v2)*scale
  123. fxch %st(1) // fv0v2+(fv1v2-fv0v2)*sc | scale
  124. fistpl fv_v+8-12(%edx) // scale
  125. decl %eax
  126. jnz LDo3Forward
  127. fstp %st(0)
  128. popl %edi
  129. popl %esi
  130. ret
  131. .globl C(R_Alias_clip_top)
  132. C(R_Alias_clip_top):
  133. pushl %esi
  134. pushl %edi
  135. movl pfv0(%esp),%esi
  136. movl pfv1(%esp),%edi
  137. movl C(r_refdef)+rd_aliasvrect+4,%eax
  138. jmp LDoForwardOrBackward
  139. .globl C(R_Alias_clip_right)
  140. C(R_Alias_clip_right):
  141. pushl %esi
  142. pushl %edi
  143. movl pfv0(%esp),%esi
  144. movl pfv1(%esp),%edi
  145. movl C(r_refdef)+rd_aliasvrectright,%eax
  146. LRightLeftEntry:
  147. movl fv_v+4(%esi),%edx
  148. movl fv_v+4(%edi),%ecx
  149. cmpl %ecx,%edx
  150. movl fv_v+0(%esi),%edx
  151. movl fv_v+0(%edi),%ecx
  152. jl LDoForward2
  153. movl fv_v+0(%esi),%ecx
  154. movl fv_v+0(%edi),%edx
  155. movl pfv0(%esp),%edi
  156. movl pfv1(%esp),%esi
  157. LDoForward2:
  158. jmp LDoForward
  159. .globl C(R_Alias_clip_left)
  160. C(R_Alias_clip_left):
  161. pushl %esi
  162. pushl %edi
  163. movl pfv0(%esp),%esi
  164. movl pfv1(%esp),%edi
  165. movl C(r_refdef)+rd_aliasvrect+0,%eax
  166. jmp LRightLeftEntry
  167. #endif // id386