Subversion Repositories Kolibri OS

Rev

Rev 9450 | 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.73 for Kolibri or hier
  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. include "..\..\..\KOSfuncs.inc"
  39. start:
  40.     cmp     dword[params], '@ss'
  41.     setz    [screensaver]
  42.     mov     ebx, EVM_REDRAW + EVM_KEY + EVM_BUTTON
  43.     cmovz   ebx, EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE
  44.     mcall   SF_SET_EVENTS_MASK
  45.  
  46.     cmp [flscr],0
  47.     jz @f
  48.     mov     edi, transparent_cursor
  49.     xor     eax, eax
  50.     mov     ecx, 32*32
  51.     rep     stosd
  52.     mcall   SF_MOUSE_GET, SSF_LOAD_CURSOR, transparent_cursor, 2
  53.     mov     ecx, eax
  54.     mcall   SF_MOUSE_GET, SSF_SET_CURSOR
  55. @@:
  56.     cld
  57.     finit
  58.     call filling_alfbet ; fill table alfbet by casual numbers
  59.  
  60.     mov eax,[tabl_calls]
  61.     mov [pp1adr],eax
  62.  
  63.  
  64.     cmp [flscr],0
  65.     jz  nofullscreen
  66.       mcall SF_GET_SCREEN_SIZE
  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 SF_WAIT_EVENT_TIMEOUT, 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,SF_PUT_IMAGE
  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.     mcall SF_GET_KEY
  122.  
  123.     cmp  al,1                   ; is key in buffer ?
  124.     jz   still
  125.     cmp  ah,0x1B                ; is key ESC ?
  126.     jz   close
  127. jmp  still
  128.  
  129. close:
  130.     cmp     [screensaver], 0
  131.     jz      @f
  132.     mcall   SF_FILE, f70
  133.   @@:
  134.     mcall   SF_TERMINATE_PROCESS
  135.  
  136.  
  137. ;   *********************************************
  138. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  139. ;   *********************************************
  140.  
  141.  
  142. draw_window:
  143.     mcall SF_REDRAW, SSF_BEGIN_DRAW ;start draw
  144.  
  145.     cmp  [flscr],0
  146.     jnz  m2
  147.       mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
  148.       mov  esi, eax
  149.                                    ; DRAW WINDOW
  150.       mov  ecx,100*65536+const480+4         ; [y start] *65536 + [y size]
  151.       add  ecx, esi
  152.       mcall SF_CREATE_WINDOW, 100*65536+const480+9,,0x74000000,,copyright
  153.  
  154.     jmp m3
  155.     m2:
  156.       movzx  ebx,[maxx]              ; [x start] *65536 + [x size]
  157.       movzx  ecx,[maxy]              ; [y start] *65536 + [y size]
  158.  
  159.       mov  edx,0x01000000            ; color of work area RRGGBB,8->color gl
  160.       mov  esi,0x805080d0            ; color of grab bar  RRGGBB,8->color gl
  161.       mov  edi,0x005080d0            ; color of frames    RRGGBB
  162.       xor  eax,eax                   ; function 0 : define and draw window
  163.       mcall
  164.  
  165.       inc bx
  166.       inc cx
  167.       mcall SF_DRAW_RECT
  168.     m3:
  169.  
  170.     mcall SF_REDRAW, SSF_END_DRAW ;end draw
  171. ret
  172.  
  173.  
  174. calcframe:
  175.      cld
  176.      mov  edi,scr
  177.      mov  ecx,const480*const480*3/4
  178.      xor  eax,eax
  179.      rep stosd     ; CLS
  180.  
  181.  
  182.      mov  ebx,[frame]
  183.      not  bh
  184.      test bh,03h
  185.      not  bh
  186.      jnz  lb1
  187.        ; ebx=xxxx xxxx  xxxx xxxx  xxxx xx11  xxxx xxxxb
  188.        mov  byte [p],bl
  189.      lb1:
  190.  
  191.      test  bx,03ffh
  192.      jnz  lb2
  193.        ; ebx=xxxx xxxx  xxxx xxxx  xxxx xx00  0000 0000b
  194.        mov [p],0
  195.  
  196.        mov  eax,[pp1adr]
  197.        mov  [pp0adr],eax
  198.  
  199.        inc [pp1]
  200.        cmp [pp1],num_tabl_calls
  201.        jnz lb3
  202.          mov [pp1],0
  203.        lb3:
  204.  
  205.        movzx eax,[pp1]
  206.        mov  eax,[tabl_calls+eax*4]
  207.        mov  [pp1adr],eax
  208.      lb2:
  209.  
  210.  
  211.      fild  [frame]    ; st0=STime
  212.      fmul  [speed1]   ; st0=STime*Speed
  213.      fst   [bt_r]     ; al_rSTime*Speed
  214.      fadd  st0,st0
  215.      fstp  [al_r]     ; al_rSTime*Speed*2
  216.  
  217.  
  218.      mov   [Fl],0
  219.      mov ecx,[mFl]
  220.      mov esi,alfbet
  221.      ckl1:
  222.        call [pp0adr]
  223.        cmp  [p],0
  224.        jz  lb4
  225.          fstp [x1]
  226.          fstp [y1]
  227.          fstp [z1]
  228.          call [pp1adr]
  229.          call mix
  230.        lb4:
  231.  
  232.        call turn
  233.  
  234.        add  esi,4
  235.        inc  [Fl]
  236.      loop ckl1
  237.  
  238.      inc ebx
  239.      mov [frame],ebx
  240. ret
  241.  
  242.  
  243. ; turn coordinate system
  244. turn:
  245.   ; around Y
  246.   ;  x= x*cos(a)-z*sin(a)
  247.   ;  y= y
  248.   ;  z= x*sin(a)+z*cos(a)
  249.   fld  st2      ; st0=z  st1=x  st2=y  st3=z
  250.   fld  st1      ; st0=x  st1=z  st2=x  st3=y  st4=z
  251.   fld  [al_r]   ; st0=a  st1=x  st2=z  st3=x  st4=y  st5=z
  252.   fsincos       ; st0=cos(a)  st1=sin(a)  st2=x  st3=z  st4=x  st5=y  st6=z
  253.   fmul  st4,st0
  254.   fmulp st6,st0 ; st0=sin(a)  st1=x  st2=z  st3=x*cos(a)  st4=y  st5=z*cos(a)
  255.   fmul  st2,st0
  256.   fmulp st1,st0 ; st0=x*sin(a)  st1=z*sin(a)  st2=x*cos(a) st3=y st4=z*c
  257.   faddp st4,st0
  258.   fsubp st1,st0
  259.  
  260.  
  261.   ; around X
  262.   ;  x=x
  263.   ;  y= y*cos(b)+z*sin(b)
  264.   ;  z=-y*sin(b)+z*cos(b)
  265.   fld  st2      ; st0=z  st1=x  st2=y  st3=z
  266.   fld  st2      ; st0=y  st1=z  st2=x  st3=y  st4=z
  267.   fld  [bt_r]   ; st0=b  st1=y  st2=z  st3=x  st4=y  st5=z
  268.   fsincos       ; st0=cos(b)  st1=sin(b)  st2=y  st3=z  st4=x  st5=y  st6=z
  269.   fmul  st5,st0
  270.   fmulp st6,st0 ; st0=sin(b)  st1=y  st2=z  st3=x  st4=y*cos(b)  st5=z*cos(b)
  271.   fmul  st2,st0
  272.   fmulp st1,st0 ; st0=y*sin(b) st1=z*sin(b) st2=x st3=y*cos(b) st4=z*cos(b)
  273.   fsubp st4,st0 ; st0=z*sin(b)  st1=x  st2=y*cos(b)  st3=z*cos(b)-y*sin(b)
  274.   faddp st2,st0
  275.  
  276.   ; st0=x  st1=y  st2=z
  277.   fistp [x1]
  278.   fistp [y1]
  279.   fmul    [Zdepth]   ; st0=z*Zdepth
  280.   fiadd   [Zcolor]   ; st0=z*Zdepth+Zcolor
  281.   fistp   [z_w]      ; st0z*Zdepth+Zcolor
  282.  
  283.  
  284.   push edx
  285.  
  286.   mov  eax,[x1]
  287.   add  eax,[mid]
  288.   mul  [consts]
  289.   add  eax,[y1]
  290.   add  eax,[mid]
  291.   mul  [const3]
  292.  
  293.   mov  dl,byte [z_w]      ; al=ZZ
  294.   mov  [scr+0+eax],dl
  295.   mov  [scr+1+eax],dl
  296.   mov  [scr+2+eax],dl
  297.  
  298.   pop  edx
  299. ret
  300.  
  301.  
  302.  
  303. mix:
  304.   fild  [p]       ; st0=p
  305.   fmul  [mp]      ; st0=p=p*mp
  306.   fld   st0       ; st0=p  st1=p
  307.   fmul  st4,st0
  308.   fmul  st3,st0
  309.   fmulp st2,st0   ; st0=p    st1=x*p  st2=y*p  st3=z*p
  310.  
  311.   fld1
  312.   fsubrp st1,st0  ; st0=1-p  st1=x*p  st2=y*p  st3=z*p
  313.   fld    [z1]     ; st0=z1   st1=1-p  st2=x*p  st3=y*p  st4=z*p
  314.   fmul  st0,st1
  315.   faddp st4,st0
  316.   fld    [y1]     ; st0=y1   st1=1-p  st2=x*p  st3=y*p  st4=
  317.   fmul  st0,st1
  318.   faddp st3,st0
  319.   fld    [x1]     ; st0=x1   st1=1-p  st2=x*p  st3=y*p+y1*(1-p)  st4=
  320.   fmulp st1,st0   ; st0=x1*(1-p)      st1=x*p  st2=y*p+y1*(1-p)  st3=
  321.   faddp st1,st0   ; st0=x=x*p+x1*(1-p)  st1=y=y*p+y1*(1-p)  st2=z
  322. ret
  323.  
  324.  
  325. filling_alfbet:
  326.      ; Initialize RND
  327.      mcall SF_GET_SYS_TIME
  328.      ; eax - fist random number
  329.  
  330.      mov   ecx,n_points
  331.      mov   edi,alfbet
  332.      mov   ebx,8088405h
  333.      ck2:
  334.        stosd
  335.        ; Compute next random number
  336.        ; New := 8088405H * Old + 1
  337.        mul   ebx
  338.        inc   eax
  339.      loop ck2
  340. ret
  341.  
  342.  
  343. ; DATA AREA
  344. align 2
  345.  
  346.   frame   dd     0
  347.  
  348.   mp      dd     0.00390625
  349.   n_r     dd     0.00390625
  350.  
  351.   mal_r   dd     6.28318530717958648
  352.   mbt_r   dd     6.28318530717958648
  353.  
  354.   const3   dd    3
  355.   const6   dw    6
  356.   consts   dd    const480
  357.  
  358.   mFl     dd     n_points
  359.   pp1     dw     0
  360.  
  361.   Zdepth  dd     0.3
  362.   Zcolor  dw     140
  363.  
  364.   mid     dd     240   ; centre of screen
  365.  
  366.   speed1  dd     speed
  367.   flscr   db     fullscreen
  368.  
  369.   align 4
  370.  
  371.   outsize dd     ?
  372.   posy    dw     ?
  373.   posx    dw     ?
  374.   maxy    dw     ?
  375.   maxx    dw     ?
  376.  
  377.   Fl      dd     ?
  378.  
  379.   p       dd     ?
  380.   al_r    dd     ?
  381.   bt_r    dd     ?
  382.  
  383.  
  384.   pp0adr  dd     ?
  385.   pp1adr  dd     ?
  386.  
  387.   z_w     dw     ?
  388.  
  389.   x1      dd     ?
  390.   y1      dd     ?
  391.   z1      dd     ?
  392.  
  393. f70:    ; run
  394.         dd SSF_START_APP, 0, 0, 0, 0
  395.         db '/sys/@SS',0
  396.  
  397. screensaver db ?
  398. params rb 4
  399. transparent_cursor rd 32*32
  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+const480*const480*3+1 ; i_param db  256         dup (?)
  405.