1  /********************************************************************** <BR>


2  This file is part of Crack dot Com's free source code release of


3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for


4  information about compiling & licensing issues visit this URL</a>


5  <PRE> If that doesn't help, contact Jonathan Clark at


6  golgotha_source@usa.net (Subject should have "GOLG" in it)


7  ***********************************************************************/


8 


9  #include "software/r1_software.hh"


10  #include "software/r1_software_globals.hh"


11  #include "software/span_buffer.hh"


12  #include "software/inline_fpu.hh"


13  #include "software/mappers.hh"


14  #include "software/amd3d/amd3d.h"


15 


16  #ifndef USE_AMD3D


17 


18  void span_draw_affine_lit_amd3d(span_tri_info *tri) {}


19  void span_draw_affine_unlit_amd3d(span_tri_info *tri) {}


20 


21  #else


22 


23  void span_draw_affine_unlit_amd3d(span_tri_info *tri)


24  {


25  //setup some of the global variables


26  r1_software_class_instance.set_color_tint(tri>color_tint);


27 


28  r1_software_texture_ptr = tri>texture;


29  r1_software_twidth_log2 = tri>twidth_log2;


30  r1_software_texture_width = tri>texture_width;


31  cur_grads = tri>grads;


32 


33  //about to draw, setup pertinent global vars (s_t_frac_add, s_t_carry, dldx_fixed)


34  _asm


35  {


36  movd mm0,dword ptr [cur_grads]tri_gradients.dsdx


37  nop


38 


39  movd mm1,dword ptr [cur_grads]tri_gradients.dtdx


40  pf2id (m0, m0)


41 


42  movd dword ptr [temp_dsdx],mm0


43  pf2id (m1, m1)


44 


45  movd dword ptr [temp_dtdx],mm1


46  }


47 


48  dsdx_frac = (temp_dsdx<<16);


49  dtdx_frac = (temp_dtdx<<16);


50 


51  s_t_carry[1] = (temp_dsdx>>16) + ((temp_dtdx>>16)<<r1_software_twidth_log2); //integral add when t doesnt carry


52  s_t_carry[0] = s_t_carry[1] + r1_software_texture_width; //integral add when t carrys


53 


54  span_entry *s = &global_span_list[tri>span_list_head];


55 


56  affine_span left;


57  while (s!=global_span_list)


58  {


59  left.ooz = s>s.ooz;


60 


61  _asm


62  {


63  //the ordering of variables in the structures used here is AMAZINGLY important


64 


65  mov edi, dword ptr [s]


66  lea eax, dword ptr [cur_grads]


67 


68  pi2fd (m0, _edi)


69  movq mm1,qword ptr [eax]tri_gradients.dsdx


70 


71  pfmul (m1, m0)


72  movq mm2,qword ptr [eax]tri_gradients.dtdx


73 


74  pfmul (m2, m0)


75  movq mm4,qword ptr [eax]tri_gradients.sat00


76 


77  pfacc (m1, m2)


78 


79  //low 32bits of m1  fx*dsdx + fy*dsdy


80  //high 32bits of m1  fx*dtdx + fy*dtdy


81 


82  pfadd (m1, m4)


83 


84  //low 32bits of m1  sat00 + fx*dsdx + fy*dsdy


85  //high 32bits of m1  tat00 + fx*dtdx + fy*dtdy


86 


87  pf2id (m5,m1)


88 


89  paddd mm5, qword ptr [eax]tri_gradients.s_adjust


90 


91  movq qword ptr [left]affine_span.s,mm5


92  }


93 


94  cur_scanline_texture_func(s>s.scanline_ptr,(s>s.x<<1),&left,s>s.width);


95  s = &global_span_list[s>s.next_tri_span];


96  }


97  }


98 


99  void span_draw_affine_lit_amd3d(span_tri_info *tri)


100  {


101  //setup some of the global variables


102  r1_software_class_instance.set_color_tint(tri>color_tint);


103 


104  r1_software_texture_ptr = tri>texture;


105  r1_software_twidth_log2 = tri>twidth_log2;


106  r1_software_texture_width = tri>texture_width;


107  cur_grads = tri>grads;


108 


109  //about to draw, setup pertinent global vars (s_t_frac_add, s_t_carry, dldx_fixed)


110  _asm


111  {


112  movd mm0,dword ptr [cur_grads]tri_gradients.dsdx


113  movd mm1,dword ptr [cur_grads]tri_gradients.dtdx


114 


115  pf2id (m0, m0)


116  movd mm2,dword ptr [cur_grads]tri_gradients.dldx


117 


118  pf2id (m1, m1)


119  movd dword ptr [temp_dsdx],mm0


120 


121  pf2id (m2, m2)


122  movd dword ptr [temp_dtdx],mm1


123 


124  movd dword ptr [dldx_fixed],mm2


125  }


126 


127  dsdx_frac = (temp_dsdx<<16);


128  dtdx_frac = (temp_dtdx<<16);


129 


130  s_t_carry[1] = (temp_dsdx>>16) + ((temp_dtdx>>16)<<r1_software_twidth_log2); //integral add when t doesnt carry


131  s_t_carry[0] = s_t_carry[1] + r1_software_texture_width; //integral add when t carrys


132 


133  span_entry *s = &global_span_list[tri>span_list_head];


134 


135  affine_span left;


136  while (s!=global_span_list)


137  {


138  left.ooz = s>s.ooz;


139 


140  _asm


141  {


142  //the ordering of variables in the structures used here is AMAZINGLY important


143 


144  mov edi, dword ptr [s]


145  lea eax, dword ptr [cur_grads]


146 


147  pi2fd (m0, _edi)


148  movq mm1,qword ptr [eax]tri_gradients.dsdx


149 


150  pfmul (m1, m0)


151  movq mm2,qword ptr [eax]tri_gradients.dtdx


152 


153  pfmul (m2, m0)


154  movq mm4,qword ptr [eax]tri_gradients.sat00


155 


156  pfacc (m1, m2)


157  movq mm3,qword ptr [eax]tri_gradients.dldx


158 


159  //low 32bits of m1  fx*dsdx + fy*dsdy


160  //high 32bits of m1  fx*dtdx + fy*dtdy


161 


162  pfadd (m1, m4)


163  pfmul (m3, m0)


164 


165  //low 32bits of m1  sat00 + fx*dsdx + fy*dsdy


166  //high 32bits of m1  tat00 + fx*dtdx + fy*dtdy


167 


168  pfacc (m3,m0) //2nd arg can be whatever


169  movq mm4,dword ptr [eax]tri_gradients.lat00


170 


171  //low 32 bits of m3  fx*dldx + fy*dldy


172 


173  pfadd (m3, m4)


174  //low 32 bits of m3  lat00 + fx*dldx + fy*dldy


175  pf2id (m5,m1)


176 


177  pf2id (m6,m3)


178  paddd mm5, qword ptr [eax]tri_gradients.s_adjust


179 


180  movq qword ptr [left]affine_span.s,mm5


181  movd dword ptr [left]affine_span.l,mm6


182  }


183 


184  cur_scanline_texture_func(s>s.scanline_ptr,(s>s.x<<1),&left,s>s.width);


185  s = &global_span_list[s>s.next_tri_span];


186  }


187  }


188 


189  #endif 
