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