Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;   SCREENSAVER APPLICATION by lisovin@26.ru
  2. ;
  3. ;   Compile with FASM for Menuet
  4. ;
  5.    use32
  6.    org    0x0
  7.  
  8.    db     'MENUET01'     ; 8 byte id
  9.    dd     0x01           ; header version
  10.    dd     START          ; start of code
  11.    dd     I_END          ; size of image
  12.    dd     0x40000        ; memory for app (256 Kb)
  13.    dd     0x40000        ; esp
  14.    dd     0x0 , 0x0      ; I_Param , I_Icon
  15.  
  16. include   'lang.inc'
  17. include   'macros.inc'
  18.  
  19. ;include   'debug.inc'
  20.  
  21. START:
  22.      mov  eax,14
  23.      int  0x40
  24.      and  eax,0xFFFF0000
  25.      mov  [top_right_corner],eax
  26.  
  27.      mov  eax,40        ; ãáâ ­®¢¨âì ¬ áªã ᮡë⨩
  28.      mov  ebx,110010b   ; ॠ£¨à㥬 ­  ª« ¢¨ âãàã, ¬ëèì, ®âà¨á®¢ªã ä®­ 
  29.      int  0x40
  30.  
  31.      mov  eax,14        ; ¯®«ã稬 à §¬¥àë íªà ­ 
  32.      int  0x40
  33.      mov  [y_max],ax
  34.      shr  eax,16
  35.      mov  [x_max],ax
  36.  
  37.   event:              ; ®¡à ¡®â稪 ᮡë⨩ (¢á¥å)
  38.     mov  eax,26
  39.     mov  ebx,9
  40.     int  0x40         ; ¯®«ãç¨âì ¢à¥¬ï á¨á⥬ë
  41. ;    mov  eax,3
  42. ;    int  0x40
  43.     mov  [evtime],eax ; § ¯®¬­¨âì ¥£®
  44.     mov  eax,37
  45.     mov  ebx,2
  46.     int  0x40
  47.     cmp  eax,3        ; ¯à®¤®«¦¨¬, ¥á«¨ ­ ¦ â  á।­ïï ª­®¯ª  ¬ëè¨
  48.     jne  still
  49.     mov  eax,37       ; ¯à®¢¥à¨¬ ª®®à¤¨­ âë
  50.     mov  ebx,0
  51.     int  0x40
  52.     cmp  [top_right_corner],eax
  53.     je   create_setup ; ᮧ¤ ñ¬ ®ª­® ­ áâனª¨, ¥á«¨ ¬ëèì ¢ ¢¥àå­¥¬ ¯à ¢®¬
  54.                       ; 㣫ã íªà ­ 
  55.  
  56.  
  57.  
  58. still:                  ; ®á­®¢­®© 横« ¯à®£à ¬¬ë
  59.  
  60.     mov  eax,23         ; ¦¤ñ¬ ᮡëâ¨ï ¢ â¥ç¥­¨¥ 1 ᥪ㭤ë
  61.     mov  ebx,100
  62.     int  0x40
  63.  
  64.     bt   dword [params],0  ; ssaver works?
  65.     jc   event
  66.     bt   dword [params],1  ; setup works?
  67.     jc   event
  68.  
  69.     cmp  eax,2          ; key in buffer ?
  70.     je   event
  71.     cmp  eax,5
  72.     je   event
  73.     cmp  eax,6
  74.     je   event
  75.  
  76.     mov  eax,26
  77.     mov  ebx,9
  78.     int  0x40
  79.     sub  eax,[evtime]
  80.     xor  edx,edx
  81.     mov  ebx,60*100     ; ¯®¤¥«¨¬ ­  60*100, ¯®«ã稬 ¢à¥¬ï ¢ ¬¨­ãâ å
  82.     div  ebx
  83.     cmp  al,[time]
  84.     jb   still
  85.  
  86. ; current_time-evtime/100/60 = ¢à¥¬ï ¢ ¬¨­ãâ å á ¯à®è«®£® ᮡëâ¨ï
  87.  
  88.     call create_ss
  89.     jmp  still
  90.  
  91.  
  92.  
  93.   create_setup:
  94.     bt dword [params],1
  95.     jc   still
  96.     mov  eax,51
  97.     mov  ebx,1
  98.     mov  ecx,sthread
  99.     mov  edx,0x3F000
  100.     int  0x40
  101.     bts dword [params],1
  102.     jmp  still
  103.  
  104.   create_ss:
  105.     mov  eax,51
  106.     mov  ebx,1
  107.     mov  ecx,thread
  108.     mov  edx,0x3E000
  109.     int  0x40
  110.     bts dword [params],0
  111.     ret
  112.  
  113.  thread:
  114.     mov  eax,5
  115.     mov  ebx,eax
  116.     int  0x40
  117.     mov  eax,40
  118.     mov  ebx,100010b
  119.     int  0x40
  120.     cmp  dword [type],0
  121.     je   drawsswin
  122.     cmp  dword [type],24
  123.     je   asminit
  124.     mov  dword [delay],1
  125.     mov  [lx1],10         ; for "draw line"
  126.     mov  [lx2],40
  127.     mov  [ly1],50
  128.     mov  [ly2],100
  129.     mov  [addx1],1
  130.     mov  [addx2],1
  131.     mov  [addy1],1
  132.     mov  [addy2],1
  133.     jmp  drawsswin
  134.  asminit:                 ; for "assembler"
  135.     mov  dword [delay],25
  136.     mov  eax,58
  137.     mov  ebx,fileinfo
  138.     int  0x40
  139.  asminit1:
  140.     mov  eax,data_from_file
  141.     mov  [stringstart],eax
  142.     mov  dword [stringlen],1
  143.  newpage:
  144.     mov  word [stringpos],10
  145.  
  146.  drawsswin:
  147.     xor  eax,eax
  148.     mov  ebx,eax
  149.     mov  ecx,eax
  150.     mov  bx,[x_max]
  151.     mov  cx,[y_max]
  152.     inc  ebx
  153.     inc  ecx
  154.     mov  edx,0x01000000
  155.     int  0x40
  156.     mov  eax,13
  157.     xor  edx,edx
  158.     int  0x40
  159.  tstill:
  160.     mov  eax,23
  161.     mov  ebx,[delay]
  162.     int  0x40
  163.     cmp  eax,2
  164.     je   thr_end
  165.     cmp  eax,6
  166.     je   thr_end
  167.     cmp  dword [type],0
  168.     je   tstill
  169.     cmp  dword [type],24
  170.     je   drawssasm
  171.     call draw_line
  172.     jmp  tstill
  173.  thr_end:
  174.     btr  dword [params],0
  175.     mov  eax,26
  176.     mov  ebx,9
  177.     int  0x40
  178.     mov  [evtime],eax
  179.     or   eax,-1
  180.     int  0x40
  181.  
  182.  drawssasm:
  183.     mov  edi,[stringstart]
  184.     add  edi,[stringlen]
  185.     dec  edi
  186.     mov  eax,edi
  187.     sub  eax,data_from_file
  188.     cmp  eax,10450
  189.     ja   asminit1
  190.     cmp word [edi],0x0a0d
  191.     jne  noaddstring
  192.     add  word [stringpos],10
  193.     add  edi,2
  194.     mov  [stringstart],edi
  195.     mov dword [stringlen],1
  196.     mov  ax,[stringpos]
  197.     cmp  ax,[y_max]
  198.     jb   tstill
  199.     jmp  newpage
  200.  noaddstring:
  201.     mov  eax,4
  202.     mov  ebx,10*65536
  203.     mov  bx,[stringpos]
  204.     mov  ecx,0x104ba010
  205.     mov  edx,[stringstart]
  206.     mov  esi,[stringlen]
  207.     int  0x40
  208.     inc dword [stringlen]
  209.     cmp byte [edi],byte ' '
  210.     je   drawssasm
  211.     jmp  tstill
  212.  
  213. draw_line:
  214.  
  215.     xor  esi,esi
  216.     xor  edi,edi
  217.     mov  si,[x_max]
  218.     mov  di,[y_max]
  219.  
  220.     mov  eax,[addx1]
  221.     add  [lx1],eax
  222.     mov  eax,[addy1]
  223.     add  [ly1],eax
  224.  
  225.     mov  eax,[addx2]
  226.     add  [lx2],eax
  227.     mov  eax,[addy2]
  228.     add  [ly2],eax
  229.  
  230.     cmp  [lx1],1
  231.     jge  dl1
  232.     mov  [addx1],1
  233.   dl1:
  234.     cmp  [lx2],1
  235.     jge  dl2
  236.     mov  [addx2],1
  237.   dl2:
  238.     cmp  [lx1],esi
  239.     jbe  dl3
  240.     mov  [addx1],0xffffffff
  241.   dl3:
  242.     cmp  [lx2],esi
  243.     jbe  dl4
  244.     mov  [addx2],0xffffffff
  245.   dl4:
  246.  
  247.     cmp  [ly1],1
  248.     jge  dl5
  249.     mov  [addy1],1
  250.   dl5:
  251.     cmp  [ly2],2
  252.     jge  dl6
  253.     mov  [addy2],1
  254.   dl6:
  255.     cmp  [ly1],edi
  256.     jbe  dl7
  257.     mov  [addy1],-1
  258.   dl7:
  259.     cmp  [ly2],edi
  260.     jbe  dl8
  261.     mov  [addy2],-1
  262.   dl8:
  263.  
  264.     mov  eax,[lx2]
  265.     cmp  [lx1],eax
  266.     jz   dnol
  267.  
  268.     mov  bx,word [lx1]
  269.     shl  ebx,16
  270.     mov  bx,word [lx2]
  271.  
  272.     mov  cx,word [ly1]
  273.     shl  ecx,16
  274.     mov  cx,word [ly2]
  275.  
  276.     mov  eax,38
  277.     mov  edx,[lcolor]
  278.     and  edx,0xffffff
  279.     int  0x40
  280.  
  281.    dnol:
  282.  
  283.     add  [lcolor],0x010201
  284.  
  285.     ret
  286.  
  287.  
  288. sthread:                        ; start of execution
  289.  
  290.      call sdraw_window
  291.  
  292. sstill:
  293.  
  294.     mov  eax,10                 ; wait here for event
  295.     int  0x40
  296.  
  297.     cmp  eax,1                  ; redraw request ?
  298.     je   sthread
  299.     cmp  eax,2                  ; key in buffer ?
  300.     je   sstill
  301.     cmp  eax,3                  ; button in buffer ?
  302.     je   sbutton
  303.  
  304.     jmp  sstill
  305.  
  306.   sbutton:                       ; button
  307.     mov  eax,17                 ; get id
  308.     int  0x40
  309.  
  310.     cmp  ah,1                   ; button id=1 ?
  311.     jne  snoclose
  312.  
  313.     btr dword [params],1
  314.     mov  eax,-1                 ; close this program
  315.     int  0x40
  316.   snoclose:
  317.     cmp  ah,7
  318.     jne  nosetfl
  319.     btc dword [params],0
  320.     call drawflag
  321.     call drawtype
  322.     call drawtime
  323.     jmp  sstill
  324.   nosetfl:
  325.     bt dword [params],0
  326.     jc   sstill
  327.     cmp  ah,2
  328.     jne  notypedown
  329.     mov  eax,[type]
  330.     test  eax,eax
  331.     je   sstill
  332.     sub  eax,12
  333.     jmp  typeupdn
  334.   notypedown:
  335.     cmp  ah,3
  336.     jne  notypeup
  337.     mov  eax,[type]
  338.     cmp  eax,24
  339.     jae  sstill
  340.     add  eax,12
  341.     jmp  typeupdn
  342.   notypeup:
  343.     cmp  ah,4
  344.     jne  notimedown
  345.     mov  al,[time]
  346.     cmp  al,1
  347.     jbe  sstill
  348.     dec  al
  349. ;    das
  350.     jmp  timeupdn
  351.   notimedown:
  352.     cmp  ah,5
  353.     jne  notimeup
  354.     mov  al,[time]
  355.     cmp  al,59 ; 0x59
  356.     jae  sstill
  357.     inc  al
  358. ;    daa
  359.     jmp  timeupdn
  360.   notimeup:
  361.     cmp  ah,6
  362.     jne  noshow
  363.     mov  eax,5
  364.     mov  ebx,150
  365.     int  0x40
  366.     call create_ss
  367.     jmp  sstill
  368.   noshow:
  369.     jmp  sstill
  370.  
  371.   timeupdn:
  372.     mov  [time],al
  373.     call drawtime
  374.     jmp  sstill
  375.   typeupdn:
  376.     mov  [type],eax
  377.     call drawtype
  378.     jmp  sstill
  379.  
  380. ;   *********************************************
  381. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  382. ;   *********************************************
  383.  
  384.  
  385. sdraw_window:
  386.  
  387.  
  388.     mov  eax,12                    ; function 12:tell os about windowdraw
  389.     mov  ebx,1                     ; 1, start of draw
  390.     int  0x40
  391.  
  392.                                    ; DRAW WINDOW
  393.     xor  eax,eax                   ; function 0 : define and draw window
  394.     mov  ebx,100*65536+215         ; [x start] *65536 + [x size]
  395.     mov  ecx,100*65536+70          ; [y start] *65536 + [y size]
  396.     mov  edx,0x03400088            ; color of work area RRGGBB,8->color gl
  397.     int  0x40
  398.  
  399.     mov  eax,8
  400.     mov  ebx,47*65536+10
  401.     mov  ecx,31*65536+10
  402.     mov  edx,2
  403.     mov  esi,0x702050
  404.     int  0x40
  405.     push ebx
  406.     add  ebx,13*65536
  407.     mov  edi,ebx
  408.     inc  edx
  409.     int  0x40
  410.     pop  ebx
  411.     add  ecx,15*65536
  412.     inc  edx
  413.     int  0x40
  414.     mov  ebx,edi
  415.     inc  edx
  416.     int  0x40
  417.     mov  ebx,160*65536+40
  418.     mov  ecx,28*65536+14
  419.     inc  edx
  420.     int  0x40
  421.                                    ; WINDOW LABEL
  422.     mov  eax,4                     ; function 4 : write text to window
  423.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  424.     mov  ecx,0x10ddeeff            ; font 1 & color ( 0xF0RRGGBB )
  425.     mov  edx,labelt                ; pointer to text beginning
  426.     mov  esi,17                    ; text length
  427.     int  0x40
  428.     add  ebx,7*65536+25
  429.     mov  ecx,0xffffff
  430.     mov  edx,setuptext
  431.     mov  esi,9
  432.     int  0x40
  433.     add  ebx,15
  434.     add  edx,esi
  435.     mov  esi,30
  436.     int  0x40
  437.     mov  ebx,169*65536+32
  438.     mov  edx,buttext
  439.     mov  esi,4
  440.     int  0x40
  441.  
  442.     call drawtype
  443.     call drawtime
  444.     call drawflag
  445.  
  446.     mov  eax,12                    ; function 12:tell os about windowdraw
  447.     mov  ebx,2                     ; 2, end of draw
  448.     int  0x40
  449.  
  450.     ret
  451.  
  452. drawtype:
  453.     mov  eax,13
  454.     mov  ebx,80*65536+75
  455.     mov  ecx,30*65536+12
  456.     mov  edx,0xffffff
  457.     bt   dword [params],0
  458.     jnc  noblue
  459.     mov  edx,0x4e00e7
  460.  noblue:
  461.     int  0x40
  462.     mov  eax,4
  463.     mov  ebx,82*65536+32
  464.     xor  ecx,ecx
  465.     mov  edx,typetext
  466.     add  edx,[type]
  467.     mov  esi,12
  468.     int  0x40
  469.     ret
  470.  
  471. drawtime:
  472.     mov  eax,13
  473.     mov  ebx,80*65536+15
  474.     mov  ecx,45*65536+12
  475.     mov  edx,0xffffff
  476.     bt   dword [params],0
  477.     jnc  noblue1
  478.     mov  edx,0x4e00e7
  479.  noblue1:
  480.     int  0x40
  481.     mov  eax,47
  482.     mov  edx,82*65536+47
  483.     xor  esi,esi
  484.     movzx ecx,byte [time]
  485.     mov  ebx,0x00020000
  486.     int  0x40
  487.     ret
  488.  
  489. drawflag:
  490.     mov  eax,8
  491.     mov  ebx,150*65536+10
  492.     mov  ecx,45*65536+10
  493.     mov  edx,7
  494.     mov  esi,0xe0e0e0
  495.     int  0x40
  496.     mov  eax,4
  497.     mov  ebx,153*65536+47
  498.     xor  ecx,ecx
  499.     mov  esi,1
  500.     mov  edx,flag
  501.     bt   dword [params],0
  502.     jc   setf
  503.     inc  edx
  504.   setf:
  505.     int  0x40
  506.     ret
  507.  
  508. ; DATA AREA
  509. buttext    db 'SHOW'
  510. flag       db 'V '
  511. labelt     db   'SCREENSAVER SETUP'
  512. setuptext  db 'TYPE: < >TIME: < >     MINUTES    NEVER'
  513. typetext   db 'BLACK SCREENCOLOR LINES ASSEMBLER   '
  514. type       dd 12
  515. time       db 15     ; ¢à¥¬ï ¤® § ¯ã᪠ § áâ ¢ª¨ ¢ ¬¨­ãâ å
  516. delay      dd 100
  517.  
  518. lx1   dd  10
  519. lx2   dd  40
  520.  
  521. ly1   dd  50
  522. ly2   dd  100
  523.  
  524. addx1 dd  1
  525. addx2 dd  1
  526.  
  527. addy1 dd  1
  528. addy2 dd  1
  529.  
  530. stringlen   dd 1
  531. stringstart dd 0
  532. stringpos   dw 10
  533.  
  534. params  dd 0     ;if bit 0 set-ssaver works if bit 1 set-setup works
  535.  
  536. fileinfo:
  537.   dd 0,0,21,data_from_file,work_area
  538.   db '/RD/1/SS.ASM',0
  539.  
  540. I_END:
  541.  
  542.  
  543. ; UNINITIALIZED DATA:
  544.  
  545. lcolor           dd ?
  546. evtime           dd ?     ; ¢à¥¬ï ¯à¥¤ë¤ã饣® ᮡëâ¨ï
  547. x_max            dw ?     ; à §¬¥àë íªà ­ 
  548. y_max            dw ?
  549.  
  550. top_right_corner dd ?
  551. work_area:
  552. rb 0x10000
  553. data_from_file: