Rev 1245 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2984 | leency | 1 | do_sinus: |
2 | .x equ [ebp-8] |
||
3 | .y equ [ebp-12] |
||
4 | .new_y equ [ebp-16] |
||
5 | .temp equ [ebp-20] |
||
6 | push ebp |
||
7 | mov ebp,esp |
||
8 | sub esp,64 |
||
9 | mov dword .x,0 |
||
10 | mov dword .y,0 |
||
11 | mov esi,[screen_ptr] |
||
12 | mov edi,[Zbuffer_ptr] |
||
13 | push edi |
||
14 | ; clear Zbuffer temporally used as image buffer |
||
15 | mov ecx,SIZE_X*SIZE_Y |
||
16 | xor eax,eax |
||
17 | cld |
||
18 | rep stosd |
||
19 | pop edi |
||
20 | ; movzx eax,[sinus_flag] |
||
21 | ; mov edx,10 |
||
22 | ; mul edx |
||
23 | ; mov [sin_amplitude],eax |
||
24 | ; mov [sin_frq],eax |
||
25 | fninit |
||
26 | ;if Ext = SSE2 |
||
27 | ; movups xmm1,[const0123] ; xmm1 - init values |
||
28 | ; mov eax,0x000000ff |
||
29 | ; movd xmm2,eax |
||
30 | ; shufps xmm2,xmm2,0 ; xmm2 - mask value |
||
31 | ; mov eax,4 |
||
32 | ; movd xmm3,eax |
||
33 | ; shufps xmm3,xmm3,0 |
||
34 | .again: |
||
35 | if 0 |
||
36 | fild dword .x |
||
37 | fidiv [sin_frq] |
||
38 | fsin |
||
39 | fimul [sin_amplitude] |
||
40 | fiadd dword .y |
||
41 | fistp dword .new_y |
||
42 | else |
||
43 | fild dword .x |
||
44 | fmul [sin_frq] |
||
45 | fistp dword .temp |
||
46 | mov eax, .temp |
||
47 | ; mov bx, [angle_x] |
||
48 | ; add bx, [angle_y] |
||
49 | ; movzx ebx,bx |
||
50 | ; shr ebx,1 ; change phase |
||
51 | ; add eax,ebx |
||
52 | |||
53 | |||
54 | and eax, 0x000000ff |
||
55 | |||
56 | ; cdq |
||
57 | ; mul [sin_frq] |
||
58 | ; and eax,0x000000ff |
||
59 | ; and ax,0x00ff |
||
60 | ; cwde |
||
61 | |||
62 | fld dword [sin_tab+eax*4] |
||
63 | fimul dword [sin_amplitude] |
||
64 | fiadd dword .y |
||
65 | fistp dword .new_y |
||
66 | end if |
||
67 | mov eax,.new_y |
||
68 | or eax,eax |
||
69 | jl .skip |
||
70 | cmp eax,SIZE_Y |
||
71 | jg .skip |
||
72 | ; mov edx,SIZE_X |
||
73 | ; mul edx |
||
74 | shl eax,9 |
||
75 | add eax,dword .x |
||
76 | lea ebx,[eax*3] |
||
77 | mov eax,[esi] |
||
78 | mov [edi+ebx],eax |
||
79 | .skip: |
||
80 | add esi,3 |
||
81 | inc dword .x |
||
82 | cmp dword .x,SIZE_X |
||
83 | jl .again |
||
84 | mov dword .x,0 |
||
85 | inc dword .y |
||
86 | cmp dword .y,SIZE_Y |
||
87 | jl .again |
||
88 | |||
89 | ; copy from temporary buffer -> Zbuffer to screen |
||
90 | mov esi,[Zbuffer_ptr] |
||
91 | mov edi,[screen_ptr] |
||
92 | mov ecx,SIZE_X*SIZE_Y*3/4 |
||
93 | cld |
||
94 | rep movsd |
||
95 | |||
96 | |||
97 | mov esp,ebp |
||
98 | pop ebp |
||
99 | ret |
||
100 | |||
101 | |||
1245 | hidnplayr | 102 | draw_dots: |
103 | mov esi,[points_translated_ptr] |
||
104 | movzx ecx,[points_count_var] |
||
105 | .drw: |
||
106 | @@: |
||
107 | lodsd |
||
108 | add esi,2 ; skip z |
||
109 | movzx ebx,ax |
||
110 | shr eax,16 ; bx = x , ax = y |
||
111 | or ax,ax |
||
112 | jl @f |
||
113 | or bx,bx |
||
114 | jl @f |
||
115 | cmp ax,SIZE_Y |
||
116 | jge @f |
||
117 | cmp bx,SIZE_X |
||
118 | jge @f |
||
119 | mov edx,SIZE_X ; SIZE_X not only power of 2 -> 256,512,... |
||
120 | mul edx |
||
121 | add eax,ebx |
||
122 | mov edi,[screen_ptr] |
||
123 | lea eax,[eax*3] |
||
124 | add edi,eax |
||
125 | xor eax,eax |
||
126 | not eax |
||
127 | stosd |
||
128 | @@: |
||
129 | loop .drw |
||
130 | |||
131 | ret |
||
132 | |||
133 | do_emboss: |
||
134 | ; emboss - after drawing all, |
||
135 | ; transfer screen buffer into bump map |
||
136 | ; and draw two bump triangles |
||
137 | ; ************************************* |
||
138 | mov esi,screen |
||
139 | mov edi,bumpmap2 |
||
140 | mov ecx,TEXTURE_SIZE/3 |
||
141 | cld |
||
142 | if Ext=NON |
||
143 | xor eax,eax |
||
144 | xor bh,bh |
||
145 | xor dh,dh |
||
146 | @@: |
||
147 | lodsb |
||
148 | movzx bx,al |
||
149 | lodsb |
||
150 | movzx dx,al |
||
151 | lodsb |
||
152 | add ax,bx |
||
153 | add ax,dx |
||
154 | ; cwd |
||
155 | ; div [i3] |
||
156 | ;; push ax |
||
157 | ;; pop bx |
||
158 | ;; shr bx,3 |
||
159 | ;; shr ax,2 |
||
160 | ;; add ax,bx |
||
161 | |||
162 | lea eax,[eax*5] |
||
163 | shr ax,4 |
||
164 | |||
165 | stosb |
||
166 | loop @b |
||
167 | else |
||
168 | emms |
||
169 | pxor mm1,mm1 |
||
170 | mov ebx,0x0000ffff |
||
171 | @@: |
||
172 | movd mm0,[esi] |
||
173 | punpcklbw mm0,mm1 |
||
174 | movq mm2,mm0 |
||
175 | psrlq mm2,16 |
||
176 | movq mm3,mm0 |
||
177 | psrlq mm3,32 |
||
178 | paddw mm0,mm2 |
||
179 | paddw mm0,mm3 |
||
180 | |||
181 | |||
182 | movd eax,mm0 |
||
183 | and eax,ebx |
||
184 | lea eax,[eax*5] |
||
185 | shr ax,4 |
||
186 | stosb |
||
187 | add esi,3 |
||
188 | loop @b |
||
189 | |||
190 | end if |
||
191 | push ebp |
||
192 | |||
193 | push dword 0 ; env coords |
||
194 | push word 0 |
||
195 | push word SIZE_X |
||
196 | push word SIZE_Y |
||
197 | push dword 0 |
||
198 | push dword 0 ; bump coords |
||
199 | push word SIZE_X |
||
200 | push word SIZE_Y |
||
201 | push word 0 |
||
202 | mov eax,SIZE_Y |
||
203 | mov ebx,SIZE_X*65536+0 |
||
204 | xor ecx,ecx |
||
205 | mov edx,bumpmap2 |
||
206 | mov esi,envmap |
||
207 | mov edi,screen |
||
208 | call bump_triangle |
||
209 | |||
210 | push dword SIZE_X shl 16 + SIZE_Y ; env coords |
||
211 | push word 0 |
||
212 | push word SIZE_X |
||
213 | push word SIZE_Y |
||
214 | push word 0 |
||
215 | push dword SIZE_X shl 16 + SIZE_Y ; bump coords |
||
216 | push word 0 |
||
217 | push word SIZE_X |
||
218 | push word SIZE_Y |
||
219 | push word 0 |
||
220 | mov eax,SIZE_Y |
||
221 | mov ebx,SIZE_X * 65536+0 |
||
222 | mov ecx,SIZE_X shl 16 + SIZE_Y |
||
223 | mov edx,bumpmap2 |
||
224 | mov esi,envmap |
||
225 | mov edi,screen |
||
226 | call bump_triangle |
||
227 | |||
228 | pop ebp |
||
229 | ret |
||
230 | ;********************************EMBOSS DONE******************************* |
||
231 | |||
232 | |||
233 | generate_object2: ; torus |
||
234 | ;in ax - figure number 2=torus, 3=loop, 4=loop |
||
235 | ;locals |
||
236 | ; counter dw ? |
||
237 | ; sin dd ? |
||
238 | ; cos dd ? |
||
239 | ;endl |
||
240 | .counter equ word[ebp-2] |
||
241 | .sin equ dword[ebp-6] |
||
242 | .cos equ dword[ebp-10] |
||
243 | .sin2 equ dword[ebp-14] |
||
244 | .cos2 equ dword[ebp-18] |
||
245 | .piD180m3 equ dword[ebp-22] |
||
246 | .cD2 equ word[ebp-24] |
||
247 | push ebp |
||
248 | mov ebp,esp |
||
249 | sub esp,24 |
||
250 | |||
251 | push ax |
||
252 | |||
253 | fninit |
||
254 | mov edi,[points_ptr] |
||
255 | xor eax,eax |
||
256 | ; init seed -> 4 3d points |
||
257 | mov dword[edi],-1.0 ; x |
||
258 | add edi,4 |
||
259 | stosd ; y |
||
260 | stosd ; z |
||
261 | mov dword[edi],-0.9 ; x1 |
||
262 | mov dword[edi+4],0.1 ; y1 |
||
263 | add edi,8 |
||
264 | stosd ; z1 |
||
265 | mov dword[edi],-0.8 |
||
266 | add edi,4 |
||
267 | stosd |
||
268 | stosd |
||
269 | mov dword[edi],-0.9 ; x3 |
||
270 | mov dword[edi+4],-0.1 ; y3 |
||
271 | add edi,8 |
||
272 | stosd ; z3 |
||
273 | mov [points_count_var],4 |
||
274 | |||
275 | fld [piD180] |
||
276 | fidiv [i3] |
||
277 | fstp .piD180m3 |
||
278 | mov .cD2,5 |
||
279 | |||
280 | pop ax |
||
281 | mov ecx,1 |
||
282 | mov edx,9 |
||
283 | .next: ; calc angle and rotate seed 4 points |
||
284 | mov .counter,cx |