              NAME      DAYTIME
              PAGE      65,80
              TITLE     DAYTIME AUTOMATICALLY SETS REAL TIME CLOCK IN TAPR TNC

                  ;This program is to be used in conjunction with either
                  ;a TAPR TNC2 clone ,PK 232  or most any other packet TNC.
                  ;This program when run, will read the DATE and TIME of the
                  ;real time clock in most IBM compatible PC/XT/AT computers.
                  ;This data will be sent to the selected comm port along
                  ;with the appropriate TAPR compatible command, thus setting
                  ;the real time clock in the TNC. This allows use of the
                  ;CONSTAMP,MSTAMP and DAYSTAMP commands in conjunction
                  ;with the TNC,s clock for date/time stamping.
                  ;DAYTIME.COM may be loaded along with a program such as
                  ;YAPP from a batch file.
                  ;In this case DAYTIME.COM is loaded first. This will set
                  ;the real time clock in the TNC, prior to the computer
                  ;executing the YAPP program.

                  ;
                  ;Copyright (c) 1988 Richard Tashner N2EO
                  ;                   163-34 21 Road
                  ;                   Whitestone N.Y. 11357
                  ;
                  ;To assemble use MASM 5.0 and follow these steps:
                  ;
                  ;C> MASM DAYTIME
                  ;C> LINK DAYTIME
                  ;C> EXE2BIN DAYTIME DAYTIME.COM
                  ;C> DEL DAYTIME.EXE

                ;NOTE IGNORE warning L4021: no stack segment
                ;WHEN RUNNING THE LINKER

            ;**************************************************
            ;* THESE THREE PARAMETERS MAY BE CHANGED TO SUIT  *
            ;* INDIVIDUAL NEEDS. SEE DAYTIME.DOC FOR DETAILS  *
            ;**************************************************
BAUDRATE          EQU       083H                ;BAUD RATE SELECT
COMMPORT          EQU       0                   ;COMM PORT SELECT
ATTRIB            EQU       07H                 ;VIDIO COLOR ATTRIBUTE
;**********************************************************************

CR                EQU       0DH                 ;ASCII CARRAGE RETURN
LF                EQU       0AH                 ;ASCII LINE FEED
SPCE              EQU       20H                 ;ASCII SPACE

CSEG              SEGMENT PARA PUBLIC 'CODE'

                  ORG       100H

                  ASSUME CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG
                  ;**************************************************
                  ;*   ROUTINE TO INITIALIZE APPROPRIATE COMM PORT  *
                  ;**************************************************
