Subversion Repositories Kolibri OS

Rev

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