Rev 317 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
205 | heavyiron | 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 | |||
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 | red: ; redraw |
||
59 | call draw_window |
||
60 | jmp still |
||
61 | |||
62 | key: ; key |
||
63 | mov eax,2 ; just read it and ignore |
||
64 | int 0x40 |
||
65 | jmp still |
||
66 | |||
67 | button: ; button |
||
68 | mov eax,17 ; get id |
||
69 | int 0x40 |
||
70 | |||
71 | cmp ah,1 ; button id=1 ? |
||
72 | jnz still |
||
73 | mov eax,-1 ; close this program |
||
74 | int 0x40 |
||
75 | |||
76 | |||
77 | ; ********************************************* |
||
78 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
79 | ; ********************************************* |
||
80 | |||
81 | |||
82 | draw_window: |
||
83 | |||
84 | mov eax,12 ; function 12:tell os about windowdraw |
||
85 | mov ebx,1 ; 1, start of draw |
||
86 | int 0x40 |
||
87 | |||
88 | mov eax,48 |
||
89 | mov ebx,3 |
||
90 | mov ecx,sc |
||
91 | mov edx,sizeof.system_colors |
||
92 | int 0x40 |
||
93 | |||
94 | ; DRAW WINDOW |
||
95 | mov eax,0 ; function 0 : define and draw window |
||
96 | mov ebx,100*65536+200 ; [x start] *65536 + [x size] |
||
97 | mov ecx,100*65536+65 ; [y start] *65536 + [y size] |
||
98 | mov edx,[sc.work] ; color of work area RRGGBB,8->color glide |
||
99 | mov esi,[sc.grab] ; color of grab bar RRGGBB,8->color |
||
100 | or esi,0x80000000 |
||
101 | mov edi,[sc.frame] ; color of frames RRGGBB |
||
102 | int 0x40 |
||
103 | |||
104 | ; WINDOW LABEL |
||
105 | mov eax,4 ; function 4 : write text to window |
||
106 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
107 | mov ecx,[sc.grab_text] ; color of text RRGGBB |
||
108 | or ecx,0x10000000 |
||
109 | mov edx,labelt ; pointer to text beginning |
||
110 | mov esi,labellen-labelt ; text length |
||
111 | int 0x40 |
||
112 | ; CLOSE BUTTON |
||
113 | mov eax,8 ; function 8 : define and draw button |
||
114 | mov ebx,(200-17)*65536+12 ; [x start] *65536 + [x size] |
||
115 | mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
||
116 | mov edx,1 ; button id |
||
117 | mov esi,[sc.grab_button] ; button color RRGGBB |
||
118 | int 0x40 |
||
119 | |||
120 | mov ebx,25*65536+35 ; draw info text with function 4 |
||
121 | mov ecx,[sc.work_text] |
||
122 | mov edx,text |
||
123 | mov esi,40 |
||
124 | newline: |
||
125 | mov eax,4 |
||
126 | int 0x40 |
||
127 | add ebx,10 |
||
128 | add edx,40 |
||
129 | cmp [edx],byte 'x' |
||
130 | jnz newline |
||
131 | |||
132 | mov eax,12 ; function 12:tell os about windowdraw |
||
133 | mov ebx,2 ; 2, end of draw |
||
134 | int 0x40 |
||
135 | |||
136 | ret |
||
137 | |||
138 | |||
139 | ; DATA AREA |
||
140 | |||
141 | |||
142 | text: |
||
143 | db 'CPU RUNNING AT MHZ ' |
||
144 | db 'x' ; <- END MARKER, DONT DELETE |
||
145 | |||
146 | labelt: |
||
147 | db 'CPU SPEED' |
||
148 | labellen: |
||
149 | |||
150 | I_END: |
||
151 | |||
152 | sc system_colors-> |
||
153 |