Rev 9237 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9512 | IgorA | 1 | ;============================================================= |
9237 | leency | 2 | |
9512 | IgorA | 3 | remove_dead_tri: |
4 | ; push ebp |
||
5 | ; mov ebp,esp |
||
6 | mov edi,-1 |
||
7 | movd xmm7,edi |
||
8 | pshufd xmm7,xmm7,0 |
||
9237 | leency | 9 | |
9512 | IgorA | 10 | mov esi,[triangles_ptr] |
11 | mov ecx,[triangles_count_var] |
||
12 | .chck: |
||
13 | ; jecxz .cop |
||
14 | mov eax,[esi] |
||
15 | ; mov ebx,[esi+4] |
||
16 | ; mov edx,[esi+8] |
||
17 | cmp eax,[esi+4] |
||
18 | je .tri_fail |
||
19 | cmp eax,[esi+8] |
||
20 | je .tri_fail |
||
21 | mov eax,[esi+4] |
||
22 | cmp eax,[esi+8] |
||
23 | je .tri_fail |
||
24 | |||
25 | ; cmp ebx,[esi] |
||
26 | ; je .tri_fail |
||
27 | ; cmp ebx,[esi+8] |
||
28 | ; je .tri_fail |
||
29 | ; cmp edx,[esi] |
||
30 | ; je .tri_fail |
||
31 | ; cmp edx,[esi+4] |
||
32 | ; je .tri_fail |
||
33 | add esi,12 |
||
34 | loop .chck |
||
35 | jmp .cop |
||
36 | .tri_fail: |
||
37 | movq [esi],xmm7 |
||
38 | movd [esi+8],xmm7 |
||
39 | add esi,12 |
||
40 | loop .chck |
||
41 | .cop: |
||
42 | mov esi,[triangles_ptr] |
||
43 | mov edi,[triangles_ptr] |
||
44 | mov ecx,[triangles_count_var] |
||
45 | xor edx,edx |
||
46 | .cp: |
||
47 | cmp [esi],dword -1 |
||
48 | je @f |
||
49 | movdqu xmm0,[esi] |
||
50 | movq [edi],xmm0 |
||
51 | movhlps xmm0,xmm0 |
||
52 | movd [edi+8],xmm0 |
||
53 | add edi,12 |
||
54 | inc edx |
||
55 | @@: |
||
56 | add esi,12 |
||
57 | loop .cp |
||
58 | mov [triangles_count_var],edx |
||
59 | ret |
||
60 | ;======================================================== |
||
61 | |||
9237 | leency | 62 | if Ext > SSE2 |
63 | ;-------------------------------------------------------------------- |
||
64 | init_point_lights: |
||
65 | ; mov eax,1000 |
||
66 | ; cvtsi2ss xmm1,eax |
||
67 | ; shufps xmm1,xmm1,11000000b |
||
68 | ; mov esi,lights_aligned |
||
69 | ; mov edi,point_light_coords |
||
70 | ; mov ecx,3 |
||
71 | ; @@: |
||
72 | ; movaps xmm0,[esi] |
||
73 | ; addps xmm0,[f05xz] |
||
74 | ; mulps xmm0,xmm1 |
||
75 | ; movaps [edi],xmm0 |
||
76 | ; add esi,64 |
||
77 | ; add edi,16 |
||
78 | ; loop @b |
||
79 | mov ecx,3 |
||
80 | mov edi,point_light_coords |
||
81 | @@: |
||
82 | push ecx |
||
83 | xor ecx,ecx |
||
84 | movzx edx,word[size_x_var] |
||
85 | call random |
||
86 | cvtsi2ss xmm0,eax |
||
87 | movss [edi],xmm0 |
||
88 | xor ecx,ecx |
||
89 | movzx edx,word[size_x_var] |
||
90 | call random |
||
91 | cvtsi2ss xmm0,eax |
||
92 | movss [edi+4],xmm0 |
||
93 | ; movzx ebx,word[size_x_var] |
||
94 | ; shl ebx,2 |
||
95 | ; neg ebx |
||
96 | mov ecx,-1900 |
||
97 | ; sub ecx,100 |
||
98 | mov edx,-600 |
||
99 | call random |
||
100 | cvtsi2ss xmm0,eax |
||
101 | movss [edi+8],xmm0 |
||
102 | ; mov dword[edi+8],-1700.0 |
||
103 | mov [edi+12],dword 0 |
||
104 | add edi,16 |
||
105 | pop ecx |
||
106 | loop @b |
||
107 | |||
108 | ret |
||
109 | |||
110 | ;------------------------------------------------------------------ |
||
111 | intersect_tri: ; Moeller-Trumbore method |
||
112 | ; in: |
||
113 | ; xmm0 - ray direction ; should be normalized |
||
114 | ; xmm1 - ray orgin |
||
115 | ; xmm2 - tri vert1 |
||
116 | ; xmm3 - tri vert2 |
||
117 | ; xmm4 - tri vert3 |
||
118 | ; if eax = 1 - intersction with edge |
||
119 | ; xmm6 - edge lenght |
||
120 | ; if eax = 0 - intersect with ray (classic) |
||
121 | ; out: |
||
122 | ; eax = 1 - intersection occured |
||
123 | ; xmm0 - float lo -> hi = t, v, u, ... |
||
124 | push ebp |
||
125 | mov ebp,esp |
||
126 | and ebp,-16 |
||
127 | sub esp,220 |
||
128 | |||
129 | .dir equ [ebp-16] |
||
130 | .origin equ [ebp-32] |
||
131 | .ta equ [ebp-48] |
||
132 | .tb equ [ebp-64] |
||
133 | .tc equ [ebp-80] |
||
134 | .tvec equ [ebp-96] |
||
135 | .pvec equ [ebp-112] |
||
136 | .qvec equ [ebp-128] |
||
137 | .e1 equ [ebp-128-16] |
||
138 | .ift equ dword[ebp-152] |
||
139 | .invdet equ [ebp-156] |
||
140 | .det equ [ebp-160] |
||
141 | .ed_l equ [ebp-164] |
||
142 | .u equ [ebp-168] |
||
143 | .v equ [ebp-172] |
||
144 | .t equ [ebp-176] |
||
145 | .e2 equ [ebp-192] |
||
146 | |||
147 | movaps .dir,xmm0 |
||
148 | movaps .origin,xmm1 |
||
149 | movaps .ta,xmm2 |
||
150 | movaps .tb,xmm3 |
||
151 | movaps .tc,xmm4 |
||
152 | mov .ift,eax |
||
153 | movss .ed_l,xmm6 |
||
154 | subps xmm3,xmm2 |
||
155 | subps xmm4,xmm2 |
||
156 | andps xmm3,[zero_hgst_dd] |
||
157 | andps xmm4,[zero_hgst_dd] |
||
158 | movaps .e1,xmm3 |
||
159 | movaps .e2,xmm4 |
||
160 | |||
161 | lea esi,.dir |
||
162 | lea edi,.e2 |
||
163 | lea ebx,.pvec |
||
164 | call cross_aligned |
||
165 | |||
166 | movaps xmm0,.e1 |
||
167 | mulps xmm0,.pvec |
||
168 | ; andps xmm0,[zero_hgst_dd] |
||
169 | haddps xmm0,xmm0 |
||
170 | haddps xmm0,xmm0 |
||
171 | movss .det,xmm0 |
||
172 | ; cmpnless xmm0,[eps] |
||
173 | ; movd eax,xmm0 |
||
174 | ; or eax,eax |
||
175 | ; jz @f |
||
176 | comiss xmm0,[eps] |
||
177 | jl @f |
||
178 | |||
179 | rcpss xmm0,.det |
||
180 | movss .invdet,xmm0 |
||
181 | |||
182 | movaps xmm0,.origin |
||
183 | subps xmm0,.ta |
||
184 | andps xmm0,[zero_hgst_dd] |
||
185 | movaps .tvec,xmm0 |
||
186 | |||
187 | mulps xmm0,.pvec |
||
188 | haddps xmm0,xmm0 |
||
189 | haddps xmm0,xmm0 |
||
190 | mulss xmm0,.invdet |
||
191 | movss xmm1,xmm0 |
||
192 | movss .u,xmm0 |
||
193 | cmpnless xmm1,[epsone] |
||
194 | cmpnless xmm0,[epsminus] |
||
195 | pxor xmm1,xmm0 |
||
196 | movd eax,xmm1 |
||
197 | or eax,eax |
||
198 | jz @f |
||
199 | |||
200 | lea esi,.tvec |
||
201 | lea edi,.e1 |
||
202 | lea ebx,.qvec |
||
203 | call cross_aligned |
||
204 | |||
205 | movaps xmm0,.dir |
||
206 | mulps xmm0,.qvec |
||
207 | haddps xmm0,xmm0 |
||
208 | haddps xmm0,xmm0 |
||
209 | mulss xmm0,.invdet |
||
210 | movss .v,xmm0 |
||
211 | movss xmm1,xmm0 |
||
212 | addss xmm1,.u |
||
213 | cmpnless xmm1,[epsone] |
||
214 | cmpnless xmm0,[epsminus] |
||
215 | pxor xmm1,xmm0 |
||
216 | movd eax,xmm1 |
||
217 | or eax,eax |
||
218 | jz @f |
||
219 | |||
220 | movaps xmm1,.e2 |
||
221 | mulps xmm1,.qvec |
||
222 | haddps xmm1,xmm1 |
||
223 | haddps xmm1,xmm1 |
||
224 | mulss xmm1,.invdet |
||
225 | movss .t,xmm1 |
||
226 | ; cmpnless xmm1,[eps] |
||
227 | ; movmskps eax,xmm1 |
||
228 | ; test eax,1 |
||
229 | ; jz @f |
||
230 | comiss xmm1,[eps] |
||
231 | jl @f |
||
232 | |||
233 | mov eax,1 |
||
234 | cmp .ift,0 |
||
235 | je .end ; ok intersect occured, no edge cause |
||
236 | |||
237 | movss xmm0,.t ; else check with edge lenght |
||
238 | ; movss xmm1,.t |
||
239 | cmpnless xmm0,[eps] |
||
240 | cmpnless xmm1,.ed_l |
||
241 | xorps xmm0,xmm1 |
||
242 | movd ebx,xmm0 |
||
243 | or ebx,ebx |
||
244 | jz @f |
||
245 | |||
246 | ; mov eax,1 |
||
247 | ; movaps xmm0,.t |
||
248 | jmp .end |
||
249 | @@: |
||
250 | xor eax,eax |
||
251 | .end: |
||
252 | movaps xmm0,.t |
||
253 | add esp,220 |
||
254 | pop ebp |
||
255 | ret |
||
256 | end if |
||
8719 | leency | 257 | ;=============================================================== |
258 | do_edges_list: |
||
259 | push ebp |
||
260 | mov ebp,esp |
||
261 | sub esp,32 |
||
262 | |||
263 | .ed_cnt equ [ebp-4] |
||
264 | .edd_ptr equ [ebp-8] |
||
265 | .counter equ [ebp-12] |
||
266 | |||
267 | |||
268 | mov ebx,[edges_ptr] |
||
269 | mov eax,[triangles_ptr] |
||
270 | mov ecx,[triangles_count_var] |
||
271 | @@: |
||
272 | movdqu xmm0,[eax] |
||
273 | movq [ebx],xmm0 |
||
274 | pshufd xmm0,xmm0,11001001b |
||
275 | movq [ebx+8],xmm0 |
||
276 | pshufd xmm0,xmm0,11001001b |
||
277 | movq [ebx+16],xmm0 |
||
278 | add ebx,24 |
||
279 | add eax,12 |
||
280 | loop @b |
||
281 | |||
282 | |||
283 | mov ebx,[edges_ptr] |
||
284 | mov ecx,[triangles_count_var] |
||
285 | lea ecx,[ecx*3] |
||
286 | .mxd: |
||
287 | mov eax,[ebx] |
||
288 | cmp eax,[ebx+4] |
||
289 | jl @f |
||
290 | movq xmm0,[ebx] |
||
291 | pshufd xmm0,xmm0,11100001b |
||
292 | movq [ebx],xmm0 |
||
293 | @@: |
||
294 | add ebx,8 |
||
295 | loop .mxd |
||
296 | |||
297 | |||
298 | ; insert sort |
||
299 | mov ebx,[edges_ptr] |
||
300 | mov ecx,[triangles_count_var] |
||
301 | lea ecx,[ecx*3] |
||
302 | |||
303 | mov esi,ecx |
||
304 | shl esi,3 |
||
305 | add esi,ebx |
||
306 | |||
307 | .ccc: |
||
308 | mov eax,[ebx+8] |
||
309 | cmp eax,[ebx] |
||
310 | jge .g |
||
311 | movq xmm0,[ebx+8] |
||
312 | push ebx |
||
313 | .c: |
||
314 | cmp ebx,esi |
||
315 | jge .done |
||
316 | cmp ebx,[edges_ptr] |
||
317 | jl .done |
||
318 | cmp eax,[ebx] |
||
319 | jge .done |
||
320 | movq xmm7,[ebx] |
||
321 | movq [ebx+8],xmm7 |
||
322 | sub ebx,8 |
||
323 | jnz .c |
||
324 | add ebx,8 |
||
325 | .done: |
||
326 | movq [ebx+8],xmm0 |
||
327 | .p: |
||
328 | pop ebx |
||
329 | .g: |
||
330 | add ebx,8 |
||
331 | dec ecx |
||
332 | cmp ecx,1 |
||
333 | jnz .ccc |
||
334 | |||
335 | |||
336 | ; insert sort again |
||
337 | mov ebx,[edges_ptr] |
||
338 | mov ecx,[triangles_count_var] |
||
339 | lea ecx,[ecx*3] |
||
340 | mov esi,ecx |
||
341 | shl esi,3 |
||
342 | add esi,ebx |
||
343 | |||
344 | .count: |
||
345 | push ecx |
||
346 | push ebx |
||
347 | xor ecx,ecx |
||
348 | mov eax,[ebx] ; count |
||
349 | .aa: |
||
350 | inc ecx |
||
351 | add ebx,8 |
||
352 | cmp ebx,esi |
||
353 | jge .br ; break |
||
354 | cmp eax,[ebx] |
||
355 | je .aa |
||
356 | mov .counter,ecx |
||
357 | pop ebx |
||
358 | mov edi,ebx |
||
359 | sub edi,8 |
||
360 | mov edx,[ebx+8] |
||
361 | .ccc2: |
||
362 | |||
363 | cmp ebx,esi |
||
364 | jbe @f |
||
365 | add esp,4 |
||
366 | jmp .ff |
||
367 | @@: |
||
368 | mov eax,[ebx+12] |
||
369 | mov edx,[ebx+8] |
||
370 | cmp eax,[ebx+4] |
||
371 | jge .gg2 |
||
372 | movq xmm0,[ebx+8] |
||
373 | push ebx |
||
374 | .c2: |
||
375 | cmp eax,[ebx+4] |
||
376 | jge .done2 |
||
377 | movq xmm7,[ebx] |
||
378 | movq [ebx+8],xmm7 |
||
379 | |||
380 | sub ebx,8 |
||
381 | cmp ebx,edi |
||
382 | jz @f |
||
383 | cmp [ebx+8],edx |
||
384 | jz .c2 |
||
385 | @@: |
||
386 | .done2: |
||
387 | add ebx,8 |
||
388 | movq [ebx],xmm0 |
||
389 | |||
390 | .p2: |
||
391 | pop ebx |
||
392 | .gg2: |
||
393 | add ebx,8 |
||
394 | dec ecx |
||
395 | cmp ecx,1 |
||
396 | jnz .ccc2 |
||
397 | |||
398 | pop ecx |
||
399 | sub ecx,.counter |
||
400 | add ebx,8 |
||
401 | ja .count |
||
402 | |||
403 | jmp .ff |
||
404 | .br: ;break |
||
405 | add esp,8 |
||
406 | .ff: |
||
407 | |||
408 | ; count edges |
||
409 | mov ecx,0 |
||
410 | mov edx,[triangles_count_var] |
||
411 | lea edx,[edx*3] |
||
412 | mov ebx,[edges_ptr] |
||
413 | ; mov esi,edx |
||
414 | ; shl esi,3 |
||
415 | ; add esi,[edges_ptr] |
||
416 | .nx: |
||
417 | movq xmm0,[ebx] |
||
418 | add ebx,8 |
||
419 | ; cmp ebx,esi |
||
420 | ; jae @f |
||
421 | movq xmm1,[ebx] |
||
422 | ; @@: |
||
423 | pcmpeqd xmm0,xmm1 |
||
424 | pmovmskb eax,xmm0 |
||
425 | and eax,0xff |
||
426 | cmp eax,0xff |
||
427 | jz @f |
||
428 | inc ecx |
||
429 | @@: |
||
430 | dec edx |
||
431 | jnz .nx |
||
432 | |||
433 | |||
434 | mov .ed_cnt,ecx |
||
435 | lea ecx,[ecx*3] |
||
436 | shl ecx,2 |
||
437 | add ecx,65536 |
||
438 | mov ebx,12 |
||
439 | mov eax,68 |
||
440 | mov edx,.edd_ptr |
||
441 | int 0x40 ; -> allocate memory to triangles |
||
442 | mov .edd_ptr, eax ; -> eax = pointer to allocated mem |
||
443 | |||
444 | |||
445 | |||
446 | mov ebx,[edges_ptr] |
||
447 | mov ecx,[triangles_count_var] |
||
448 | lea ecx,[ecx*3] |
||
449 | .seek: |
||
450 | movq xmm0,[ebx] |
||
451 | movq xmm1,[ebx+8] |
||
452 | pcmpeqd xmm1,xmm0 |
||
453 | pmovmskb edx,xmm1 |
||
454 | and edx,0xff |
||
455 | cmp edx,0xff |
||
456 | je @f |
||
457 | movq [eax],xmm0 |
||
458 | add eax,8 |
||
459 | @@: |
||
460 | add ebx,8 |
||
461 | loop .seek |
||
462 | |||
463 | mov eax,68 |
||
464 | mov ebx,13 |
||
465 | mov ecx,[edges_ptr] |
||
466 | int 0x40 ; release old edges ptr |
||
467 | |||
468 | |||
469 | mov eax,.edd_ptr |
||
470 | mov ecx,.ed_cnt |
||
471 | mov [edges_ptr],eax |
||
472 | mov [edges_count],ecx |
||
473 | |||
474 | mov esp,ebp |
||
475 | pop ebp |
||
476 | ret |
||
477 | |||
478 | ;======================= |
||
479 | |||
480 | |||
481 | do_sinus: |
||
9237 | leency | 482 | ;in - ax - render mode |
8719 | leency | 483 | .x equ [ebp-8] |
484 | .y equ [ebp-12] |
||
485 | .new_y equ [ebp-16] |
||
486 | .temp equ [ebp-20] |
||
9237 | leency | 487 | .dr_f equ word[ebp-22] |
488 | |||
8719 | leency | 489 | push ebp |
490 | mov ebp,esp |
||
9237 | leency | 491 | sub esp,30 |
492 | mov .dr_f,ax |
||
493 | |||
8719 | leency | 494 | mov dword .x,0 |
495 | mov dword .y,0 |
||
496 | mov esi,[screen_ptr] |
||
497 | mov edi,[Zbuffer_ptr] |
||
498 | push edi |
||
499 | ; clear Zbuffer temporally used as image buffer |
||
500 | movzx ecx,word[size_x_var] |
||
501 | movzx eax,word[size_y_var] |
||
502 | imul ecx,eax ;SIZE_X*SIZE_Y |
||
503 | xor eax,eax |
||
504 | cld |
||
505 | rep stosd |
||
506 | pop edi |
||
507 | fninit |
||
508 | .again: |
||
509 | fild dword .x |
||
510 | fmul [sin_frq] |
||
511 | fistp dword .temp |
||
512 | mov eax, .temp |
||
513 | |||
514 | and eax, 0x000000ff |
||
515 | |||
516 | fld dword [sin_tab+eax*4] |
||
517 | fimul dword [sin_amplitude] |
||
518 | fiadd dword .y |
||
519 | fistp dword .new_y |
||
9237 | leency | 520 | |
8719 | leency | 521 | mov eax,.new_y |
522 | or eax,eax |
||
523 | jl .skip |
||
524 | movzx ebx,word[size_y_var] |
||
525 | cmp eax,ebx ;SIZE_Y |
||
526 | jg .skip |
||
527 | movzx edx,word[size_x_var] |
||
528 | mul edx |
||
529 | add eax,dword .x |
||
530 | |||
531 | lea ebx,[eax*3] |
||
9237 | leency | 532 | cmp .dr_f,12 ; 32 bit col cause |
533 | jb @f |
||
8719 | leency | 534 | add ebx,eax |
535 | @@: |
||
536 | mov eax,[esi] |
||
537 | mov [edi+ebx],eax |
||
538 | .skip: |
||
539 | add esi,3 |
||
9237 | leency | 540 | cmp .dr_f,12 |
541 | jb @f |
||
8719 | leency | 542 | inc esi |
543 | @@: |
||
544 | inc dword .x |
||
545 | movzx edx,word[size_x_var] |
||
546 | cmp dword .x,edx ;SIZE_X |
||
547 | jl .again |
||
548 | mov dword .x,0 |
||
549 | inc dword .y |
||
550 | movzx edx,word[size_y_var] |
||
551 | cmp dword .y,edx ;SIZE_Y |
||
552 | jl .again |
||
553 | |||
554 | ; copy from temporary buffer -> Zbuffer to screen |
||
555 | mov esi,[Zbuffer_ptr] |
||
556 | mov edi,[screen_ptr] |
||
557 | movzx ecx,word[size_x_var] |
||
558 | movzx eax,word[size_y_var] |
||
559 | imul ecx,eax |
||
9237 | leency | 560 | cmp .dr_f,12 |
561 | jae @f |
||
8719 | leency | 562 | lea ecx,[ecx*3] |
563 | shr ecx,2 |
||
564 | ; mov ecx,SIZE_X*SIZE_Y*3/4 |
||
565 | @@: |
||
566 | cld |
||
567 | rep movsd |
||
568 | |||
569 | |||
570 | mov esp,ebp |
||
571 | pop ebp |
||
572 | ret |
||
573 | |||
574 | |||
575 | draw_dots: |
||
576 | mov esi,[points_translated_ptr] |
||
577 | mov ecx,[points_count_var] |
||
578 | .drw: |
||
579 | @@: |
||
580 | lodsd |
||
581 | add esi,2 ; skip z |
||
582 | movzx ebx,ax |
||
583 | shr eax,16 ; bx = x , ax = y |
||
584 | or ax,ax |
||
585 | jl @f |
||
586 | or bx,bx |
||
587 | jl @f |
||
588 | cmp ax,[size_y_var] ;SIZE_Y |
||
589 | jge @f |
||
590 | cmp bx,[size_x_var] ;SIZE_X |
||
591 | jge @f |
||
592 | movzx edx,word[size_x_var] ;SIZE_X ; SIZE_X not only power of 2 -> 256,512,... |
||
593 | mul edx |
||
594 | add eax,ebx |
||
595 | mov edi,[screen_ptr] |
||
596 | lea eax,[eax*3] |
||
597 | add edi,eax |
||
598 | xor eax,eax |
||
599 | not eax |
||
600 | stosd |
||
601 | @@: |
||
602 | loop .drw |
||
603 | |||
604 | ret |
||
605 | |||
606 | do_emboss: ; sse2 version only |
||
9237 | leency | 607 | ; in ax - render model |
608 | push ebp |
||
609 | mov ebp,esp |
||
610 | sub esp,4 |
||
611 | |||
612 | .dr_mod equ word[ebp-2] |
||
613 | |||
614 | mov .dr_mod,ax |
||
615 | |||
8719 | leency | 616 | if Ext >= SSE2 |
9237 | leency | 617 | |
618 | |||
619 | |||
8719 | leency | 620 | movzx ecx,[bumps_deep_flag] |
621 | inc ecx |
||
622 | call blur_screen ;blur n times |
||
623 | |||
624 | mov eax,[size_y_var] ;load both x, y |
||
625 | mov ebx,eax |
||
626 | shr ebx,16 |
||
627 | cwde |
||
628 | mul ebx |
||
629 | mov ecx,eax |
||
630 | sub ecx,ebx |
||
631 | sub ecx,ebx |
||
632 | mov esi,[screen_ptr] |
||
633 | mov edi,[Zbuffer_ptr] |
||
9237 | leency | 634 | cmp .dr_mod,11 |
8719 | leency | 635 | jge @f |
636 | lea ebx,[ebx*3] |
||
9237 | leency | 637 | jmp .gf |
8719 | leency | 638 | @@: |
639 | shl ebx,2 |
||
9237 | leency | 640 | .gf: |
8719 | leency | 641 | mov edx,esi |
642 | add esi,ebx |
||
643 | lea ebx,[ebx+esi] |
||
644 | pxor xmm0,xmm0 |
||
645 | push eax |
||
646 | .emb: |
||
9237 | leency | 647 | cmp .dr_mod ,11 |
8719 | leency | 648 | jge @f |
649 | movlps xmm1,[esi+3] |
||
650 | movhps xmm1,[esi+6] |
||
651 | movlps xmm2,[esi-3] |
||
652 | movhps xmm2,[esi] |
||
653 | movlps xmm3,[ebx] |
||
654 | movhps xmm3,[ebx+3] |
||
655 | movlps xmm4,[edx] |
||
656 | movhps xmm4,[edx+3] |
||
657 | jmp .ff |
||
658 | @@: |
||
659 | movlps xmm1,[esi+4] |
||
660 | movhps xmm1,[esi+8] |
||
661 | movlps xmm2,[esi-4] |
||
662 | movhps xmm2,[esi] |
||
663 | movlps xmm3,[ebx] |
||
664 | movhps xmm3,[ebx+4] |
||
665 | movlps xmm4,[edx] |
||
666 | movhps xmm4,[edx+4] |
||
667 | .ff: |
||
668 | punpcklbw xmm1,xmm0 |
||
669 | punpcklbw xmm2,xmm0 |
||
670 | punpcklbw xmm3,xmm0 |
||
671 | punpcklbw xmm4,xmm0 |
||
672 | psubsw xmm1,xmm2 |
||
673 | paddw xmm1,[emboss_bias] |
||
674 | psubsw xmm3,xmm4 |
||
675 | paddw xmm3,[emboss_bias] |
||
676 | pmulhw xmm1,xmm3 |
||
677 | movaps xmm7,xmm1 |
||
678 | movaps xmm6,xmm1 |
||
679 | psrlq xmm7,2*8 |
||
680 | psrlq xmm6,4*8 |
||
681 | pmaxsw xmm1,xmm7 |
||
682 | pmaxsw xmm1,xmm6 |
||
683 | |||
9237 | leency | 684 | |
8719 | leency | 685 | pmaxsw xmm1,xmm3 |
686 | |||
687 | movd eax,xmm1 |
||
688 | movzx eax,al |
||
689 | ; cmp [dr_flag],12 |
||
690 | ; je @f |
||
691 | lea eax,[eax*3+envmap_cub] |
||
692 | ; jmp .fff |
||
693 | ;@@: |
||
694 | |||
695 | mov eax,[eax] |
||
696 | mov [edi],eax ;xmm1 |
||
697 | psrldq xmm1,8 |
||
698 | movd eax,xmm1 |
||
699 | movzx eax,al |
||
700 | lea eax,[eax*3+envmap_cub] |
||
701 | mov eax,[eax] |
||
702 | mov [edi+4],eax |
||
703 | |||
9237 | leency | 704 | cmp .dr_mod,11 |
8719 | leency | 705 | jl @f |
706 | add esi,2 |
||
707 | add ebx,2 |
||
708 | add edx,2 |
||
709 | @@: |
||
710 | |||
711 | add edi,8 |
||
712 | add esi,6 |
||
713 | add ebx,6 |
||
714 | add edx,6 |
||
715 | sub ecx,2 |
||
716 | jnc .emb |
||
717 | |||
718 | |||
719 | pop ecx ;,eax |
||
720 | mov edi,[screen_ptr] |
||
721 | mov esi,[Zbuffer_ptr] |
||
9237 | leency | 722 | cmp .dr_mod,11 |
8719 | leency | 723 | jge .e |
724 | @@: |
||
725 | movsd |
||
726 | dec edi |
||
727 | loop @b |
||
728 | .e: |
||
729 | rep movsd |
||
730 | |||
731 | end if |
||
732 | |||
9237 | leency | 733 | |
734 | |||
735 | mov esp,ebp |
||
736 | pop ebp |
||
737 | |||
8719 | leency | 738 | ret |
739 | |||
740 | ;align 16 |
||
741 | ; emboss_bias: |
||
742 | ; dw 128, 128, 128, 128, 128, 128, 128, 128 |
||
743 | |||
744 | if 0 ; old emb proc |
||
745 | |||
746 | ; emboss - after drawing all, |
||
747 | ; transfer screen buffer into bump map |
||
748 | ; and draw two bump triangles |
||
749 | ; ************************************* |
||
750 | mov esi,screen |
||
751 | mov edi,bumpmap2 |
||
752 | mov ecx,TEXTURE_SIZE/3 |
||
753 | cld |
||
754 | if Ext=NON |
||
755 | xor eax,eax |
||
756 | xor bh,bh |
||
757 | xor dh,dh |
||
758 | @@: |
||
759 | lodsb |
||
760 | movzx bx,al |
||
761 | lodsb |
||
762 | movzx dx,al |
||
763 | lodsb |
||
764 | add ax,bx |
||
765 | add ax,dx |
||
766 | ; cwd |
||
767 | ; div [i3] |
||
768 | ;; push ax |
||
769 | ;; pop bx |
||
770 | ;; shr bx,3 |
||
771 | ;; shr ax,2 |
||
772 | ;; add ax,bx |
||
773 | |||
774 | lea eax,[eax*5] |
||
775 | shr ax,4 |
||
776 | |||
777 | stosb |
||
778 | loop @b |
||
779 | else |
||
780 | emms |
||
781 | pxor mm1,mm1 |
||
782 | mov ebx,0x0000ffff |
||
783 | @@: |
||
784 | movd mm0,[esi] |
||
785 | punpcklbw mm0,mm1 |
||
786 | movq mm2,mm0 |
||
787 | psrlq mm2,16 |
||
788 | movq mm3,mm0 |
||
789 | psrlq mm3,32 |
||
790 | paddw mm0,mm2 |
||
791 | paddw mm0,mm3 |
||
792 | |||
793 | |||
794 | movd eax,mm0 |
||
795 | and eax,ebx |
||
796 | lea eax,[eax*5] |
||
797 | shr ax,4 |
||
798 | stosb |
||
799 | add esi,3 |
||
800 | loop @b |
||
801 | |||
802 | end if |
||
803 | push ebp |
||
804 | |||
805 | push dword 0 ; env coords |
||
806 | push word 0 |
||
807 | push word SIZE_X |
||
808 | push word SIZE_Y |
||
809 | push dword 0 |
||
810 | push dword 0 ; bump coords |
||
811 | push word SIZE_X |
||
812 | push word SIZE_Y |
||
813 | push word 0 |
||
814 | mov eax,SIZE_Y |
||
815 | mov ebx,SIZE_X*65536+0 |
||
816 | xor ecx,ecx |
||
817 | mov edx,bumpmap2 |
||
818 | mov esi,envmap |
||
819 | mov edi,screen |
||
820 | call bump_triangle |
||
821 | |||
822 | push dword SIZE_X shl 16 + SIZE_Y ; env coords |
||
823 | push word 0 |
||
824 | push word SIZE_X |
||
825 | push word SIZE_Y |
||
826 | push word 0 |
||
827 | push dword SIZE_X shl 16 + SIZE_Y ; bump coords |
||
828 | push word 0 |
||
829 | push word SIZE_X |
||
830 | push word SIZE_Y |
||
831 | push word 0 |
||
832 | mov eax,SIZE_Y |
||
833 | mov ebx,SIZE_X * 65536+0 |
||
834 | mov ecx,SIZE_X shl 16 + SIZE_Y |
||
835 | mov edx,bumpmap2 |
||
836 | mov esi,envmap |
||
837 | mov edi,screen |
||
838 | call bump_triangle |
||
839 | |||
840 | pop ebp |
||
841 | ret |
||
842 | end if |
||
843 | ;********************************EMBOSS DONE******************************* |
||
844 | |||
845 | |||
846 | generate_object2: ; torus |
||
847 | ;in ax - figure number 2=torus, 3=loop, 4=loop |
||
848 | ;locals |
||
849 | ; counter dw ? |
||
850 | ; sin dd ? |
||
851 | ; cos dd ? |
||
852 | ;endl |
||
853 | .counter equ word[ebp-2] |
||
854 | .sin equ dword[ebp-6] |
||
855 | .cos equ dword[ebp-10] |
||
856 | .sin2 equ dword[ebp-14] |
||
857 | .cos2 equ dword[ebp-18] |
||
858 | .piD180m3 equ dword[ebp-22] |
||
859 | .cD2 equ word[ebp-24] |
||
860 | push ebp |
||
861 | mov ebp,esp |
||
862 | sub esp,24 |
||
863 | |||
864 | push ax |
||
865 | |||
866 | fninit |
||
867 | mov edi,[points_ptr] |
||
868 | xor eax,eax |
||
869 | ; init seed -> 4 3d points |
||
870 | mov dword[edi],-1.0 ; x |
||
871 | add edi,4 |
||
872 | stosd ; y |
||
873 | stosd ; z |
||
874 | mov dword[edi],-0.9 ; x1 |
||
875 | mov dword[edi+4],0.1 ; y1 |
||
876 | add edi,8 |
||
877 | stosd ; z1 |
||
878 | mov dword[edi],-0.8 |
||
879 | add edi,4 |
||
880 | stosd |
||
881 | stosd |
||
882 | mov dword[edi],-0.9 ; x3 |
||
883 | mov dword[edi+4],-0.1 ; y3 |
||
884 | add edi,8 |
||
885 | stosd ; z3 |
||
886 | mov [points_count_var],4 |
||
887 | |||
888 | fld [piD180] |
||
889 | fidiv [i3] |
||
890 | fstp .piD180m3 |
||
891 | mov .cD2,5 |
||
892 | |||
893 | pop ax |
||
894 | mov ecx,1 |
||
895 | mov edx,9 |
||
896 | .next: ; calc angle and rotate seed 4 points |
||
897 | mov .counter,cx |
||
898 | mov ebx,[points_ptr] |
||
899 | fld .piD180m3 |
||
900 | fimul .counter |
||
901 | fld st |
||
902 | fsincos |
||
903 | fstp .sin |
||
904 | fstp .cos |
||
905 | fadd st,st0 |
||
906 | fsincos |
||
907 | fstp .sin2 |
||
908 | fstp .cos2 |
||
909 | |||
910 | .rotor: ; next 4 |
||
911 | ; rotary y |
||
912 | fld dword[ebx] ; x |
||
913 | fld .sin |
||
914 | fmul dword[ebx+8] ; z * sinbeta |
||
915 | fchs |
||
916 | fld .cos |
||
917 | fmul dword[ebx] ; x * cosbeta |
||
918 | faddp |
||
919 | fstp dword[edi] ; new x |
||
920 | fmul .sin ; old x * sinbeta |
||
921 | fld .cos |
||
922 | fmul dword[ebx+8] ; z * cosbeta |
||
923 | faddp |
||
924 | dec dx |
||
925 | or dx,dx |
||
926 | jnz @f |
||
927 | ; mov .counter,dx |
||
928 | fld st |
||
929 | fidiv [i3] |
||
930 | faddp |
||
931 | @@: |
||
932 | fstp dword[edi+8] ; new z |
||
933 | fld dword[ebx+4] |
||
934 | or dx,dx |
||
935 | jnz @f |
||
936 | ; fld1 |
||
937 | ; faddp |
||
938 | ; fld st |
||
939 | fadd st,st0 |
||
940 | fadd st,st0 |
||
941 | ; fxch |
||
942 | ; fimul [i3] |
||
943 | ; fsin |
||
944 | ; faddp |
||
945 | mov dx,9 |
||
946 | @@: |
||
947 | fstp dword[edi+4] |
||
948 | ; rotary x |
||
949 | cmp al,3 |
||
950 | jl .end_rot |
||
951 | fld dword[edi+4] ;y |
||
952 | fld .sin2 |
||
953 | fmul dword[edi+8] ;z |
||
954 | fld .cos2 |
||
955 | fmul dword[edi+4] ;y |
||
956 | faddp |
||
957 | fstp dword[edi+4] ; new y |
||
958 | fmul .sin2 ; sinbeta * old y |
||
959 | fchs |
||
960 | fld .cos2 |
||
961 | fmul dword[edi+8] |
||
962 | faddp |
||
963 | fstp dword[edi+8] |
||
964 | ; rotary z |
||
965 | cmp al,4 |
||
966 | jl .end_rot |
||
967 | fld dword[edi] ;x |
||
968 | fld .sin |
||
969 | fmul dword[edi+4] ;y |
||
970 | fld .cos |
||
971 | fmul dword[edi] ;x |
||
972 | faddp |
||
973 | fstp dword[edi] ;new x |
||
974 | fmul .sin ; sinbeta * old x |
||
975 | fchs |
||
976 | fld .cos |
||
977 | fmul dword[edi+4] ; cosbeta * y |
||
978 | faddp |
||
979 | fstp dword[edi+4] ; new y |
||
980 | |||
981 | |||
982 | |||
983 | .end_rot: |
||
984 | |||
985 | add edi,12 |
||
986 | add ebx,12 |
||
987 | mov esi,[points_ptr] |
||
988 | add esi,12*4 |
||
989 | cmp ebx,esi |
||
990 | jl .rotor |
||
991 | |||
992 | add [points_count_var],4 |
||
993 | add cx,18 |
||
994 | cmp cx,(18*21*3)+1 |
||
995 | jle .next |
||
996 | |||
997 | mov edi,[triangles_ptr] |
||
998 | mov eax,4 |
||
999 | mov ebx,4+4 |
||
1000 | mov [triangles_count_var],160*3 ;164*3 ;140 |
||
1001 | |||
1002 | mov ecx,80*3 ;68 |
||
1003 | @@: |
||
1004 | stosd ;---- |
||
1005 | mov [edi],ebx ; | |
||
1006 | add edi,4 ; | |
||
1007 | inc eax ; | |
||
1008 | stosd ; |repeat 4 times |
||
1009 | |||
1010 | mov [edi],ebx ; | |
||
1011 | inc ebx |
||
1012 | add edi,4 |
||
1013 | stosd ; | |
||
1014 | mov [edi],ebx ; | |
||
1015 | add edi,4 ;---- |
||
1016 | loop @b |
||
1017 | |||
1018 | |||
1019 | mov dword[edi],-1 ; < - end mark |
||
1020 | mov [culling_flag],0 |
||
1021 | |||
1022 | mov esp,ebp |
||
1023 | pop ebp |
||
1024 | |||
1025 | ret |
||
1026 | generate_object3: ; heart |
||
1027 | ;locals |
||
1028 | ; counter dw ? |
||
1029 | ; sin dd ? |
||
1030 | ; cos dd ? |
||
1031 | ;endl |
||
1032 | .counter equ word[ebp-2] |
||
1033 | .sin equ dword[ebp-6] |
||
1034 | .cos equ dword[ebp-10] |
||
1035 | .sin2 equ dword[ebp-14] |
||
1036 | .cos2 equ dword[ebp-18] |
||
1037 | .piD180m3 equ dword[ebp-22] |
||
1038 | .cD2 equ word[ebp-24] |
||
1039 | push ebp |
||
1040 | mov ebp,esp |
||
1041 | sub esp,24 |
||
1042 | |||
1043 | fninit |
||
1044 | mov edi,[points_ptr] |
||
1045 | xor eax,eax |
||
1046 | ; init seed -> eight 3d points |
||
1047 | mov dword[edi],2.0 |
||
1048 | add edi,4 |
||
1049 | stosd |
||
1050 | stosd |
||
1051 | |||
1052 | mov dword[edi],2.0 |
||
1053 | mov dword[edi+4],-0.5 |
||
1054 | add edi,8 |
||
1055 | stosd |
||
1056 | |||
1057 | mov dword[edi],1.5 |
||
1058 | mov dword[edi+4],-1.5 |
||
1059 | add edi,8 |
||
1060 | stosd |
||
1061 | mov dword[edi],1.0 |
||
1062 | mov dword[edi+4],-2.0 |
||
1063 | add edi,8 |
||
1064 | stosd |
||
1065 | |||
1066 | stosd |
||
1067 | mov dword[edi],-2.5 |
||
1068 | add edi,4 |
||
1069 | stosd |
||
1070 | |||
1071 | mov [points_count_var],5 |
||
1072 | |||
1073 | mov ecx,1 |
||
1074 | .next: ; calc angle and rotate seed 4 points |
||
1075 | mov .counter,cx |
||
1076 | mov ebx,[points_ptr] |
||
1077 | fld [piD180] |
||
1078 | fimul .counter |
||
1079 | fsincos |
||
1080 | fstp .sin |
||
1081 | fstp .cos |
||
1082 | |||
1083 | .rotor: ; next 4 |
||
1084 | ; rotary y |
||
1085 | fld dword[ebx] ; x |
||
1086 | fld .sin |
||
1087 | fmul dword[ebx+8] ; z * sinbeta |
||
1088 | fchs |
||
1089 | fld .cos |
||
1090 | fmul dword[ebx] ; x * cosbeta |
||
1091 | faddp |
||
1092 | fidiv [i3] |
||
1093 | fstp dword[edi] ; new x |
||
1094 | fmul .sin ; old x * sinbeta |
||
1095 | fld .cos |
||
1096 | fmul dword[ebx+8] ; z * cosbeta |
||
1097 | faddp |
||
1098 | fstp dword[edi+8] ; new z |
||
1099 | |||
1100 | fld dword[ebx+4] ;y |
||
1101 | fstp dword[edi+4] |
||
1102 | |||
1103 | |||
1104 | .end_rot: |
||
1105 | |||
1106 | add edi,12 |
||
1107 | add ebx,12 |
||
1108 | mov esi,[points_ptr] |
||
1109 | add esi,12*5 |
||
1110 | cmp ebx,esi ;real_points + (12*5) |
||
1111 | jl .rotor |
||
1112 | |||
1113 | add [points_count_var],5 |
||
1114 | add cx,18 |
||
1115 | cmp cx,(18*21)+1 |
||
1116 | jle .next |
||
1117 | ;last points |
||
1118 | |||
1119 | xor eax,eax |
||
1120 | |||
1121 | mov dword[edi],0.22 |
||
1122 | mov dword[edi+4],0.77 |
||
1123 | mov dword[edi+8],1.25 |
||
1124 | add edi,12 |
||
1125 | |||
1126 | mov dword[edi],0.22 |
||
1127 | mov dword[edi+4],0.77 |
||
1128 | mov dword[edi+8],-1.25 |
||
1129 | add edi,12 |
||
1130 | stosd |
||
1131 | |||
1132 | add [points_count_var],2 |
||
1133 | |||
1134 | ; init triangles list |
||
1135 | |||
1136 | mov edi,[triangles_ptr] |
||
1137 | mov eax,5 |
||
1138 | mov ebx,5+5 |
||
1139 | mov [triangles_count_var],200 ;204 |
||
1140 | |||
1141 | mov ecx,100 |
||
1142 | @@: |
||
1143 | stosd ;---- |
||
1144 | mov [edi],ebx ; | |
||
1145 | add edi,4 ; | |
||
1146 | inc eax ; | |
||
1147 | stosd ; |repeat |
||
1148 | |||
1149 | mov [edi],ebx ; | |
||
1150 | inc ebx |
||
1151 | add edi,4 |
||
1152 | stosd ; | |
||
1153 | mov [edi],ebx ; | |
||
1154 | add edi,4 ;---- |
||
1155 | loop @b |
||
1156 | |||
1157 | mov eax,5 |
||
1158 | mov ebx,[points_count_var] |
||
1159 | sub ebx,2 |
||
1160 | mov dl,2 |
||
1161 | .nx: |
||
1162 | mov ecx,5 |
||
1163 | add [triangles_count_var],ecx |
||
1164 | @@: |
||
1165 | stosd |
||
1166 | add eax,5 |
||
1167 | stosd |
||
1168 | mov dword[edi],ebx |
||
1169 | add edi,4 |
||
1170 | loop @b |
||
1171 | |||
1172 | cmp dl,1 |
||
1173 | je @f |
||
1174 | |||
1175 | inc ebx |
||
1176 | jmp .lab |
||
1177 | @@: |
||
1178 | dec ebx |
||
1179 | .lab: |
||
1180 | mov ecx,5 |
||
1181 | add [triangles_count_var],ecx |
||
1182 | @@: |
||
1183 | stosd |
||
1184 | add eax,5 |
||
1185 | stosd |
||
1186 | mov dword[edi],ebx |
||
1187 | add edi,4 |
||
1188 | loop @b |
||
1189 | |||
1190 | dec dl |
||
1191 | or dl,dl |
||
1192 | jnz .nx |
||
1193 | |||
1194 | sub eax,25 |
||
1195 | stosd |
||
1196 | sub eax,50 |
||
1197 | stosd |
||
1198 | mov dword[edi],ebx |
||
1199 | add edi,4 |
||
1200 | |||
1201 | stosd |
||
1202 | add eax,50 |
||
1203 | stosd |
||
1204 | inc ebx |
||
1205 | mov dword[edi],ebx |
||
1206 | add edi,4 |
||
1207 | add [triangles_count_var],2 |
||
1208 | |||
1209 | mov dword[edi],-1 ; < - end mark |
||
1210 | mov [culling_flag],0 |
||
1211 | |||
1212 | mov esp,ebp |
||
1213 | pop ebp |
||
1214 | |||
1215 | ret>> |
||
1216 |