Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1245 | hidnplayr | 1 | ROUND equ 8 |
2 | CATMULL_SHIFT equ 8 |
||
3 | gouraud_triangle_z: |
||
4 | |||
5 | ;----procedure drawing gouraud triangle with z coordinate |
||
6 | ;----interpolation ( Catmull alghoritm )----------------- |
||
7 | ;------------------in - eax - x1 shl 16 + y1 ------------ |
||
8 | ;---------------------- ebx - x2 shl 16 + y2 ------------ |
||
9 | ;---------------------- ecx - x3 shl 16 + y3 ------------ |
||
10 | ;---------------------- esi - pointer to Z-buffer-------- |
||
11 | ;---------------------- Z-buffer filled with dd variables |
||
12 | ;---------------------- shifted CATMULL_SHIFT------------ |
||
13 | ;---------------------- edi - pointer to screen buffer--- |
||
14 | ;---------------------- stack : colors------------------- |
||
15 | ;----------------- procedure don't save registers !!----- |
||
16 | .col1r equ ebp+4 ; each color as word |
||
17 | .col1g equ ebp+6 ; each z coordinate as word |
||
18 | .col1b equ ebp+8 |
||
19 | .z1 equ ebp+10 |
||
20 | .col2r equ ebp+12 |
||
21 | .col2g equ ebp+14 |
||
22 | .col2b equ ebp+16 |
||
23 | .z2 equ ebp+18 |
||
24 | .col3r equ ebp+20 |
||
25 | .col3g equ ebp+22 |
||
26 | .col3b equ ebp+24 |
||
27 | .z3 equ ebp+26 |
||
28 | |||
29 | .x1 equ word[ebp-2] |
||
30 | .y1 equ word[ebp-4] |
||
31 | .x2 equ word[ebp-6] |
||
32 | .y2 equ word[ebp-8] |
||
33 | .x3 equ word[ebp-10] |
||
34 | .y3 equ word[ebp-12] |
||
35 | |||
36 | .dx12 equ dword[ebp-16] |
||
37 | .dz12 equ dword[ebp-20] |
||
38 | .dc12r equ dword[ebp-24] |
||
39 | .dc12g equ dword[ebp-28] |
||
40 | .dc12b equ dword[ebp-32] |
||
41 | |||
42 | .dx13 equ dword[ebp-36] |
||
43 | .dz13 equ dword[ebp-40] |
||
44 | .dc13r equ dword[ebp-44] |
||
45 | .dc13g equ dword[ebp-48] |
||
46 | .dc13b equ dword[ebp-52] |
||
47 | |||
48 | .dx23 equ dword[ebp-56] |
||
49 | .dz23 equ dword[ebp-60] |
||
50 | .dc23r equ dword[ebp-64] |
||
51 | .dc23g equ dword[ebp-68] |
||
52 | .dc23b equ dword[ebp-72] |
||
53 | |||
54 | .zz1 equ dword[ebp-76] |
||
55 | .c1r equ dword[ebp-80] |
||
56 | .c1g equ dword[ebp-84] |
||
57 | .c1b equ dword[ebp-88] |
||
58 | .zz2 equ dword[ebp-92] |
||
59 | .c2r equ dword[ebp-96] |
||
60 | .c2g equ dword[ebp-100] |
||
61 | .c2b equ dword[ebp-104] |
||
62 | ;.zz1 equ dword[ebp-100] |
||
63 | ;.zz2 equ dword[ebp-104] |
||
64 | |||
65 | .c1bM equ [ebp-88] |
||
66 | .c2bM equ [ebp-104] |
||
67 | .c1rM equ [ebp-80] |
||
68 | .c2rM equ [ebp-96] |
||
69 | .dc23bM equ [ebp-72] |
||
70 | .dc13bM equ [ebp-52] |
||
71 | .dc12bM equ [ebp-32] |
||
72 | .dc12rM equ [ebp-24] |
||
73 | .dc13rM equ [ebp-44] |
||
74 | .dc23rM equ [ebp-64] |
||
75 | if Ext=MMX |
||
76 | emms |
||
77 | end if |
||
78 | |||
79 | mov ebp,esp |
||
80 | ; sub esp,84 |
||
81 | .sort3: ; sort triangle coordinates... |
||
82 | cmp ax,bx |
||
83 | jle .sort1 |
||
84 | xchg eax,ebx |
||
85 | mov edx,dword[.col1r] |
||
86 | xchg edx,dword[.col2r] |
||
87 | mov dword[.col1r],edx |
||
88 | mov edx,dword[.col1b] |
||
89 | xchg edx,dword[.col2b] |
||
90 | mov dword[.col1b],edx |
||
91 | .sort1: |
||
92 | cmp bx,cx |
||
93 | jle .sort2 |
||
94 | xchg ebx,ecx |
||
95 | mov edx,dword[.col2r] |
||
96 | xchg edx,dword[.col3r] |
||
97 | mov dword[.col2r],edx |
||
98 | mov edx,dword[.col2b] |
||
99 | xchg edx,dword[.col3b] |
||
100 | mov dword[.col2b],edx |
||
101 | jmp .sort3 |
||
102 | .sort2: |
||
103 | push eax ; store in variables |
||
104 | push ebx |
||
105 | push ecx |
||
106 | mov edx,80008000h ; eax,ebx,ecx are ANDd together into edx which means that |
||
107 | and edx,ebx ; if *all* of them are negative a sign flag is raised |
||
108 | and edx,ecx |
||
109 | and edx,eax |
||
110 | test edx,80008000h ; Check both X&Y at once |
||
111 | jne .gt_loop2_end |
||
112 | |||
113 | mov bx,.y2 ; calc deltas |
||
114 | sub bx,.y1 |
||
115 | jnz .gt_dx12_make |
||
116 | ; mov .dx12,0 |
||
117 | ; mov .dz12,0 |
||
118 | ; mov .dc12r,0 |
||
119 | ; mov .dc12g,0 |
||
120 | ; mov .dc12b,0 |
||
121 | mov ecx,5 |
||
122 | @@: |
||
123 | push dword 0 |
||
124 | loop @b |
||
125 | jmp .gt_dx12_done |
||
126 | .gt_dx12_make: |
||
127 | mov ax,.x2 |
||
128 | sub ax,.x1 |
||
129 | cwde |
||
130 | movsx ebx,bx |
||
131 | shl eax,ROUND |
||
132 | cdq |
||
133 | idiv ebx |
||
134 | ; mov .dx12,eax |
||
135 | push eax |
||
136 | |||
137 | mov ax,word[.z2] |
||
138 | sub ax,word[.z1] |
||
139 | cwde |
||
140 | shl eax,CATMULL_SHIFT |
||
141 | cdq |
||
142 | idiv ebx |
||
143 | push eax |
||
144 | |||
145 | mov ax,word[.col2r] |
||
146 | sub ax,word[.col1r] |
||
147 | cwde |
||
148 | shl eax,ROUND |
||
149 | cdq |
||
150 | idiv ebx |
||
151 | ; mov .dc12r,eax |
||
152 | push eax |
||
153 | mov ax,word[.col2g] |
||
154 | sub ax,word[.col1g] |
||
155 | cwde |
||
156 | shl eax,ROUND |
||
157 | cdq |
||
158 | idiv ebx |
||
159 | ; mov .dc12g,eax |
||
160 | push eax |
||
161 | mov ax,word[.col2b] ;;--- |
||
162 | sub ax,word[.col1b] |
||
163 | cwde |
||
164 | shl eax,ROUND |
||
165 | cdq |
||
166 | idiv ebx |
||
167 | ; mov .dc12b,eax |
||
168 | push eax |
||
169 | .gt_dx12_done: |
||
170 | |||
171 | mov bx,.y3 ; calc deltas |
||
172 | sub bx,.y1 |
||
173 | jnz .gt_dx13_make |
||
174 | ; mov .dx13,0 |
||
175 | ; mov .dz13,0 |
||
176 | ; mov .dc13r,0 |
||
177 | ; mov .dc13g,0 |
||
178 | ; mov .dc13b,0 |
||
179 | mov ecx,5 |
||
180 | @@: |
||
181 | push dword 0 |
||
182 | loop @b |
||
183 | jmp .gt_dx13_done |
||
184 | .gt_dx13_make: |
||
185 | mov ax,.x3 |
||
186 | sub ax,.x1 |
||
187 | cwde |
||
188 | movsx ebx,bx |
||
189 | shl eax,ROUND |
||
190 | cdq |
||
191 | idiv ebx |
||
192 | ; mov .dx13,eax |
||
193 | push eax |
||
194 | |||
195 | mov ax,word[.z3] |
||
196 | sub ax,word[.z1] |
||
197 | cwde |
||
198 | shl eax,CATMULL_SHIFT |
||
199 | cdq |
||
200 | idiv ebx |
||
201 | push eax |
||
202 | |||
203 | mov ax,word[.col3r] |
||
204 | sub ax,word[.col1r] |
||
205 | cwde |
||
206 | shl eax,ROUND |
||
207 | cdq |
||
208 | idiv ebx |
||
209 | ; mov .dc13r,eax |
||
210 | push eax |
||
211 | mov ax,word[.col3g] |
||
212 | sub ax,word[.col1g] |
||
213 | cwde |
||
214 | shl eax,ROUND |
||
215 | cdq |
||
216 | idiv ebx |
||
217 | ; mov .dc13g,eax |
||
218 | push eax |
||
219 | mov ax,word[.col3b] |
||
220 | sub ax,word[.col1b] |
||
221 | cwde |
||
222 | shl eax,ROUND |
||
223 | cdq |
||
224 | idiv ebx |
||
225 | ; mov .dc13b,eax |
||
226 | push eax |
||
227 | .gt_dx13_done: |
||
228 | |||
229 | mov bx,.y3 ; calc deltas |
||
230 | sub bx,.y2 |
||
231 | jnz .gt_dx23_make |
||
232 | ; mov .dx23,0 |
||
233 | ; mov .dz23,0 |
||
234 | ; mov .dc23r,0 |
||
235 | ; mov .dc23g,0 |
||
236 | ; mov .dc23b,0 |
||
237 | mov ecx,5 |
||
238 | @@: |
||
239 | push dword 0 |
||
240 | loop @b |
||
241 | jmp .gt_dx23_done |
||
242 | .gt_dx23_make: |
||
243 | mov ax,.x3 |
||
244 | sub ax,.x2 |
||
245 | cwde |
||
246 | movsx ebx,bx |
||
247 | shl eax,ROUND |
||
248 | cdq |
||
249 | idiv ebx |
||
250 | ; mov .dx23,eax |
||
251 | push eax |
||
252 | |||
253 | mov ax,word[.z3] |
||
254 | sub ax,word[.z2] |
||
255 | cwde |
||
256 | shl eax,CATMULL_SHIFT |
||
257 | cdq |
||
258 | idiv ebx |
||
259 | push eax |
||
260 | |||
261 | mov ax,word[.col3r] |
||
262 | sub ax,word[.col2r] |
||
263 | cwde |
||
264 | shl eax,ROUND |
||
265 | cdq |
||
266 | idiv ebx |
||
267 | ; mov .dc23r,eax |
||
268 | push eax |
||
269 | mov ax,word[.col3g] |
||
270 | sub ax,word[.col2g] |
||
271 | cwde |
||
272 | shl eax,ROUND |
||
273 | cdq |
||
274 | idiv ebx |
||
275 | ; mov .dc23g,eax |
||
276 | push eax |
||
277 | mov ax,word[.col3b] |
||
278 | sub ax,word[.col2b] |
||
279 | cwde |
||
280 | shl eax,ROUND |
||
281 | cdq |
||
282 | idiv ebx |
||
283 | ; mov .dc23b,eax |
||
284 | push eax |
||
285 | .gt_dx23_done: |
||
286 | sub esp,32 |
||
287 | |||
288 | movsx eax,.x1 ; eax - cur x1 |
||
289 | shl eax,ROUND ; ebx - cur x2 |
||
290 | mov ebx,eax |
||
291 | movsx edx,word[.z1] |
||
292 | shl edx,CATMULL_SHIFT |
||
293 | mov .zz1,edx |
||
294 | mov .zz2,edx |
||
295 | movzx edx,word[.col1r] |
||
296 | shl edx,ROUND |
||
297 | mov .c1r,edx |
||
298 | mov .c2r,edx |
||
299 | movzx edx,word[.col1g] |
||
300 | shl edx,ROUND |
||
301 | mov .c1g,edx |
||
302 | mov .c2g,edx |
||
303 | movzx edx,word[.col1b] |
||
304 | shl edx,ROUND |
||
305 | mov .c1b,edx |
||
306 | mov .c2b,edx |
||
307 | mov cx,.y1 |
||
308 | cmp cx,.y2 |
||
309 | jge .gt_loop1_end |
||
310 | |||
311 | .gt_loop1: |
||
312 | pushad |
||
313 | ; macro .debug |
||
314 | |||
315 | mov edx,.c2r ; c2r,c2g,c2b,c1r,c1g,c1b - current colors |
||
316 | sar edx,ROUND |
||
317 | push dx |
||
318 | mov edx,.c2g |
||
319 | sar edx,ROUND |
||
320 | push dx |
||
321 | mov edx,.c2b |
||
322 | sar edx,ROUND |
||
323 | push dx |
||
324 | sar ebx,ROUND ; x2 |
||
325 | push bx |
||
326 | mov edx,.c1r |
||
327 | sar edx,ROUND |
||
328 | push dx |
||
329 | mov edx,.c1g |
||
330 | sar edx,ROUND |
||
331 | push dx |
||
332 | mov edx,.c1b |
||
333 | sar edx,ROUND |
||
334 | push dx |
||
335 | sar eax,ROUND |
||
336 | push ax ; x1 |
||
337 | push cx ; y |
||
338 | push .zz2 |
||
339 | push .zz1 |
||
340 | call gouraud_line_z |
||
341 | |||
342 | popad |
||
343 | if Ext >= MMX |
||
344 | movq mm0,.c1bM |
||
345 | paddd mm0,qword .dc13bM |
||
346 | movq .c1bM,mm0 |
||
347 | movq mm1,.c2bM |
||
348 | paddd mm1,qword .dc12bM |
||
349 | movq .c2bM,mm1 |
||
350 | |||
351 | movq mm0,.c1rM |
||
352 | paddd mm0,qword .dc13rM |
||
353 | movq .c1rM,mm0 |
||
354 | movq mm1,.c2rM |
||
355 | paddd mm1,qword .dc12rM |
||
356 | movq .c2rM,mm1 |
||
357 | else |
||
358 | mov edx,.dc13r |
||
359 | add .c1r,edx |
||
360 | mov edx,.dc13g |
||
361 | add .c1g,edx |
||
362 | mov edx,.dc13b |
||
363 | add .c1b,edx |
||
364 | mov edx,.dc12r |
||
365 | add .c2r,edx |
||
366 | mov edx,.dc12g |
||
367 | add .c2g,edx |
||
368 | mov edx,.dc12b |
||
369 | add .c2b,edx |
||
370 | |||
371 | mov edx,.dz13 |
||
372 | add .zz1,edx |
||
373 | mov edx,.dz12 |
||
374 | add .zz2,edx |
||
375 | end if |
||
376 | add eax,.dx13 |
||
377 | add ebx,.dx12 |
||
378 | inc cx |
||
379 | cmp cx,.y2 |
||
380 | jl .gt_loop1 |
||
381 | |||
382 | .gt_loop1_end: |
||
383 | mov cx,.y2 |
||
384 | cmp cx,.y3 |
||
385 | jge .gt_loop2_end |
||
386 | |||
387 | movsx ebx,.x2 ; eax - cur x1 |
||
388 | shl ebx,ROUND ; ebx - cur x2 |
||
389 | movsx edx,word[.z2] |
||
390 | shl edx,CATMULL_SHIFT |
||
391 | mov .zz2,edx |
||
392 | movzx edx,word[.col2r] |
||
393 | shl edx,ROUND |
||
394 | mov .c2r,edx |
||
395 | movzx edx,word[.col2g] |
||
396 | shl edx,ROUND |
||
397 | mov .c2g,edx |
||
398 | movzx edx,word[.col2b] |
||
399 | shl edx,ROUND |
||
400 | mov .c2b,edx |
||
401 | |||
402 | .gt_loop2: |
||
403 | pushad |
||
404 | ; macro .debug |
||
405 | |||
406 | mov edx,.c2r ; c2r,c2g,c2b,c1r,c1g,c1b - current colors |
||
407 | sar edx,ROUND |
||
408 | push dx |
||
409 | mov edx,.c2g |
||
410 | sar edx,ROUND |
||
411 | push dx |
||
412 | mov edx,.c2b |
||
413 | sar edx,ROUND |
||
414 | push dx |
||
415 | sar ebx,ROUND ; x2 |
||
416 | push bx |
||
417 | mov edx,.c1r |
||
418 | sar edx,ROUND |
||
419 | push dx |
||
420 | mov edx,.c1g |
||
421 | sar edx,ROUND |
||
422 | push dx |
||
423 | mov edx,.c1b |
||
424 | sar edx,ROUND |
||
425 | push dx |
||
426 | sar eax,ROUND |
||
427 | push ax ; x1 |
||
428 | push cx ; y |
||
429 | push .zz2 |
||
430 | push .zz1 |
||
431 | call gouraud_line_z |
||
432 | |||
433 | popad |
||
434 | |||
435 | if Ext >= MMX |
||
436 | movq mm0,.c1bM |
||
437 | paddd mm0,qword .dc13bM |
||
438 | movq .c1bM,mm0 |
||
439 | movq mm1,.c2bM |
||
440 | paddd mm1,qword .dc23bM |
||
441 | movq .c2bM,mm1 |
||
442 | |||
443 | movq mm0,.c1rM |
||
444 | paddd mm0,qword .dc13rM |
||
445 | movq .c1rM,mm0 |
||
446 | movq mm1,.c2rM |
||
447 | paddd mm1,qword .dc23rM |
||
448 | movq .c2rM,mm1 |
||
449 | else |
||
450 | mov edx,.dc13r |
||
451 | add .c1r,edx |
||
452 | mov edx,.dc13g |
||
453 | add .c1g,edx |
||
454 | mov edx,.dc13b |
||
455 | add .c1b,edx |
||
456 | mov edx,.dc23r |
||
457 | add .c2r,edx |
||
458 | mov edx,.dc23g |
||
459 | add .c2g,edx |
||
460 | mov edx,.dc23b |
||
461 | add .c2b,edx |
||
462 | mov edx,.dz13 |
||
463 | add .zz1,edx |
||
464 | mov edx,.dz23 |
||
465 | add .zz2,edx |
||
466 | end if |
||
467 | add eax,.dx13 |
||
468 | add ebx,.dx23 |
||
469 | inc cx |
||
470 | cmp cx,.y3 |
||
471 | jl .gt_loop2 |
||
472 | .gt_loop2_end: |
||
473 | |||
474 | mov esp,ebp |
||
475 | ret 24 |
||
476 | gouraud_line_z: |
||
477 | ;----------------- procedure drawing gouraud line |
||
478 | ;----------------- with z coordinate interpolation |
||
479 | ;----------------- esi - pointer to Z_buffer |
||
480 | ;----------------- edi - pointer to screen buffer |
||
481 | ;----------------- stack: |
||
482 | .z1 equ dword[ebp+4] ; z coordiunate shifted left CATMULL_SHIFT |
||
483 | .z2 equ dword[ebp+8] |
||
484 | .y equ word[ebp+12] |
||
485 | .x1 equ ebp+14 |
||
486 | .c1b equ ebp+16 |
||
487 | .c1g equ ebp+18 |
||
488 | .c1r equ ebp+20 |
||
489 | .x2 equ ebp+22 |
||
490 | .c2b equ ebp+24 |
||
491 | .c2g equ ebp+26 |
||
492 | .c2r equ ebp+28 |
||
493 | |||
494 | .dz equ dword[ebp-4] |
||
495 | .dc_b equ dword[ebp-8] |
||
496 | .dc_g equ dword[ebp-12] |
||
497 | .dc_r equ dword[ebp-16] |
||
498 | .c_z equ dword[ebp-20] |
||
499 | .cb equ dword[ebp-24] |
||
500 | .cg equ dword[ebp-28] |
||
501 | .cr equ dword[ebp-32] |
||
502 | ;.cg2 equ dword[ebp-36] |
||
503 | |||
504 | |||
505 | .crM equ ebp-32 |
||
506 | .cgM equ ebp-28 |
||
507 | .cbM equ ebp-24 |
||
508 | |||
509 | .dc_rM equ ebp-16 |
||
510 | .dc_gM equ ebp-12 |
||
511 | .dc_bM equ ebp-8 |
||
512 | mov ebp,esp |
||
513 | |||
514 | mov ax,.y |
||
515 | or ax,ax |
||
516 | jl .gl_quit |
||
517 | cmp ax,SIZE_Y |
||
518 | jge .gl_quit |
||
519 | |||
520 | mov eax,dword[.x1] |
||
521 | cmp ax,word[.x2] |
||
522 | je .gl_quit |
||
523 | jl @f |
||
524 | |||
525 | xchg eax,dword[.x2] |
||
526 | mov dword[.x1],eax |
||
527 | mov eax,dword[.c1g] |
||
528 | xchg eax,dword[.c2g] |
||
529 | mov dword[.c1g],eax |
||
530 | mov eax,.z1 |
||
531 | xchg eax,.z2 |
||
532 | mov .z1,eax |
||
533 | @@: |
||
534 | cmp word[.x1],SIZE_X |
||
535 | jge .gl_quit |
||
536 | cmp word[.x2],0 |
||
537 | jle .gl_quit |
||
538 | |||
539 | mov eax,.z2 |
||
540 | sub eax,.z1 |
||
541 | cdq |
||
542 | mov bx,word[.x2] ; dz = z2-z1/x2-x1 |
||
543 | sub bx,word[.x1] |
||
544 | movsx ebx,bx |
||
545 | idiv ebx |
||
546 | push eax |
||
547 | |||
548 | mov ax,word[.c2b] |
||
549 | sub ax,word[.c1b] |
||
550 | cwde |
||
551 | shl eax,ROUND |
||
552 | cdq |
||
553 | idiv ebx |
||
554 | push eax |
||
555 | |||
556 | mov ax,word[.c2g] |
||
557 | sub ax,word[.c1g] |
||
558 | cwde |
||
559 | shl eax,ROUND |
||
560 | cdq |
||
561 | idiv ebx |
||
562 | push eax |
||
563 | |||
564 | mov ax,word[.c2r] |
||
565 | sub ax,word[.c1r] |
||
566 | cwde |
||
567 | shl eax,ROUND ; dc_r = c2r-c1r/x2-x1 |
||
568 | cdq |
||
569 | idiv ebx |
||
570 | push eax |
||
571 | |||
572 | cmp word[.x1],0 ; clipping on function |
||
573 | jg @f |
||
574 | mov eax,.dz |
||
575 | movsx ebx,word[.x1] |
||
576 | neg ebx |
||
577 | imul ebx |
||
578 | add .z1,eax |
||
579 | mov word[.x1],0 |
||
580 | |||
581 | mov eax,.dc_r |
||
582 | imul ebx |
||
583 | sar eax,ROUND |
||
584 | add word[.c1r],ax |
||
585 | |||
586 | mov eax,.dc_g |
||
587 | imul ebx |
||
588 | sar eax,ROUND |
||
589 | add word[.c1g],ax |
||
590 | |||
591 | mov eax,.dc_b |
||
592 | imul ebx |
||
593 | sar eax,ROUND |
||
594 | add word[.c1b],ax |
||
595 | |||
596 | @@: |
||
597 | cmp word[.x2],SIZE_X |
||
598 | jl @f |
||
599 | mov word[.x2],SIZE_X |
||
600 | @@: |
||
601 | sub esp,16 ; calculate memory begin |
||
602 | mov edx,SIZE_X ; in buffers |
||
603 | movzx eax,.y |
||
604 | mul edx |
||
605 | movzx edx,word[.x1] |
||
606 | add eax,edx |
||
607 | push eax |
||
608 | lea eax,[eax*3] |
||
609 | add edi,eax |
||
610 | pop eax |
||
611 | shl eax,2 |
||
612 | add esi,eax |
||
613 | |||
614 | mov cx,word[.x2] |
||
615 | sub cx,word[.x1] |
||
616 | movzx ecx,cx |
||
617 | mov ebx,.z1 ; ebx - currrent z shl CATMULL_SIFT |
||
618 | ;if Ext >= SSE |
||
619 | ; mov .cz,edx |
||
620 | ;end if |
||
621 | mov edx,.dz ; edx - delta z |
||
622 | movzx eax,word[.c1r] |
||
623 | shl eax,ROUND |
||
624 | mov .cr,eax |
||
625 | movzx eax,word[.c1g] |
||
626 | shl eax,ROUND |
||
627 | mov .cg,eax |
||
628 | movzx eax,word[.c1b] |
||
629 | shl eax,ROUND |
||
630 | mov .cb,eax |
||
631 | if Ext = MMX |
||
632 | ; mov .c_z,edx |
||
633 | movd mm2,[.dc_bM] ; delta color blue MMX |
||
634 | movd mm3,[.cbM] ; current blue MMX |
||
635 | movq mm5,[.dc_rM] |
||
636 | movq mm4,[.crM] |
||
637 | pxor mm6,mm6 |
||
638 | end if |
||
639 | |||
640 | |||
641 | .ddraw: |
||
642 | ;if Ext = MMX |
||
643 | ; movq mm0,mm3 |
||
644 | ; psrsq mm0,32 |
||
645 | ; movd ebx,mm0 |
||
646 | ;end if |
||
647 | cmp ebx,dword[esi] ; esi - z_buffer |
||
648 | jge @f ; edi - Screen buffer |
||
649 | if Ext = MMX |
||
650 | movq mm0,mm3 ; mm0, mm1 - temp registers |
||
651 | psrld mm0,ROUND |
||
652 | movq mm1,mm4 |
||
653 | psrld mm1,ROUND |
||
654 | packssdw mm1,mm0 |
||
655 | packuswb mm1,mm6 |
||
656 | ; movd [edi],mm1 |
||
657 | movd eax,mm1 |
||
658 | stosw |
||
659 | shr eax,16 |
||
660 | stosb |
||
661 | else |
||
662 | mov eax,.cr |
||
663 | sar eax,ROUND |
||
664 | stosb |
||
665 | mov eax,.cg |
||
666 | sar eax,ROUND |
||
667 | stosb |
||
668 | mov eax,.cb |
||
669 | sar eax,ROUND |
||
670 | stosb |
||
671 | end if |
||
672 | mov dword[esi],ebx |
||
673 | ;if Ext = NON |
||
674 | jmp .no_skip |
||
675 | ;end if |
||
676 | @@: |
||
677 | add edi,3 |
||
678 | .no_skip: |
||
679 | add esi,4 |
||
680 | ;if Ext=NON |
||
681 | add ebx,edx |
||
682 | ;end if |
||
683 | if Ext=MMX |
||
684 | paddd mm3,mm2 |
||
685 | paddd mm4,mm5 |
||
686 | else |
||
687 | mov eax,.dc_g |
||
688 | add .cg,eax |
||
689 | mov eax,.dc_b |
||
690 | add .cb,eax |
||
691 | mov eax,.dc_r |
||
692 | add .cr,eax |
||
693 | end if |
||
694 | loop .ddraw |
||
695 | |||
696 | .gl_quit: |
||
697 | mov esp,ebp |
||
698 | ret 26 |