DAYTIME           PROC       NEAR
                  MOV        AH,0               ;INITIALIZE COMM PORT
                  MOV        AL,BAUDRATE        ;   WITH PROPER BAUD RATE
                  MOV        DX,COMMPORT        ;   AND PROPER COMM PORT
                  INT        14H                ;DO IT!
                             ;*** END OF ROUTINE ***

                  ;*********************************************************
                  ;*   ROUTINE TO INITIALIZE WINDOW AND PRINT SCREEN DATA  *
                  ;*********************************************************
                  MOV        CH,0               ;UPPER LEFT Y
                  MOV        CL,0               ;UPPER LEFT X
                  MOV        DH,24              ;LOWER RIGHT Y
                  MOV        DL,79              ;LOWER RIGHT X
                  CALL       WINDOW             ;CLEAR ENTIRE SCREEN
                  MOV        DH,2               ;Y - AXIS
                  MOV        DL,24              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DX,OFFSET MESS_1   ;DISPLAY MESS_1
                  MOV        AH,9
                  INT        21H                ;DO IT!
                             ;*** END OF ROUTINE ***

                  ;**********************************
                  ;*   ROUTINE TO GET SYSTEM DATE   *
                  ;*    CX=YEAR DH=MONTH DL=DAY     *
                  ;**********************************
                  MOV        AH,2AH             ;GET SYSTEM DATE
                  INT        21H                ;DO IT!
                  SUB        CL,06CH            ;ADJUST 'CL' FOR PROPER YEAR
                  MOV        AL,CL              ;GET LOW ORDER YEAR BYTE
                  AAM                           ;ADJUST TO 'UNPACKED' BCD
                  ADD        AH,30H             ;ADJUST TO ASCII
                  ADD        AL,30H             ;  CHARACTERS
                  MOV        BUFFER+8,AH        ;SAVE HIGH ORDER YEAR BYTE
                  MOV        BUFFER+9,AL        ;SAVE LOW ORDER YEAR BYTE
                  MOV        AL,DH              ;GET HIGH ORDER BYTE IN MONTH
                  AAM                           ;ADJUST TO 'UNPACKED' BCD
                  ADD        AH,30H             ;ADJUST TO ASCII
                  ADD        AL,30H             ;  CHARACTERS
                  MOV        BUFFER+10,AH       ;SAVE HIGH ORDER MONTH BYTE
                  MOV        BUFFER+11,AL       ;SAVE LOW ORDER MONTH BYTE
                  MOV        AL,DL              ;GET HIGH ORDER DAY BYTE
                  AAM                           ;ADJUST TO 'UNPACKED' BCD
                  ADD        AH,30H             ;ADJUST TO ASCII
                  ADD        AL,30H             ;  CHARACTERS
                  MOV        BUFFER+12,AH       ;SAVE HIGH ORDER DAY BYTE
                  MOV        BUFFER+13,AL       ;SAVE LOW ORDER DAY BYTE
                             ;*** END OF ROUTINE ***

                  ;**********************************
                  ;*   ROUTINE TO GET SYSTEM TIME   *
                  ;*       CH=HOUR CL=MINUTE        *
                  ;**********************************
                  MOV        AH,2CH             ;GET SYSTEM TIME
                  INT        21H                ;DO IT!
                  MOV        AL,CH              ;GET HIGH ORDER HOUR BYTE
                  AAM                           ;ADJUST TO 'UNPACKED' BCD
                  ADD        AH,30H             ;ADJUST TO ASCII
                  ADD        AL,30H             ;  CHARACTERS
                  MOV        BUFFER+14,Ah       ;SAVE HIGH ORDER HOUR BYTE
                  MOV        BUFFER+15,Al       ;SAVE LOW ORDER HOUR BYTE
                  MOV        AL,CL              ;GET HIGH ORDER MINUTES BYTE
                  AAM                           ;ADJUST TO 'UNPACKED' BCD
                  ADD        AH,30h             ;ADJUST TO ASCII
                  ADD        AL,30h             ;  CHARACTERS
                  MOV        BUFFER+16,AH       ;SAVE HIGH ORDER MINUTES BYTE
                  MOV        BUFFER+17,AL       ;SAVE LOW ORDER MINUTES BYTE
                             ;*** END OF ROUTINE ***

                  ;*********************************************
                  ;*   ROUTINE TO SEND REAL TIME CLOCK DATA    *
                  ;*              TO SERIAL PORT               *
                  ;*********************************************
                  MOV        DI,OFFSET BUFFER   ;POINT 'DI' TO BUFFER
READDATA:         MOV        AL,[DI]            ;GET DATA IN 1ST LOCATION
                  CMP        AL,'$'             ;TEST FOR END OF BUFFER
                  JE         TERMINATE          ;GO TERMINATE IF ENDED
                  MOV        AH,1               ;WRITE DATA TO COMM PORT
                  MOV        DX,COMMPORT        ;USE PROPER COMM PORT
                  INT        14H                ;DO IT!
HOLD:             AND        AH,128             ;GO HOLD UNTIL READ
                  JNZ        HOLD               ;   HAS BEEN COMPLETED
                  INC        DI                 ;GET NEXT BUFFER LOCATION
                  JMP        READDATA           ;GO READDATA
                             ;*** END OF ROUTINE ***

                  ;******************************************
                  ;*   ROUTINE TO PUT REAL TIME CLOCK DATA  *
                  ;*              UP ON SCREEN              *
                  ;******************************************
TERMINATE:        MOV        DH,15              ;Y - AXIS
                  MOV        DL,38              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+10       ;GET 1ST DIGIT OF MONTH
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,15              ;Y - AXIS
                  MOV        DL,39              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+11       ;GET 2ND DIGIT OF MONTH
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,16              ;Y - AXIS
                  MOV        DL,38              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+12       ;GET 1ST DIGIT OF DAY
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,16              ;Y - AXIS
                  MOV        DL,39              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+13       ;GET 2ND DIGIT OF DAY
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,17              ;Y - AXIS
                  MOV        DL,38              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+8        ;GET 1ST DIGIT OF YEAR
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,17              ;Y - AXIS
                  MOV        DL,39              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+9        ;GET 2ND DIGIT OF YEAR
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,18              ;Y - AXIS
                  MOV        DL,38              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+14       ;GET 1ST DIGIT OF HOUR
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,18              ;Y - AXIS
                  MOV        DL,39              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+15       ;GET 2ND DIGIT OF HOUR
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT
                  MOV        DH,19              ;Y - AXIS
                  MOV        DL,38              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+16       ;GET 1ST DIGIT OF MINUTE
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT
                  MOV        DH,19              ;Y - AXIS
                  MOV        DL,39              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                  MOV        DL,BUFFER+17       ;GET 2ND DIGIT OF MINUTE
                  MOV        AH,2
                  INT        21H                ;DISPLAY IT!
                  MOV        DH,23              ;Y - AXIS
                  MOV        DL,60              ;X - AXIS
                  CALL       POSCURSE           ;POSITION CURSOR
                             ;*** END OF ROUTINE ***

                  ;********************
                  ;*   BELL ROUTINE   *
                  ;********************
                  IN         AL,61H             ;GET DATA IN SOUND PORT
                  AND        AL,0FCH            ;MASK OUT D2 - D7
                  CLI                           ;CLEAR INTERRUPTS
                  MOV        BX,1200            ;SET LOOP FOR BELL DURATION
