;************************************************
; CLOCK.M68 - A simple time/date display program
;
; by Dave Heyliger - AMUS Staff
;
; for AAA - February '87
;************************************************

       SEARCH  SYS                             ;AMOS universal files
       SEARCH  SYSSYM
       SEARCH  TRM
       SEARCH  AAA                             ;AAA universal file

       AUTOEXTERN                              ;external label $ODTIM

       PHDR    -1,0,PH$REE!PH$REU              ;re-entrant, re-usable

       ;create new MACRO's from old
       DEFINE  CLEAR=PRTTAB -1,0               ;clear screen
       DEFINE  CUROFF=PRTTAB -1,29.            ;cursor off
       DEFINE  CURON=PRTTAB -1,28.             ;cursor on

       ;setup registers for call to $ODTIM
       CLR     D3                              ;use system date/time
       MOV     #0,A2                           ;zero out A2 (output to term)
       MOV     #^H000002F6,D5                  ;set the flag (just date)

       ;now clear the screen and display startup time
       CLEAR                                   ;equivalent to PRTTAB -1,0
       CUROFF                                  ;cursor off
       PRTTAB  3,20.                           ;tab to row 3, column 1
       TYPE    <Today is >                     ;give the user the day
       CALL    $ODTIM                          ;output system date and time

       ;output "Current time" header...
       PRTTAB  5,25.                           ;tab row 5, column 30.
       TYPE    <Current time is: >             ;our "clock" header

       ;set control C and setup registers for $ODTIM
       CTC                                     ;"set" control C (safety)
       CLR     D3                              ;setup for $ODTIM
       MOV     #^H00004801,D5                  ;set flags for $ODTIM

       ;now at every .5 seconds, get updated time out on the screen
LOOP:   CTRLC   BYEBYE                          ;quit on ^C
       PRTTAB  5,42.                           ;tab to end of <Current ti...>
       CALL    $ODTIM                          ;output the time
       SLEEP   #5000.                          ;sleep for .5 seconds
       BR      LOOP

       ;come here on control c (quit)
BYEBYE: CURON                                   ;cursor back on
       CLEAR                                   ;clear the screen
       EXIT                                    ;return to the dot

       END