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 |
||
1776 | yogev_ezra | 488 | |
489 | movq mm1,.cur1r |
||
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 | else |
||
507 | mov edx,.dc13b |
||
508 | add .cur1b,edx |
||
1245 | hidnplayr | 509 | mov esi,.dc13g |
510 | add .cur1g,esi |
||
511 | mov edi,.dc13r |
||
512 | add .cur1r,edi |
||
513 | mov edx,.dz13 |
||
514 | add .zz1,edx |
||
1776 | yogev_ezra | 515 | mov edx,.tex_dx13 |
516 | add .scan_x1,edx |
||
1245 | hidnplayr | 517 | mov esi,.tex_dy13 |
518 | add .scan_y1,esi |
||
519 | |||
520 | mov edi,.dc12b |
||
521 | |||
522 | mov esi,.dc12g |
||
523 | add .cur2g,esi |
||
524 | mov edx,.dc12r |
||
525 | add .cur2r,edx |
||
526 | mov edi,.tex_dx12 |
||
527 | add .scan_x2,edi |
||
528 | mov esi,.tex_dy12 |
||
529 | add .scan_y2,esi |
||
530 | mov edx,.dz12 |
||
531 | add .zz2,edx |
||
532 | end if |
||
533 | add eax,.dx13 |
||
1776 | yogev_ezra | 534 | add ebx,.dx12 |
1245 | hidnplayr | 535 | inc cx |
536 | cmp cx,.y2 |
||
537 | jl .loop_1 |
||
538 | .loop1_end: |
||
539 | movzx ecx,.y2 |
||
540 | cmp cx,.y3 |
||
541 | jge .loop2_end |
||
542 | |||
543 | movsx ebx,.x2 ; eax - cur x1 |
||
544 | |||
545 | |||
546 | movsx edx,word .z2 |
||
547 | |||
548 | ; mov .zz1,edx |
||
549 | mov .zz2,edx |
||
550 | |||
551 | movzx edi,word .col2r |
||
552 | |||
553 | ; mov .cur1r,edi |
||
554 | mov .cur2r,edi |
||
555 | movzx esi,word .col2g |
||
556 | shl esi,ROUND |
||
557 | ; mov .cur1g,esi |
||
558 | mov .cur2g,esi |
||
559 | movzx edx,word .col2b |
||
560 | shl edx,ROUND |
||
561 | ; mov .cur1b,edx |
||
562 | mov .cur2b,edx |
||
563 | |||
564 | movzx edi,word .tex_x2 |
||
565 | |||
566 | ; mov .scan_x1,edi |
||
567 | mov .scan_x2,edi |
||
568 | movzx edx,word .tex_y2 |
||
569 | shl edx,ROUND |
||
570 | ; mov .scan_y1,edx |
||
571 | mov .scan_y2,edx |
||
572 | |||
573 | .loop_2: |
||
574 | |||
575 | |||
576 | push .tex_ptr |
||
577 | |||
578 | push .z_ptr |
||
579 | push cx |
||
580 | |||
581 | push .zz2 |
||
582 | |||
583 | push .scan_x2 |
||
584 | |||
585 | push dword .cur2r |
||
1776 | yogev_ezra | 586 | push .cur2g |
587 | push dword .cur2b |
||
1245 | hidnplayr | 588 | |
1776 | yogev_ezra | 589 | push .zz1 |
1245 | hidnplayr | 590 | |
591 | push .scan_x1 |
||
592 | |||
593 | push dword .cur1r |
||
1776 | yogev_ezra | 594 | push .cur1g |
595 | push dword .cur1b |
||
1245 | hidnplayr | 596 | |
1776 | yogev_ezra | 597 | sar eax,ROUND |
1245 | hidnplayr | 598 | |
599 | call horizontal_tex_grd_line |
||
600 | |||
601 | popad |
||
602 | |||
603 | if Ext >= MMX |
||
1776 | yogev_ezra | 604 | |
605 | movq mm1,.cur1r |
||
606 | movq mm2,.scan_y1 |
||
607 | movq mm3,.cur2b |
||
608 | movq mm4,.cur2r |
||
609 | movq mm5,.scan_y2 |
||
610 | paddd mm0,.dc13b |
||
611 | paddd mm1,.dc13r |
||
612 | paddd mm2,.tex_dy13 |
||
613 | paddd mm3,.dc23b |
||
614 | paddd mm4,.dc23r |
||
615 | paddd mm5,.tex_dy23 |
||
616 | movq .cur1b,mm0 |
||
617 | movq .cur1r,mm1 |
||
618 | movq .scan_y1,mm2 |
||
619 | movq .cur2b,mm3 |
||
620 | movq .cur2r,mm4 |
||
621 | movq .scan_y2,mm5 |
||
622 | else |
||
623 | mov edx,.dc13b |
||
624 | add .cur1b,edx |
||
1245 | hidnplayr | 625 | mov esi,.dc13g |
626 | add .cur1g,esi |
||
627 | mov edi,.dc13r |
||
628 | add .cur1r,edi |
||
629 | mov edx,.tex_dx13 |
||
630 | add .scan_x1,edx |
||
631 | mov esi,.tex_dy13 |
||
632 | add .scan_y1,esi |
||
633 | mov edx,.dz13 |
||
634 | add .zz1,edx |
||
635 | |||
636 | mov edi,.dc23b |
||
637 | |||
638 | mov esi,.dc23g |
||
639 | add .cur2g,esi |
||
640 | mov edx,.dc23r |
||
641 | add .cur2r,edx |
||
642 | mov edi,.tex_dx23 |
||
643 | add .scan_x2,edi |
||
644 | mov esi,.tex_dy23 |
||
645 | add .scan_y2,esi |
||
646 | mov edx,.dz23 |
||
647 | add .zz2,edx |
||
648 | end if |
||
649 | add eax,.dx13 |
||
1776 | yogev_ezra | 650 | add ebx,.dx23 |
1245 | hidnplayr | 651 | inc cx |
652 | cmp cx,.y3 |
||
653 | jl .loop_2 |
||
654 | |||
655 | .loop2_end: |
||
656 | |||
657 | ret 36 |
||
658 | horizontal_tex_grd_line: |
||
659 | ;in: |
||
660 | ; eax : x1, ebx : x2 |
||
661 | |||
662 | .tex_ptr equ [ebp+62] |
||
663 | |||
664 | .z_buffer equ [ebp+54] |
||
665 | .y equ [ebp+52] |
||
666 | |||
667 | .z2 equ [ebp+48] |
||
668 | |||
669 | .tex_y2 equ [ebp+40] |
||
670 | .r2 equ [ebp+36] |
||
671 | .g2 equ [ebp+32] |
||
672 | .b2 equ [ebp+28] |
||
673 | |||
674 | .z1 equ [ebp+24] |
||
675 | |||
676 | .tex_y1 equ [ebp+16] |
||
677 | .r1 equ [ebp+12] |
||
678 | .g1 equ [ebp+8] |
||
679 | .b1 equ [ebp+4] |
||
680 | |||
681 | .x1 equ word[ebp-2] |
||
682 | |||
683 | .dz equ dword[ebp-8] |
||
684 | .db equ dword[ebp-12] |
||
685 | .dg equ dword[ebp-16] |
||
686 | .dr equ dword[ebp-20] |
||
687 | .dtex_x equ dword[ebp-24] |
||
688 | .dtex_y equ dword[ebp-28] |
||
689 | |||
690 | .c_ty equ [ebp-32] |
||
691 | |||
692 | .cb equ [ebp-40] |
||
693 | .cg equ [ebp-44] |
||
694 | .cr equ [ebp-48] |
||
695 | .t_col equ [ebp-52] |
||
696 | |||
697 | .dtex_yM equ qword[ebp-28] |
||
698 | |||
699 | .dbM equ qword[ebp-12] |
||
700 | |||
701 | mov ebp,esp |
||
702 | |||
703 | |||
704 | mov cx,word .y |
||
705 | |||
706 | jl .quit_l |
||
707 | |||
708 | cmp cx,SIZE_Y |
||
709 | |||
710 | |||
711 | cmp ax,bx |
||
712 | |||
713 | jl @f |
||
714 | |||
715 | xchg eax,ebx |
||
716 | |||
717 | if Ext=NON |
||
718 | |||
719 | xchg ecx, .r2 |
||
720 | mov dword .r1, ecx |
||
721 | |||
722 | mov ecx,dword .g1 |
||
723 | |||
724 | mov dword .g1, ecx |
||
725 | |||
726 | mov ecx,dword .b1 |
||
727 | |||
728 | mov dword .b1, ecx |
||
729 | |||
730 | mov ecx,dword .tex_x1 |
||
731 | |||
732 | mov dword .tex_x1, ecx |
||
733 | |||
734 | mov ecx,dword .tex_y1 |
||
735 | |||
736 | mov dword .tex_y1, ecx |
||
737 | |||
738 | mov ecx,dword .z1 |
||
739 | |||
740 | mov dword .z1, ecx |
||
741 | |||
742 | else |
||
743 | |||
744 | movq mm1,.b2 |
||
745 | movq .b1, mm1 |
||
746 | movq .b2, mm0 |
||
747 | movq mm2,.r1 ; r, y |
||
748 | movq mm3,.r2 |
||
749 | movq .r1,mm3 |
||
750 | movq .r2,mm2 |
||
751 | movq mm4,.tex_x1 ; x, z |
||
752 | movq mm5,.tex_x2 |
||
753 | movq .tex_x1,mm5 |
||
754 | movq .tex_x2,mm4 |
||
755 | |||
756 | end if |
||
757 | |||
758 | @@: |
||
759 | |||
760 | jle .quit_l |
||
761 | cmp ax,SIZE_X |
||
762 | jge .quit_l |
||
763 | |||
764 | push ax |
||
765 | |||
766 | |||
767 | mov eax,.z2 ; delta zone************ |
||
768 | |||
769 | cdq |
||
770 | mov bx,.x2 |
||
771 | sub bx,.x1 |
||
772 | movsx ebx,bx |
||
773 | idiv ebx |
||
774 | push eax ; .dz |
||
775 | |||
776 | mov eax,.b2 |
||
777 | |||
778 | cdq |
||
779 | idiv ebx |
||
780 | push eax ; .db |
||
781 | |||
782 | mov eax,.g2 |
||
783 | |||
784 | cdq |
||
785 | idiv ebx |
||
786 | push eax ; .dg |
||
787 | |||
788 | mov eax,.r2 |
||
789 | |||
790 | cdq |
||
791 | idiv ebx |
||
792 | push eax ; .dr |
||
793 | |||
794 | mov eax,.tex_x2 |
||
795 | |||
796 | cdq |
||
797 | idiv ebx |
||
798 | push eax ; .dtex_x |
||
799 | |||
800 | mov eax,.tex_y2 |
||
801 | |||
802 | cdq |
||
803 | idiv ebx |
||
804 | push eax ; .dtey_x |
||
805 | |||
806 | cmp .x1,0 |
||
807 | |||
808 | |||
809 | mov eax,.dz ; clipping |
||
810 | |||
811 | neg ebx |
||
812 | imul ebx |
||
813 | add .z1,eax |
||
814 | mov .x1,0 |
||
815 | |||
816 | mov eax,.dr |
||
817 | |||
818 | add .r1,eax |
||
819 | ;if Ext=NON |
||
820 | mov eax,.dg |
||
821 | imul ebx |
||
822 | add .g1,eax |
||
823 | |||
824 | mov eax,.db |
||
825 | |||
826 | add .b1,eax |
||
827 | |||
828 | mov eax,.dtex_x |
||
829 | |||
830 | add .tex_x1,eax |
||
831 | |||
832 | mov eax,.dtex_y |
||
833 | |||
834 | add .tex_y1,eax |
||
835 | @@: |
||
836 | mov edx,SIZE_X |
||
837 | cmp .x2,dx |
||
838 | jl @f |
||
839 | mov .x2,dx |
||
840 | @@: |
||
841 | ; calc line addres begin in screen and Z buffer |
||
842 | movsx eax,word .y |
||
843 | mul edx |
||
844 | movsx edx,.x1 |
||
845 | add eax,edx |
||
846 | |||
847 | mov esi,eax |
||
848 | |||
849 | add esi,.z_buffer |
||
850 | |||
851 | lea eax,[eax*3] |
||
852 | |||
853 | add edi,eax |
||
854 | |||
855 | mov cx,.x2 |
||
856 | |||
857 | movzx ecx,cx |
||
858 | |||
859 | ; init current variables |
||
860 | |||
861 | ;if Ext=NON |
||
862 | push dword .tex_x1 |
||
863 | |||
864 | push dword .b1 |
||
865 | |||
866 | push dword .r1 |
||
867 | |||
868 | if Ext>=MMX |
||
869 | |||
870 | movq mm6,.cb ; hi -> b, tex_x |
||
871 | pxor mm0,mm0 |
||
872 | end if |
||
873 | mov ebx,.z1 |
||
874 | .ddraw: |
||
875 | cmp ebx,dword[esi] |
||
876 | jge @f |
||
877 | mov eax,.c_ty |
||
878 | ; if ROUND |
||
879 | ; shl eax,TEX_SHIFT-ROUND |
||
880 | ; end if |
||
881 | ; if ROUND>TEX_SHIFT |
||
882 | ; shr eax,ROUND-TEX_SHIFT |
||
883 | ; end if |
||
884 | shr eax,ROUND |
||
885 | shl Eax,TEX_SHIFT |
||
886 | mov edx,.c_tx ; calc texture pixel mem addres |
||
887 | shr edx,ROUND |
||
888 | add eax,edx |
||
889 | and eax,TEXTURE_SIZE ; cutting |
||
890 | lea eax,[3*eax] |
||
891 | add eax,.tex_ptr |
||
892 | mov dword[esi],ebx |
||
893 | if Ext = NON |
||
894 | mov eax,dword[eax] |
||
895 | ; mov .tex_col,eax |
||
896 | push ax |
||
897 | shl eax,8 |
||
898 | pop ax |
||
899 | mov edx,.cr |
||
900 | sar edx,ROUND |
||
901 | mul dl ; al*dl |
||
902 | shr ax,8 |
||
903 | stosb |
||
904 | ror eax,16 |
||
905 | push ax |
||
906 | mov edx,.cg |
||
907 | sar edx,ROUND |
||
908 | mul dl |
||
909 | shr ax,8 |
||
910 | stosb |
||
911 | pop ax |
||
912 | shr ax,8 |
||
913 | mov edx,.cb |
||
914 | sar edx,ROUND |
||
915 | mul dl |
||
916 | shr ax,8 |
||
917 | stosb |
||
918 | jmp .no_skip |
||
919 | else |
||
920 | movd mm1,[eax] |
||
921 | punpcklbw mm1,mm0 |
||
922 | movq mm3,mm4 ;.cr ; lo -> r,g |
||
923 | movq mm5,mm6 ;.cb ; lo -> b,tex_x |
||
924 | psrld mm3,ROUND ; |
||
925 | psrld mm5,ROUND ; |
||
926 | packssdw mm3,mm5 |
||
927 | pmullw mm1,mm3 |
||
928 | psrlw mm1,8 |
||
929 | packuswb mm1,mm0 |
||
930 | movd [edi],mm1 |
||
931 | end if |
||
932 | mov dword[esi],ebx |
||
933 | if Ext = NON |
||
934 | jmp .no_skip |
||
935 | end if |
||
936 | @@: |
||
937 | add edi,3 |
||
938 | .no_skip: |
||
939 | add esi,4 |
||
940 | add ebx,.dz |
||
941 | |||
942 | mov eax,.dtex_x |
||
943 | |||
944 | mov edx,.dtex_y |
||
945 | add .c_ty, edx |
||
946 | if Ext=NON |
||
947 | mov eax,.dr |
||
948 | add .cr,eax |
||
949 | mov edx,.dg |
||
950 | add .cg,edx |
||
951 | mov eax,.db |
||
952 | add .cb,eax |
||
953 | |||
954 | else |
||
955 | |||
956 | paddd mm6,.dbM |
||
957 | ;; paddd mm7,.dtex_y ; mm4 - b, g |
||
958 | ;; movq .c_tx,mm7 |
||
959 | ; mm6 - r, x |
||
960 | end if ; mm7 - y, x |
||
961 | |||
962 | dec ecx |
||
963 | |||
964 | |||
965 | .quit_l: |
||
966 | |||
967 | mov esp,ebp |
||
968 | |||
969 | ;>><><<><<<><<<<><<<<<><<<<<<> |
||
970 |