home *** CD-ROM | disk | FTP | other *** search
- ;┌───────────────────────────────────────────────────────────┐
- ;│ CLOCK.ASM │
- ;│ Dan Travison │
- ;├───────────────────────────────────────────────────────────┤
- ;│ Clock uses fields for the positions of each 'LCD' │
- ;│ position. │
- ;│ │
- ;│ Fields are 'turned on' by filling the field with a │
- ;│ character. The fields are turned off by writing │
- ;│ 0 to the field (transparent blank). │
- ;│ │
- ;│ Also, the user can press a key to change the fill │
- ;│ character. Using the ALT key with the numeric │
- ;│ keypad allows the use of translucent blanks │
- ;│ with ALT-255. │
- ;│ │
- ;└───────────────────────────────────────────────────────────┘
-
- title clock
- page 60,132
-
- include dvapi.inc
- include dvapi.mac
-
- code segment
- assume cs:code,ds:code
- org 0100h
-
- entry: jmp start
-
- numtable db 01110111b ;0
- db 01000100b ;1
- db 00111110b ;2
- db 01101110b ;3
- db 01001101b ;4
- db 01101011b ;5
- db 01111001b ;6
- db 01000110b ;7
- db 01111111b ;8
- db 01001111b ;9
-
- fldchar db 1bh,0
- dw fldcharl-4
- db 0f1h
- fldchar_fld db 0
- fldchar_chr db 20h
- fldcharl equ $-fldchar
-
- fldoff db 1bh,0
- dw fldoffl-4
- db 0f1h
- fldoff_num db 0
- db 0h
- fldoffl equ $-fldoff
-
- @asciiz panel_name, 'CLOCK.PLB'
- @str pan_entry,'CLOCK'
-
- tim dd 0 ;timer handle
- obq dd 0
- win dd 0 ;window handle
- key dd 0 ;keyboard handle
- pan dd 0 ;panel handle
-
- hour db 25
- min db 61
-
- start: mov ax,cs ;setup data segment
- mov ds,ax
-
- @call dvpresent ;check for DESqview
- test ax,ax
- jz eoj ;if not present, exit
- call inits ;get object handles and setup window
- jc eoj
- main:
- call time ;display time
- mov cx,100 ;1 second delay
- xor dx,dx ;clear high word
- @push dxcx ;push delay
- @send addto,tim ;set timer
- @send read,obq ;wait on timer
- @pop bxax
- @cmp key
- jne main
- @send read,key
- @pop esdi
- @pop esdi
- mov al,byte ptr es:[di]
- mov fldchar_chr,al
- mov hour,99
- mov min,99
- jmp main ;loop indefinitely
-
- eoj:
- mov ah,4ch
- int 21h
-
- ;┌───────────────────────────────────────────────────────────┐
- ;│ inits: initialization routines │
- ;│ │
- ;│ get/create required handles │
- ;│ open the panel library │
- ;│ apply the CLOCK panel │
- ;│ turn off the hardware cursor │
- ;├───────────────────────────────────────────────────────────┤
- ;│ input: │
- ;│ none │
- ;│ output: │
- ;│ none │
- ;└───────────────────────────────────────────────────────────┘
-
- inits proc near
- @send new,timer ;get required object handles
- @pop tim
- @send handle,me
- @pop win
- @send handle,keyme
- @pop key
- @send handle,objqme
- @pop obq
- @send new,panel
- @pop pan
- mov si,offset panel_name ;panel file name
- mov cx,panel_namel ;length of file name
- @mov esdi,pan
- call pan_open
- jc inits_end
-
- mov si,offset pan_entry
- mov cx,pan_entryl
- @mov esdi,pan
- call pan_apply ;apply the CLOCK panel
- jc inits_end
- mov ax,02h
- xor bx,bx
- @push bxax
- @send subfrom,keyme ;turn off the hardware cursor
- inits_end:
- ret
- inits endp
-
- ;┌───────────────────────────────────────────────────────────┐
- ;│ get_time: get system time, format for display │
- ;├───────────────────────────────────────────────────────────┤
- ;│ input: │
- ;│ none │
- ;│ output: │
- ;│ none │
- ;└───────────────────────────────────────────────────────────┘
-
- time proc near
- mov ah,2ch
- int 21h
- push dx
- push cx
- mov al,ch
- cmp al,hour
- je time_min
- mov hour,al
- mov dh,1
- call fld_set
- time_min:
- pop ax
- cmp al,min
- je time_sec
- mov min,al
- mov dh,15
- call fld_set
- time_sec:
- pop ax
- xchg ah,al
- mov dh,29
- call fld_set
- @send redraw,win
- time_end:
- ret
- time endp
-
- ;
-
- fld_set proc near
- aam ;divide by 10
- push ax
- call fld_test
- pop ax
- xchg ah,al
- call fld_test
- ret
- fld_set endp
-
-
- fld_test proc near
- call num_off
- mov bx,offset numtable
- add bl,ah
- mov al,byte ptr [bx]
- mov ah,1
- mov cx,7
- fld_test_loop:
- test al,ah
- jz fld_test_off
- call fld_char
- fld_test_off:
- inc dh
- shl ah,1
- loop fld_test_loop
- ret
- fld_test endp
-
- num_off proc near
- @push bxax
- push dx
- mov cx,7
- num_off_loop:
- @push dxcx
- mov fldoff_num,dh
- xor dx,dx
- mov cx,fldoffl
- mov si,offset fldoff
- @push dssi
- @push dxcx
- @send write,win
- @pop dxcx
- inc dh
- loop num_off_loop
-
- pop dx
- @pop bxax
- ret
- num_off endp
-
-
- ; dh field number
- ; dl character
-
- fld_char proc near
- @push dxcx
- @push bxax
-
- mov fldchar_fld,dh
- mov si,offset fldchar
- mov cx,fldcharl
- xor dx,dx
- @push dssi
- @push dxcx
- @send write,win
-
- @pop bxax
- @pop dxcx
- ret
- fld_char endp
-
- include pan_open.inc
- include pan_appl.inc
-
- code ends
- end entry
-