Subversion Repositories Kolibri OS

Rev

Rev 8666 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8666 Rev 8719
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 [ebp+8]            ; minimum color - ambient
63
.min_col_r equ word[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 [ebp+14]           ; maximum color - specular
66
.max_col_r equ word[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 [ebp+20]           ; orginal color - diffuse
69
.org_col_r equ word[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 [ebp-6]
74
.color_sum_r equ dword[ebp-6]
75
.color_sum_g equ [ebp-10]
75
.color_sum_g equ dword[ebp-10]
76
.color_sum_b equ [ebp-14]
76
.color_sum_b equ dword[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 80... Line -...
80
 
-
 
81
 
80
 
82
         mov      ax,.min_col_r
81
         mov      ax,.min_col_r
83
         add      ax,.max_col_r
82
         add      ax,.max_col_r
84
         add      ax,.org_col_r
83
         add      ax,.org_col_r
85
         cwde
84
         cwde
Line 94... Line 93...
94
         mov      ax,.min_col_b
93
         mov      ax,.min_col_b
95
         add      ax,.max_col_b
94
         add      ax,.max_col_b
96
         add      ax,.org_col_b
95
         add      ax,.org_col_b
97
         cwde
96
         cwde
98
         mov      .color_sum_b,eax
97
         mov      .color_sum_b,eax
99
if 0
-
 
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
 
-
 
Line 128... Line -...
128
 
-
 
Line 129... Line 98...
129
end if
98
 
130
 
99
 
131
;         fld     .dot_prd
100
;         fld     .dot_prd
132
       ;  fild    .n
101
       ;  fild    .n
Line 152... Line 121...
152
         fild    .org_col_b
121
         fild    .org_col_b
153
         fmul    st,st3
122
         fmul    st,st3
154
         faddp                 ; st0=first piece of col, st1=dot_pr^n..
123
         faddp                 ; st0=first piece of col, st1=dot_pr^n..
155
         fiadd   .min_col_b
124
         fiadd   .min_col_b
156
         fimul   .max_col_b
125
         fimul   .max_col_b
157
         fidiv   dword .color_sum_b
126
         fidiv   .color_sum_b
158
         fistp   .temp
127
         fistp   .temp
159
         movzx   eax,.temp
128
         movzx   eax,.temp
160
         shl     eax,16
129
         shl     eax,16
Line 161... Line 130...
161
 
130
 
Line 164... Line 133...
164
         fild    .org_col_g
133
         fild    .org_col_g
165
         fmul    st,st3
134
         fmul    st,st3
166
         faddp
135
         faddp
167
         fiadd   .min_col_g
136
         fiadd   .min_col_g
168
         fimul   .max_col_g
137
         fimul   .max_col_g
169
         fidiv   dword .color_sum_g
138
         fidiv   .color_sum_g
170
         fistp   .temp
139
         fistp   .temp
171
         mov     ax,.temp
140
         mov     ax,.temp
172
         mov     ah,al
141
         mov     ah,al
173
         shl     eax,8
142
         shl     eax,8
Line 174... Line 143...
174
 
143
 
175
         fimul   word .max_col_r
144
         fimul   .max_col_r
176
         fild    word .org_col_r
145
         fild    .org_col_r
177
         fmulp   st2,st
146
         fmulp   st2,st
178
         faddp
147
         faddp
179
         fiadd   word .min_col_r
148
         fiadd   .min_col_r
180
         fimul   word .max_col_r
149
         fimul   .max_col_r
181
         fidiv   dword .color_sum_r
150
         fidiv   .color_sum_r
182
         fistp   .temp
151
         fistp   .temp
183
         mov     ax,.temp          ;eax -  0xbbgg00rr
152
         mov     ax,.temp          ;eax -  0xbbgg00rr
184
     ;   mov     ah,al
153
     ;   mov     ah,al
185
         ror     eax,16
154
         ror     eax,16