home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 14 / MA_Cover_14.iso / source / c / q1source_amy / qw / server / worlda.s < prev   
Encoding:
Text File  |  1996-07-12  |  2.1 KB  |  125 lines

  1. //
  2. // worlda.s
  3. // x86 assembly-language server testing stuff
  4. //
  5.  
  6. #include "asm_i386.h"
  7. #include "quakeasm.h"
  8. //include "d_ifacea.h"
  9.  
  10. #if id386
  11.  
  12.     .data
  13.  
  14. Ltemp:    .long    0
  15.  
  16.     .text
  17.  
  18. //----------------------------------------------------------------------
  19. // hull-point test
  20. //----------------------------------------------------------------------
  21.  
  22. #define hull    4+8                // because only partially pushed
  23. #define    num        8+4                // because only partially pushed
  24. #define p        12+12            // because only partially pushed
  25.  
  26.     .align 4
  27. .globl C(SV_HullPointContents)
  28. C(SV_HullPointContents):
  29.     pushl    %edi                // preserve register variables
  30.     movl    num(%esp),%eax
  31.     testl    %eax,%eax
  32.     js        Lhquickout
  33.  
  34. //    float        d;
  35. //    dclipnode_t    *node;
  36. //    mplane_t    *plane;
  37.  
  38.     pushl    %ebx
  39.     movl    hull(%esp),%ebx
  40.  
  41.     pushl    %ebp
  42.     movl    p(%esp),%edx
  43.  
  44.     movl    hu_clipnodes(%ebx),%edi
  45.     movl    hu_planes(%ebx),%ebp
  46.  
  47.     subl    %ebx,%ebx
  48.     pushl    %esi
  49.  
  50. // %ebx: 0
  51. // %eax: num
  52. // %edx: p
  53. // %edi: hull->clipnodes
  54. // %ebp: hull->planes
  55.  
  56. //    while (num >= 0)
  57. //    {
  58.  
  59. Lhloop:
  60.  
  61. //        node = hull->clipnodes + num;
  62. //        plane = hull->planes + node->planenum;
  63. // !!! if the size of dclipnode_t changes, the scaling of %eax needs to be
  64. //     changed !!!
  65.     movl    nd_planenum(%edi,%eax,8),%ecx
  66.     movl    nd_children(%edi,%eax,8),%eax
  67.     movl    %eax,%esi
  68.     rorl    $16,%eax
  69.     leal    (%ecx,%ecx,4),%ecx
  70.  
  71. //        if (plane->type < 3)
  72. //            d = p[plane->type] - plane->dist;
  73.     movl    pl_type(%ebp,%ecx,4),%bl
  74.     cmpb    $3,%bl
  75.     jb        Lnodot
  76.  
  77. //        else
  78. //            d = DotProduct (plane->normal, p) - plane->dist;
  79.     flds    pl_normal(%ebp,%ecx,4)
  80.     fmuls    0(%edx)
  81.     flds    pl_normal+4(%ebp,%ecx,4)
  82.     fmuls    4(%edx)
  83.     flds    pl_normal+8(%ebp,%ecx,4)
  84.     fmuls    8(%edx)
  85.     fxch    %st(1)
  86.     faddp    %st(0),%st(2)
  87.     faddp    %st(0),%st(1)
  88.     fsubs    pl_dist(%ebp,%ecx,4)
  89.     jmp        Lsub
  90.  
  91. Lnodot:
  92.     flds    pl_dist(%ebp,%ecx,4)
  93.     fsubrs    (%edx,%ebx,4)
  94.  
  95. Lsub:
  96.     sarl    $16,%eax
  97.     sarl    $16,%esi
  98.  
  99. //        if (d < 0)
  100. //            num = node->children[1];
  101. //        else
  102. //            num = node->children[0];
  103.     fstps    Ltemp
  104.     movl    Ltemp,%ecx
  105.     sarl    $31,%ecx
  106.     andl    %ecx,%esi
  107.     xorl    $0xFFFFFFFF,%ecx
  108.     andl    %ecx,%eax
  109.     orl        %esi,%eax
  110.     jns        Lhloop
  111.  
  112. //    return num;
  113. Lhdone:
  114.     popl    %esi
  115.     popl    %ebp
  116.     popl    %ebx                // restore register variables
  117.  
  118. Lhquickout:
  119.     popl    %edi
  120.  
  121.     ret
  122.  
  123. #endif    // id386
  124.  
  125.