Subversion Repositories Kolibri OS

Rev

Rev 317 | Rev 872 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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