Subversion Repositories Kolibri OS

Rev

Rev 205 | Rev 485 | 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.     int  0x40
  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. red:
  42.     call draw_window            ; at first, draw the window
  43.  
  44. still:
  45.  
  46.     mov  eax,10                 ; wait here for event
  47.     int  0x40
  48.  
  49.     cmp  eax,1                  ; redraw request ?
  50.     jz   red
  51.     cmp  eax,2                  ; key in buffer ?
  52.     jz   key
  53.     cmp  eax,3                  ; button in buffer ?
  54.     jz   button
  55.  
  56.     jmp  still
  57.  
  58.   key:                          ; key
  59.     mov  eax,2                  ; just read it and ignore
  60.     int  0x40
  61.     jmp  still
  62.  
  63.   button:                       ; button
  64.     mov  eax,17                 ; get id
  65.     int  0x40
  66.  
  67.     cmp  ah,1                   ; button id=1 ?
  68.     jnz  still
  69.     or   eax,-1                 ; close this program
  70.     int  0x40
  71.  
  72.  
  73. ;   *********************************************
  74. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  75. ;   *********************************************
  76.  
  77.  
  78. draw_window:
  79.  
  80.     mov  eax,12                    ; function 12:tell os about windowdraw
  81.     mov  ebx,1                     ; 1, start of draw
  82.     int  0x40
  83.  
  84.     mov  eax,48
  85.     mov  ebx,3
  86.     mov  ecx,sc
  87.     mov  edx,sizeof.system_colors
  88.     int  0x40
  89.  
  90.                                    ; DRAW WINDOW
  91.     mov  eax,0                     ; function 0 : define and draw window
  92.     mov  ebx,100*65536+200         ; [x start] *65536 + [x size]
  93.     mov  ecx,100*65536+65          ; [y start] *65536 + [y size]
  94.     mov  edx,[sc.work]             ; color of work area RRGGBB,8->color glide
  95.     or   edx,0x33000000            ; color of grab bar  RRGGBB,8->color
  96.     mov  edi,header                ; WINDOW LABEL
  97.     int  0x40
  98.  
  99.  
  100.     mov  ebx,20*65536+14           ; draw info text with function 4
  101.     mov  ecx,[sc.work_text]
  102.     mov  edx,text
  103.     mov  esi,24
  104.     mov  eax,4
  105.     int  0x40
  106.    
  107.     mov  eax,12                    ; function 12:tell os about windowdraw
  108.     mov  ebx,2                     ; 2, end of draw
  109.     int  0x40
  110.  
  111.     ret
  112.  
  113.  
  114. ; DATA AREA
  115.  
  116.  
  117. text:
  118.     db 'CPU RUNNING AT       MHZ'
  119.  
  120. header    db   'CPU SPEED',0
  121.  
  122. I_END:
  123.  
  124. sc system_colors
  125.  
  126.