Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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