source: golgotha/src/render/software/solid_blend_half_c.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.3 KB
Line 
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
11void texture_scanline_solid_blend_half(w16 *start_pixel,
12                                       sw32 start_x,
13                                       void *left,//solid_blend_span *left,
14                                       sw32 width)
15{
16  w16 color = (((solid_blend_span *)left)->color & pre_blend_and)>>1;
17
18  start_pixel = (w16 *)((w8 *)start_pixel + start_x);
19
20  while (width)
21  {
22    *start_pixel = color + ((*start_pixel & pre_blend_and)>>1);
23    start_pixel++;
24   
25    width--;
26  }
27}
28
29void texture_scanline_solid_true_alpha(w16 *start_pixel,
30                                       sw32 start_x,
31                                       void *left,//solid_blend_span *left,
32                                       sw32 width)
33{
34  register w32 pixel;
35  register w32 color = ((solid_blend_span *)left)->color;
36  register w32 alpha = ((solid_blend_span *)left)->alpha & NUM_LIGHT_SHADES;
37
38  if (!alpha)
39    return;
40
41  //lookup low bits
42  register w32 output_color = ((w32 *)(software_color_tables))[alpha + (color & 0xFF)];
43
44  //lookup high bits
45  output_color += ((w32 *)(software_color_tables)+ctable_size)[alpha + (color>>8)];
46
47  color = output_color;
48
49  alpha ^= (NUM_LIGHT_SHADES<<8);
50     
51  if (alpha)
52  {
53    while (width)
54    {
55      output_color = color;
56
57      pixel = (w32)(*start_pixel);
58
59      //lookup low bits
60      output_color += ((w32 *)(software_color_tables))[alpha + (pixel & 0xFF)];
61
62      //lookup high bits
63      output_color += ((w32 *)(software_color_tables)+ctable_size)[alpha + (pixel>>8)];
64
65      *start_pixel = (w16)output_color;
66     
67      start_pixel++;
68      width--;
69    }
70  }
71  else
72  {
73    while (width)
74    {
75      *start_pixel = (w16)color;
76      start_pixel++;
77   
78      width--;
79    }
80  }
81}
Note: See TracBrowser for help on using the repository browser.