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.hh"
|
---|
10 | #include "software/r1_software_globals.hh"
|
---|
11 | #include "software/span_buffer.hh"
|
---|
12 | #include "software/inline_fpu.hh"
|
---|
13 | #include "software/mappers.hh"
|
---|
14 | #include "software/amd3d/amd3d.h"
|
---|
15 |
|
---|
16 | #ifndef USE_AMD3D
|
---|
17 |
|
---|
18 | void span_draw_perspective_lit_amd3d(span_tri_info *tri) {}
|
---|
19 | void span_draw_perspective_unlit_amd3d(span_tri_info *tri) {}
|
---|
20 |
|
---|
21 | #else
|
---|
22 |
|
---|
23 | void span_draw_perspective_lit_amd3d(span_tri_info *tri)
|
---|
24 | {
|
---|
25 | //setup some of the global variables
|
---|
26 | r1_software_class_instance.set_color_tint(tri->color_tint);
|
---|
27 |
|
---|
28 | r1_software_texture_ptr = tri->texture;
|
---|
29 | r1_software_twidth_log2 = tri->twidth_log2;
|
---|
30 | r1_software_texture_width = tri->texture_width;
|
---|
31 | r1_software_texture_height = tri->texture_height;
|
---|
32 | cur_grads = tri->grads;
|
---|
33 |
|
---|
34 | s_mask = ((r1_software_texture_width -1)<<16) | 0xFFFF;
|
---|
35 | t_mask = ((r1_software_texture_height-1)<<16) | 0xFFFF;
|
---|
36 |
|
---|
37 | //dont forget the light
|
---|
38 | //dldx_fixed = qftoi(tri->grads.dldx);
|
---|
39 | _asm
|
---|
40 | {
|
---|
41 | movd mm0,dword ptr [cur_grads]tri_gradients.dldx
|
---|
42 |
|
---|
43 | pf2id (m0, m0)
|
---|
44 |
|
---|
45 | movd dword ptr [dldx_fixed],mm0
|
---|
46 | }
|
---|
47 |
|
---|
48 | span_entry *s = &global_span_list[tri->span_list_head];
|
---|
49 |
|
---|
50 | perspective_span left;
|
---|
51 | while (s!=global_span_list)
|
---|
52 | {
|
---|
53 | left.ooz = s->s.ooz;
|
---|
54 |
|
---|
55 | //float left.toz = cur_grads.tozat00 + (s->x * cur_grads.dtozdx) + (s->y * cur_grads.dtozdy);
|
---|
56 | //float left.soz = cur_grads.sozat00 + (s->x * cur_grads.dsozdx) + (s->y * cur_grads.dsozdy);
|
---|
57 | //float left.l = qftoi(cur_grads.lat00 + (s->x * cur_grads.dldx) + (s->y * cur_grads.dldy));
|
---|
58 | _asm
|
---|
59 | {
|
---|
60 | mov edi, dword ptr [s]
|
---|
61 | lea eax, dword ptr [cur_grads]
|
---|
62 |
|
---|
63 | pi2fd (m0, _edi)
|
---|
64 | movq mm1,qword ptr [eax]tri_gradients.dsozdx
|
---|
65 |
|
---|
66 | pfmul (m1, m0)
|
---|
67 | movq mm2,qword ptr [eax]tri_gradients.dtozdx
|
---|
68 |
|
---|
69 | pfmul (m2, m0)
|
---|
70 | movq mm4,qword ptr [eax]tri_gradients.sozat00
|
---|
71 |
|
---|
72 | pfacc (m1, m2)
|
---|
73 | movq mm3,qword ptr [eax]tri_gradients.dldx
|
---|
74 |
|
---|
75 | //low 32bits of m1 - fx*dsdx + fy*dsdy
|
---|
76 | //high 32bits of m1 - fx*dtdx + fy*dtdy
|
---|
77 |
|
---|
78 | pfadd (m1, m4)
|
---|
79 | pfmul (m3, m0)
|
---|
80 |
|
---|
81 | //low 32bits of m1 - sat00 + fx*dsdx + fy*dsdy
|
---|
82 | //high 32bits of m1 - tat00 + fx*dtdx + fy*dtdy
|
---|
83 |
|
---|
84 | pfacc (m3, m3) //2nd arg can be whatever
|
---|
85 | movq mm4,dword ptr [eax]tri_gradients.lat00
|
---|
86 |
|
---|
87 | //low 32 bits of m3 - fx*dldx + fy*dldy
|
---|
88 |
|
---|
89 | pfadd (m3, m4)
|
---|
90 | movq qword ptr [left]perspective_span.soz,mm1
|
---|
91 |
|
---|
92 | //low 32 bits of m3 - lat00 + fx*dldx + fy*dldy
|
---|
93 |
|
---|
94 | pf2id (m5,m3)
|
---|
95 |
|
---|
96 | //low 32 bits of m5 - (int) (lat00 + fx*dldx + fy*dldy)
|
---|
97 |
|
---|
98 | movd dword ptr [left]perspective_span.l,mm5
|
---|
99 | }
|
---|
100 |
|
---|
101 | cur_scanline_texture_func(s->s.scanline_ptr,(s->s.x<<1),&left,s->s.width);
|
---|
102 | s = &global_span_list[s->s.next_tri_span];
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | void span_draw_perspective_unlit_amd3d(span_tri_info *tri)
|
---|
107 | {
|
---|
108 | //setup some of the global variables
|
---|
109 | r1_software_class_instance.set_color_tint(tri->color_tint);
|
---|
110 |
|
---|
111 | r1_software_texture_ptr = tri->texture;
|
---|
112 | r1_software_twidth_log2 = tri->twidth_log2;
|
---|
113 | r1_software_texture_width = tri->texture_width;
|
---|
114 | r1_software_texture_height = tri->texture_height;
|
---|
115 | cur_grads = tri->grads;
|
---|
116 |
|
---|
117 | s_mask = ((r1_software_texture_width -1)<<16) | 0xFFFF;
|
---|
118 | t_mask = ((r1_software_texture_height-1)<<16) | 0xFFFF;
|
---|
119 |
|
---|
120 | span_entry *s = &global_span_list[tri->span_list_head];
|
---|
121 |
|
---|
122 | perspective_span left;
|
---|
123 | while (s!=global_span_list)
|
---|
124 | {
|
---|
125 | left.ooz = s->s.ooz;
|
---|
126 |
|
---|
127 | //left.toz = cur_grads.tozat00 + (fx * cur_grads.dtozdx) + (fy * cur_grads.dtozdy);
|
---|
128 | //left.soz = cur_grads.sozat00 + (fx * cur_grads.dsozdx) + (fy * cur_grads.dsozdy);
|
---|
129 | //left.l = qftoi(cur_grads.lat00 + (fx * cur_grads.dldx) + (fy * cur_grads.dldy));
|
---|
130 | _asm
|
---|
131 | {
|
---|
132 | mov edi, dword ptr [s]
|
---|
133 | lea eax, dword ptr [cur_grads]
|
---|
134 |
|
---|
135 | pi2fd (m0, _edi)
|
---|
136 | movq mm1,qword ptr [eax]tri_gradients.dsozdx
|
---|
137 |
|
---|
138 | pfmul (m1, m0)
|
---|
139 | movq mm2,qword ptr [eax]tri_gradients.dtozdx
|
---|
140 |
|
---|
141 | pfmul (m2, m0)
|
---|
142 | movq mm4,qword ptr [eax]tri_gradients.sozat00
|
---|
143 |
|
---|
144 | pfacc (m1, m2)
|
---|
145 |
|
---|
146 | //low 32bits of m1 - fx*dsdx + fy*dsdy
|
---|
147 | //high 32bits of m1 - fx*dtdx + fy*dtdy
|
---|
148 |
|
---|
149 | pfadd (m1, m4)
|
---|
150 |
|
---|
151 | //low 32bits of m1 - sat00 + fx*dsdx + fy*dsdy
|
---|
152 | //high 32bits of m1 - tat00 + fx*dtdx + fy*dtdy
|
---|
153 |
|
---|
154 | movq qword ptr [left]perspective_span.soz,mm1
|
---|
155 | }
|
---|
156 |
|
---|
157 | cur_scanline_texture_func(s->s.scanline_ptr,(s->s.x<<1),&left,s->s.width);
|
---|
158 | s = &global_span_list[s->s.next_tri_span];
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | #endif |
---|