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