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(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  *start_pixel = *( r1_software_texture_ptr + (left_s>>16) + ((left_t>>16) << r1_software_twidth_log2) );


77 


78  start_pixel++;


79 


80  left_s += temp_dsdx;


81  left_t += temp_dtdx;


82 


83  width_global;


84  }


85 


86  left_s = right_s;


87  left_t = right_t;


88 


89  num_subdivisions;


90  }


91  }


92 


93  if (num_leftover)


94  {


95  if (num_leftover > 1)


96  {


97  if (had_subdivisions!=0)


98  {


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


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


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


102 


103  right_z = 1.f / ooz_right;


104  }


105  else


106  {


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


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


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


110 


111  right_z = 1.f / ooz_right;


112  }


113 


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


115  if (right_s < 0)


116  right_s = 0;


117  else


118  if (right_s > s_mask)


119  right_s = s_mask;


120 


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


122  if (right_t < 0)


123  right_t = 0;


124  else


125  if (right_t > t_mask)


126  right_t = t_mask;


127 


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


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


130 


131  while (num_leftover)


132  {


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


134 


135  start_pixel++;


136 


137  left_s += temp_dsdx;


138  left_t += temp_dtdx;


139 


140  num_leftover;


141  }


142  }


143  else


144  {


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


146  }


147  }


148  }

