Rev 8232 | Rev 8719 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8232 | Rev 8666 | ||
---|---|---|---|
Line 58... | Line 58... | ||
58 | ; procedure don't save registers !!! |
58 | ; procedure don't save registers !!! |
59 | ; in - st - dot_product |
59 | ; in - st - dot_product |
60 | ; stack - other parameters |
60 | ; stack - other parameters |
61 | ; out - eax - 0x00rrggbb |
61 | ; out - eax - 0x00rrggbb |
62 | .dot_prd equ dword[ebp+4] ; dot product - cos x - not now |
62 | .dot_prd equ dword[ebp+4] ; dot product - cos x - not now |
63 | .min_col_r equ word[ebp+8] ; minimum color - ambient |
63 | .min_col_r equ [ebp+8] ; minimum color - ambient |
64 | .min_col_g equ word[ebp+10] |
64 | .min_col_g equ word[ebp+10] |
65 | .min_col_b equ word[ebp+12] |
65 | .min_col_b equ word[ebp+12] |
66 | .max_col_r equ word[ebp+14] ; maximum color - specular |
66 | .max_col_r equ [ebp+14] ; maximum color - specular |
67 | .max_col_g equ word[ebp+16] |
67 | .max_col_g equ word[ebp+16] |
68 | .max_col_b equ word[ebp+18] |
68 | .max_col_b equ word[ebp+18] |
69 | .org_col_r equ word[ebp+20] ; orginal color - diffuse |
69 | .org_col_r equ [ebp+20] ; orginal color - diffuse |
70 | .org_col_g equ word[ebp+22] |
70 | .org_col_g equ word[ebp+22] |
71 | .org_col_b equ word[ebp+24] |
71 | .org_col_b equ word[ebp+24] |
72 | .n equ word[ebp+26] ; shines - not implemented |
72 | .n equ word[ebp+26] ; shines - not implemented |
73 | .temp equ word[ebp-2] |
73 | .temp equ word[ebp-2] |
74 | .color_sum_r equ dword[ebp-6] |
74 | .color_sum_r equ [ebp-6] |
75 | .color_sum_g equ dword[ebp-10] |
75 | .color_sum_g equ [ebp-10] |
76 | .color_sum_b equ dword[ebp-14] |
76 | .color_sum_b equ [ebp-14] |
77 | ; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular |
77 | ; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular |
78 | mov ebp,esp |
78 | mov ebp,esp |
79 | sub esp,14 |
79 | sub esp,14 |
Line -... | Line 80... | ||
- | 80 | ||
80 | 81 | ||
81 | mov ax,.min_col_r |
82 | mov ax,.min_col_r |
82 | add ax,.max_col_r |
83 | add ax,.max_col_r |
83 | add ax,.org_col_r |
84 | add ax,.org_col_r |
84 | cwde |
85 | cwde |
Line 93... | Line 94... | ||
93 | mov ax,.min_col_b |
94 | mov ax,.min_col_b |
94 | add ax,.max_col_b |
95 | add ax,.max_col_b |
95 | add ax,.org_col_b |
96 | add ax,.org_col_b |
96 | cwde |
97 | cwde |
97 | mov .color_sum_b,eax |
98 | mov .color_sum_b,eax |
- | 99 | if 0 |
|
Line -... | Line 100... | ||
- | 100 | ||
- | 101 | ||
- | 102 | movq xmm0,.min_col_r |
|
- | 103 | movq xmm1,.max_col_r |
|
- | 104 | movq xmm2,.org_col_r |
|
- | 105 | packuswb xmm0,[the_zero] |
|
- | 106 | packuswb xmm1,[the_zero] |
|
- | 107 | packuswb xmm2,[the_zero] |
|
- | 108 | punpcklbw xmm0,xmm1 |
|
- | 109 | punpcklbw xmm2,[the_zero] |
|
- | 110 | packusdw xmm2,[the_zero] |
|
- | 111 | cvtdq2ps xmm0,xmm0 |
|
- | 112 | cvtdq2ps xmm1,xmm1 |
|
- | 113 | cvtdq2ps xmm2,xmm2 |
|
- | 114 | haddps xmm0,xmm0 |
|
- | 115 | haddps xmm1,xmm1 |
|
- | 116 | haddps xmm2,xmm2 |
|
- | 117 | haddps xmm0,xmm0 |
|
- | 118 | haddps xmm1,xmm1 |
|
- | 119 | haddps xmm2,xmm2 |
|
- | 120 | ||
- | 121 | cvtss2si eax,xmm0 |
|
- | 122 | cvtss2si ebx,xmm1 |
|
- | 123 | cvtss2si ecx,xmm2 |
|
- | 124 | mov .color_sum_r,eax |
|
- | 125 | mov .color_sum_g,ebx |
|
- | 126 | mov .color_sum_b,ecx |
|
- | 127 | ||
- | 128 | ||
98 | 129 | end if |
|
99 | 130 | ||
100 | ; fld .dot_prd |
131 | ; fld .dot_prd |
101 | ; fild .n |
132 | ; fild .n |
102 | ; fxch st1 |
133 | ; fxch st1 |
Line 121... | Line 152... | ||
121 | fild .org_col_b |
152 | fild .org_col_b |
122 | fmul st,st3 |
153 | fmul st,st3 |
123 | faddp ; st0=first piece of col, st1=dot_pr^n.. |
154 | faddp ; st0=first piece of col, st1=dot_pr^n.. |
124 | fiadd .min_col_b |
155 | fiadd .min_col_b |
125 | fimul .max_col_b |
156 | fimul .max_col_b |
126 | fidiv .color_sum_b |
157 | fidiv dword .color_sum_b |
127 | fistp .temp |
158 | fistp .temp |
128 | movzx eax,.temp |
159 | movzx eax,.temp |
129 | shl eax,16 |
160 | shl eax,16 |
Line 130... | Line 161... | ||
130 | 161 | ||
Line 133... | Line 164... | ||
133 | fild .org_col_g |
164 | fild .org_col_g |
134 | fmul st,st3 |
165 | fmul st,st3 |
135 | faddp |
166 | faddp |
136 | fiadd .min_col_g |
167 | fiadd .min_col_g |
137 | fimul .max_col_g |
168 | fimul .max_col_g |
138 | fidiv .color_sum_g |
169 | fidiv dword .color_sum_g |
139 | fistp .temp |
170 | fistp .temp |
140 | mov ax,.temp |
171 | mov ax,.temp |
141 | mov ah,al |
172 | mov ah,al |
142 | shl eax,8 |
173 | shl eax,8 |
Line 143... | Line 174... | ||
143 | 174 | ||
144 | fimul .max_col_r |
175 | fimul word .max_col_r |
145 | fild .org_col_r |
176 | fild word .org_col_r |
146 | fmulp st2,st |
177 | fmulp st2,st |
147 | faddp |
178 | faddp |
148 | fiadd .min_col_r |
179 | fiadd word .min_col_r |
149 | fimul .max_col_r |
180 | fimul word .max_col_r |
150 | fidiv .color_sum_r |
181 | fidiv dword .color_sum_r |
151 | fistp .temp |
182 | fistp .temp |
152 | mov ax,.temp ;eax - 0xbbgg00rr |
183 | mov ax,.temp ;eax - 0xbbgg00rr |
153 | ; mov ah,al |
184 | ; mov ah,al |
154 | ror eax,16 |
185 | ror eax,16 |