Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;   BCD CLOCK
3
;
4
;   Compile with FASM for Menuet
5
;
6
;
7
 
8
use32
9
 
10
 org 0x0
11
 
12
 db 'MENUET01'
13
 dd 0x01
14
 dd START
15
 dd I_END
16
 dd 0x100000
17
 dd 0x7fff0
18
 dd 0x0 , 0x0
19
 
20
include "lang.inc"
21
include "macros.inc"
22
 
23
 
24
START:
25
 
26
     call drawwindow
27
 
28
still:
29
 
30
 
31
    mov  eax,23   ; wait for timeout
32
    mov  ebx,50
33
    int  0x40
34
 
35
    cmp  eax,1 ; redraw ?
36
    je red
37
 
38
    cmp  eax,3 ; button in buffer ?
39
    je button
40
 
41
    call  drawclock
42
 
43
    jmp still
44
 
45
red: ; redraw
46
    call drawwindow
47
    jmp  still
48
 
49
button:
50
    mov  eax,17   ; get id
51
    int  0x40
52
 
53
    cmp  ah,1 ; button id=1 ?
54
    jne  noclose
55
    mov  eax,-1   ; close this program
56
    int  0x40
57
  noclose:
58
 
59
    jmp  still
60
 
61
drawclock:
62
 
63
    mov eax,3 ; get time
64
    int  0x40
65
    bswap eax
66
    shr  eax,8
67
    mov  edi,dg1
68
    mov  ecx,6
69
dgtomem:
70
    push eax
71
    and  al,15
72
    mov  [edi],al
73
    inc  edi
74
    pop  eax
75
    shr  eax,4
76
    loop dgtomem
77
    mov  ebx,74*65536+10
78
    mov  edi,dg1
79
digitlp:
80
    mov  ecx,30*65536+10
81
    xor  esi,esi
82
plotlp:
83
    xor  edx,edx
84
    test byte[edi],8
85
    je	 nobit
86
    mov  edx,0x00ff0000
87
nobit:
88
    mov  eax,13  ; plot 8,4,2,1
89
    int  0x40
90
    add  ecx,12*65536
91
    shl  byte[edi],1
92
    inc  esi
93
    cmp  esi,4
94
    jne  plotlp
95
    shr  byte[edi],4
96
    mov  edx,0x00880040
97
    mov  eax,13 ; draw digit box
98
    int  0x40
99
    pusha
100
    mov  edx,ebx
101
    and  edx,0xffff0000
102
    shr  ecx,16
103
    or	 edx,ecx
104
    add  edx,3*65536+2
105
    mov  ebx,0x00010100
106
    mov  ecx,[edi]
107
    mov  esi,0x00ffffff
108
    mov  eax,47  ; display decimal
109
    int  0x40
110
    popa
111
    sub  ebx,12*65536
112
    inc  edi
113
    cmp  edi,dg1+6
114
    jne  digitlp
115
    ret
116
 
117
 
118
drawwindow:
119
 
120
 
121
    mov  eax,12
122
    mov  ebx,1 ; start redraw
123
    int  0x40
124
 
125
    mov  eax,0 ; window
126
    mov  ebx,100*65536+100
127
    mov  ecx,100*65536+100
128
    mov  edx,0x83400088
129
    mov  esi,0x805080d0
130
    mov  edi,0x000000ff
131
    int  0x40
132
 
133
call drawclock
134
 
135
    mov  eax,4 ; text
136
    mov  ebx,8*65536+8
137
    mov  ecx,0x10ddeeff
138
    mov  edx,title
122 diamond 139
    mov  esi,titlend-title
31 halyavin 140
    int  0x40
141
 
142
 
143
    mov  eax,12
144
    mov  ebx,2 ; end redraw
145
    int  0x40
146
 
147
    ret
148
 
149
 
150
 
151
title:
152
     db   'BCD Clock'
153
titlend:
154
 
155
dg1:   db  ?
156
 
157
      I_END: