Rev 5353 | Rev 5418 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5353 | Rev 5415 | ||
---|---|---|---|
1 | if DEBUG |
1 | if DEBUG |
2 | align 4 |
2 | align 4 |
3 | txt_gl_scal db 'glopScale',0 |
3 | txt_gl_scal db 'glopScale',0 |
4 | txt_gl_tran db 'glopTranslate',0 |
4 | txt_gl_tran db 'glopTranslate',0 |
5 | 5 | ||
6 | align 4 |
6 | align 4 |
7 | proc gl_print_matrix uses eax ebx ecx edi, m:dword, rows:dword |
7 | proc gl_print_matrix uses eax ebx ecx edi, m:dword, rows:dword |
8 | mov ecx,[rows] |
8 | mov ecx,[rows] |
9 | cmp ecx,1 |
9 | cmp ecx,1 |
10 | jl .end_f |
10 | jl .end_f |
11 | mov ebx,[m] |
11 | mov ebx,[m] |
12 | mov word[NumberSymbolsAD],3 |
12 | mov word[NumberSymbolsAD],3 |
13 | finit |
13 | finit |
14 | @@: |
14 | @@: |
15 | lea edi,[buf_param] |
15 | lea edi,[buf_param] |
16 | mov byte[edi],0 |
16 | mov byte[edi],0 |
17 | 17 | ||
18 | fld dword[ebx] |
18 | fld dword[ebx] |
19 | fstp qword[Data_Double] |
19 | fstp qword[Data_Double] |
20 | call DoubleFloat_to_String |
20 | call DoubleFloat_to_String |
21 | stdcall str_cat, edi,Data_String |
21 | stdcall str_cat, edi,Data_String |
22 | 22 | ||
23 | stdcall str_n_cat,edi,txt_zp_sp,2 |
23 | stdcall str_n_cat,edi,txt_zp_sp,2 |
24 | stdcall str_len,edi |
24 | stdcall str_len,edi |
25 | add edi,eax |
25 | add edi,eax |
26 | 26 | ||
27 | fld dword[ebx+4] |
27 | fld dword[ebx+4] |
28 | fstp qword[Data_Double] |
28 | fstp qword[Data_Double] |
29 | call DoubleFloat_to_String |
29 | call DoubleFloat_to_String |
30 | stdcall str_cat, edi,Data_String |
30 | stdcall str_cat, edi,Data_String |
31 | 31 | ||
32 | stdcall str_n_cat,edi,txt_zp_sp,2 |
32 | stdcall str_n_cat,edi,txt_zp_sp,2 |
33 | stdcall str_len,edi |
33 | stdcall str_len,edi |
34 | add edi,eax |
34 | add edi,eax |
35 | 35 | ||
36 | fld dword[ebx+8] |
36 | fld dword[ebx+8] |
37 | fstp qword[Data_Double] |
37 | fstp qword[Data_Double] |
38 | call DoubleFloat_to_String |
38 | call DoubleFloat_to_String |
39 | stdcall str_cat, edi,Data_String |
39 | stdcall str_cat, edi,Data_String |
40 | 40 | ||
41 | stdcall str_n_cat,edi,txt_zp_sp,2 |
41 | stdcall str_n_cat,edi,txt_zp_sp,2 |
42 | stdcall str_len,edi |
42 | stdcall str_len,edi |
43 | add edi,eax |
43 | add edi,eax |
44 | 44 | ||
45 | fld dword[ebx+12] |
45 | fld dword[ebx+12] |
46 | fstp qword[Data_Double] |
46 | fstp qword[Data_Double] |
47 | call DoubleFloat_to_String |
47 | call DoubleFloat_to_String |
48 | stdcall str_cat, edi,Data_String |
48 | stdcall str_cat, edi,Data_String |
49 | 49 | ||
50 | stdcall str_n_cat,edi,txt_nl,2 |
50 | stdcall str_n_cat,edi,txt_nl,2 |
51 | stdcall dbg_print,txt_sp,buf_param |
51 | stdcall dbg_print,txt_sp,buf_param |
52 | 52 | ||
53 | add ebx,16 |
53 | add ebx,16 |
54 | dec ecx |
54 | dec ecx |
55 | cmp ecx,0 |
55 | cmp ecx,0 |
56 | jg @b |
56 | jg @b |
57 | .end_f: |
57 | .end_f: |
58 | ret |
58 | ret |
59 | endp |
59 | endp |
60 | end if |
60 | end if |
61 | 61 | ||
62 | macro gl_matrix_update context, reg |
62 | macro gl_matrix_update context, reg |
63 | { |
63 | { |
64 | local .end_0 |
64 | local .end_0 |
65 | xor reg,reg |
65 | xor reg,reg |
66 | cmp dword[context+offs_cont_matrix_mode],1 |
66 | cmp dword[context+offs_cont_matrix_mode],1 |
67 | jg .end_0 |
67 | jg .end_0 |
68 | inc reg |
68 | inc reg |
69 | .end_0: |
69 | .end_0: |
70 | mov dword[context+offs_cont_matrix_model_projection_updated],reg |
70 | mov dword[context+offs_cont_matrix_model_projection_updated],reg |
71 | } |
71 | } |
72 | 72 | ||
73 | align 4 |
73 | align 4 |
74 | proc glopMatrixMode uses eax ebx, context:dword, p:dword |
74 | proc glopMatrixMode uses eax ebx, context:dword, p:dword |
75 | mov eax,[context] |
75 | mov eax,[context] |
76 | mov ebx,[p] |
76 | mov ebx,[p] |
77 | 77 | ||
78 | cmp dword[ebx+4],GL_MODELVIEW ;cmp p[1],... |
78 | cmp dword[ebx+4],GL_MODELVIEW ;cmp p[1],... |
79 | jne @f |
79 | jne @f |
80 | mov dword[eax+offs_cont_matrix_mode],0 |
80 | mov dword[eax+offs_cont_matrix_mode],0 |
81 | jmp .end_f |
81 | jmp .end_f |
82 | @@: |
82 | @@: |
83 | cmp dword[ebx+4],GL_PROJECTION |
83 | cmp dword[ebx+4],GL_PROJECTION |
84 | jne @f |
84 | jne @f |
85 | mov dword[eax+offs_cont_matrix_mode],1 |
85 | mov dword[eax+offs_cont_matrix_mode],1 |
86 | jmp .end_f |
86 | jmp .end_f |
87 | @@: |
87 | @@: |
88 | cmp dword[ebx+4],GL_TEXTURE |
88 | cmp dword[ebx+4],GL_TEXTURE |
89 | jne .def |
89 | jne .def |
90 | mov dword[eax+offs_cont_matrix_mode],2 |
90 | mov dword[eax+offs_cont_matrix_mode],2 |
91 | jmp .end_f |
91 | jmp .end_f |
92 | .def: |
92 | .def: |
93 | ;assert(0); |
93 | ;assert(0); |
94 | .end_f: |
94 | .end_f: |
95 | ret |
95 | ret |
96 | endp |
96 | endp |
97 | 97 | ||
98 | align 4 |
98 | align 4 |
99 | proc glopLoadMatrix uses eax edi esi, context:dword, p:dword |
99 | proc glopLoadMatrix uses eax edi esi, context:dword, p:dword |
100 | mov eax,[context] |
100 | mov eax,[context] |
101 | mov edi,[eax+offs_cont_matrix_mode] |
101 | mov edi,[eax+offs_cont_matrix_mode] |
102 | shl edi,2 |
102 | shl edi,2 |
103 | add edi,eax |
103 | add edi,eax |
104 | mov edi,dword[edi+offs_cont_matrix_stack_ptr] |
104 | mov edi,dword[edi+offs_cont_matrix_stack_ptr] |
105 | 105 | ||
106 | mov esi,[p] |
106 | mov esi,[p] |
107 | add esi,4 |
107 | add esi,4 |
108 | stdcall gl_M4_Transpose,edi,esi ;транспонируем входную матрицу в матрицу context.matrix_stack_ptr[context.matrix_mode] |
108 | stdcall gl_M4_Transpose,edi,esi ;транспонируем входную матрицу в матрицу context.matrix_stack_ptr[context.matrix_mode] |
109 | 109 | ||
110 | gl_matrix_update eax,edi |
110 | gl_matrix_update eax,edi |
111 | ret |
111 | ret |
112 | endp |
112 | endp |
113 | 113 | ||
114 | align 4 |
114 | align 4 |
115 | proc glopLoadIdentity uses eax ebx, context:dword, p:dword |
115 | proc glopLoadIdentity uses eax ebx, context:dword, p:dword |
116 | mov eax,[context] |
116 | mov eax,[context] |
117 | mov ebx,[eax+offs_cont_matrix_mode] |
117 | mov ebx,[eax+offs_cont_matrix_mode] |
118 | shl ebx,2 |
118 | shl ebx,2 |
119 | add ebx,eax |
119 | add ebx,eax |
120 | 120 | ||
121 | stdcall gl_M4_Id,[ebx+offs_cont_matrix_stack_ptr] |
121 | stdcall gl_M4_Id,[ebx+offs_cont_matrix_stack_ptr] |
122 | if DEBUG ;glopLoadIdentity |
122 | if DEBUG ;glopLoadIdentity |
123 | stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
123 | stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
124 | end if |
124 | end if |
125 | gl_matrix_update eax,ebx |
125 | gl_matrix_update eax,ebx |
126 | ret |
126 | ret |
127 | endp |
127 | endp |
128 | 128 | ||
129 | align 4 |
129 | align 4 |
130 | proc glopMultMatrix uses eax edi esi, context:dword, p:dword |
130 | proc glopMultMatrix uses eax edi esi, context:dword, p:dword |
131 | locals |
131 | locals |
132 | m M4 |
132 | m M4 |
133 | endl |
133 | endl |
134 | mov esi,[p] |
134 | mov esi,[p] |
135 | add esi,4 |
135 | add esi,4 |
136 | mov edi,ebp |
136 | mov edi,ebp |
137 | sub edi,sizeof.M4 |
137 | sub edi,sizeof.M4 |
138 | stdcall gl_M4_Transpose,edi,esi ;транспонируем входную матрицу в локальную матрицу m |
138 | stdcall gl_M4_Transpose,edi,esi ;транспонируем входную матрицу в локальную матрицу m |
139 | 139 | ||
140 | mov eax,[context] |
140 | mov eax,[context] |
141 | mov esi,[eax+offs_cont_matrix_mode] |
141 | mov esi,[eax+offs_cont_matrix_mode] |
142 | shl esi,2 |
142 | shl esi,2 |
143 | add esi,eax |
143 | add esi,eax |
144 | stdcall gl_M4_MulLeft,dword[esi+offs_cont_matrix_stack_ptr],edi |
144 | stdcall gl_M4_MulLeft,dword[esi+offs_cont_matrix_stack_ptr],edi |
145 | 145 | ||
146 | gl_matrix_update eax,edi |
146 | gl_matrix_update eax,edi |
147 | ret |
147 | ret |
148 | endp |
148 | endp |
149 | 149 | ||
150 | align 4 |
150 | align 4 |
151 | proc glopPushMatrix uses eax ebx, context:dword, p:dword |
151 | proc glopPushMatrix uses eax ebx, context:dword, p:dword |
152 | mov eax,[context] |
152 | mov eax,[context] |
153 | mov ebx,[eax+offs_cont_matrix_mode] |
153 | mov ebx,[eax+offs_cont_matrix_mode] |
154 | 154 | ||
155 | ; assert( (c->matrix_stack_ptr[ebx] - c->matrix_stack[ebx] + 1 ) |
155 | ; assert( (c->matrix_stack_ptr[ebx] - c->matrix_stack[ebx] + 1 ) |
156 | ; < c->matrix_stack_depth_max[ebx] ); |
156 | ; < c->matrix_stack_depth_max[ebx] ); |
157 | 157 | ||
158 | shl ebx,2 |
158 | shl ebx,2 |
159 | add ebx,eax |
159 | add ebx,eax |
160 | add ebx,offs_cont_matrix_stack_ptr |
160 | add ebx,offs_cont_matrix_stack_ptr |
161 | add dword[ebx],sizeof.M4 |
161 | add dword[ebx],sizeof.M4 |
162 | mov ebx,[ebx] ;ebx = ++context.matrix_stack_ptr[context.matrix_mode] |
162 | mov ebx,[ebx] ;ebx = ++context.matrix_stack_ptr[context.matrix_mode] |
163 | 163 | ||
164 | sub ebx,sizeof.M4 |
164 | sub ebx,sizeof.M4 |
165 | push ebx |
165 | push ebx |
166 | add ebx,sizeof.M4 |
166 | add ebx,sizeof.M4 |
167 | stdcall gl_M4_Move, ebx |
167 | stdcall gl_M4_Move, ebx |
168 | 168 | ||
169 | gl_matrix_update eax,ebx |
169 | gl_matrix_update eax,ebx |
170 | ret |
170 | ret |
171 | endp |
171 | endp |
172 | 172 | ||
173 | align 4 |
173 | align 4 |
174 | proc glopPopMatrix uses eax ebx, context:dword, p:dword |
174 | proc glopPopMatrix uses eax ebx, context:dword, p:dword |
175 | mov eax,[context] |
175 | mov eax,[context] |
176 | mov ebx,[eax+offs_cont_matrix_mode] |
176 | mov ebx,[eax+offs_cont_matrix_mode] |
177 | 177 | ||
178 | ; assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] ); |
178 | ; assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] ); |
179 | 179 | ||
180 | shl ebx,2 |
180 | shl ebx,2 |
181 | add ebx,eax |
181 | add ebx,eax |
182 | sub dword[ebx+offs_cont_matrix_stack_ptr],sizeof.M4 |
182 | sub dword[ebx+offs_cont_matrix_stack_ptr],sizeof.M4 |
183 | 183 | ||
184 | gl_matrix_update eax,ebx |
184 | gl_matrix_update eax,ebx |
185 | ret |
185 | ret |
186 | endp |
186 | endp |
187 | 187 | ||
188 | align 4 |
188 | align 4 |
189 | proc glopRotate uses eax ebx ecx, context:dword, p:dword |
189 | proc glopRotate uses eax ebx ecx edx, context:dword, p:dword |
190 | locals |
190 | locals |
191 | u0 dd ? |
191 | u0 dd ? |
192 | u1 dd ? |
192 | u1 dd ? |
193 | u2 dd ? |
193 | u2 dd ? |
194 | angle dd ? |
194 | angle dd ? |
195 | cost dd ? |
195 | cost dd ? |
196 | sint dd ? |
196 | sint dd ? |
197 | m M4 |
197 | m M4 |
198 | endl |
198 | endl |
199 | 199 | ||
200 | mov eax,[context] |
200 | mov eax,[context] |
201 | mov ebx,[p] |
201 | mov ebx,[p] |
202 | mov ecx,ebp |
202 | mov ecx,ebp |
203 | sub ecx,sizeof.M4 ;ecx=&m |
203 | sub ecx,sizeof.M4 ;ecx=&m |
204 | finit |
204 | finit |
205 | fldpi |
205 | fldpi |
206 | fmul dword[ebx+4] |
206 | fmul dword[ebx+4] |
207 | fdiv dword[an180f] |
207 | fdiv dword[an180f] |
208 | fst dword[angle] ;angle = p[1].f * M_PI / 180.0 |
208 | fst dword[angle] ;angle = p[1].f * M_PI / 180.0 |
209 | ;st0 = angle |
209 | ;st0 = angle |
210 | 210 | ||
211 | fldz |
- | |
212 | fild dword[ebx+8] |
- | |
213 | fstp dword[u0] |
- | |
214 | fild dword[ebx+12] |
- | |
215 | fstp dword[u1] |
- | |
216 | fild dword[ebx+16] |
- | |
217 | fst dword[u2] |
- | |
218 | - | ||
219 | ; simple case detection |
211 | ; simple case detection |
220 | xor ebx,ebx |
212 | xor edx,edx |
221 | fcomp st1 ;u2 ... 0 |
213 | fld dword[ebx+16] |
- | 214 | ftst |
|
222 | fstsw ax |
215 | fstsw ax |
223 | sahf |
216 | sahf |
224 | je @f |
217 | je @f |
225 | inc ebx |
218 | inc edx |
226 | @@: |
219 | @@: |
227 | fcom dword[u1] ;0 ... u1 |
220 | fstp dword[u2] |
228 | fstsw ax |
221 | fld dword[ebx+12] |
- | 222 | ftst |
|
- | 223 | fstsw ax |
|
229 | sahf |
224 | sahf |
230 | je @f |
225 | je @f |
231 | or ebx,2 |
226 | or edx,2 |
232 | @@: |
227 | @@: |
233 | fcom dword[u0] ;0 ... u0 |
228 | fstp dword[u1] |
234 | fstsw ax |
229 | fld dword[ebx+8] |
- | 230 | ftst |
|
- | 231 | fstsw ax |
|
235 | sahf |
232 | sahf |
236 | je @f |
233 | je @f |
237 | or ebx,4 |
234 | or edx,4 |
238 | @@: |
235 | @@: |
239 | ;st0 = 0, st1 = angle |
236 | fstp dword[u0] |
240 | 237 | ||
- | 238 | ;st0 = angle |
|
241 | ;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0) |
239 | ;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0) |
242 | cmp ebx,0 |
240 | or edx,edx |
243 | je .end_f ;если нет поворотов выход из функции |
241 | jz .end_f ;если нет поворотов выход из функции |
244 | cmp ebx,4 |
242 | cmp edx,4 |
245 | jne @f |
243 | jne @f |
246 | fcomp dword[u0] ;0 ... u0 |
244 | fld dword[u0] |
- | 245 | ftst |
|
247 | fstsw ax |
246 | fstsw ax |
- | 247 | ffree st0 |
|
- | 248 | fincstp |
|
248 | sahf |
249 | sahf |
249 | jae .u0ch |
250 | jae .u0ch |
250 | fchs |
- | |
251 | fstp dword[angle] ;if (u0 < 0) angle *= -1 |
251 | fchs ;if (u0 < 0) angle *= -1 |
252 | .u0ch: |
252 | .u0ch: |
- | 253 | push dword 0 |
|
- | 254 | fstp dword[esp-4] |
|
- | 255 | sub esp,4 |
|
253 | stdcall gl_M4_Rotate, ecx,[angle],0 |
256 | stdcall gl_M4_Rotate, ecx |
254 | jmp .end_sw |
257 | jmp .end_sw |
255 | @@: |
258 | @@: |
256 | cmp ebx,2 |
259 | cmp edx,2 |
257 | jne @f |
260 | jne @f |
258 | fcomp dword[u1] ;0 ... u1 |
261 | fld dword[u1] |
- | 262 | ftst |
|
259 | fstsw ax |
263 | fstsw ax |
- | 264 | ffree st0 |
|
- | 265 | fincstp |
|
260 | sahf |
266 | sahf |
261 | jae .u1ch |
267 | jae .u1ch |
262 | fchs |
- | |
263 | fstp dword[angle] ;if (u1 < 0) angle *= -1 |
268 | fchs ;if (u1 < 0) angle *= -1 |
264 | .u1ch: |
269 | .u1ch: |
- | 270 | push dword 1 |
|
- | 271 | fstp dword[esp-4] |
|
- | 272 | sub esp,4 |
|
265 | stdcall gl_M4_Rotate, ecx,[angle],1 |
273 | stdcall gl_M4_Rotate, ecx |
266 | jmp .end_sw |
274 | jmp .end_sw |
267 | @@: |
275 | @@: |
268 | cmp ebx,1 |
276 | cmp edx,1 |
269 | jne @f |
277 | jne @f |
270 | fcomp dword[u2] ;0 ... u2 |
278 | fld dword[u2] |
- | 279 | ftst |
|
271 | fstsw ax |
280 | fstsw ax |
- | 281 | ffree st0 |
|
- | 282 | fincstp |
|
272 | sahf |
283 | sahf |
273 | jae .u2ch |
284 | jae .u2ch |
274 | fchs |
- | |
275 | fstp dword[angle] ;if (u2 < 0) angle *= -1 |
285 | fchs ;if (u2 < 0) angle *= -1 |
276 | .u2ch: |
286 | .u2ch: |
- | 287 | push dword 2 |
|
- | 288 | fstp dword[esp-4] |
|
- | 289 | sub esp,4 |
|
277 | stdcall gl_M4_Rotate, ecx,[angle],2 |
290 | stdcall gl_M4_Rotate, ecx |
278 | jmp .end_sw |
291 | jmp .end_sw |
279 | @@: ;default: |
292 | @@: ;default: |
280 | if DEBUG ;glopRotete |
293 | if DEBUG ;glopRotete |
281 | stdcall dbg_print,txt_sp,m_1 |
294 | stdcall dbg_print,txt_sp,m_1 |
282 | end if |
295 | end if |
283 | 296 | ||
284 | ; normalize vector |
297 | ; normalize vector |
285 | fld dword[u0] |
298 | fld dword[u0] |
286 | fmul st0,st0 |
299 | fmul st0,st0 |
287 | fld dword[u1] |
300 | fld dword[u1] |
288 | fmul st0,st0 |
301 | fmul st0,st0 |
289 | fld dword[u2] |
302 | faddp |
- | 303 | fld dword[u2] |
|
290 | fmul st0,st0 |
304 | fmul st0,st0 |
291 | fadd st0,st1 |
305 | faddp |
292 | fadd st0,st2 |
- | |
293 | ; fst dword[len] ;len = u0*u0+u1*u1+u2*u2 |
306 | ; fst dword[len] ;len = u0*u0+u1*u1+u2*u2 |
294 | fcom st1 |
307 | ftst |
295 | fstsw ax |
308 | fstsw ax |
296 | sahf |
309 | sahf |
297 | je .end_f ;if (len == 0.0f) return |
310 | je .f2 ;if (len == 0.0f) return |
298 | fsqrt |
311 | fsqrt |
299 | fld1 |
312 | fld1 |
300 | fdiv st0,st1 |
313 | fxch |
301 | ; fst dword[len] ;len = 1.0f / sqrt(len) |
314 | fdivp ;len = 1.0f / sqrt(len) |
302 | fld dword[u0] |
315 | ; fst dword[len] |
- | 316 | fld dword[u0] |
|
303 | fmul st0,st1 |
317 | fmul st0,st1 |
304 | fstp dword[u0] ;u0 *= len |
318 | fstp dword[u0] ;u0 *= len |
305 | fld dword[u1] |
319 | fld dword[u1] |
306 | fmul st0,st1 |
320 | fmul st0,st1 |
307 | fstp dword[u1] ;u1 *= len |
321 | fstp dword[u1] ;u1 *= len |
308 | fld dword[u2] |
322 | fld dword[u2] |
309 | fmul st0,st1 |
323 | fmul st0,st1 |
310 | fstp dword[u2] ;u2 *= len |
324 | fstp dword[u2] ;u2 *= len |
311 | ;st0 = len, st1=..., st2=..., st3 = 0, st4 = angle |
325 | ;st0 = len, st1 = angle |
312 | 326 | ffree st0 |
|
- | 327 | fincstp |
|
- | 328 | ||
313 | ; store cos and sin values |
329 | ; store cos and sin values |
314 | finit |
- | |
315 | fld dword[angle] |
- | |
316 | fcos |
330 | fcos |
317 | fst dword[cost] ;cost=cos(angle) |
331 | fst dword[cost] ;cost=cos(angle) |
318 | fld dword[angle] |
332 | fld dword[angle] |
319 | fsin |
333 | fsin |
320 | fst dword[sint] ;sint=sin(angle) |
334 | fst dword[sint] ;sint=sin(angle) |
321 | 335 | ||
322 | ; fill in the values |
336 | ; fill in the values |
323 | mov ebx,0.0 |
337 | mov ebx,0.0 |
324 | mov [ecx+3*16 ],ebx ;m[3][0] |
338 | mov [ecx+3*16 ],ebx ;m[3][0] |
325 | mov [ecx+3*16 +4],ebx ;m[3][1] |
339 | mov [ecx+3*16 +4],ebx ;m[3][1] |
326 | mov [ecx+3*16 +8],ebx ;m[3][2] |
340 | mov [ecx+3*16 +8],ebx ;m[3][2] |
327 | mov [ecx+ 12],ebx ;m[0][3] |
341 | mov [ecx+ 12],ebx ;m[0][3] |
328 | mov [ecx+ 16+12],ebx ;m[1][3] |
342 | mov [ecx+ 16+12],ebx ;m[1][3] |
329 | mov [ecx+2*16+12],ebx ;m[2][3] |
343 | mov [ecx+2*16+12],ebx ;m[2][3] |
330 | mov ebx,1.0 |
344 | mov ebx,1.0 |
331 | mov [ecx+3*16+12],ebx ;m[3][3] |
345 | mov [ecx+3*16+12],ebx ;m[3][3] |
332 | 346 | ||
333 | ; do the math |
347 | ; do the math |
334 | ; m.m[0][0]=u[0]*u[0]+cost*(1-u[0]*u[0]); |
348 | fld dword[u0] |
- | 349 | fmul st0,st0 |
|
- | 350 | fld1 |
|
- | 351 | fsub st0,st1 |
|
- | 352 | fmul st0,st3 ;st0 = cost*(1-u0^2) |
|
- | 353 | faddp |
|
- | 354 | fstp dword[ecx] ;m[0][0] = u0*u0+cost*(1-u0*u0) |
|
335 | ; m.m[1][0]=u[0]*u[1]*(1-cost)-u[2]*sint; |
355 | |
- | 356 | fld1 |
|
- | 357 | fsub st0,st2 ;st0 = 1-cost |
|
- | 358 | ||
- | 359 | fld st0 |
|
- | 360 | fmul dword[u0] |
|
- | 361 | fmul dword[u1] |
|
- | 362 | fld dword[u2] |
|
- | 363 | fmul st0,st3 ;st0 = u2*sint |
|
- | 364 | fchs |
|
- | 365 | faddp |
|
- | 366 | fstp dword[ecx+16] ;m[1][0] = u0*u1*(1-cost)-u2*sint |
|
336 | ; m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint; |
367 | |
- | 368 | fld st0 |
|
- | 369 | fmul dword[u0] |
|
- | 370 | fmul dword[u2] |
|
- | 371 | fld dword[u1] |
|
- | 372 | fmul st0,st3 ;st0 = u1*sint |
|
- | 373 | faddp |
|
- | 374 | fstp dword[ecx+32] ;m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint |
|
337 | ; m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint; |
375 | |
- | 376 | fld st0 |
|
- | 377 | fmul dword[u0] |
|
- | 378 | fmul dword[u1] |
|
- | 379 | fld dword[u2] |
|
- | 380 | fmul st0,st3 ;st0 = u2*sint |
|
- | 381 | faddp |
|
- | 382 | fstp dword[ecx+4] ;m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint |
|
338 | ; m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1]); |
383 | |
- | 384 | fld dword[u1] |
|
- | 385 | fmul st0,st0 |
|
- | 386 | fld1 |
|
- | 387 | fsub st0,st1 |
|
- | 388 | fmul st0,st4 ;st0 = cost*(1-u1^2) |
|
- | 389 | faddp |
|
- | 390 | fstp dword[ecx+20] ;m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1]) |
|
339 | ; m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint; |
391 | |
- | 392 | fld st0 |
|
- | 393 | fmul dword[u1] |
|
- | 394 | fmul dword[u2] |
|
- | 395 | fld dword[u0] |
|
- | 396 | fmul st0,st3 ;st0 = u0*sint |
|
- | 397 | fchs |
|
- | 398 | faddp |
|
- | 399 | fstp dword[ecx+36] ;m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint |
|
340 | ; m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint; |
400 | |
- | 401 | fld st0 |
|
- | 402 | fmul dword[u0] |
|
- | 403 | fmul dword[u2] |
|
- | 404 | fld dword[u1] |
|
- | 405 | fmul st0,st3 ;st0 = u1*sint |
|
- | 406 | fchs |
|
- | 407 | faddp |
|
- | 408 | fstp dword[ecx+8] ;m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint |
|
341 | ; m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint; |
409 | |
- | 410 | fld st0 |
|
- | 411 | fmul dword[u1] |
|
- | 412 | fmul dword[u2] |
|
- | 413 | fld dword[u0] |
|
- | 414 | fmul st0,st3 ;st0 = u0*sint |
|
- | 415 | faddp |
|
- | 416 | fstp dword[ecx+24] ;m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint |
|
342 | ; m.m[2][2]=u[2]*u[2]+cost*(1-u[2]*u[2]); |
417 | |
- | 418 | ffree st0 ;1-cost |
|
- | 419 | fincstp |
|
- | 420 | ||
- | 421 | fld dword[u2] |
|
- | 422 | fmul st0,st0 |
|
- | 423 | fld1 |
|
- | 424 | fsub st0,st1 |
|
- | 425 | fmul st0,st3 ;st0 = cost*(1-u2^2) |
|
- | 426 | faddp |
|
- | 427 | fstp dword[ecx+40] ;m[2][2] = u2*u2+cost*(1-u2*u2) |
|
343 | .end_sw: |
428 | |
- | 429 | ffree st0 ;sint |
|
- | 430 | fincstp |
|
- | 431 | ffree st0 ;cost |
|
- | 432 | fincstp |
|
- | 433 | .end_sw: |
|
344 | 434 | ||
345 | mov eax,[context] |
435 | mov eax,[context] |
346 | mov ebx,[eax+offs_cont_matrix_mode] |
436 | mov ebx,[eax+offs_cont_matrix_mode] |
347 | shl ebx,2 |
437 | shl ebx,2 |
348 | add ebx,eax |
438 | add ebx,eax |
349 | stdcall gl_M4_MulLeft,dword[ebx+offs_cont_matrix_stack_ptr],ecx |
439 | stdcall gl_M4_MulLeft,dword[ebx+offs_cont_matrix_stack_ptr],ecx |
350 | if DEBUG ;glopRotete |
440 | if DEBUG ;glopRotete |
351 | stdcall gl_print_matrix,ecx,4 |
441 | stdcall gl_print_matrix,ecx,4 |
352 | end if |
442 | end if |
353 | gl_matrix_update eax,ebx |
443 | gl_matrix_update eax,ebx |
354 | .end_f: |
444 | jmp .end_f |
- | 445 | .f2: |
|
- | 446 | ffree st0 ;len |
|
- | 447 | fincstp |
|
- | 448 | ffree st0 ;angle |
|
- | 449 | fincstp |
|
- | 450 | .end_f: |
|
355 | ret |
451 | ret |
356 | endp |
452 | endp |
357 | 453 | ||
358 | align 4 |
454 | align 4 |
359 | proc glopScale uses eax ebx ecx, context:dword, p:dword |
455 | proc glopScale uses eax ebx ecx, context:dword, p:dword |
360 | mov ecx,[p] |
456 | mov ecx,[p] |
361 | 457 | ||
362 | mov eax,[context] |
458 | mov eax,[context] |
363 | mov ebx,[eax+offs_cont_matrix_mode] |
459 | mov ebx,[eax+offs_cont_matrix_mode] |
364 | shl ebx,2 |
460 | shl ebx,2 |
365 | add ebx,eax |
461 | add ebx,eax |
366 | mov ebx,[ebx+offs_cont_matrix_stack_ptr] ;ebx = &m[0] |
462 | mov ebx,[ebx+offs_cont_matrix_stack_ptr] ;ebx = &m[0] |
367 | 463 | ||
368 | fld dword[ecx+ 4] ;x |
464 | fld dword[ecx+ 4] ;x |
369 | fld dword[ecx+ 8] ;y |
465 | fld dword[ecx+ 8] ;y |
370 | fld dword[ecx+12] ;z |
466 | fld dword[ecx+12] ;z |
371 | mov ecx,4 |
467 | mov ecx,4 |
372 | @@: |
468 | @@: |
373 | fld dword[ebx] ;m[0] |
469 | fld dword[ebx] ;m[0] |
374 | fmul st0,st3 ;m[0] * x |
470 | fmul st0,st3 ;m[0] * x |
375 | fstp dword[ebx] ;m[0] *= x |
471 | fstp dword[ebx] ;m[0] *= x |
376 | fld dword[ebx+4] ;m[1] |
472 | fld dword[ebx+4] ;m[1] |
377 | fmul st0,st2 ;m[1] * y |
473 | fmul st0,st2 ;m[1] * y |
378 | fstp dword[ebx+4];m[1] *= y |
474 | fstp dword[ebx+4];m[1] *= y |
379 | fld dword[ebx+8] ;m[2] |
475 | fld dword[ebx+8] ;m[2] |
380 | fmul st0,st1 ;m[2] * z |
476 | fmul st0,st1 ;m[2] * z |
381 | fstp dword[ebx+8];m[2] *= z |
477 | fstp dword[ebx+8];m[2] *= z |
382 | add ebx,16 |
478 | add ebx,16 |
383 | loop @b |
479 | loop @b |
384 | 480 | ffree st0 |
|
- | 481 | fincstp |
|
- | 482 | ffree st0 |
|
- | 483 | fincstp |
|
- | 484 | ffree st0 |
|
- | 485 | fincstp |
|
- | 486 | ||
385 | if DEBUG ;glopScale |
487 | if DEBUG ;glopScale |
386 | pushad |
488 | pushad |
387 | stdcall dbg_print,txt_gl_scal,txt_nl |
489 | stdcall dbg_print,txt_gl_scal,txt_nl |
388 | mov ebx,[eax+offs_cont_matrix_mode] |
490 | mov ebx,[eax+offs_cont_matrix_mode] |
389 | shl ebx,2 |
491 | shl ebx,2 |
390 | add ebx,eax |
492 | add ebx,eax |
391 | stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
493 | stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
392 | popad |
494 | popad |
393 | end if |
495 | end if |
394 | gl_matrix_update eax,ebx |
496 | gl_matrix_update eax,ebx |
395 | ret |
497 | ret |
396 | endp |
498 | endp |
397 | 499 | ||
398 | align 4 |
500 | align 4 |
399 | proc glopTranslate uses eax ebx ecx, context:dword, p:dword |
501 | proc glopTranslate uses eax ebx ecx, context:dword, p:dword |
400 | mov ecx,[p] |
502 | mov ecx,[p] |
401 | 503 | ||
402 | mov eax,[context] |
504 | mov eax,[context] |
403 | mov ebx,[eax+offs_cont_matrix_mode] |
505 | mov ebx,[eax+offs_cont_matrix_mode] |
404 | shl ebx,2 |
506 | shl ebx,2 |
405 | add ebx,eax |
507 | add ebx,eax |
406 | mov ebx,[ebx+offs_cont_matrix_stack_ptr] ;ebx = &m[0] |
508 | mov ebx,[ebx+offs_cont_matrix_stack_ptr] ;ebx = &m[0] |
407 | 509 | ||
408 | fld dword[ecx+ 4] ;x |
510 | fld dword[ecx+ 4] ;x |
409 | fld dword[ecx+ 8] ;y |
511 | fld dword[ecx+ 8] ;y |
410 | fld dword[ecx+12] ;z |
512 | fld dword[ecx+12] ;z |
411 | mov ecx,4 |
513 | mov ecx,4 |
412 | @@: |
514 | @@: |
413 | fld dword[ebx] ;m[0] |
515 | fld dword[ebx] ;m[0] |
414 | fmul st0,st3 ;m[0] * x |
516 | fmul st0,st3 ;m[0] * x |
415 | fld dword[ebx+4] ;m[1] |
517 | fld dword[ebx+4] ;m[1] |
416 | fmul st0,st3 ;m[1] * y |
518 | fmul st0,st3 ;m[1] * y |
417 | faddp |
519 | faddp |
418 | fld dword[ebx+8] ;m[2] |
520 | fld dword[ebx+8] ;m[2] |
419 | fmul st0,st2 ;m[2] * z |
521 | fmul st0,st2 ;m[2] * z |
420 | faddp |
522 | faddp |
421 | fadd dword[ebx+12] ;m[3] |
523 | fadd dword[ebx+12] ;m[3] |
422 | fstp dword[ebx+12] ;m[3] = m[0] * x + m[1] * y + m[2] * z + m[3] |
524 | fstp dword[ebx+12] ;m[3] = m[0] * x + m[1] * y + m[2] * z + m[3] |
423 | add ebx,16 |
525 | add ebx,16 |
424 | loop @b |
526 | loop @b |
425 | ffree st0 |
527 | ffree st0 |
426 | fincstp |
528 | fincstp |
427 | ffree st0 |
529 | ffree st0 |
428 | fincstp |
530 | fincstp |
429 | ffree st0 |
531 | ffree st0 |
430 | fincstp |
532 | fincstp |
431 | 533 | ||
432 | if DEBUG ;glopTranslate |
534 | if DEBUG ;glopTranslate |
433 | pushad |
535 | pushad |
434 | stdcall dbg_print,txt_gl_tran,txt_nl |
536 | stdcall dbg_print,txt_gl_tran,txt_nl |
435 | mov ebx,[eax+offs_cont_matrix_mode] |
537 | mov ebx,[eax+offs_cont_matrix_mode] |
436 | shl ebx,2 |
538 | shl ebx,2 |
437 | add ebx,eax |
539 | add ebx,eax |
438 | stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
540 | stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 |
439 | popad |
541 | popad |
440 | end if |
542 | end if |
441 | gl_matrix_update eax,ebx |
543 | gl_matrix_update eax,ebx |
442 | ret |
544 | ret |
443 | endp |
545 | endp |
444 | 546 | ||
445 | align 4 |
547 | align 4 |
446 | proc glopFrustum uses eax ebx ecx, context:dword, p:dword |
548 | proc glopFrustum uses eax ebx ecx, context:dword, p:dword |
447 | locals |
549 | locals |
448 | x dd ? |
550 | x dd ? |
449 | y dd ? |
551 | y dd ? |
450 | A dd ? |
552 | A dd ? |
451 | B dd ? |
553 | B dd ? |
452 | C dd ? |
554 | C dd ? |
453 | D dd ? |
555 | D dd ? |
454 | m M4 |
556 | m M4 |
455 | endl |
557 | endl |
456 | mov eax,[context] |
558 | mov eax,[context] |
457 | mov ebx,[p] |
559 | mov ebx,[p] |
458 | 560 | ||
459 | fld dword[ebx+8] |
561 | fld dword[ebx+8] |
460 | fsub dword[ebx+4] ;st0 = (right-left) |
562 | fsub dword[ebx+4] ;st0 = (right-left) |
461 | fld dword[ebx+20] ;st0 = near |
563 | fld dword[ebx+20] ;st0 = near |
462 | fadd st0,st0 |
564 | fadd st0,st0 |
463 | fdiv st0,st1 |
565 | fdiv st0,st1 |
464 | fstp dword[x] ;x = (2.0*near) / (right-left) |
566 | fstp dword[x] ;x = (2.0*near) / (right-left) |
465 | fld dword[ebx+16] |
567 | fld dword[ebx+16] |
466 | fsub dword[ebx+12] ;st0 = (top-bottom) |
568 | fsub dword[ebx+12] ;st0 = (top-bottom) |
467 | fld dword[ebx+20] ;st0 = near |
569 | fld dword[ebx+20] ;st0 = near |
468 | fadd st0,st0 |
570 | fadd st0,st0 |
469 | fdiv st0,st1 |
571 | fdiv st0,st1 |
470 | fstp dword[y] ;y = (2.0*near) / (top-bottom) |
572 | fstp dword[y] ;y = (2.0*near) / (top-bottom) |
471 | fld dword[ebx+8] |
573 | fld dword[ebx+8] |
472 | fadd dword[ebx+4] ;st0 = (right+left) |
574 | fadd dword[ebx+4] ;st0 = (right+left) |
473 | fdiv st0,st2 ;st2 = (right-left) |
575 | fdiv st0,st2 ;st2 = (right-left) |
474 | fstp dword[A] ;A = (right+left) / (right-left) |
576 | fstp dword[A] ;A = (right+left) / (right-left) |
475 | fld dword[ebx+16] |
577 | fld dword[ebx+16] |
476 | fadd dword[ebx+12] ;st0 = (top+bottom) |
578 | fadd dword[ebx+12] ;st0 = (top+bottom) |
477 | fdiv st0,st1 ;st1 = (top-bottom) |
579 | fdiv st0,st1 ;st1 = (top-bottom) |
478 | fstp dword[B] ;B = (top+bottom) / (top-bottom) |
580 | fstp dword[B] ;B = (top+bottom) / (top-bottom) |
479 | fld dword[ebx+24] |
581 | fld dword[ebx+24] |
480 | fsub dword[ebx+20] ;st0 = (farp-near) |
582 | fsub dword[ebx+20] ;st0 = (farp-near) |
481 | fldz |
583 | fldz |
482 | fsub dword[ebx+24] |
584 | fsub dword[ebx+24] |
483 | fsub dword[ebx+20] ;st0 = -(farp+near) |
585 | fsub dword[ebx+20] ;st0 = -(farp+near) |
484 | fdiv st0,st1 |
586 | fdiv st0,st1 |
485 | fstp dword[C] ;C = -(farp+near) / (farp-near) |
587 | fstp dword[C] ;C = -(farp+near) / (farp-near) |
486 | fld dword[ebx+24] |
588 | fld dword[ebx+24] |
487 | fmul dword[ebx+20] ;st0 = farp*near |
589 | fmul dword[ebx+20] ;st0 = farp*near |
488 | fadd st0,st0 |
590 | fadd st0,st0 |
489 | fchs ;st0 = -(2.0*farp*near) |
591 | fchs ;st0 = -(2.0*farp*near) |
490 | fdiv st0,st1 |
592 | fdiv st0,st1 |
491 | fstp dword[D] ;D = -(2.0*farp*near) / (farp-near) |
593 | fstp dword[D] ;D = -(2.0*farp*near) / (farp-near) |
492 | 594 | ||
493 | mov ecx,ebp |
595 | mov ecx,ebp |
494 | sub ecx,sizeof.M4 |
596 | sub ecx,sizeof.M4 |
495 | 597 | ||
496 | mov ebx,[x] |
598 | mov ebx,[x] |
497 | mov dword[ecx],ebx |
599 | mov dword[ecx],ebx |
498 | mov dword[ecx+4],0.0 |
600 | mov dword[ecx+4],0.0 |
499 | mov ebx,[A] |
601 | mov ebx,[A] |
500 | mov dword[ecx+8],ebx |
602 | mov dword[ecx+8],ebx |
501 | mov dword[ecx+12],0.0 |
603 | mov dword[ecx+12],0.0 |
502 | mov dword[ecx+16],0.0 |
604 | mov dword[ecx+16],0.0 |
503 | mov ebx,[y] |
605 | mov ebx,[y] |
504 | mov dword[ecx+20],ebx |
606 | mov dword[ecx+20],ebx |
505 | mov ebx,[B] |
607 | mov ebx,[B] |
506 | mov dword[ecx+24],ebx |
608 | mov dword[ecx+24],ebx |
507 | mov dword[ecx+28],0.0 |
609 | mov dword[ecx+28],0.0 |
508 | mov dword[ecx+32],0.0 |
610 | mov dword[ecx+32],0.0 |
509 | mov dword[ecx+36],0.0 |
611 | mov dword[ecx+36],0.0 |
510 | mov ebx,[C] |
612 | mov ebx,[C] |
511 | mov dword[ecx+40],ebx |
613 | mov dword[ecx+40],ebx |
512 | mov ebx,[D] |
614 | mov ebx,[D] |
513 | mov dword[ecx+44],ebx |
615 | mov dword[ecx+44],ebx |
514 | mov dword[ecx+48],0.0 |
616 | mov dword[ecx+48],0.0 |
515 | mov dword[ecx+52],0.0 |
617 | mov dword[ecx+52],0.0 |
516 | mov dword[ecx+56],-1.0 |
618 | mov dword[ecx+56],-1.0 |
517 | mov dword[ecx+60],0.0 |
619 | mov dword[ecx+60],0.0 |
518 | 620 | ||
519 | mov ebx,[eax+offs_cont_matrix_mode] |
621 | mov ebx,[eax+offs_cont_matrix_mode] |
520 | shl ebx,2 |
622 | shl ebx,2 |
521 | add ebx,eax |
623 | add ebx,eax |
522 | stdcall gl_M4_MulLeft,dword[ebx+offs_cont_matrix_stack_ptr],ecx |
624 | stdcall gl_M4_MulLeft,dword[ebx+offs_cont_matrix_stack_ptr],ecx |
523 | 625 | ||
524 | if DEBUG ;glopFrustum |
626 | if DEBUG ;glopFrustum |
525 | stdcall gl_print_matrix,ecx,4 |
627 | stdcall gl_print_matrix,ecx,4 |
526 | stdcall gl_print_matrix,dword[ebx+offs_cont_matrix_stack_ptr],4 |
628 | stdcall gl_print_matrix,dword[ebx+offs_cont_matrix_stack_ptr],4 |
527 | end if |
629 | end if |
528 | gl_matrix_update eax,ebx |
630 | gl_matrix_update eax,ebx |
529 | ret |
631 | ret |
530 | endp>>>1)><1)>2)><2)>> |
632 | endp>>>1)><1)>2)><2)>> |