Rev 6388 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6388 | Rev 6506 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | MAX_SPHERES = 5 |
1 | MAX_SPHERES = 4 ;8 |
2 | MAX_LIGHTS = 3 |
2 | MAX_LIGHTS = 6 |
3 | ;ray |
- | |
Line 4... | Line 3... | ||
4 | 3 | ||
- | 4 | main_loop: |
|
5 | main_loop: |
5 | call normalize_surface |
6 | xor eax,eax ; y |
6 | xor eax,eax ; y |
7 | .next_line: |
7 | .next_line: |
Line 8... | Line 8... | ||
8 | xor ebx,ebx ; x |
8 | xor ebx,ebx ; x |
9 | 9 | ||
10 | @@: |
10 | @@: |
- | 11 | push eax |
|
- | 12 | push ebx |
|
- | 13 | ||
11 | push eax |
14 | |
12 | push ebx |
15 | |
13 | call find_intersection |
16 | call find_intersection |
14 | pop ebx |
17 | pop ebx |
15 | pop eax |
18 | pop eax |
Line 20... | Line 23... | ||
20 | add eax,1 |
23 | add eax,1 |
21 | cmp eax,YRES |
24 | cmp eax,YRES |
22 | jnz .next_line |
25 | jnz .next_line |
Line 23... | Line 26... | ||
23 | 26 | ||
24 | ret |
- | |
Line -... | Line 27... | ||
- | 27 | ret |
|
- | 28 | ||
- | 29 | normalize_surface: |
|
- | 30 | movss xmm0,[surface+8] |
|
- | 31 | movlhps xmm0,xmm0 |
|
- | 32 | movlps xmm0,[surface] |
|
- | 33 | movaps xmm1,xmm0 |
|
- | 34 | mulps xmm0,xmm0 |
|
- | 35 | haddps xmm0,xmm0 |
|
- | 36 | haddps xmm0,xmm0 |
|
- | 37 | sqrtss xmm0,xmm0 |
|
- | 38 | shufps xmm0,xmm0,0 |
|
- | 39 | divps xmm1,xmm0 |
|
- | 40 | movaps xmm2,xmm1 |
|
- | 41 | pslldq xmm2,4 |
|
- | 42 | psrldq xmm2,4 |
|
- | 43 | movaps [surface_without_d],xmm2 |
|
- | 44 | movlps [surface],xmm1 |
|
25 | init_calc: ; do some intial calculations |
45 | movhlps xmm1,xmm1 |
Line 26... | Line 46... | ||
26 | 46 | movss [surface+8],xmm1 |
|
27 | ret |
47 | ret |
28 | 48 | ||
29 | find_intersection: ;with for now single sphere |
49 | find_intersection: |
30 | ; eax - y |
50 | ; eax - y |
31 | ; ebx - x |
51 | ; ebx - x |
32 | push ebp |
52 | push ebp |
33 | mov ebp,esp |
53 | mov ebp,esp |
34 | sub esp,128 |
54 | sub esp,256 |
35 | and ebp,0xfffffff0 |
55 | and ebp,0xfffffff0 |
36 | .dz equ dword[ebp-8] |
56 | .dz equ dword[ebp-8] |
Line 46... | Line 66... | ||
46 | .t2 equ [ebp-48] |
66 | .t2 equ [ebp-48] |
47 | .n equ [ebp-64] |
67 | .n equ [ebp-64] |
48 | .sph_xyz equ [ebp-80] |
68 | .sph_xyz equ [ebp-80] |
49 | .one_write equ byte [ebp-81] ;tells if sth written in 'nearest' data |
69 | .one_write equ byte [ebp-81] ;tells if sth written in 'nearest' data |
50 | .sph_counter equ dword [ebp-85] |
70 | .sph_counter equ dword [ebp-85] |
- | 71 | .dx_sh equ [ebp-96] |
|
- | 72 | .a_sh equ [ebp-100] |
|
- | 73 | .b_sh equ [ebp-104] |
|
- | 74 | .c_sh equ [ebp-108] |
|
- | 75 | .delta_sh equ [ebp-112] |
|
- | 76 | .sph_counter_sh equ dword[ebp-116] |
|
51 | - | ||
- | 77 | .shadow_mark equ dword [ebp-120] |
|
- | 78 | .nearest_surface equ [ebp-144] |
|
- | 79 | .vd equ [ebp-148] ; denominator in plane inters. equation |
|
Line 52... | Line 80... | ||
52 | 80 | ||
53 | mov .iy,eax |
81 | mov .iy,eax |
Line 54... | Line 82... | ||
54 | mov .ix,ebx |
82 | mov .ix,ebx |
- | 83 | ||
55 | 84 | mov .one_write,0 |
|
56 | mov .one_write,0 |
85 | mov .shadow_mark,0 |
57 | xorps xmm0,xmm0 |
86 | xorps xmm0,xmm0 |
58 | cvtpi2ps xmm0,.ix |
87 | cvtpi2ps xmm0,.ix |
59 | mov ecx,XRES |
88 | mov ecx,XRES |
Line 66... | Line 95... | ||
66 | mulps xmm1,xmm0 |
95 | mulps xmm1,xmm0 |
67 | haddps xmm1,xmm1 |
96 | haddps xmm1,xmm1 |
68 | haddps xmm1,xmm1 |
97 | haddps xmm1,xmm1 |
69 | movss .a,xmm1 |
98 | movss .a,xmm1 |
70 | mov .sph_counter,0 |
99 | mov .sph_counter,0 |
71 | .next_sph: |
- | |
72 | xorps xmm5,xmm5 |
100 | .next_sph: ; intersection with sphere |
73 | movaps xmm5,[camera] |
101 | movaps xmm5,[camera] |
74 | mov edx,.sph_counter |
102 | mov edx,.sph_counter |
75 | shl edx,4 |
103 | shl edx,4 |
76 | add edx,sphere |
104 | add edx,sphere |
77 | subps xmm5,[edx] ;[sphere] ;;[edx] |
105 | subps xmm5,[edx] |
78 | mulps xmm5,[float2] |
106 | mulps xmm5,[float2] |
79 | movaps xmm0,.dx |
- | |
80 | mulps xmm5,xmm0 |
107 | mulps xmm5,.dx |
81 | haddps xmm5,xmm5 |
108 | haddps xmm5,xmm5 |
82 | haddps xmm5,xmm5 |
109 | haddps xmm5,xmm5 |
83 | movss .b,xmm5 |
110 | movss .b,xmm5 |
Line 84... | Line 111... | ||
84 | 111 | ||
85 | 112 | ||
86 | movaps xmm4,[edx] ;[sphere] ; [edx] |
- | |
87 | mulps xmm4,xmm4 |
- | |
88 | ; haddps xmm4,xmm4 |
113 | movaps xmm4,[edx] |
89 | ; haddps xmm4,xmm4 |
114 | mulps xmm4,xmm4 |
90 | movaps xmm5,[camera] |
115 | movaps xmm5,[camera] |
91 | mulps xmm5,xmm5 |
116 | mulps xmm5,xmm5 |
92 | addps xmm4,xmm5 |
117 | addps xmm4,xmm5 |
93 | haddps xmm4,xmm4 |
- | |
94 | haddps xmm4,xmm4 |
118 | haddps xmm4,xmm4 |
95 | ; addss xmm4,xmm5 |
119 | haddps xmm4,xmm4 |
96 | movaps xmm5,[edx] ;;[sphere] ;; [edx] |
120 | movaps xmm5,[edx] ;;[sphere] ;; [edx] |
97 | mulps xmm5,[camera] |
121 | mulps xmm5,[camera] |
98 | haddps xmm5,xmm5 |
122 | haddps xmm5,xmm5 |
Line 113... | Line 137... | ||
113 | mulss xmm4,[float4] |
137 | mulss xmm4,[float4] |
114 | subss xmm5,xmm4 |
138 | subss xmm5,xmm4 |
115 | movss .delta,xmm5 |
139 | movss .delta,xmm5 |
116 | xorps xmm6,xmm6 |
140 | xorps xmm6,xmm6 |
117 | cmpnltss xmm5,xmm6 |
141 | cmpnltss xmm5,xmm6 |
118 | movd ecx,xmm5 ; ecx = -1 greater than 0.0 |
142 | movd ecx,xmm5 ; ecx = -1 => greater than 0.0 |
119 | cmp ecx,0 |
143 | cmp ecx,0 |
120 | jnz @f |
144 | jnz @f |
121 | jmp .next_s ; no intersection |
145 | jmp .next_s ; no intersection |
122 | ; add .sph_counter,1 |
- | |
123 | ; cmp .sph_counter,MAX_SPHERES |
- | |
124 | ; jnz .next_sph |
- | |
125 | ; jmp .put_pixel |
- | |
Line 126... | Line 146... | ||
126 | 146 | ||
127 | 147 | ||
128 | @@: |
148 | @@: |
Line 137... | Line 157... | ||
137 | movss .t1,xmm6 |
157 | movss .t1,xmm6 |
138 | addss xmm4,xmm7 |
158 | addss xmm4,xmm7 |
139 | divss xmm4,[float2] |
159 | divss xmm4,[float2] |
140 | divss xmm4,.a |
160 | divss xmm4,.a |
141 | movss .t2,xmm4 |
161 | movss .t2,xmm4 |
142 | movss xmm5,xmm4 |
162 | maxss xmm6,xmm4 |
143 | - | ||
144 | cmpnltss xmm4,.t1 |
- | |
145 | movd ecx,xmm4 |
- | |
146 | or ecx,ecx |
- | |
147 | jne @f |
- | |
148 | movss xmm5,.t2 |
- | |
149 | @@: |
- | |
150 | cmp .one_write,0 ; test if sth in 'nearest' data is written |
163 | cmp .one_write,0 ; test if sth in 'nearest' data is written |
151 | jz @f |
164 | jz @f |
152 | movss xmm4,xmm5 |
165 | movss xmm4,xmm6 ;5 |
153 | cmpnltss xmm4,[smalest_t] |
166 | cmpnltss xmm4,[smalest_t] |
154 | movd ecx,xmm4 |
167 | movd ecx,xmm4 |
155 | or ecx,ecx |
168 | or ecx,ecx |
156 | jz .next_s |
169 | jz .next_s |
157 | @@: |
170 | @@: |
158 | movss [smalest_t],xmm5 |
171 | movss [smalest_t],xmm6 ;5 |
159 | ; push .a |
- | |
160 | ; pop [smalest_a] |
- | |
161 | ; push .b |
- | |
162 | ; pop [smalest_b] |
- | |
163 | ; push .c |
- | |
164 | ; pop [smalest_c] |
- | |
165 | ; push .delta |
- | |
166 | ; pop [smalest_delta] |
- | |
167 | movaps xmm0,[edx] |
172 | movaps xmm0,[edx] |
168 | movaps [nearest_sphere],xmm0 |
173 | movaps [nearest_sphere],xmm0 |
169 | push dword[ebx] |
174 | push dword[ebx] |
170 | pop dword[nearest_radius] |
175 | pop dword[nearest_radius] |
171 | mov .one_write,1 |
176 | mov .one_write,1 ; one_write - object index -> 1 = sphere |
172 | - | ||
173 | .next_s: |
177 | .next_s: |
174 | add .sph_counter,1 |
178 | add .sph_counter,1 |
175 | cmp .sph_counter,MAX_SPHERES |
179 | cmp .sph_counter,MAX_SPHERES |
176 | jnz .next_sph |
180 | jnz .next_sph |
Line -... | Line 181... | ||
- | 181 | ||
- | 182 | if 1 |
|
- | 183 | movaps xmm0,[surface_without_d] ; find with plane intersection |
|
- | 184 | mulps xmm0,[camera] ; only one surface is computed |
|
- | 185 | haddps xmm0,xmm0 |
|
- | 186 | haddps xmm0,xmm0 |
|
- | 187 | addss xmm0,[surface+12] |
|
177 | 188 | movaps xmm1,[surface_without_d] |
|
- | 189 | mulps xmm1,.dx |
|
- | 190 | haddps xmm1,xmm1 |
|
- | 191 | haddps xmm1,xmm1 |
|
- | 192 | xorps xmm2,xmm2 |
|
- | 193 | cmpnless xmm2,xmm1 |
|
- | 194 | movd ecx,xmm2 |
|
- | 195 | cmp ecx,0 ;-1 |
|
- | 196 | je .put_pixel ; denominator equal 'zero' - no intersection |
|
- | 197 | xorps xmm2,xmm2 ; denominator > 0 -> inters. not in screen area |
|
- | 198 | movss .vd,xmm1 ; write to memory this denom. |
|
- | 199 | divss xmm0,xmm1 |
|
178 | .put_pixel: |
200 | subss xmm2,xmm0 |
- | 201 | cmp .one_write,0 |
|
- | 202 | jz @f |
|
- | 203 | movss xmm0,xmm2 |
|
- | 204 | cmpnltss xmm2,[smalest_t] |
|
- | 205 | movd ecx,xmm2 |
|
- | 206 | cmp ecx,0 |
|
- | 207 | je .put_pixel |
|
- | 208 | @@: |
|
- | 209 | movss [smalest_t],xmm0 |
|
- | 210 | ; test [smalest_t],0x80000000 |
|
- | 211 | ; jz @f |
|
- | 212 | ; and [smalest_t],0x7fffffff |
|
- | 213 | ; @@: |
|
- | 214 | movaps xmm2,[surface] |
|
- | 215 | movaps .nearest_surface,xmm2 |
|
- | 216 | mov .one_write,2 ; nearest object -> 2 = flat plane |
|
- | 217 | ||
- | 218 | end if |
|
- | 219 | ||
- | 220 | .put_pixel: |
|
179 | cmp .one_write,0 |
221 | cmp .one_write,0 ; end if no intersection |
Line 180... | Line 222... | ||
180 | je .end |
222 | je .end |
181 | 223 | ||
182 | movss xmm5,[smalest_t] |
224 | movss xmm5,[smalest_t] |
183 | shufps xmm5,xmm5,0 ; calc and put pixel |
225 | shufps xmm5,xmm5,0 ; calc and put pixel |
184 | movaps xmm6,.dx |
226 | movaps xmm6,.dx |
185 | mulps xmm6,xmm5 |
227 | mulps xmm6,xmm5 |
- | 228 | movaps xmm4,[camera] |
|
- | 229 | addps xmm4,xmm6 ; xmm4 - x,y,z on the sphere or on surface |
|
- | 230 | movaps .sph_xyz,xmm4 |
|
- | 231 | if 1 |
|
- | 232 | cmp .one_write,2 |
|
- | 233 | jne .shadow |
|
- | 234 | ; movaps xmm4,.sph_xyz |
|
- | 235 | movaps xmm7,xmm4 |
|
- | 236 | lea ebx,.nearest_surface |
|
- | 237 | movss xmm4,[ebx+8] |
|
- | 238 | movlhps xmm4,xmm4 |
|
- | 239 | movlps xmm4,[ebx] ; xmm4 - normal to surface vector |
|
- | 240 | test dword .vd,0x80000000 |
|
- | 241 | jz @f |
|
- | 242 | andps xmm4,[positive_mask] ;0x7fffffff |
|
- | 243 | @@: |
|
- | 244 | ||
- | 245 | jmp .calc_pix |
|
- | 246 | ||
- | 247 | end if |
|
- | 248 | .shadow: |
|
- | 249 | if 1 |
|
- | 250 | ; to find shadow intersect: |
|
- | 251 | ; P0 - point on sphere |
|
- | 252 | ; P1 - light |
|
- | 253 | ; with every other sphere in scene if any intersection occured - |
|
- | 254 | ; - point is in shadow |
|
- | 255 | ; next_sph_shad: |
|
- | 256 | mov ecx,MAX_LIGHTS |
|
- | 257 | .next_light_sh: |
|
- | 258 | push ecx |
|
- | 259 | shl ecx,4 |
|
- | 260 | movaps xmm0,[ecx+light] ;xmm4 - point on nearest sphere |
|
- | 261 | subps xmm0,xmm4 |
|
- | 262 | movaps .dx_sh,xmm0 |
|
- | 263 | ||
- | 264 | mulps xmm0,xmm0 |
|
- | 265 | haddps xmm0,xmm0 |
|
- | 266 | haddps xmm0,xmm0 |
|
- | 267 | movss .a_sh,xmm0 |
|
- | 268 | ||
- | 269 | mov .sph_counter_sh,0 |
|
- | 270 | .next_sph_sh: ; be sure you not intersect nearest sphere with itself |
|
- | 271 | movaps xmm5,.sph_xyz ;[light] |
|
- | 272 | mov edx,.sph_counter_sh |
|
- | 273 | shl edx,4 |
|
- | 274 | add edx,sphere |
|
- | 275 | movaps xmm7,[edx] |
|
- | 276 | cmpeqps xmm7,[nearest_sphere] |
|
- | 277 | movmskps ecx,xmm7 |
|
- | 278 | and ecx,0111b |
|
- | 279 | cmp ecx,0 |
|
- | 280 | jne .next_s_sh |
|
- | 281 | ||
- | 282 | subps xmm5,[edx] ; [edx] - cur sph |
|
- | 283 | mulps xmm5,[float2] |
|
- | 284 | mulps xmm5,.dx_sh |
|
- | 285 | haddps xmm5,xmm5 |
|
- | 286 | haddps xmm5,xmm5 |
|
- | 287 | movss .b_sh,xmm5 |
|
- | 288 | ||
- | 289 | movaps xmm4,[edx] |
|
- | 290 | mulps xmm4,xmm4 |
|
- | 291 | movaps xmm5,.sph_xyz |
|
- | 292 | mulps xmm5,xmm5 |
|
- | 293 | addps xmm4,xmm5 |
|
- | 294 | haddps xmm4,xmm4 |
|
- | 295 | haddps xmm4,xmm4 |
|
- | 296 | movaps xmm5,.sph_xyz |
|
- | 297 | mulps xmm5,[edx] |
|
- | 298 | haddps xmm5,xmm5 |
|
- | 299 | haddps xmm5,xmm5 |
|
- | 300 | mulss xmm5,[float2] |
|
- | 301 | subss xmm4,xmm5 |
|
- | 302 | mov ebx,.sph_counter_sh |
|
- | 303 | shl ebx,2 |
|
- | 304 | add ebx,sph_radius |
|
- | 305 | movss xmm5,[ebx] |
|
- | 306 | mulss xmm5,xmm5 |
|
- | 307 | subss xmm4,xmm5 |
|
- | 308 | movss .c_sh,xmm4 |
|
- | 309 | ||
- | 310 | movss xmm5,.b_sh |
|
- | 311 | mulss xmm5,xmm5 |
|
- | 312 | mulss xmm4,.a_sh |
|
- | 313 | mulss xmm4,[float4] |
|
- | 314 | subss xmm5,xmm4 |
|
- | 315 | movss .delta_sh,xmm5 |
|
- | 316 | xorps xmm6,xmm6 |
|
- | 317 | cmpnltss xmm5,xmm6 |
|
- | 318 | movd ecx,xmm5 ; ecx = -1 greater than 0.0 |
|
- | 319 | cmp ecx,0 |
|
- | 320 | jnz @f |
|
- | 321 | jmp .next_s_sh ; no intersection |
|
- | 322 | @@: |
|
- | 323 | add .shadow_mark,1 ; mark ->point in shadow |
|
- | 324 | pop ecx |
|
- | 325 | sub ecx,1 |
|
- | 326 | jnz .next_light_sh |
|
- | 327 | jmp .put_pix |
|
- | 328 | .next_s_sh: |
|
- | 329 | add .sph_counter_sh,1 |
|
- | 330 | cmp .sph_counter_sh,MAX_SPHERES |
|
- | 331 | jnz .next_sph_sh |
|
- | 332 | pop ecx |
|
- | 333 | sub ecx,1 |
|
- | 334 | jnz .next_light_sh |
|
- | 335 | ||
- | 336 | end if |
|
- | 337 | ||
- | 338 | ||
- | 339 | ||
- | 340 | ||
- | 341 | ||
- | 342 | ||
186 | movaps xmm4,[camera] |
343 | .put_pix: |
187 | addps xmm4,xmm6 ; xmm4 - x,y,z on the sphere |
344 | movaps xmm4,.sph_xyz |
188 | movaps xmm7,xmm4 |
- | |
189 | subps xmm4,[nearest_sphere] |
- | |
190 | ; movaps xmm6,xmm7 |
- | |
Line 191... | Line 345... | ||
191 | ; addps xmm6,[nearest_sphere] |
345 | movaps xmm7,xmm4 |
192 | ; movaps .sph_xyz,xmm6 |
346 | subps xmm4,[nearest_sphere] |
193 | 347 | ||
- | 348 | movss xmm0,[nearest_radius] |
|
194 | movss xmm0,[nearest_radius] |
349 | shufps xmm0,xmm0,0 |
195 | shufps xmm0,xmm0,0 |
350 | divps xmm4,xmm0 ; xmm4 - normal to surface vector |
196 | divps xmm4,xmm0 ; xmm4 - normal to surface vector |
351 | .calc_pix: ; normal computed |
197 | movaps xmm1,xmm4 ; copy of normal in xmm1 |
352 | movaps xmm1,xmm4 ; copy of normal in xmm1 |
198 | xor eax,eax |
353 | xor eax,eax |
Line 199... | Line 354... | ||
199 | xorps xmm3,xmm3 |
354 | xorps xmm3,xmm3 |
200 | movss xmm2,[light_factor] |
- | |
201 | shufps xmm2,xmm2,0 |
355 | ; movss xmm2,[light_factor] ; other model of lighting |
202 | 356 | ; shufps xmm2,xmm2,0 |
|
203 | .next_light: |
- | |
204 | ; push eax |
357 | |
205 | mov ebx,eax |
358 | .next_light: |
206 | shl ebx,4 |
359 | mov ebx,eax |
207 | ;add eax,light |
360 | shl ebx,4 |
208 | movaps xmm5,[light+ebx];[light] ;; [eax] |
361 | movaps xmm5,[light+ebx] |
209 | subps xmm5,xmm7 ; calc light unit vector |
362 | subps xmm5,xmm7 ; calc light unit vector |
210 | movaps xmm6,xmm5 |
363 | movaps xmm6,xmm5 |
- | 364 | mulps xmm5,xmm5 |
|
211 | mulps xmm5,xmm5 |
365 | haddps xmm5,xmm5 |
212 | haddps xmm5,xmm5 |
366 | haddps xmm5,xmm5 |
213 | haddps xmm5,xmm5 |
367 | sqrtss xmm5,xmm5 |
214 | sqrtss xmm5,xmm5 |
368 | shufps xmm5,xmm5,0 |
215 | divps xmm6,xmm5 ; xmm6 - normalized light vector |
369 | divps xmm6,xmm5 ; xmm6 - normalized light vector |
216 | ; dot_product |
370 | ; dot_product |
217 | movaps xmm4,xmm1 ; xmm4 - normal to surface |
371 | movaps xmm4,xmm1 ; xmm4 - normal to surface |
218 | mulps xmm4,xmm6 |
- | |
219 | haddps xmm4,xmm4 |
- | |
220 | haddps xmm4,xmm4 |
- | |
221 | shufps xmm4,xmm4,0 |
- | |
222 | ; movaps xmm5,xmm4 |
372 | mulps xmm4,xmm6 |
- | 373 | haddps xmm4,xmm4 |
|
223 | ; mulps xmm5,xmm5 |
374 | haddps xmm4,xmm4 |
224 | ; mulps xmm5,xmm5 |
375 | shufps xmm4,xmm4,0 |
- | 376 | mulps xmm4,[lights_color+ebx] ; xmm4 - computed col. light vector dep. |
|
225 | ; mulps xmm5,[color] |
377 | |
226 | mulps xmm4,[lights_color+ebx] ; xmm4 - computed col. light vector dep. |
- | |
- | 378 | ; mulps xmm4,xmm2 ; other model of lighting |
|
227 | ; addps xmm4,xmm5 |
379 | ; addps xmm3,xmm4 |
228 | mulps xmm4,xmm2 |
380 | |
229 | addps xmm3,xmm4 |
381 | maxps xmm3,xmm4 ; will be this better ? |
230 | ; pop eax |
- | |
231 | add eax,1 |
- | |
232 | cmp eax,MAX_LIGHTS |
- | |
233 | jnz .next_light |
- | |
234 | if 0 |
- | |
235 | ; mix with texture |
- | |
236 | movaps xmm0,.sph_xyz |
- | |
237 | movss xmm1,[nearest_radius] |
- | |
238 | shufps xmm1,xmm1,0 |
- | |
239 | divps xmm0,xmm1 |
- | |
240 | mulps xmm0,[correct_tex] ; f64 |
- | |
241 | ; addps xmm0,[correct_tex] |
- | |
242 | cvtss2si eax,xmm0 |
- | |
243 | psrldq xmm0,4 |
- | |
244 | cvtss2si ebx,xmm0 |
- | |
245 | imul ebx,[tex_x] |
- | |
246 | add ebx,eax |
- | |
247 | lea ebx,[ebx*3] |
- | |
248 | add ebx,bitmap |
- | |
249 | ;mov eax,[ebx] |
- | |
250 | movd xmm1,[ebx] |
- | |
251 | xorps xmm7,xmm7 |
- | |
252 | punpcklbw xmm1,xmm7 |
- | |
253 | punpcklwd xmm1,xmm7 |
- | |
254 | cvtdq2ps xmm1,xmm1 |
- | |
255 | mulps xmm3,xmm1 |
- | |
256 | divps xmm3,[float255] |
- | |
257 | ; divps xmm1,[float2] |
- | |
Line 258... | Line 382... | ||
258 | ; divps xmm3,[float2] |
382 | |
- | 383 | add eax,1 |
|
- | 384 | cmp eax,MAX_LIGHTS |
|
- | 385 | jnz .next_light |
|
- | 386 | ||
- | 387 | minps xmm3,[float255] |
|
- | 388 | cmp .shadow_mark,0 |
|
- | 389 | je @f |
|
- | 390 | cvtsi2ss xmm2,.shadow_mark |
|
- | 391 | shufps xmm2,xmm2,0 |
|
- | 392 | mulps xmm2,[shadow_factor] |
|
259 | ; addps xmm3,xmm1 |
393 | subps xmm3,xmm2 |
260 | end if |
394 | xorps xmm0,xmm0 |
261 | 395 | maxps xmm3,xmm0 |
|
- | 396 | @@: |
|
Line -... | Line 397... | ||
- | 397 | ||
- | 398 | cvtps2dq xmm3,xmm3 |
|
- | 399 | packssdw xmm3,xmm3 |
|
- | 400 | packuswb xmm3,xmm3 |
|
- | 401 | paddusb xmm3,[ambient_col] |
|
- | 402 | ||
- | 403 | if 1 |
|
- | 404 | cmp .one_write,2 |
|
- | 405 | jne .perspective |
|
- | 406 | movaps xmm0,xmm3 ; calc texture on plane |
|
- | 407 | movaps xmm1,.sph_xyz |
|
- | 408 | mov ecx,XRES |
|
- | 409 | cvtsi2ss xmm4,ecx |
|
- | 410 | shufps xmm4,xmm4,0 |
|
- | 411 | mulps xmm1,xmm4 |
|
- | 412 | cvtps2dq xmm1,xmm1 |
|
- | 413 | movd ecx,xmm1 |
|
- | 414 | test ecx,0x8 |
|
- | 415 | jz @f |
|
- | 416 | mov ecx,0xffffffff |
|
- | 417 | jmp .next_tex_test |
|
- | 418 | @@: |
|
- | 419 | xor ecx,ecx |
|
- | 420 | .next_tex_test: |
|
- | 421 | psrldq xmm1,8 |
|
- | 422 | movd ebx,xmm1 |
|
- | 423 | test ebx,0x20 |
|
- | 424 | jz @f |
|
- | 425 | mov ebx,0xffffffff |
|
- | 426 | jmp .set_tex |
|
- | 427 | @@: |
|
- | 428 | xor ebx,ebx |
|
Line -... | Line 429... | ||
- | 429 | .set_tex: |
|
Line -... | Line 430... | ||
- | 430 | xor ebx,ecx |
|
- | 431 | shr ebx,28 |
|
- | 432 | mov bh,bl |
|
- | 433 | movd xmm7,ebx |
|
- | 434 | paddusb xmm3,xmm7 |
|
- | 435 | ||
- | 436 | end if |
|
- | 437 | ||
- | 438 | ||
- | 439 | .perspective: |
|
- | 440 | movaps xmm0,.sph_xyz ; perspective correction |
|
- | 441 | subps xmm0,[camera] |
|
- | 442 | movss xmm1,[camera] |
|
- | 443 | movss xmm2,xmm0 |
|
- | 444 | movaps xmm4,xmm0 |
|
- | 445 | shufps xmm4,xmm4,00000010b |
|
- | 446 | divss xmm2,xmm4 |
|
- | 447 | mulss xmm2,[camera+8] |
|
- | 448 | subss xmm1,xmm2 ; xmm1 - x |
|
- | 449 | ||
- | 450 | movaps xmm2,xmm0 |
|
- | 451 | shufps xmm2,xmm2,00000001b |
|
- | 452 | movaps xmm4,xmm0 |
|
- | 453 | shufps xmm4,xmm4,00000010b |
|
- | 454 | divss xmm2,xmm4 |
|
- | 455 | mulss xmm2,[camera+8] |
|
- | 456 | movss xmm4,[camera+4] |
|
- | 457 | subss xmm4,xmm2 ; xmm4 - y |
|
- | 458 | ||
262 | 459 | mov ebx,XRES |
|
263 | minps xmm3,[float255] |
460 | cvtsi2ss xmm2,ebx |
264 | cvtps2dq xmm3,xmm3 |
461 | mulss xmm1,xmm2 |
265 | packssdw xmm3,xmm3 |
462 | mulss xmm4,xmm2 |
266 | packuswb xmm3,xmm3 |
463 | cvtss2si ecx,xmm1 |
267 | 464 | mov .ix,ecx |
|
268 | 465 | cvtss2si edx,xmm4 |
|
269 | - | ||
270 | 466 | mov .iy,edx |
|
271 | mov edi,screen |
467 | |
272 | mov ecx,XRES |
468 | mov edi,screen |
Line 273... | Line 469... | ||
273 | imul ecx,.iy |
469 | mov ecx,XRES |