Quake II RTX doxygen  1.0 dev
block.h File Reference

Go to the source code of this file.

Macros

#define BLOCK_SIZE   (1 << BLOCK_SHIFT)
 

Functions

static void BLOCK_FUNC (void)
 

Macro Definition Documentation

◆ BLOCK_SIZE

#define BLOCK_SIZE   (1 << BLOCK_SHIFT)

Definition at line 1 of file block.h.

Function Documentation

◆ BLOCK_FUNC()

static void BLOCK_FUNC ( void  )
static

Definition at line 3 of file block.h.

4 {
5  int lightleft[3], lightright[3];
6  int lightleftstep[3], lightrightstep[3];
7  int v, i, b, lightstep[3], light[3];
8  byte *psource, *prowdest;
9 
10  psource = pbasesource;
11  prowdest = prowdestbase;
12 
13  for (v = 0 ; v < r_numvblocks ; v++) {
14  // FIXME: use delta rather than both right and left, like ASM?
15  lightleft[0] = r_lightptr[0 * LIGHTMAP_BYTES + 0];
16  lightleft[1] = r_lightptr[0 * LIGHTMAP_BYTES + 1];
17  lightleft[2] = r_lightptr[0 * LIGHTMAP_BYTES + 2];
18  lightright[0] = r_lightptr[1 * LIGHTMAP_BYTES + 0];
19  lightright[1] = r_lightptr[1 * LIGHTMAP_BYTES + 1];
20  lightright[2] = r_lightptr[1 * LIGHTMAP_BYTES + 2];
22  lightleftstep[0] = (r_lightptr[0 * LIGHTMAP_BYTES + 0] - lightleft[0]) >> BLOCK_SHIFT;
23  lightleftstep[1] = (r_lightptr[0 * LIGHTMAP_BYTES + 1] - lightleft[1]) >> BLOCK_SHIFT;
24  lightleftstep[2] = (r_lightptr[0 * LIGHTMAP_BYTES + 2] - lightleft[2]) >> BLOCK_SHIFT;
25  lightrightstep[0] = (r_lightptr[1 * LIGHTMAP_BYTES + 0] - lightright[0]) >> BLOCK_SHIFT;
26  lightrightstep[1] = (r_lightptr[1 * LIGHTMAP_BYTES + 1] - lightright[1]) >> BLOCK_SHIFT;
27  lightrightstep[2] = (r_lightptr[1 * LIGHTMAP_BYTES + 2] - lightright[2]) >> BLOCK_SHIFT;
28 
29  for (i = 0 ; i < BLOCK_SIZE ; i++) {
30  lightstep[0] = (lightleft[0] - lightright[0]) >> BLOCK_SHIFT;
31  lightstep[1] = (lightleft[1] - lightright[1]) >> BLOCK_SHIFT;
32  lightstep[2] = (lightleft[2] - lightright[2]) >> BLOCK_SHIFT;
33 
34  light[0] = lightright[0];
35  light[1] = lightright[1];
36  light[2] = lightright[2];
37 
38  for (b = BLOCK_SIZE - 1; b >= 0; b--) {
39  prowdest[b * TEX_BYTES + 0] = (psource[b * TEX_BYTES + 0] * light[0]) >> 16;
40  prowdest[b * TEX_BYTES + 1] = (psource[b * TEX_BYTES + 1] * light[1]) >> 16;
41  prowdest[b * TEX_BYTES + 2] = (psource[b * TEX_BYTES + 2] * light[2]) >> 16;
42  light[0] += lightstep[0];
43  light[1] += lightstep[1];
44  light[2] += lightstep[2];
45  }
46 
47  psource += sourcetstep;
48  lightright[0] += lightrightstep[0];
49  lightright[1] += lightrightstep[1];
50  lightright[2] += lightrightstep[2];
51  lightleft[0] += lightleftstep[0];
52  lightleft[1] += lightleftstep[1];
53  lightleft[2] += lightleftstep[2];
54  prowdest += surfrowbytes;
55  }
56 
57  if (psource >= r_sourcemax)
58  psource -= r_stepback;
59  }
60 }
r_numvblocks
static int r_numvblocks
Definition: surf.c:31
pbasesource
static byte * pbasesource
Definition: surf.c:26
r_lightwidth
static int r_lightwidth
Definition: surf.c:30
TEX_BYTES
#define TEX_BYTES
Definition: sw.h:50
r_lightptr
static unsigned * r_lightptr
Definition: surf.c:28
BLOCK_SIZE
#define BLOCK_SIZE
Definition: block.h:1
prowdestbase
static void * prowdestbase
Definition: surf.c:25
BLOCK_SHIFT
#define BLOCK_SHIFT
Definition: surf.c:160
r_sourcemax
static byte * r_sourcemax
Definition: surf.c:32
LIGHTMAP_BYTES
#define LIGHTMAP_BYTES
Definition: sw.h:203
r_stepback
static int r_stepback
Definition: surf.c:29
sourcetstep
static int sourcetstep
Definition: surf.c:24
surfrowbytes
static int surfrowbytes
Definition: surf.c:27