Rev 122 | Rev 9450 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; |
2 | ; Crown_s Soft Screensaver v1.13m |
||
3 | ; WWW: http://www.crown-s-soft.com |
||
4 | ; |
||
5 | ; You may add you own figures. See file FIGURES.INC |
||
6 | ; |
||
7 | ; Compile with FASM v1.48 for Menuet or hier (FASM v1.40 contains bug) |
||
8 | ; |
||
9 | ; Copyright(c) 2002-2004 Crown_s Soft. All rights reserved. |
||
10 | ; |
||
11 | |||
12 | fullscreen = 1 |
||
13 | n_points = 0x1800 |
||
14 | delay = 2 |
||
15 | speed equ 0.004 |
||
16 | |||
17 | |||
18 | macro align value { rb (value-1) - ($ + value-1) mod value } |
||
19 | |||
20 | use32 |
||
21 | org 0x0 |
||
22 | db 'MENUET01' ; 8 byte id |
||
23 | dd 0x01 ; header version |
||
24 | dd start ; start of code |
||
25 | dd i_end ; size of image |
||
26 | dd i_end+0x1000 ; memory for app |
||
27 | dd i_end+0x1000 ; esp |
||
28 | dd 0x0 ; I_Param |
||
29 | dd 0x0 ; I_Icon |
||
30 | |||
31 | copyright db 'Crown_s Soft(c) Screensaver v1.13m www.crown-s-soft.com',0 |
||
32 | copyrightlen: |
||
33 | |||
34 | include "lang.inc" |
||
35 | include "figuresi.inc" |
||
485 | heavyiron | 36 | include "..\..\..\macros.inc" |
31 | halyavin | 37 | start: |
38 | cld |
||
39 | finit |
||
40 | call filling_alfbet ; fill table alfbet by casual numbers |
||
41 | |||
42 | mov eax,[tabl_calls] |
||
43 | mov [pp1adr],eax |
||
44 | |||
45 | |||
46 | cmp [flscr],0 |
||
47 | jz nofullscreen |
||
48 | mov eax,14 |
||
485 | heavyiron | 49 | mcall |
31 | halyavin | 50 | |
51 | mov [maxy],ax |
||
52 | sub ax,480 |
||
53 | jnc m5 |
||
54 | xor ax,ax |
||
55 | m5: |
||
56 | shr ax,1 |
||
57 | mov [posy],ax |
||
58 | |||
59 | shr eax,16 |
||
60 | mov [maxx],ax |
||
61 | sub ax,480 |
||
62 | jnc m6 |
||
63 | xor ax,ax |
||
64 | m6: |
||
65 | shr ax,1 |
||
66 | mov [posx],ax |
||
67 | |||
68 | mov [outsize],480+65536*480 |
||
69 | jmp m4 |
||
70 | nofullscreen: |
||
71 | mov [posx],75 |
||
72 | mov [posy],20 |
||
73 | |||
74 | mov [outsize],450+65536*480 |
||
75 | m4: |
||
76 | |||
77 | red: |
||
78 | call draw_window |
||
79 | |||
80 | still: |
||
81 | mov eax,23 |
||
82 | mov ebx,delay |
||
485 | heavyiron | 83 | mcall ; wait here for event |
31 | halyavin | 84 | |
85 | cmp eax,1 ; redraw request ? |
||
86 | je red |
||
87 | cmp eax,2 ; key in buffer ? |
||
88 | je key |
||
89 | cmp eax,3 ; button in buffer ? |
||
90 | je button |
||
91 | |||
92 | |||
93 | call calcframe |
||
94 | mov edx,dword [posy] ; edx=image position in window [x]*65536+[y] |
||
95 | mov ecx,[outsize] ; ecx=image position in window [x]*65536+[y] |
||
96 | mov ebx,scr ; ebx pointer to image in memory |
||
97 | mov eax,07 ; putimage |
||
485 | heavyiron | 98 | mcall |
31 | halyavin | 99 | jmp still |
100 | |||
101 | key: |
||
102 | mov eax,2 |
||
485 | heavyiron | 103 | mcall |
31 | halyavin | 104 | |
105 | cmp al,1 ; is key in buffer ? |
||
106 | jz still |
||
107 | cmp ah,0x1B ; is key ESC ? |
||
108 | jz close |
||
109 | jmp still |
||
110 | |||
111 | button: ; button |
||
112 | mov eax,17 ; get id |
||
485 | heavyiron | 113 | mcall |
31 | halyavin | 114 | |
115 | ; cmp ah,1 ; button id=1 ? |
||
116 | ; jne still |
||
117 | |||
118 | close: |
||
119 | mov eax,-1 ; close this program |
||
485 | heavyiron | 120 | mcall |
31 | halyavin | 121 | |
122 | |||
123 | ; ********************************************* |
||
124 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
125 | ; ********************************************* |
||
126 | |||
127 | |||
128 | draw_window: |
||
129 | mov eax,12 ; function 12:tell os about windowdraw |
||
130 | mov ebx,1 ; 1, start of draw |
||
485 | heavyiron | 131 | mcall |
31 | halyavin | 132 | |
133 | cmp [flscr],0 |
||
134 | jnz m2 |
||
122 | diamond | 135 | mov ebx,1*65536+638 ; [x start] *65536 + [x size] |
136 | mov ecx,1*65536+478 ; [y start] *65536 + [y size] |
||
31 | halyavin | 137 | mov edx,0x02000000 ; color of work area RRGGBB,8->color gl |
138 | mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
||
139 | mov edi,0x005080d0 ; color of frames RRGGBB |
||
140 | xor eax,eax ; function 0 : define and draw window |
||
485 | heavyiron | 141 | mcall |
31 | halyavin | 142 | |
143 | ; WINDOW LABEL |
||
144 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
145 | mov ecx,0x10ddeeff ; color of text RRGGBB |
||
146 | mov edx,copyright ; pointer to text beginning |
||
147 | mov esi,copyrightlen-copyright; text length |
||
148 | mov eax,4 ; function 4 : write text to window |
||
485 | heavyiron | 149 | mcall |
31 | halyavin | 150 | |
151 | ; CLOSE BUTTON |
||
152 | mov ebx,(640-19)*65536+12 ; [x start] *65536 + [x size] |
||
153 | mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
||
154 | mov edx,1 ; button id |
||
155 | mov esi,0x6688dd ; button color RRGGBB |
||
156 | mov eax,8 ; function 8 : define and draw button |
||
485 | heavyiron | 157 | mcall |
31 | halyavin | 158 | jmp m3 |
159 | m2: |
||
160 | movzx ebx,[maxx] ; [x start] *65536 + [x size] |
||
161 | movzx ecx,[maxy] ; [y start] *65536 + [y size] |
||
162 | |||
163 | mov edx,0x01000000 ; color of work area RRGGBB,8->color gl |
||
164 | mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
||
165 | mov edi,0x005080d0 ; color of frames RRGGBB |
||
166 | xor eax,eax ; function 0 : define and draw window |
||
485 | heavyiron | 167 | mcall |
31 | halyavin | 168 | |
169 | inc bx |
||
170 | inc cx |
||
171 | mov eax,13 ; functiom 13 : draw bar |
||
485 | heavyiron | 172 | mcall |
31 | halyavin | 173 | m3: |
174 | |||
175 | mov eax,12 ; function 12:tell os about windowdraw |
||
176 | mov ebx,2 ; 2, end of draw |
||
485 | heavyiron | 177 | mcall |
31 | halyavin | 178 | ret |
179 | |||
180 | |||
181 | calcframe: |
||
182 | cld |
||
183 | mov edi,scr |
||
184 | mov ecx,480*480*3/4 |
||
185 | xor eax,eax |
||
186 | rep stosd ; CLS |
||
187 | |||
188 | |||
189 | mov ebx,[frame] |
||
190 | not bh |
||
191 | test bh,03h |
||
192 | not bh |
||
193 | jnz lb1 |
||
194 | ; ebx=xxxx xxxx xxxx xxxx xxxx xx11 xxxx xxxxb |
||
195 | mov byte [p],bl |
||
196 | lb1: |
||
197 | |||
198 | test bx,03ffh |
||
199 | jnz lb2 |
||
200 | ; ebx=xxxx xxxx xxxx xxxx xxxx xx00 0000 0000b |
||
201 | mov [p],0 |
||
202 | |||
203 | mov eax,[pp1adr] |
||
204 | mov [pp0adr],eax |
||
205 | |||
206 | inc [pp1] |
||
207 | cmp [pp1],num_tabl_calls |
||
208 | jnz lb3 |
||
209 | mov [pp1],0 |
||
210 | lb3: |
||
211 | |||
212 | movzx eax,[pp1] |
||
213 | mov eax,[tabl_calls+eax*4] |
||
214 | mov [pp1adr],eax |
||
215 | lb2: |
||
216 | |||
217 | |||
218 | fild [frame] ; st0=STime |
||
219 | fmul [speed1] ; st0=STime*Speed |
||
220 | fst [bt_r] ; al_rSTime*Speed |
||
221 | fadd st0,st0 |
||
222 | fstp [al_r] ; al_rSTime*Speed*2 |
||
223 | |||
224 | |||
225 | mov [Fl],0 |
||
226 | mov ecx,[mFl] |
||
227 | mov esi,alfbet |
||
228 | ckl1: |
||
229 | call [pp0adr] |
||
230 | cmp [p],0 |
||
231 | jz lb4 |
||
232 | fstp [x1] |
||
233 | fstp [y1] |
||
234 | fstp [z1] |
||
235 | call [pp1adr] |
||
236 | call mix |
||
237 | lb4: |
||
238 | |||
239 | call turn |
||
240 | |||
241 | add esi,4 |
||
242 | inc [Fl] |
||
243 | loop ckl1 |
||
244 | |||
245 | inc ebx |
||
246 | mov [frame],ebx |
||
247 | ret |
||
248 | |||
249 | |||
250 | ; turn coordinate system |
||
251 | turn: |
||
252 | ; around Y |
||
253 | ; x= x*cos(a)-z*sin(a) |
||
254 | ; y= y |
||
255 | ; z= x*sin(a)+z*cos(a) |
||
256 | fld st2 ; st0=z st1=x st2=y st3=z |
||
257 | fld st1 ; st0=x st1=z st2=x st3=y st4=z |
||
258 | fld [al_r] ; st0=a st1=x st2=z st3=x st4=y st5=z |
||
259 | fsincos ; st0=cos(a) st1=sin(a) st2=x st3=z st4=x st5=y st6=z |
||
260 | fmul st4,st0 |
||
261 | fmulp st6,st0 ; st0=sin(a) st1=x st2=z st3=x*cos(a) st4=y st5=z*cos(a) |
||
262 | fmul st2,st0 |
||
263 | fmulp st1,st0 ; st0=x*sin(a) st1=z*sin(a) st2=x*cos(a) st3=y st4=z*c |
||
264 | faddp st4,st0 |
||
265 | fsubp st1,st0 |
||
266 | |||
267 | |||
268 | ; around X |
||
269 | ; x=x |
||
270 | ; y= y*cos(b)+z*sin(b) |
||
271 | ; z=-y*sin(b)+z*cos(b) |
||
272 | fld st2 ; st0=z st1=x st2=y st3=z |
||
273 | fld st2 ; st0=y st1=z st2=x st3=y st4=z |
||
274 | fld [bt_r] ; st0=b st1=y st2=z st3=x st4=y st5=z |
||
275 | fsincos ; st0=cos(b) st1=sin(b) st2=y st3=z st4=x st5=y st6=z |
||
276 | fmul st5,st0 |
||
277 | fmulp st6,st0 ; st0=sin(b) st1=y st2=z st3=x st4=y*cos(b) st5=z*cos(b) |
||
278 | fmul st2,st0 |
||
279 | fmulp st1,st0 ; st0=y*sin(b) st1=z*sin(b) st2=x st3=y*cos(b) st4=z*cos(b) |
||
280 | fsubp st4,st0 ; st0=z*sin(b) st1=x st2=y*cos(b) st3=z*cos(b)-y*sin(b) |
||
281 | faddp st2,st0 |
||
282 | |||
283 | ; st0=x st1=y st2=z |
||
284 | fistp [x1] |
||
285 | fistp [y1] |
||
286 | fmul [Zdepth] ; st0=z*Zdepth |
||
287 | fiadd [Zcolor] ; st0=z*Zdepth+Zcolor |
||
288 | fistp [z_w] ; st0z*Zdepth+Zcolor |
||
289 | |||
290 | |||
291 | push edx |
||
292 | |||
293 | mov eax,[x1] |
||
294 | add eax,[mid] |
||
295 | mul [const480] |
||
296 | add eax,[y1] |
||
297 | add eax,[mid] |
||
298 | mul [const3] |
||
299 | |||
300 | mov dl,byte [z_w] ; al=ZZ |
||
301 | mov [scr+0+eax],dl |
||
302 | mov [scr+1+eax],dl |
||
303 | mov [scr+2+eax],dl |
||
304 | |||
305 | pop edx |
||
306 | ret |
||
307 | |||
308 | |||
309 | |||
310 | mix: |
||
311 | fild [p] ; st0=p |
||
312 | fmul [mp] ; st0=p=p*mp |
||
313 | fld st0 ; st0=p st1=p |
||
314 | fmul st4,st0 |
||
315 | fmul st3,st0 |
||
316 | fmulp st2,st0 ; st0=p st1=x*p st2=y*p st3=z*p |
||
317 | |||
318 | fld1 |
||
319 | fsubrp st1,st0 ; st0=1-p st1=x*p st2=y*p st3=z*p |
||
320 | fld [z1] ; st0=z1 st1=1-p st2=x*p st3=y*p st4=z*p |
||
321 | fmul st0,st1 |
||
322 | faddp st4,st0 |
||
323 | fld [y1] ; st0=y1 st1=1-p st2=x*p st3=y*p st4= |
||
324 | fmul st0,st1 |
||
325 | faddp st3,st0 |
||
326 | fld [x1] ; st0=x1 st1=1-p st2=x*p st3=y*p+y1*(1-p) st4= |
||
327 | fmulp st1,st0 ; st0=x1*(1-p) st1=x*p st2=y*p+y1*(1-p) st3= |
||
328 | faddp st1,st0 ; st0=x=x*p+x1*(1-p) st1=y=y*p+y1*(1-p) st2=z |
||
329 | ret |
||
330 | |||
331 | |||
332 | filling_alfbet: |
||
333 | ; Initialize RND |
||
334 | mov eax,3 |
||
485 | heavyiron | 335 | mcall |
31 | halyavin | 336 | ; eax - fist random number |
337 | |||
338 | mov ecx,n_points |
||
339 | mov edi,alfbet |
||
340 | mov ebx,8088405h |
||
341 | ck2: |
||
342 | stosd |
||
343 | ; Compute next random number |
||
344 | ; New := 8088405H * Old + 1 |
||
345 | mul ebx |
||
346 | inc eax |
||
347 | loop ck2 |
||
348 | ret |
||
349 | |||
350 | |||
351 | ; DATA AREA |
||
352 | align 2 |
||
353 | |||
354 | frame dd 0 |
||
355 | |||
356 | mp dd 0.00390625 |
||
357 | n_r dd 0.00390625 |
||
358 | |||
359 | mal_r dd 6.28318530717958648 |
||
360 | mbt_r dd 6.28318530717958648 |
||
361 | |||
362 | const3 dd 3 |
||
363 | const6 dw 6 |
||
364 | const480 dd 480 |
||
365 | |||
366 | mFl dd n_points |
||
367 | pp1 dw 0 |
||
368 | |||
369 | Zdepth dd 0.3 |
||
370 | Zcolor dw 140 |
||
371 | |||
372 | mid dd 240 ; centre of screen |
||
373 | |||
374 | speed1 dd speed |
||
375 | flscr db fullscreen |
||
376 | |||
377 | align 4 |
||
378 | |||
379 | outsize dd ? |
||
380 | posy dw ? |
||
381 | posx dw ? |
||
382 | maxy dw ? |
||
383 | maxx dw ? |
||
384 | |||
385 | Fl dd ? |
||
386 | |||
387 | p dd ? |
||
388 | al_r dd ? |
||
389 | bt_r dd ? |
||
390 | |||
391 | |||
392 | pp0adr dd ? |
||
393 | pp1adr dd ? |
||
394 | |||
395 | z_w dw ? |
||
396 | |||
397 | x1 dd ? |
||
398 | y1 dd ? |
||
399 | z1 dd ? |
||
400 | |||
401 | align 16 |
||
402 | alfbet: ; alfbet db n_points*4 dup (?) |
||
403 | scr = alfbet+n_points*4 ; scr db 480*480*3+1 dup (?) |
||
404 | i_end = scr+480*480*3+1 ; i_param db 256 dup (?) |