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 | w32 *texture_affine_lit_starter()
|
---|
13 | {
|
---|
14 | w32 returnval;
|
---|
15 | _asm
|
---|
16 | {
|
---|
17 | mov eax,OFFSET dumb_addr
|
---|
18 | dumb_addr:
|
---|
19 | mov returnval,eax
|
---|
20 | }
|
---|
21 | return (w32 *)returnval;
|
---|
22 | }
|
---|
23 |
|
---|
24 | void texture_scanline_affine_lit(w16 *start_pixel,
|
---|
25 | sw32 start_x,
|
---|
26 | void *_left,//perspective_span *left,
|
---|
27 | sw32 width)
|
---|
28 | {
|
---|
29 | //temporary dwords for lighting calculations
|
---|
30 | w16 texel;
|
---|
31 | w32 t1,t2;
|
---|
32 | w32 l_lookup;
|
---|
33 |
|
---|
34 | start_pixel = (w16 *)((w8 *)start_pixel + start_x);
|
---|
35 |
|
---|
36 | affine_span *left = (affine_span *)_left;
|
---|
37 |
|
---|
38 | left_s = left->s + cur_grads.s_adjust;
|
---|
39 | left_t = left->t + cur_grads.t_adjust;
|
---|
40 | left_l = left->l;
|
---|
41 |
|
---|
42 | temp_dsdx = qftoi(cur_grads.dsdx);
|
---|
43 | temp_dtdx = qftoi(cur_grads.dtdx);
|
---|
44 |
|
---|
45 | width_global = width;
|
---|
46 |
|
---|
47 | while (width_global)
|
---|
48 | {
|
---|
49 | texel = *(r1_software_texture_ptr + (left_s>>16) + ((left_t>>16)<<r1_software_twidth_log2));
|
---|
50 |
|
---|
51 | l_lookup = left_l & (NUM_LIGHT_SHADES<<8);
|
---|
52 |
|
---|
53 | //lookup low bits
|
---|
54 | t1 = ((w32 *)(0xDEADBEEF))[l_lookup + (texel & 0xFF)];
|
---|
55 |
|
---|
56 | //lookup high bits
|
---|
57 | t2 = ((w32 *)(0xDEADBEEF)+ctable_size)[l_lookup + (texel>>8)];
|
---|
58 |
|
---|
59 | *start_pixel = (w16)(t1+t2);
|
---|
60 |
|
---|
61 | start_pixel++;
|
---|
62 |
|
---|
63 | left_s += temp_dsdx;
|
---|
64 | left_t += temp_dtdx;
|
---|
65 | left_l += dldx_fixed;
|
---|
66 |
|
---|
67 | width_global--;
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | w32 *texture_affine_lit_sentinel()
|
---|
72 | {
|
---|
73 | w32 returnval;
|
---|
74 | _asm
|
---|
75 | {
|
---|
76 | mov eax,OFFSET dumb_addr
|
---|
77 | dumb_addr:
|
---|
78 | mov returnval,eax
|
---|
79 | }
|
---|
80 | return (w32 *)returnval;
|
---|
81 | }
|
---|
82 |
|
---|
83 | void insert_color_modify_address_low(w32 *address);
|
---|
84 | void insert_color_modify_address_high(w32 *address);
|
---|
85 | extern w32 color_modify_list[];
|
---|
86 | extern sw32 num_color_modifies;
|
---|
87 |
|
---|
88 | void setup_color_modify_affine_lit()
|
---|
89 | {
|
---|
90 | w32 *stop = texture_affine_lit_sentinel();
|
---|
91 |
|
---|
92 | w32 *search = texture_affine_lit_starter();
|
---|
93 | //start searching for 0xDEADBEEF
|
---|
94 | while (search < stop)
|
---|
95 | {
|
---|
96 | //casting craziness
|
---|
97 | search = (w32 *)((w8 *)search + 1);
|
---|
98 | if (*search==0xDEADBEEF)
|
---|
99 | {
|
---|
100 | insert_color_modify_address_low(search);
|
---|
101 | }
|
---|
102 | else
|
---|
103 | if (*search==(0xDEADBEEF + ctable_size_bytes))
|
---|
104 | {
|
---|
105 | insert_color_modify_address_high(search);
|
---|
106 | }
|
---|
107 | }
|
---|
108 | } |
---|