Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1245 | hidnplayr | 1 | |
2 | |||
3 | ;NON=0 |
||
4 | ;MMX=1 |
||
5 | ;Ext=MMX |
||
6 | ;TEX_SIZE=0x3fff |
||
7 | ;SIZE_X equ 512 |
||
8 | ;SIZE_Y equ 512 |
||
9 | ;ROUND = 8 |
||
10 | ;TEX_SHIFT equ 6 |
||
11 | |||
12 | ; procedure drawing textured triangle with Gouraud shading |
||
13 | |||
14 | ; I set the color by this way -- (col1 * col2)/256 ------ |
||
15 | ;------------------in - eax - x1 shl 16 + y1 ------------ |
||
16 | ;---------------------- ebx - x2 shl 16 + y2 ------------ |
||
17 | ;---------------------- ecx - x3 shl 16 + y3 ------------ |
||
18 | ;---------------------- esi - pointer to Z-buffer-------- |
||
19 | ;---------------------- edx - pointer to texture--------- |
||
20 | ;---------------------- Z-buffer filled with dd variables |
||
21 | ;---------------------- shifted CATMULL_SHIFT------------ |
||
22 | ;---------------------- edi - pointer to screen buffer--- |
||
23 | ;---------------------- stack : colors------------------- |
||
24 | |||
25 | |||
26 | |||
27 | |||
28 | |||
29 | .tex_y3 equ [ebp+38] ; 36 bytes through stack |
||
30 | .tex_x3 equ [ebp+36] |
||
31 | .tex_y2 equ [ebp+34] |
||
32 | .tex_x2 equ [ebp+32] |
||
33 | .tex_y1 equ [ebp+30] |
||
34 | .tex_x1 equ [ebp+28] |
||
35 | |||
36 | .z3 equ [ebp+26] |
||
37 | |||
38 | .col3g equ [ebp+22] |
||
39 | .col3r equ [ebp+20] |
||
40 | |||
41 | .z2 equ [ebp+18] |
||
42 | |||
43 | .col2g equ [ebp+14] |
||
44 | .col2r equ [ebp+12] |
||
45 | |||
46 | .z1 equ [ebp+10] |
||
47 | |||
48 | .col1g equ [ebp+6] |
||
49 | .col1r equ [ebp+4] |
||
50 | |||
51 | ; local variables: |
||
52 | |||
53 | .tex_ptr equ dword[ebp-4] |
||
54 | |||
55 | .scr_buff equ dword[ebp-12] |
||
56 | |||
57 | .x1 equ word[ebp-14] ;dw ? ;equ word[ebp-10] |
||
58 | |||
59 | .x2 equ word[ebp-18] ;dw ? ;equ word[ebp-14] |
||
60 | .y2 equ word[ebp-20] ;dw ? ;equ word[ebp-16] |
||
61 | .x3 equ word[ebp-22] ;dw ? ;equ word[ebp-18] |
||
62 | .y3 equ word[ebp-24] ;dw ? ;equ word[ebp-20] |
||
63 | |||
64 | .dx12 equ dword[ebp-28] ;dd ? |
||
65 | |||
66 | .tex_dy12 equ [ebp-36] ;dd ? |
||
67 | .dz12 equ dword[ebp-40] ;dd ? |
||
1776 | yogev_ezra | 68 | .dc12r equ [ebp-44] ;dd ? |
1245 | hidnplayr | 69 | .dc12g equ dword[ebp-48] ;dd ? |
1776 | yogev_ezra | 70 | .dc12b equ [ebp-52] ;dd ? |
1245 | hidnplayr | 71 | |
1776 | yogev_ezra | 72 | .dx23 equ dword[ebp-56] ;dd ? |
1245 | hidnplayr | 73 | |
74 | .tex_dy23 equ [ebp-64] ;dd ? |
||
75 | .dz23 equ dword[ebp-68] ;dd ? |
||
1776 | yogev_ezra | 76 | .dc23r equ [ebp-72] ;dd ? |
1245 | hidnplayr | 77 | .dc23g equ dword[ebp-76] ;dd ? |
1776 | yogev_ezra | 78 | .dc23b equ [ebp-80] ;dword[ebp-8]dd ? |
1245 | hidnplayr | 79 | |
1776 | yogev_ezra | 80 | .dx13 equ dword[ebp-84] ;dd ? |
1245 | hidnplayr | 81 | |
82 | .tex_dy13 equ [ebp-92] ;dd ? |
||
83 | .dz13 equ dword[ebp-96] ;dd ? |
||
1776 | yogev_ezra | 84 | .dc13r equ [ebp-100] ;dd ? |
1245 | hidnplayr | 85 | .dc13g equ dword[ebp-104] ;dd ? |
1776 | yogev_ezra | 86 | .dc13b equ [ebp-108] ;dd ? |
1245 | hidnplayr | 87 | |
1776 | yogev_ezra | 88 | .scan_x1 equ dword[ebp-112] ;dd ? |
1245 | hidnplayr | 89 | |
1776 | yogev_ezra | 90 | .zz1 equ dword[ebp-120] ;dw ? |
91 | .cur1r equ [ebp-124] ;dw ? |
||
92 | .cur1g equ dword[ebp-128] ;dw ? |
||
93 | .cur1b equ [ebp-132] ;dw ? |
||
94 | |||
95 | .scan_x2 equ dword[ebp-136] ;dd ? |
||
1245 | hidnplayr | 96 | |
1776 | yogev_ezra | 97 | .zz2 equ dword[ebp-144] ;dw ? |
98 | .cur2r equ [ebp-148] ;dw ? |
||
99 | .cur2g equ dword[ebp-152] ;dw ? |
||
100 | .cur2b equ [ebp-156] ;dw ? |
||
101 | |||
102 | |||
1245 | hidnplayr | 103 | |
1776 | yogev_ezra | 104 | |
1245 | hidnplayr | 105 | ; mov .tex_ptr,edx |
106 | |||
107 | ; mov .scr_buff,edi |
||
108 | push edx esi edi |
||
109 | ; push esi |
||
110 | ; push edi |
||
111 | mov edx,80008000h ; eax,ebx,ecx are ANDd together into edx which means that |
||
112 | and edx,ebx ; if *all* of them are negative a sign flag is raised |
||
113 | and edx,ecx |
||
114 | and edx,eax |
||
115 | test edx,80008000h ; Check both X&Y at once |
||
116 | jne .loop2_end |
||
117 | |||
118 | .sort3: |
||
119 | |||
120 | jle .sort1 |
||
121 | xchg eax,ebx |
||
122 | if Ext>=MMX |
||
123 | movq mm0, .col1r ; exchange r, g, b, z |
||
124 | movq mm1, .col2r |
||
125 | movq .col1r ,mm1 |
||
126 | movq .col2r ,mm0 |
||
127 | else |
||
128 | mov edx,dword .col1r ; exchange both r and g |
||
129 | xchg edx,dword .col2r |
||
130 | mov dword .col1r ,edx |
||
131 | |||
132 | mov edx,dword .col1b ; b and z |
||
133 | |||
134 | mov dword .col1b ,edx |
||
135 | end if |
||
136 | |||
137 | mov edx,dword .tex_x1 |
||
138 | |||
139 | mov dword .tex_x1 ,edx |
||
140 | |||
141 | .sort1: |
||
142 | |||
143 | jle .sort2 |
||
144 | xchg ebx,ecx |
||
145 | |||
146 | if Ext>=MMX |
||
147 | |||
148 | movq mm1, .col3r |
||
149 | movq .col3r ,mm0 |
||
150 | movq .col2r ,mm1 |
||
151 | else |
||
152 | |||
153 | mov edx,dword .col2r ; r, g |
||
154 | |||
155 | mov dword .col2r,edx |
||
156 | |||
157 | mov edx,dword .col2b ; b, z |
||
158 | |||
159 | mov dword .col2b,edx |
||
160 | end if |
||
161 | |||
162 | mov edx,dword .tex_x2 |
||
163 | |||
164 | mov dword .tex_x2,edx |
||
165 | |||
166 | jmp .sort3 |
||
167 | |||
168 | .sort2: |
||
169 | |||
170 | push eax ebx ecx ; store in variables |
||
171 | |||
172 | ; push ecx |
||
173 | |||
174 | ;****************** delta computng zone ************** |
||
175 | |||
176 | mov bx,.y2 ; calc delta12 |
||
177 | sub bx,.y1 |
||
178 | jnz .dx12_make |
||
179 | mov ecx,7 |
||
180 | @@: |
||
181 | push dword 0 |
||
182 | loop @b |
||
183 | jmp .dx12_done |
||
184 | .dx12_make: |
||
185 | |||
186 | |||
187 | |||
188 | |||
189 | cwde |
||
190 | movsx ebx,bx |
||
191 | shl eax,ROUND |
||
192 | cdq |
||
193 | idiv ebx |
||
194 | ; mov .dx12,eax |
||
195 | push eax |
||
196 | |||
197 | if 0 ; Ext=SSE |
||
198 | |||
199 | pxor mm1,mm1 |
||
200 | punpcklwd mm0,mm1 |
||
201 | cvtpi2ps xmm0,mm0 |
||
202 | movlhps xmm0,xmm0 |
||
203 | movd mm0,.col1g ; 2 words b, z |
||
204 | punpcklwd mm0,mm1 |
||
205 | cvtpi2ps xmm0,mm0 |
||
206 | ; xmm0=four float double words |
||
207 | divss xmm0,.pack3 |
||
208 | ;convert and insert mm0 to lower xmm1 .. |
||
209 | end if |
||
210 | |||
211 | mov ax,word .tex_x2 |
||
212 | |||
213 | cwde |
||
214 | shl eax,ROUND |
||
215 | cdq |
||
216 | idiv ebx |
||
217 | ; mov .tex_dx12r,eax |
||
218 | push eax |
||
219 | |||
220 | mov ax,word .tex_y2 |
||
221 | |||
222 | cwde |
||
223 | shl eax,ROUND |
||
224 | cdq |
||
225 | idiv ebx |
||
226 | ; mov .tex_dx12,eax |
||
227 | push eax |
||
228 | |||
229 | mov ax,word .z2 |
||
230 | |||
231 | cwde |
||
232 | shl eax,CATMULL_SHIFT |
||
233 | cdq |
||
234 | idiv ebx |
||
235 | ; mov .dz12,eax |
||
236 | push eax ; .dza12 |
||
237 | |||
238 | mov ax,word .col2r |
||
239 | |||
240 | cwde |
||
241 | shl eax,ROUND |
||
242 | cdq |
||
243 | idiv ebx |
||
244 | ; mov .dc12r,eax |
||
245 | push eax |
||
246 | |||
247 | mov ax,word .col2g |
||
248 | |||
249 | cwde |
||
250 | shl eax,ROUND |
||
251 | cdq |
||
252 | idiv ebx |
||
253 | ; mov .dc12g,eax |
||
254 | push eax |
||
255 | |||
256 | mov ax,word .col2b ;;--- |
||
257 | |||
258 | cwde |
||
259 | shl eax,ROUND |
||
260 | cdq |
||
261 | idiv ebx |
||
262 | ; mov .dc12b,eax |
||
263 | push eax |
||
264 | |||
265 | ;+++++++++++++++++ second zone +++++++++++++ |
||
266 | |||
267 | |||
268 | mov bx,.y3 ; calc delta23 |
||
269 | |||
270 | jnz .dx23_make |
||
271 | mov ecx,7 |
||
272 | @@: |
||
273 | push dword 0 |
||
274 | loop @b |
||
275 | jmp .dx23_done |
||
276 | |||
277 | .dx23_make: |
||
278 | |||
279 | sub ax,.x2 |
||
280 | cwde |
||
281 | movsx ebx,bx |
||
282 | shl eax,ROUND |
||
283 | cdq |
||
284 | idiv ebx |
||
285 | ; mov .dx23,eax |
||
286 | push eax |
||
287 | |||
288 | mov ax,word .tex_x3 |
||
289 | |||
290 | cwde |
||
291 | shl eax,ROUND |
||
292 | cdq |
||
293 | idiv ebx |
||
294 | ; mov .tex_dx23,eax |
||
295 | push eax |
||
296 | |||
297 | mov ax,word .tex_y3 |
||
298 | |||
299 | cwde |
||
300 | shl eax,ROUND |
||
301 | cdq |
||
302 | idiv ebx |
||
303 | ; mov .tex_dy23,eax |
||
304 | push eax |
||
305 | |||
306 | mov ax,word .z3 |
||
307 | |||
308 | cwde ; |
||
309 | shl eax,CATMULL_SHIFT ; 2222222 |
||
310 | cdq ; 2 2 |
||
311 | idiv ebx ; 2 |
||
312 | ; mov .dz23,eax ; 2 |
||
313 | push eax ; .dza12 ; 2 |
||
314 | ; 2 |
||
315 | mov ax,word .col3r ; 2 |
||
316 | sub ax,word .col2r ; 2222222 |
||
317 | cwde ; second delta |
||
318 | shl eax,ROUND ; |
||
319 | cdq ; |
||
320 | idiv ebx ; |
||
321 | ; mov .dc23r,eax ; |
||
322 | push eax |
||
323 | |||
324 | mov ax,word .col3g |
||
325 | |||
326 | cwde |
||
327 | shl eax,ROUND |
||
328 | cdq |
||
329 | idiv ebx |
||
330 | ; mov .dc23g,eax |
||
331 | push eax |
||
332 | |||
333 | mov ax,word .col3b ;;--- |
||
334 | |||
335 | cwde |
||
336 | shl eax,ROUND |
||
337 | cdq |
||
338 | idiv ebx |
||
339 | ; mov .dc23b,eax |
||
340 | push eax |
||
341 | |||
342 | .dx23_done: |
||
343 | |||
344 | mov bx,.y3 ; calc delta13 |
||
345 | sub bx,.y1 |
||
346 | jnz .dx13_make |
||
347 | mov ecx,7 |
||
348 | @@: |
||
349 | push dword 0 |
||
350 | loop @b |
||
351 | jmp .dx13_done |
||
352 | .dx13_make: |
||
353 | mov ax,.x3 |
||
354 | sub ax,.x1 |
||
355 | cwde |
||
356 | movsx ebx,bx |
||
357 | shl eax,ROUND |
||
358 | cdq |
||
359 | idiv ebx |
||
360 | ; mov .dx13,eax |
||
361 | push eax |
||
362 | |||
363 | mov ax,word .tex_x3 ; triangle b |
||
364 | |||
365 | cwde |
||
366 | shl eax,ROUND |
||
367 | cdq |
||
368 | idiv ebx |
||
369 | ; mov .tex_dx13r,eax |
||
370 | push eax |
||
371 | |||
372 | mov ax,word .tex_y3 |
||
373 | |||
374 | cwde |
||
375 | shl eax,ROUND |
||
376 | cdq |
||
377 | idiv ebx |
||
378 | ; mov .tex_dy13,eax |
||
379 | push eax |
||
380 | |||
381 | mov ax,word .z3 |
||
382 | |||
383 | cwde ; 3 3 |
||
384 | shl eax,CATMULL_SHIFT ; 3 |
||
385 | cdq ; 3 |
||
386 | idiv ebx ; 3 |
||
387 | ; mov .dz13,eax ; 3 |
||
388 | push eax ; .dza12 ; 3 |
||
389 | ; 3 |
||
390 | mov ax,word .col3r ; 3333333333 |
||
391 | sub ax,word .col1r ; 3 |
||
392 | cwde ; 3 |
||
393 | shl eax,ROUND ; 3 |
||
394 | cdq ; 3 |
||
395 | idiv ebx ; 3 |
||
396 | ; mov .dc13r,eax ; 3 3 |
||
397 | push eax ; 33333333 |
||
398 | |||
399 | mov ax,word .col3g |
||
400 | |||
401 | cwde |
||
402 | shl eax,ROUND |
||
403 | cdq |
||
404 | idiv ebx |
||
405 | ; mov .dc13g,eax |
||
406 | push eax |
||
407 | |||
408 | mov ax,word .col3b ;;--- |
||
409 | |||
410 | cwde |
||
411 | shl eax,ROUND |
||
412 | cdq |
||
413 | idiv ebx |
||
414 | ; mov .dc13b,eax |
||
415 | push eax |
||
416 | |||
417 | .dx13_done: |
||
418 | |||
419 | ; <<<<<<< ::delta zone end+++++++++++++++++++++ >>>>>>>> |
||
420 | |||
421 | |||
422 | movsx eax,.x1 ; eax - cur x1 |
||
423 | |||
424 | mov ebx,eax |
||
425 | movsx edx,word .z1 |
||
426 | shl edx,CATMULL_SHIFT |
||
427 | mov .zz1,edx |
||
428 | mov .zz2,edx |
||
429 | |||
430 | movzx edi,word .col1r |
||
431 | |||
432 | mov .cur1r,edi |
||
433 | mov .cur2r,edi |
||
434 | movzx esi,word .col1g |
||
435 | shl esi,ROUND |
||
436 | mov .cur1g,esi |
||
437 | mov .cur2g,esi |
||
438 | movzx edx,word .col1b |
||
439 | shl edx,ROUND |
||
440 | mov .cur1b,edx |
||
441 | mov .cur2b,edx |
||
442 | |||
443 | movzx edi,word .tex_x1 |
||
444 | |||
445 | mov .scan_x1,edi |
||
446 | mov .scan_x2,edi |
||
447 | movzx edx,word .tex_y1 |
||
448 | shl edx,ROUND |
||
449 | mov .scan_y1,edx |
||
450 | mov .scan_y2,edx |
||
451 | |||
452 | mov cx,.y1 |
||
453 | |||
454 | jge .loop1_end |
||
455 | .loop_1: |
||
456 | ; push eax ebx ebp |
||
457 | pushad |
||
458 | |||
459 | push .tex_ptr |
||
460 | |||
461 | push .z_ptr |
||
462 | push cx |
||
463 | |||
464 | push .zz2 |
||
465 | |||
466 | push .scan_x2 |
||
467 | |||
468 | push dword .cur2r |
||
1776 | yogev_ezra | 469 | push .cur2g |
470 | push dword .cur2b |
||
1245 | hidnplayr | 471 | |
1776 | yogev_ezra | 472 | push .zz1 |
1245 | hidnplayr | 473 | |
474 | push .scan_x1 |
||
475 | |||
476 | push dword .cur1r |
||
1776 | yogev_ezra | 477 | push .cur1g |
478 | push dword .cur1b |
||
1245 | hidnplayr | 479 | |
1776 | yogev_ezra | 480 | sar eax,ROUND |
1245 | hidnplayr | 481 | |
482 | call horizontal_tex_grd_line |
||
483 | |||
484 | ; pop ebp ebx eax |
||
485 | |||
486 | |||
487 | if (Ext = MMX)|(Ext=SSE) |
||
1776 | yogev_ezra | 488 | |
2192 | leency | 489 | movq mm1,.cur1r |
1776 | yogev_ezra | 490 | movq mm2,.scan_y1 |
491 | movq mm3,.cur2b |
||
492 | movq mm4,.cur2r |
||
493 | movq mm5,.scan_y2 |
||
494 | paddd mm0,.dc13b |
||
495 | paddd mm1,.dc13r |
||
496 | paddd mm2,.tex_dy13 |
||
497 | paddd mm3,.dc12b |
||
498 | paddd mm4,.dc12r |
||
499 | paddd mm5,.tex_dy12 |
||
500 | movq .cur1b,mm0 |
||
501 | movq .cur1r,mm1 |
||
502 | movq .scan_y1,mm2 |
||
503 | movq .cur2b,mm3 |
||
504 | movq .cur2r,mm4 |
||
505 | movq .scan_y2,mm5 |
||
506 | end if |
||
507 | if Ext >= SSE2 |
||
2192 | leency | 508 | movups xmm0,.cur1b |
509 | movups xmm1,.dc13b |
||
510 | movups xmm2,.cur2b |
||
511 | movups xmm3,.dc12b |
||
512 | movq mm2,.scan_y1 |
||
513 | movq mm5,.scan_y2 |
||
514 | paddd xmm0,xmm1 |
||
515 | paddd xmm2,xmm3 |
||
516 | paddd mm2,.tex_dy13 |
||
517 | paddd mm5,.tex_dy12 |
||
518 | movq .scan_y1,mm2 |
||
519 | movq .scan_y2,mm5 |
||
520 | movups .cur1b,xmm0 |
||
521 | movups .cur2b,xmm2 |
||
522 | end if |
||
523 | |||
524 | if Ext = NON |
||
525 | |||
526 | add .cur1b,edx |
||
1245 | hidnplayr | 527 | mov esi,.dc13g |
528 | add .cur1g,esi |
||
529 | mov edi,.dc13r |
||
530 | add .cur1r,edi |
||
531 | mov edx,.dz13 |
||
532 | add .zz1,edx |
||
1776 | yogev_ezra | 533 | mov edx,.tex_dx13 |
534 | add .scan_x1,edx |
||
1245 | hidnplayr | 535 | mov esi,.tex_dy13 |
536 | add .scan_y1,esi |
||
537 | |||
538 | mov edi,.dc12b |
||
539 | |||
540 | mov esi,.dc12g |
||
541 | add .cur2g,esi |
||
542 | mov edx,.dc12r |
||
543 | add .cur2r,edx |
||
544 | mov edi,.tex_dx12 |
||
545 | add .scan_x2,edi |
||
546 | mov esi,.tex_dy12 |
||
547 | add .scan_y2,esi |
||
548 | mov edx,.dz12 |
||
549 | add .zz2,edx |
||
550 | end if |
||
551 | add eax,.dx13 |
||
1776 | yogev_ezra | 552 | add ebx,.dx12 |
1245 | hidnplayr | 553 | inc cx |
554 | cmp cx,.y2 |
||
555 | jl .loop_1 |
||
556 | .loop1_end: |
||
557 | movzx ecx,.y2 |
||
558 | cmp cx,.y3 |
||
559 | jge .loop2_end |
||
560 | |||
561 | movsx ebx,.x2 ; eax - cur x1 |
||
562 | |||
563 | |||
564 | movsx edx,word .z2 |
||
565 | |||
566 | ; mov .zz1,edx |
||
567 | mov .zz2,edx |
||
568 | |||
569 | movzx edi,word .col2r |
||
570 | |||
571 | ; mov .cur1r,edi |
||
572 | mov .cur2r,edi |
||
573 | movzx esi,word .col2g |
||
574 | shl esi,ROUND |
||
575 | ; mov .cur1g,esi |
||
576 | mov .cur2g,esi |
||
577 | movzx edx,word .col2b |
||
578 | shl edx,ROUND |
||
579 | ; mov .cur1b,edx |
||
580 | mov .cur2b,edx |
||
581 | |||
582 | movzx edi,word .tex_x2 |
||
583 | |||
584 | ; mov .scan_x1,edi |
||
585 | mov .scan_x2,edi |
||
586 | movzx edx,word .tex_y2 |
||
587 | shl edx,ROUND |
||
588 | ; mov .scan_y1,edx |
||
589 | mov .scan_y2,edx |
||
590 | |||
591 | .loop_2: |
||
592 | |||
593 | |||
594 | push .tex_ptr |
||
595 | |||
596 | push .z_ptr |
||
597 | push cx |
||
598 | |||
599 | push .zz2 |
||
600 | |||
601 | push .scan_x2 |
||
602 | |||
603 | push dword .cur2r |
||
1776 | yogev_ezra | 604 | push .cur2g |
605 | push dword .cur2b |
||
1245 | hidnplayr | 606 | |
1776 | yogev_ezra | 607 | push .zz1 |
1245 | hidnplayr | 608 | |
609 | push .scan_x1 |
||
610 | |||
611 | push dword .cur1r |
||
1776 | yogev_ezra | 612 | push .cur1g |
613 | push dword .cur1b |
||
1245 | hidnplayr | 614 | |
1776 | yogev_ezra | 615 | sar eax,ROUND |
1245 | hidnplayr | 616 | |
617 | call horizontal_tex_grd_line |
||
618 | |||
619 | popad |
||
620 | |||
621 | if (Ext = MMX)|(Ext=SSE) |
||
1776 | yogev_ezra | 622 | |
2192 | leency | 623 | movq mm1,.cur1r |
1776 | yogev_ezra | 624 | movq mm2,.scan_y1 |
625 | movq mm3,.cur2b |
||
626 | movq mm4,.cur2r |
||
627 | movq mm5,.scan_y2 |
||
628 | paddd mm0,.dc13b |
||
629 | paddd mm1,.dc13r |
||
630 | paddd mm2,.tex_dy13 |
||
631 | paddd mm3,.dc23b |
||
632 | paddd mm4,.dc23r |
||
633 | paddd mm5,.tex_dy23 |
||
634 | movq .cur1b,mm0 |
||
635 | movq .cur1r,mm1 |
||
636 | movq .scan_y1,mm2 |
||
637 | movq .cur2b,mm3 |
||
638 | movq .cur2r,mm4 |
||
639 | movq .scan_y2,mm5 |
||
640 | end if |
||
641 | if Ext >= SSE2 |
||
2192 | leency | 642 | movups xmm0,.cur1b |
643 | movups xmm1,.dc13b |
||
644 | movups xmm2,.cur2b |
||
645 | movups xmm3,.dc23b |
||
646 | movq mm2,.scan_y1 |
||
647 | movq mm5,.scan_y2 |
||
648 | paddd xmm0,xmm1 |
||
649 | paddd xmm2,xmm3 |
||
650 | paddd mm2,.tex_dy13 |
||
651 | paddd mm5,.tex_dy23 |
||
652 | movq .scan_y1,mm2 |
||
653 | movq .scan_y2,mm5 |
||
654 | movups .cur1b,xmm0 |
||
655 | movups .cur2b,xmm2 |
||
656 | end if |
||
657 | if Ext = NON |
||
658 | mov edx,.dc13b |
||
659 | add .cur1b,edx |
||
1245 | hidnplayr | 660 | mov esi,.dc13g |
661 | add .cur1g,esi |
||
662 | mov edi,.dc13r |
||
663 | add .cur1r,edi |
||
664 | mov edx,.tex_dx13 |
||
665 | add .scan_x1,edx |
||
666 | mov esi,.tex_dy13 |
||
667 | add .scan_y1,esi |
||
668 | mov edx,.dz13 |
||
669 | add .zz1,edx |
||
670 | |||
671 | mov edi,.dc23b |
||
672 | |||
673 | mov esi,.dc23g |
||
674 | add .cur2g,esi |
||
675 | mov edx,.dc23r |
||
676 | add .cur2r,edx |
||
677 | mov edi,.tex_dx23 |
||
678 | add .scan_x2,edi |
||
679 | mov esi,.tex_dy23 |
||
680 | add .scan_y2,esi |
||
681 | mov edx,.dz23 |
||
682 | add .zz2,edx |
||
683 | end if |
||
684 | add eax,.dx13 |
||
1776 | yogev_ezra | 685 | add ebx,.dx23 |
1245 | hidnplayr | 686 | inc cx |
687 | cmp cx,.y3 |
||
688 | jl .loop_2 |
||
689 | |||
690 | .loop2_end: |
||
691 | |||
692 | ret 36 |
||
693 | horizontal_tex_grd_line: |
||
694 | ;in: |
||
695 | ; eax : x1, ebx : x2 |
||
696 | |||
697 | .tex_ptr equ [ebp+62] |
||
698 | |||
699 | .z_buffer equ [ebp+54] |
||
700 | .y equ [ebp+52] |
||
701 | |||
702 | .z2 equ [ebp+48] |
||
703 | |||
704 | .tex_y2 equ [ebp+40] |
||
705 | .r2 equ [ebp+36] |
||
706 | .g2 equ [ebp+32] |
||
707 | .b2 equ [ebp+28] |
||
708 | |||
709 | .z1 equ [ebp+24] |
||
710 | |||
711 | .tex_y1 equ [ebp+16] |
||
712 | .r1 equ [ebp+12] |
||
713 | .g1 equ [ebp+8] |
||
714 | .b1 equ [ebp+4] |
||
715 | |||
716 | .x1 equ word[ebp-2] |
||
717 | |||
718 | .dz equ dword[ebp-8] |
||
719 | .db equ dword[ebp-12] |
||
720 | .dg equ dword[ebp-16] |
||
721 | .dr equ dword[ebp-20] |
||
722 | .dtex_x equ dword[ebp-24] |
||
723 | .dtex_y equ dword[ebp-28] |
||
724 | |||
725 | .c_ty equ [ebp-32] |
||
726 | |||
727 | .cb equ [ebp-40] |
||
728 | .cg equ [ebp-44] |
||
729 | .cr equ [ebp-48] |
||
730 | .t_col equ [ebp-52] |
||
731 | |||
732 | .dtex_yM equ qword[ebp-28] |
||
733 | |||
734 | .dbM equ qword[ebp-12] |
||
735 | |||
736 | mov ebp,esp |
||
737 | |||
738 | |||
739 | mov cx,word .y |
||
740 | |||
741 | jl .quit_l |
||
742 | |||
743 | cmp cx,word[size_y_var] ;SIZE_Y |
||
744 | |||
6619 | leency | 745 | |
1245 | hidnplayr | 746 | cmp ax,bx |
747 | |||
748 | jl @f |
||
749 | |||
750 | xchg eax,ebx |
||
751 | |||
752 | if Ext=NON |
||
753 | |||
754 | xchg ecx, .r2 |
||
755 | mov dword .r1, ecx |
||
756 | |||
757 | mov ecx,dword .g1 |
||
758 | |||
759 | mov dword .g1, ecx |
||
760 | |||
761 | mov ecx,dword .b1 |
||
762 | |||
763 | mov dword .b1, ecx |
||
764 | |||
765 | mov ecx,dword .tex_x1 |
||
766 | |||
767 | mov dword .tex_x1, ecx |
||
768 | |||
769 | mov ecx,dword .tex_y1 |
||
770 | |||
771 | mov dword .tex_y1, ecx |
||
772 | |||
773 | mov ecx,dword .z1 |
||
774 | |||
775 | mov dword .z1, ecx |
||
776 | end if |
||
777 | if (Ext=MMX) |
||
2192 | leency | 778 | movq mm0,.b1 ; b, g |
779 | movq mm1,.b2 |
||
1245 | hidnplayr | 780 | movq .b1, mm1 |
781 | movq .b2, mm0 |
||
782 | movq mm2,.r1 ; r, y |
||
783 | movq mm3,.r2 |
||
784 | movq .r1,mm3 |
||
785 | movq .r2,mm2 |
||
786 | movq mm4,.tex_x1 ; x, z |
||
787 | movq mm5,.tex_x2 |
||
788 | movq .tex_x1,mm5 |
||
789 | movq .tex_x2,mm4 |
||
790 | |||
791 | end if |
||
792 | |||
793 | movups xmm0,.b1 |
||
2192 | leency | 794 | movups xmm1,.b2 |
795 | movups .b1,xmm1 |
||
796 | movups .b2,xmm0 |
||
797 | movq mm4,.tex_x1 ; x, z |
||
798 | movq mm5,.tex_x2 |
||
799 | movq .tex_x1,mm5 |
||
800 | movq .tex_x2,mm4 |
||
801 | end if |
||
802 | |||
803 | @@: |
||
1245 | hidnplayr | 804 | |
805 | jle .quit_l |
||
806 | cmp ax,word[size_x_var] ;SIZE_X |
||
807 | jge .quit_l |
||
6619 | leency | 808 | |
1245 | hidnplayr | 809 | push ax |
810 | |||
811 | |||
812 | mov eax,.z2 ; delta zone************ |
||
813 | |||
814 | cdq |
||
815 | mov bx,.x2 |
||
816 | sub bx,.x1 |
||
817 | movsx ebx,bx |
||
818 | idiv ebx |
||
819 | push eax ; .dz |
||
820 | |||
821 | mov eax,.b2 |
||
822 | |||
823 | cdq |
||
824 | idiv ebx |
||
825 | push eax ; .db |
||
826 | |||
827 | mov eax,.g2 |
||
828 | |||
829 | cdq |
||
830 | idiv ebx |
||
831 | push eax ; .dg |
||
832 | |||
833 | mov eax,.r2 |
||
834 | |||
835 | cdq |
||
836 | idiv ebx |
||
837 | push eax ; .dr |
||
838 | |||
839 | mov eax,.tex_x2 |
||
840 | |||
841 | cdq |
||
842 | idiv ebx |
||
843 | push eax ; .dtex_x |
||
844 | |||
845 | mov eax,.tex_y2 |
||
846 | |||
847 | cdq |
||
848 | idiv ebx |
||
849 | push eax ; .dtey_x |
||
850 | |||
851 | cmp .x1,0 |
||
852 | |||
853 | |||
854 | mov eax,.dz ; clipping |
||
855 | |||
856 | neg ebx |
||
857 | imul ebx |
||
858 | add .z1,eax |
||
859 | mov .x1,0 |
||
860 | |||
861 | mov eax,.dr |
||
862 | |||
863 | add .r1,eax |
||
864 | ;if Ext=NON |
||
865 | mov eax,.dg |
||
866 | imul ebx |
||
867 | add .g1,eax |
||
868 | |||
869 | mov eax,.db |
||
870 | |||
871 | add .b1,eax |
||
872 | |||
873 | mov eax,.dtex_x |
||
874 | |||
875 | add .tex_x1,eax |
||
876 | |||
877 | mov eax,.dtex_y |
||
878 | |||
879 | add .tex_y1,eax |
||
880 | @@: |
||
881 | movsx edx,word[size_x_var] ;SIZE_X |
||
882 | cmp .x2,dx |
||
6619 | leency | 883 | jl @f |
1245 | hidnplayr | 884 | mov .x2,dx |
885 | @@: |
||
886 | ; calc line addres begin in screen and Z buffer |
||
887 | movsx eax,word .y |
||
888 | mul edx |
||
889 | movsx edx,.x1 |
||
890 | add eax,edx |
||
891 | |||
892 | mov esi,eax |
||
893 | |||
894 | add esi,.z_buffer |
||
895 | |||
896 | lea eax,[eax*3] |
||
897 | |||
898 | add edi,eax |
||
899 | |||
900 | mov cx,.x2 |
||
901 | |||
902 | movzx ecx,cx |
||
903 | |||
904 | ; init current variables |
||
905 | |||
906 | ;if Ext=NON |
||
907 | push dword .tex_x1 |
||
908 | |||
909 | push dword .b1 |
||
910 | |||
911 | push dword .r1 |
||
912 | |||
913 | if Ext>=MMX |
||
914 | |||
915 | movq mm6,.cb ; hi -> b, tex_x |
||
916 | pxor mm0,mm0 |
||
917 | end if |
||
918 | mov ebx,.z1 |
||
919 | .ddraw: |
||
920 | cmp ebx,dword[esi] |
||
921 | jge @f |
||
922 | mov eax,.c_ty |
||
923 | ; if ROUND |
||
924 | ; shl eax,TEX_SHIFT-ROUND |
||
925 | ; end if |
||
926 | ; if ROUND>TEX_SHIFT |
||
927 | ; shr eax,ROUND-TEX_SHIFT |
||
928 | ; end if |
||
929 | shr eax,ROUND |
||
930 | shl Eax,TEX_SHIFT |
||
931 | mov edx,.c_tx ; calc texture pixel mem addres |
||
932 | shr edx,ROUND |
||
933 | add eax,edx |
||
934 | and eax,TEXTURE_SIZE ; cutting |
||
935 | lea eax,[3*eax] |
||
936 | add eax,.tex_ptr |
||
937 | mov dword[esi],ebx |
||
938 | if Ext = NON |
||
939 | mov eax,dword[eax] |
||
940 | ; mov .tex_col,eax |
||
941 | push ax |
||
942 | shl eax,8 |
||
943 | pop ax |
||
944 | mov edx,.cr |
||
945 | sar edx,ROUND |
||
946 | mul dl ; al*dl |
||
947 | shr ax,8 |
||
948 | stosb |
||
949 | ror eax,16 |
||
950 | push ax |
||
951 | mov edx,.cg |
||
952 | sar edx,ROUND |
||
953 | mul dl |
||
954 | shr ax,8 |
||
955 | stosb |
||
956 | pop ax |
||
957 | shr ax,8 |
||
958 | mov edx,.cb |
||
959 | sar edx,ROUND |
||
960 | mul dl |
||
961 | shr ax,8 |
||
962 | stosb |
||
963 | jmp .no_skip |
||
964 | else |
||
965 | movd mm1,[eax] |
||
966 | punpcklbw mm1,mm0 |
||
967 | movq mm3,mm4 ;.cr ; lo -> r,g |
||
968 | movq mm5,mm6 ;.cb ; lo -> b,tex_x |
||
969 | psrld mm3,ROUND ; |
||
970 | psrld mm5,ROUND ; |
||
971 | packssdw mm3,mm5 |
||
972 | pmullw mm1,mm3 |
||
973 | psrlw mm1,8 |
||
974 | packuswb mm1,mm0 |
||
975 | movd [edi],mm1 |
||
976 | end if |
||
977 | mov dword[esi],ebx |
||
978 | if Ext = NON |
||
979 | jmp .no_skip |
||
980 | end if |
||
981 | @@: |
||
982 | add edi,3 |
||
983 | .no_skip: |
||
984 | add esi,4 |
||
985 | add ebx,.dz |
||
986 | |||
987 | mov eax,.dtex_x |
||
988 | |||
989 | mov edx,.dtex_y |
||
990 | add .c_ty, edx |
||
991 | if Ext=NON |
||
992 | mov eax,.dr |
||
993 | add .cr,eax |
||
994 | mov edx,.dg |
||
995 | add .cg,edx |
||
996 | mov eax,.db |
||
997 | add .cb,eax |
||
998 | |||
999 | else |
||
1000 | |||
1001 | paddd mm6,.dbM |
||
1002 | ;; paddd mm7,.dtex_y ; mm4 - b, g |
||
1003 | ;; movq .c_tx,mm7 |
||
1004 | ; mm6 - r, x |
||
1005 | end if ; mm7 - y, x |
||
1006 | |||
1007 | dec ecx |
||
1008 | |||
1009 | |||
1010 | .quit_l: |
||
1011 | |||
1012 | mov esp,ebp |
||
1013 | |||
1014 | ;>><><<><<<><<<<><<<<<><<<<<<> |
||
1015 |