BELL:             XOR        AL,3               ;TOGGLE BITS D0 - D1
                  OUT        61H,AL             ;OUT SOUND PORT NEW VALUE
                  MOV        CX,250             ;SET DELAY
DELAY:            LOOP       DELAY              ;DELAY
                  DEC        BX                 ;DECREMENT BELL DURATION
                  CMP        BX,0               ;TEST FOR END OF BELL
                  JNZ        BELL               ;GO BELL UNTIL DONE
                  STI                           ;ENABLE INTERRUPTS
                             ;*** ROUTINE ENDS ***

                  ;***********************************
                  ;*   ROUTINE TO CLEAR SCREEN AND   *
                  ;*          EXIT PROGRAM           *
                  ;***********************************
HOLD_1:           MOV        AH,6               ;CHECK KEYBOARD
                  MOV        DL,0FFH
                  INT        21H                ;DO IT!
                  JZ         HOLD_1             ;IF NO KEY PRESSED GO HOLD_1
                  MOV        CH,0               ;UPPER LEFT Y
                  MOV        CL,0               ;UPPER LEFT X
                  MOV        DH,24              ;LOWER RIGHT Y
                  MOV        DL,79              ;LOWER RIGHT X
                  CALL       WINDOW             ;CLEAR ENTIRE SCREEN
                  MOV        DH,0               ;Y - AXIS
                  MOV        DL,0               ;X - AXIS
                  CALL       POSCURSE           ;SET CURSOR TO HOME POSITION
                  MOV        AH,04CH            ;TERMINATE PROGRAM
                  INT        21H                ;DO IT!
DAYTIME           ENDP
                             ;*** END OF ROUTINE ***

WINDOW            PROC       NEAR
                  MOV        AH,6               ;INITIALIZE WINDOW
                  MOV        AL,0               ;BLANK ENTIRE CONTENTS
                  MOV        BH,ATTRIB          ;VIDIO ATTRIBUTE
                  INT        10H                ;DO IT!
                  RET
WINDOW            ENDP

POSCURSE          PROC       NEAR
                  MOV        AH,2               ;SET CURSOR POSITION
                  MOV        BH,0               ;SELECT PAGE 0
                  INT        10H                ;DO IT!
                  RET
POSCURSE          ENDP

MESS_1            DB                       'Fight the high cost of software by',CR,LF
                  DB         24 DUP (SPCE),'supporting the SHAREWARE concept..',CR,LF
                  DB         24 DUP (SPCE),' If you find this program useful,',CR,LF
                  DB         21 DUP (SPCE),'a small donation would be appreciated...',CR,4 DUP (LF)
                  DB         24 DUP (SPCE),'DAYTIME by: Richard Tashner N2EO',CR,LF
                  DB         36 DUP (SPCE),'163-34 21 Road',CR,LF
                  DB         36 DUP (SPCE),'Whitestone N.Y.11357',CR,LF,LF
                  DB         11 DUP (SPCE),'DAY/TIME clock in TNC now set to following specifications:',CR,LF,LF
                  DB         30 DUP (SPCE),'Month =',CR,LF
                  DB         30 DUP (SPCE),'  Day =',CR,LF
                  DB         30 DUP (SPCE),' Year =',CR,LF
                  DB         30 DUP (SPCE),'Hours =',CR,LF
                  DB         28 DUP (SPCE),'Minutes =',CR,4 DUP (LF)
                  DB         21 DUP (SPCE),'--< Press any key to exit program >--','$'

BUFFER            DB         'DAYTIME ',10 DUP (?),CR,'$'

CSEG              ENDS
                  END        DAYTIME