Subversion Repositories Kolibri OS

Rev

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

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