Subversion Repositories Kolibri OS

Rev

Rev 9449 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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