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_globals.hh"


10  #include "software/inline_fpu.hh"


11 


12  void texture_scanline_perspective_unlit_holy(w16 *start_pixel,


13  sw32 start_x,


14  void *_left,//perspective_span *left,


15  sw32 width)


16  {


17  //temporary stuff for lighting calculations


18  w16 texel;


19  w32 t1,t2;


20  w32 l_lookup;


21 


22  start_pixel = (w16 *)((w8 *)start_pixel + start_x);


23 


24  perspective_span *left = (perspective_span *)_left;


25 


26  left_z = 1.f / left>ooz;


27  left_s = qftoi(left>soz * left_z) + cur_grads.s_adjust;


28  left_t = qftoi(left>toz * left_z) + cur_grads.t_adjust;


29 


30  sw32 had_subdivisions = width & (~15);


31 


32  num_subdivisions = width >> 4;


33  num_leftover = width & 15;


34 


35  if (num_subdivisions)


36  {


37  ooz_right = left>ooz + (cur_grads.doozdxspan);


38  soz_right = left>soz + (cur_grads.dsozdxspan);


39  toz_right = left>toz + (cur_grads.dtozdxspan);


40 


41  right_z = 1.f / ooz_right;


42 


43  while (num_subdivisions)


44  {


45 


46  right_s = qftoi(soz_right * right_z) + cur_grads.s_adjust;


47  if (right_s < 0)


48  right_s = 0;


49  else


50  if (right_s > s_mask)


51  right_s = s_mask;


52 


53  right_t = qftoi(toz_right * right_z) + cur_grads.t_adjust;


54  if (right_t < 0)


55  right_t = 0;


56  else


57  if (right_t > t_mask)


58  right_t = t_mask;


59 


60  temp_dsdx = (right_s  left_s) >> 4;


61  temp_dtdx = (right_t  left_t) >> 4;


62 


63  if (num_subdivisions!=1)


64  {


65  ooz_right += (cur_grads.doozdxspan);


66  soz_right += (cur_grads.dsozdxspan);


67  toz_right += (cur_grads.dtozdxspan);


68 


69  right_z = 1.f / ooz_right;


70  }


71 


72  width_global = 16;


73 


74  while (width_global)


75  {


76  texel = *( r1_software_texture_ptr + (left_s>>16) + ((left_t>>16) << r1_software_twidth_log2) );


77 


78  if (texel)


79  *start_pixel = texel;


80 


81  start_pixel++;


82 


83  left_s += temp_dsdx;


84  left_t += temp_dtdx;


85 


86  width_global;


87  }


88 


89  left_s = right_s;


90  left_t = right_t;


91 


92  num_subdivisions;


93  }


94  }


95 


96  if (num_leftover)


97  {


98  if (num_leftover > 1)


99  {


100  if (had_subdivisions!=0)


101  {


102  ooz_right += (cur_grads.doozdx * num_leftover);


103  soz_right += (cur_grads.dsozdx * num_leftover);


104  toz_right += (cur_grads.dtozdx * num_leftover);


105 


106  right_z = 1.f / ooz_right;


107  }


108  else


109  {


110  ooz_right = left>ooz + (cur_grads.doozdx * num_leftover);


111  soz_right = left>soz + (cur_grads.dsozdx * num_leftover);


112  toz_right = left>toz + (cur_grads.dtozdx * num_leftover);


113 


114  right_z = 1.f / ooz_right;


115  }


116 


117  right_s = qftoi(soz_right * right_z) + cur_grads.s_adjust;


118  if (right_s < 0)


119  right_s = 0;


120  else


121  if (right_s > s_mask)


122  right_s = s_mask;


123 


124  right_t = qftoi(toz_right * right_z) + cur_grads.t_adjust;


125  if (right_t < 0)


126  right_t = 0;


127  else


128  if (right_t > t_mask)


129  right_t = t_mask;


130 


131  temp_dsdx = qftoi((float)(right_s  left_s) * inverse_leftover_lookup[num_leftover]);


132  temp_dtdx = qftoi((float)(right_t  left_t) * inverse_leftover_lookup[num_leftover]);


133 


134  while (num_leftover)


135  {


136  texel = *(r1_software_texture_ptr + (left_s>>16) + ((left_t>>16)<<r1_software_twidth_log2));


137 


138  if (texel)


139  *start_pixel = texel;


140 


141  start_pixel++;


142 


143  left_s += temp_dsdx;


144  left_t += temp_dtdx;


145 


146  num_leftover;


147  }


148  }


149  else


150  {


151  *start_pixel = *(r1_software_texture_ptr + (left_s>>16) + ((left_t>>16)<<r1_software_twidth_log2));


152  }


153  }


154  }

