Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;   TIMER (show how much system works)
  3. ;
  4. ;   Compile with flat assembler
  5. ;
  6.  
  7. use32
  8.  
  9.     org    0x0
  10.  
  11.     db     'MENUET01'       ; 8 byte id
  12.     dd     0x01             ; header version
  13.     dd     START            ; start of code
  14.     dd     I_END            ; size of image
  15.     dd     0x1000           ; memory for app
  16.     dd     0x1000           ; esp
  17.     dd     0x0 , 0x0        ; I_Param , I_Icon
  18.  
  19. include 'lang.inc'
  20. include '..\..\..\macros.inc'
  21.  
  22. START:                      ; start of execution
  23.     mov  eax, 40
  24.     mov  ebx, 101b
  25.     mcall
  26.  
  27. red:
  28.     call draw_window
  29.  
  30. still:
  31.  
  32.     mov  eax,23                 ; wait here for event
  33.     mov  ebx,50
  34.     mcall
  35.  
  36.     cmp  eax,1                  ; redraw request ?
  37.     je   red
  38.     cmp  eax,3                  ; button in buffer ?
  39.     je   button
  40.  
  41.     call draw_clock
  42.  
  43.     jmp  still
  44.  
  45.  
  46.   button:                       ; button
  47.     or   eax,-1                 ; close this program
  48.     mcall
  49.  
  50.  
  51. ;   *********************************************
  52. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  53. ;   *********************************************
  54.  
  55. draw_clock:
  56.  
  57.     mov  eax, 26           ; get system counter
  58.     mov  ebx, 9
  59.     mcall
  60.  
  61.     cdq ;xor  edx,edx
  62.     mov  ebx,100
  63.     div  ebx
  64.  
  65.   push eax
  66.  
  67.   xor  edx,edx
  68.   mov  ebx,60
  69.   div  ebx
  70.   mov  ecx,eax
  71.  
  72.   push ecx
  73.   push ecx
  74.  
  75.   xor  edx,edx
  76.   mov  ebx,60
  77.   div  ebx
  78.   mov  ecx,eax
  79.  
  80.   mov  eax,47           ; HH
  81.   mov  esi,[sc.work_text]
  82.   or   esi,0x50000000
  83.   mov  edi,[sc.work]
  84.   mov  ebx,0x00020000
  85.   mov  edx,15*65536+5
  86.   mcall
  87.  
  88.   pop  eax              ; MM
  89.   imul ecx,ecx,60
  90.   sub  eax,ecx
  91.   mov  ecx,eax
  92.   mov  eax,47
  93.   add  edx,20*65536
  94.   mcall
  95.  
  96.   pop  ecx
  97.   pop  eax
  98.  
  99.   imul ecx,ecx,60
  100.   sub  eax,ecx
  101.  
  102.   mov  ecx,eax          ; SS
  103.   mov  eax,47
  104.   add  edx,20*65536
  105.   mcall
  106.  
  107.   ret
  108.  
  109. draw_window:
  110.     mov  eax,48
  111.     mov  ebx,3
  112.     mov  ecx,sc
  113.     mov  edx,sizeof.system_colors
  114.     mcall
  115.  
  116.     mov  eax,12                    ; function 12:tell os about windowdraw
  117.     mov  ebx,1                     ; 1, start of draw
  118.     mcall
  119.  
  120.                                    ; DRAW WINDOW
  121.     xor  eax,eax                   ; function 0 : define and draw window
  122.     mov  ebx,100*65536+100         ; [x start] *65536 + [x size]
  123.     mov  ecx,100*65536+40          ; [y start] *65536 + [y size]
  124.     mov  edx,[sc.work]             ; color of work area RRGGBB,8->color gl
  125.     or   edx,0x34000000
  126.     mov  edi,title
  127.     mcall
  128.  
  129.     call draw_clock
  130.  
  131.     mov  eax,12                    ; function 12:tell os about windowdraw
  132.     mov  ebx,2                     ; 2, end of draw
  133.     mcall
  134.  
  135.     ret
  136.  
  137.  
  138. ; DATA AREA
  139.  
  140. if lang eq ru
  141.     title   db   '’€‰Œ…',0
  142. else
  143.     title   db   'TIMER',0
  144. end if
  145.  
  146.  
  147. I_END:
  148.  
  149. temp dd ?
  150. sc system_colors
  151.