Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;    CPU SPEED INDICATIOR
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;
  6.  
  7.   use32
  8.   org     0x0
  9.  
  10.   db      'MENUET00'   ; 8 byte id
  11.   dd      38           ; required os
  12.   dd      START        ; program start
  13.   dd      I_END        ; program image size
  14.   dd      0x1000       ; required amount of memory
  15.   dd      0x1000       ; esp
  16.   dd      0x00000000   ; reserved=no extended header
  17.  
  18. include 'lang.inc'
  19. include '..\..\..\..\macros.inc'
  20.  
  21. START:                          ; start of execution
  22.  
  23.     mov  eax,18
  24.     mov  ebx,5
  25.     mcall
  26.  
  27.     xor  edx,edx
  28.     mov  ebx,1000000
  29.     div  ebx
  30.     mov  ebx,10
  31.     mov  edi,text+19
  32.     mov  ecx,5
  33.   newnum:
  34.     xor  edx,edx
  35.     mov  ebx,10
  36.     div  ebx
  37.     add  dl,48
  38.     mov  [edi],dl
  39.     sub  edi,1
  40.     loop newnum
  41.    
  42.     mov  eax,48
  43.     mov  ebx,3
  44.     mov  ecx,sc
  45.     mov  edx,sizeof.system_colors
  46.     mcall
  47.  
  48. red:
  49.     call draw_window            ; at first, draw the window
  50.  
  51. still:
  52.  
  53.     mov  eax,10                 ; wait here for event
  54.     mcall
  55.  
  56.     cmp  eax,1                  ; redraw request ?
  57.     jz   red
  58.     cmp  eax,2                  ; key in buffer ?
  59.     jz   key
  60.     cmp  eax,3                  ; button in buffer ?
  61.     jz   button
  62.  
  63.     jmp  still
  64.  
  65.   key:                          ; key
  66.     mov  eax,2                  ; just read it and ignore
  67.     mcall
  68.     jmp  still
  69.  
  70.   button:                       ; button
  71.     mov  eax,17                 ; get id
  72.     mcall
  73.  
  74.     cmp  ah,1                   ; button id=1 ?
  75.     jnz  still
  76.     or   eax,-1                 ; close this program
  77.     mcall
  78.  
  79.  
  80. ;   *********************************************
  81. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  82. ;   *********************************************
  83.  
  84.  
  85. draw_window:
  86.  
  87.     mov  eax,12                    ; function 12:tell os about windowdraw
  88.     mov  ebx,1                     ; 1, start of draw
  89.     mcall
  90.  
  91.                                    ; DRAW WINDOW
  92.     mov  eax,0                     ; function 0 : define and draw window
  93.     mov  ebx,100*65536+200         ; [x start] *65536 + [x size]
  94.     mov  ecx,100*65536+65          ; [y start] *65536 + [y size]
  95.     mov  edx,[sc.work]             ; color of work area RRGGBB,8->color glide
  96.     or   edx,0x33000000            ; color of grab bar  RRGGBB,8->color
  97.     mov  edi,title                ; WINDOW LABEL
  98.     mcall
  99.  
  100.  
  101.     mov  ebx,20*65536+14           ; draw info text with function 4
  102.     mov  ecx,[sc.work_text]
  103.     mov  edx,text
  104.     mov  esi,24
  105.     mov  eax,4
  106.     mcall
  107.    
  108.     mov  eax,12                    ; function 12:tell os about windowdraw
  109.     mov  ebx,2                     ; 2, end of draw
  110.     mcall
  111.  
  112.     ret
  113.  
  114.  
  115. ; DATA AREA
  116.  
  117.  
  118. text:
  119.     db 'CPU RUNNING AT       MHZ'
  120.  
  121. title    db   'CPU SPEED',0
  122.  
  123. I_END:
  124.  
  125. sc system_colors
  126.  
  127.