; ; CLK.A86 - Version 0.0 (for IBM-compatibles) ; Displays The Time-Of-Day In The Center Of The Screen, With "Tick" ; Freeware from Kirk Lawrence ; ; cseg ;start of code segment org 100h ;leave room for base page jmp clrsc ;go start the program ; snd db 1 notes dw 2700,0001,0FFFFh oldsec db 0 pos db 27,'Y+D' time db '00:00:00$' clr db 27,'0',27,'n',27,'c0',27,'b3',27,'E$' cls db 27,'1',27,'m',27,'b7',27,'E$' ; ;------------------------------------------------------------------------ ;Turn off the status line and cursor, set screen colors to cyan-on-black, ;and clear the screen. ; clrsc: mov cl,9 ;function 9 - print string mov dx,offset clr ;point to screen-setting sequence int 224 ;call BDOS ;----------------------------------------------------------------- ;Fetch the time-of-day from the CP/M-86 system clock, and store it ;if the time has changed since the last time we checked. ; fetch: push es ;preserve ES pushf ;preserve the flags mov cl,31h ;function 31h - get SYSDAT address (in BX) int 224 ;call BDOS mov ah,es: byte ptr [bx] + 41 ;get 10's hr in AH mov al,es: byte ptr [bx] + 42 ;get 1's hr in AL mov ch,es: byte ptr [bx] + 44 ;get 10's min in CH mov cl,es: byte ptr [bx] + 45 ;get 1's min in CL mov dh,es: byte ptr [bx] + 47 ;get 10's sec in DH mov dl,es: byte ptr [bx] + 48 ;get 1's sec in DL popf ;restore the flags pop es ;restore ES cmp dl,oldsec ;has the second changed? je chkkey ;no, so go check for a user keypress mov oldsec,dl ;yes, so store the new 'seconds' digit mov bx,offset time ;point BX to time storage area mov [bx] + 0,ah ;store the digits comprising the time mov [bx] + 1,al ; " mov [bx] + 3,ch ; " mov [bx] + 4,cl ; " mov [bx] + 6,dh ; " mov [bx] + 7,dl ; " ;----------------------------- ;Print the time to the screen. ; mov cl,9 ;function 9 - print string mov dx,offset pos ;point DX to positioning & time sequence int 224 ;call BDOS jmp tick ;go check for sound ;--------------------------------------------------------------------------- ;Check to see if user has pressed a key. If not, continue with the program. ;If a key was pressed, check to see if it was the ESC or the "S" key. If ;so, take appropriate action. If not, ignore the keypress and continue. ; chkkey: mov ah,1 ;function 1 - check keyboard buffer int 16h ;call BIOS keyboard services jz fetch ;if no key pressed, go check time again mov ah,0 ;function 0 - get keypress from buffer int 16h ;call BIOS keyboard services cmp al,'s' ;was it the 's' key? je toggle ;yes, go alter the sound status cmp al,'S' ;was it the 'S' key? je toggle ;yes, go alter the sound status cmp al,1Bh ;was it the ESC key? jne fetch ;no, so ignore and go check time again xor ax,ax ;yes, so swallow the keypress mov cl,9 ;function 9 - print string mov dx,offset cls ;point to screen-setting sequence int 224 ;call BDOS xor cx,cx ;function 0 - reset system int 224 ;call BDOS ;------------------------------------------------------------------- ;Check to see if user has specified sound. If so, sound the "tick." ;If not, don't. ; tick: cmp snd,1 ;does user want sound? jne chkkey ;no, so go check for keypress cli ;interrupts off lea si,notes ;point SI to the note sequence cld ;move forward lodsw ;load word into AX and increment SI cmp ax,0FFFFh ;end of sound? jz endtick ;yes, so go end this routine push ax ;no, so push note value onto the stack mov al,10110110b ;value to enable audio into AL out 43h,al ;send it to the port pop ax ;pop note off the stack out 42h,al ;send LSB first mov al,ah ;place MSB in AL out 42h,al ;send it next in al,61h ;read the speaker port or al,00000011b ;OR the gotten value out 61h,al ;send it to the port to turn on speaker lodsw ;load the repeat loop count into AX slowdown: mov cx,1000 ;set delay count in CX sound: loop sound ;do the delay dec ax ;decrement repeat count jnz slowdown ;if not 0, do it again in al,61h ;read the speaker port and al,11111100b ;load value to turn off the speaker in AL out 61h,al ;send it to the speaker port mov cx,500 ;load second delay count into CX endtick: sti ;enable interrupts jmp chkkey ;go check for user keypress ;----------------------------------------------------------------- ;Toggle the sound 'off' or 'on,' depending upon its current state. ; toggle: cmp snd,0 ;is sound off now? je turnon ;yes, so go turn it on mov snd,0 ;set the 'sound' flag to 'off' jmp chkkey ;go check for user keypress turnon: mov snd,1 ;set the 'sound' flag to 'on' jmp chkkey ;go check for user keypress ; end