Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;   TIMER
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
    int  0x40
26
 
27
red:
28
    call draw_window
29
 
30
still:
31
 
32
    mov  eax,23                 ; wait here for event
33
    mov  ebx,50
34
    int  0x40
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
    int  0x40
49
 
50
 
51
;   *********************************************
52
;   *******  WINDOW DEFINITIONS AND DRAW ********
53
;   *********************************************
54
 
55
draw_clock:
56
    mov  eax, 13           ; clear area
57
    mov  ebx, 10*65536+55
58
    mov  ecx, 30*65536+10
59
    mov  edx, [sc.work]
60
    int  0x40
61
 
62
    mov  eax, 26           ; get system counter
63
    mov  ebx, 9
64
    int  0x40
65
 
66
    cdq ;xor  edx,edx
67
    mov  ebx,100
68
    div  ebx
69
 
70
  push eax
71
 
72
  xor  edx,edx
73
  mov  ebx,60
74
  div  ebx
75
  mov  ecx,eax
76
 
77
  push ecx
78
  push ecx
79
 
80
  xor  edx,edx
81
  mov  ebx,60
82
  div  ebx
83
  mov  ecx,eax
84
 
85
  mov  eax,47           ; HH
86
  mov  esi,[sc.work_text]
87
  or   esi,0x10000000
88
  mov  ebx,0x00020000
89
  mov  edx,10*65536+30
90
  int  0x40
91
 
92
  pop  eax              ; MM
93
  imul ecx,ecx,60
94
  sub  eax,ecx
95
  mov  ecx,eax
96
  mov  eax,47
97
  add  edx,20*65536
98
  int  0x40
99
 
100
  pop  ecx
101
  pop  eax
102
 
103
  imul ecx,ecx,60
104
  sub  eax,ecx
105
 
106
  mov  ecx,eax          ; SS
107
  mov  eax,47
108
  add  edx,20*65536
109
  int  0x40
110
 
111
  ret
112
 
113
draw_window:
114
    mov  eax,48
115
    mov  ebx,3
116
    mov  ecx,sc
117
    mov  edx,sizeof.system_colors
118
    int  0x40
119
 
120
    mov  eax,12                    ; function 12:tell os about windowdraw
121
    mov  ebx,1                     ; 1, start of draw
122
    int  0x40
123
 
124
                                   ; DRAW WINDOW
125
    mov  eax,0                     ; function 0 : define and draw window
126
    mov  ebx,100*65536+75          ; [x start] *65536 + [x size]
127
    mov  ecx,100*65536+45          ; [y start] *65536 + [y size]
128
    mov  edx,[sc.work]             ; color of work area RRGGBB,8->color gl
129
    mov  esi,[sc.grab]            ; color of grab bar  RRGGBB,8->color gl
130
    or   esi,0x80000000
131
    mov  edi,[sc.frame]            ; color of frames    RRGGBB
132
    int  0x40
133
 
134
                                   ; WINDOW LABEL
135
    mov  eax,4                     ; function 4 : write text to window
136
    mov  ebx,6*65536+7             ; [x start] *65536 + [y start]
137
    mov  ecx,[sc.grab_text]            ; font 1 & color ( 0xF0RRGGBB )
138
    or   ecx,0x10000000
139
    mov  edx,header                ; pointer to text beginning
140
    mov  esi,header.len            ; text length
141
    int  0x40
142
 
143
                                   ; CLOSE BUTTON
144
    mov  eax,8                     ; function 8 : define and draw button
145
    mov  ebx,(75-16)*65536+12      ; [x start] *65536 + [x size]
146
    mov  ecx,4*65536+12            ; [y start] *65536 + [y size]
147
    mov  edx,1                     ; button id
148
    mov  esi,[sc.grab_button]      ; button color RRGGBB
149
    int  0x40
150
 
151
    call draw_clock
152
 
153
    mov  eax,12                    ; function 12:tell os about windowdraw
154
    mov  ebx,2                     ; 2, end of draw
155
    int  0x40
156
 
157
    ret
158
 
159
 
160
; DATA AREA
161
 
162
if lang eq ru
163
    header:
164
         db   ''
165
      .len = $ - header
166
else
167
    header:
168
         db   'TIMER'
169
      .len = $ - header
170
end if
171
 
172
 
173
I_END:
174
 
175
temp dd ?
176
sc system_colors