2011-01-29 21:21:42 +01:00
|
|
|
;
|
|
|
|
; BCD CLOCK
|
|
|
|
;
|
|
|
|
; Compile with FASM for Menuet
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
use32
|
|
|
|
|
|
|
|
org 0x0
|
|
|
|
|
|
|
|
db 'MENUET01'
|
|
|
|
dd 0x01
|
|
|
|
dd START
|
|
|
|
dd I_END
|
|
|
|
dd 0x1000
|
|
|
|
dd 0x1000
|
|
|
|
dd 0x0 , 0x0
|
|
|
|
|
|
|
|
include 'lang.inc'
|
|
|
|
include '../../../macros.inc'
|
|
|
|
|
|
|
|
|
|
|
|
START:
|
|
|
|
red:
|
|
|
|
call drawwindow
|
|
|
|
|
|
|
|
still:
|
|
|
|
|
|
|
|
|
|
|
|
mov eax,23 ; wait for timeout
|
|
|
|
mov ebx,50
|
|
|
|
mcall
|
|
|
|
|
|
|
|
cmp eax,1 ; redraw ?
|
|
|
|
je red
|
|
|
|
|
2011-07-26 05:28:25 +02:00
|
|
|
cmp eax, 2 ; key
|
|
|
|
je key
|
|
|
|
|
2011-01-29 21:21:42 +01:00
|
|
|
cmp eax,3 ; button in buffer ?
|
|
|
|
je button
|
|
|
|
|
|
|
|
call drawclock
|
|
|
|
|
|
|
|
jmp still
|
2011-07-26 05:28:25 +02:00
|
|
|
|
|
|
|
key:
|
|
|
|
mov eax, 2
|
|
|
|
int 0x40
|
|
|
|
jmp still
|
|
|
|
|
2011-01-29 21:21:42 +01:00
|
|
|
button:
|
2011-07-26 05:28:25 +02:00
|
|
|
mov al,17 ; get id
|
2011-01-29 21:21:42 +01:00
|
|
|
mcall
|
|
|
|
|
|
|
|
cmp ah,1 ; button id=1 ?
|
|
|
|
jne noclose
|
2011-07-26 05:28:25 +02:00
|
|
|
or eax,-1 ; close this program
|
2011-01-29 21:21:42 +01:00
|
|
|
mcall
|
|
|
|
noclose:
|
|
|
|
|
|
|
|
jmp still
|
|
|
|
|
|
|
|
drawclock:
|
|
|
|
|
|
|
|
mov eax,3 ; get time
|
|
|
|
mcall
|
|
|
|
bswap eax
|
|
|
|
shr eax,8
|
|
|
|
mov edi,dg1
|
|
|
|
mov ecx,6
|
|
|
|
dgtomem:
|
|
|
|
push eax
|
2012-06-05 12:07:58 +02:00
|
|
|
and al,0x0f
|
2011-01-29 21:21:42 +01:00
|
|
|
mov [edi],al
|
|
|
|
inc edi
|
|
|
|
pop eax
|
|
|
|
shr eax,4
|
|
|
|
loop dgtomem
|
2012-06-05 12:07:58 +02:00
|
|
|
mov ebx,79*65536+11
|
2011-01-29 21:21:42 +01:00
|
|
|
mov edi,dg1
|
|
|
|
digitlp:
|
2012-06-05 12:07:58 +02:00
|
|
|
mov ecx,10*65536+11
|
2011-01-29 21:21:42 +01:00
|
|
|
xor esi,esi
|
|
|
|
plotlp:
|
|
|
|
xor edx,edx
|
|
|
|
test byte[edi],8
|
|
|
|
je nobit
|
|
|
|
mov edx,0x00ff0000
|
|
|
|
nobit:
|
|
|
|
mov eax,13 ; plot 8,4,2,1
|
|
|
|
mcall
|
2012-06-05 12:07:58 +02:00
|
|
|
add ecx,13*65536
|
2011-01-29 21:21:42 +01:00
|
|
|
shl byte[edi],1
|
|
|
|
inc esi
|
|
|
|
cmp esi,4
|
|
|
|
jne plotlp
|
|
|
|
shr byte[edi],4
|
|
|
|
mov edx,0x00880040
|
|
|
|
mov eax,13 ; draw digit box
|
|
|
|
mcall
|
|
|
|
pusha
|
|
|
|
mov edx,ebx
|
|
|
|
and edx,0xffff0000
|
|
|
|
shr ecx,16
|
|
|
|
or edx,ecx
|
|
|
|
add edx,3*65536+2
|
|
|
|
mov ebx,0x00010100
|
|
|
|
mov ecx,[edi]
|
|
|
|
mov esi,0x00ffffff
|
|
|
|
mov eax,47 ; display decimal
|
|
|
|
mcall
|
|
|
|
popa
|
2012-06-05 12:07:58 +02:00
|
|
|
sub ebx,13*65536
|
2011-01-29 21:21:42 +01:00
|
|
|
inc edi
|
|
|
|
cmp edi,dg1+6
|
|
|
|
jne digitlp
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
drawwindow:
|
|
|
|
|
|
|
|
|
|
|
|
mov eax,12
|
|
|
|
mov ebx,1 ; start redraw
|
|
|
|
mcall
|
|
|
|
|
2012-06-05 12:07:58 +02:00
|
|
|
mov eax, 48
|
|
|
|
mov ebx, 4
|
|
|
|
mcall
|
|
|
|
mov ecx, eax
|
2011-01-29 21:21:42 +01:00
|
|
|
xor eax,eax ; window
|
2012-06-05 12:07:58 +02:00
|
|
|
mov ebx,100*65536+113
|
|
|
|
add ecx,100*65536+87
|
2011-01-29 21:21:42 +01:00
|
|
|
mov edx,0x34400088
|
|
|
|
mov edi,title
|
|
|
|
mcall
|
|
|
|
|
|
|
|
call drawclock
|
|
|
|
|
|
|
|
mov eax,12
|
|
|
|
mov ebx,2 ; end redraw
|
|
|
|
mcall
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2011-07-26 05:28:25 +02:00
|
|
|
title db 'BCD Clock',0
|
2011-01-29 21:21:42 +01:00
|
|
|
I_END:
|
2012-06-05 12:07:58 +02:00
|
|
|
dg1: db ?
|