;**************************** AMUS Program Label ******************************
;* Filename: ALMTIM.M68                                      Date: 4/18/90
;* Category: UTIL         Hash Code: 260-254-244-264      Version: 1.0(100)
;* Initials: GR/AM        Name: James A. Jarboe IV
;* Company: Educational Video Network, Inc.         Telephone #: 4092955767
;* Related Files: MUST LNKLIT TO PRODUCE ALMTIM.LIT
;* Min. Op. Sys.: 1.3                           Expertise Level: BEG
;* Special: 2.x assembly is 260-254-244-264, 1.x assembly is 164-214-630-117
;* Description: Sets internal terminal clock on AM65 and Wyse60 terminals to
;* current system time.  Different hash totals are due to differences in $ODTIM
;* call on 1.x and 2.x systems.
;******************************************************************************
;*; Updated on 18-Apr-90 at 10:26 PM by James A. Jarboe IV; edit time: 0:17:04
;****************************************************************************
;*                                                                         *
;*                              ALMTIM.M68                                 *
;*                                                                         *
;*                     Written By: James A. Jarboe IV                      *
;*                            1401 19th Street                             *
;*                          Huntsville, TX 77340                           *
;*                              409-295-5767                               *
;*                                                                         *
;*                               18-Apr-90                                 *
;*                                 GR/AM                                   *
;****************************************************************************
;*                Copyright (c) 1990 - James A. Jarboe IV                  *
;*                   Free to AMUS Users - Not for Sale.                    *
;***************************************************************************
;
; Description:  Sets the internal terminal clock on an AM65, or WYSE60
;               to current system time.
;
;               Sets WYSEWORKS clock for WYSE terminals
;               Sets AM65 clock for Calculator-Calendar-Clock toolkit.
;                      (Press FancyFunct key and CapsLock for Toolkit.)
;
; Note: If terminal is turned off, ALMTIM must be run again when terminal
;       is turned back on to reset terminal time to current system time.
;
; Edit History:
;
;[100] 18-Apr-90 Written by James A. Jarboe IV.
;
       ASMMSG  " "
       ASMMSG  "(                By                  )"
       ASMMSG  "(        James A. Jarboe IV          )"
       ASMMSG  "(                                    )"
       ASMMSG  "(   LNKLIT ALMTIM after assembly to  )"
       ASMMSG  "(        create ALMTIM.LIT.          )"
       ASMMSG  "(                                    )"
       ASMMSG  "(     Type ALMTIM/?  for Help        )"
       ASMMSG  " "

       PAGE
;***************************************************************************
;                                                                          *
;                           S Y M B O L I C S                              *
;                                                                          *
;***************************************************************************
;
       SEARCH  SYS                     ; Amos Standard symbolic.
       SEARCH  SYSSYM                  ; Amos Standard symbolic.

       EXTERN $ODTIM                   ; Define external.

       PAGE
;***************************************************************************
;                                                                          *
;                      C U R R E N T   V E R S I O N                       *
;                                                                          *
;***************************************************************************
;
       VMAJOR  =       1.              ; Written by James A. Jarboe IV
       VMINOR  =       0               ;
       VEDIT   =       100.            ; Current release. /JAJ
       VWHO    =       0               ;


       PAGE
;***************************************************************************
;                                                                          *
;                       P R O G R A M   M A C R O S                        *
;                                                                          *
;***************************************************************************
;
;*************
;   PRTTAB   *
;*************
;
; Similar to Basic PRINT TAB directive.
;
; Where:
;        ROW = Decimal Row number to set or beginning of TCRT call.
;        COL = Decimal Column number to set or end of TCRT call.
;
; Example:
;           PRTTAB 3, 15.     ; Will place cursor at row 3, column 15.
;           PRTTAB -1, 0.     ; Will Clear screen.
;
; D1 will be destroyed.
;
DEFINE  PRTTAB  ROW, COL
       MOVW    #<ROW_8.+COL>, D1       ; Set up D1.
       TCRT                            ; Do TCRT call.
ENDM


;*************
;   HTYPE    *
;*************
;
; Description:
;               Output to terminal, the defined text in a
;               highlighted fashion. Text will always start out in
;               low intensity {? TAB(-1,11)} until an "_" character
;               is found then text will be output in normal intensity
;               {? TAB(-1,12)} until another "_" is found.
; Where:
;        TEXT  = A line of text.
;                A $CR will output a $CR $LF pair.
;
;        HLT   = Value of highlight character.
;                If HLT is not defined then defaults to "_".
; Example:
;           HTYPE  <_This is bright._ This is dim.>
;           {continuation of code}
;           EXIT
;
DEFINE  HTYPE   TEXT1, HLT              ; Highlight type text.

; If HLT is blank then default to "_" else set to HLT value
;  Must MOVB to maintain even assembly.
;
       IF      B,  HLT, MOV    #$UL, D6  ; Use _.
       IF      NB, HLT, MOV    #HLT, D6  ; Use defined character.
       LEA     A6, 10$$                ; Index Text.
       CALL    $HTYP.                  ; Do highlight type.
       BR      20$$                    ; Bypass text.

10$$:   ASCII   `TEXT1`                 ; Text.
       BYTE    0                       ; End of text.
       EVEN                            ; Even up assembly.
20$$:                                   ; Next line of code.
ENDM

;*************
;   HTYPSP   *
;*************
;
; Description:
;               Output to terminal, the defined text and a space in a
;               highlighted fashion. Text will always start out in
;               low intensity {? TAB(-1,11)} until an "_" character
;               is found then text will be output in normal intensity
;               {? TAB(-1,12)} until another "_" is found.
; Where:
;        TEXT  = A line of text.
;                An additional space will be output after text.
;
;        HLT   = Value of highlight character.
;                If HLT is not defined then defaults to "_".
;
; Example:
;           HTYPSP  <_This is bright._ This is dim.>
;           {continuation of code}
;           EXIT
;
DEFINE  HTYPSP  TEXT1, HLT

; If HLT is blank then default to "_" else set to HLT value
;  Must MOVB to maintain even assembly.
;
       IF      B, HLT,         MOVB    #$UL, D6  ; Use "_".
       IF      NB, HLT,        MOVB    #HLT, D6  ; Use defined character.
       LEA     A6, 10$$                ; Index text to type out.
       CALL    $HTYP.                  ; Call Highlight TYPe.
       BR      20$$                    ; Branch over text.

10$$:   ASCII   `TEXT1`                 ; Defined text.
       BYTE    32.,0                   ; Add a space.
       EVEN                            ; Even assembly.
20$$:
ENDM

;*************
;   HTYPCR   *
;*************
;
; Description:
;               Output to terminal, the defined text and CRLF pair in a
;               highlighted fashion. Text will always start out in
;               low intensity {? TAB(-1,11)} until an "_" character
;               is found then text will be output in normal intensity
;               {? TAB(-1,12)} until another "_" is found.
; Where:
;        TEXT  = A line of text.
;                A $CR will output a $CR $LF pair.
;
;        HLT   = Value of highlight character.
;                If HLT is not defined then defaults to "_".
;
; Example:
;           HTYPCR  <_This is bright._ This is dim.>, $UL
;           {continuation of code}
;           EXIT
;
DEFINE  HTYPCR  TEXT1, HLT

; If HLT is blank then default to "_" else set to HLT value
;  Must MOVB to maintain even assembly.
;
       IF      B, HLT,         MOV     #$UL, D6  ; Use _.
       IF      NB, HLT,        MOV     #HLT, D6  ; Use defined character.
       LEA     A6,10$$                 ; Index text.
       CALL    $HTYP.                  ; Use Highlight TYPe.
       BR      20$$                    ; Branch over text.

10$$:   ASCII   `TEXT1`                 ; The text.
       BYTE    13.,0                   ; Add a CR. $HTYP. does LF.
       EVEN                            ; Even assembly.
20$$:
ENDM


       PAGE
;***************************************************************************
;                                                                          *
;              B U F F E R   S I Z E S   A N D   E Q U A T E S             *
;                                                                          *
;***************************************************************************
;
       IF      NDF, $LF,       $LF  = 10.  ; A linefeed character.
       IF      NDF, $CR,       $CR  = 13.  ; A Carriage return.
       IF      NDF, $ESC,      $ESC = 27.  ; The "escape" character.
       IF      NDF, $QUOTE,    $QUOTE = 34.; The " character.
       IF      NDF, $UL,       $UL  = 95.  ; The "_" character.

       PAGE
;***************************************************************************
;                                                                          *
;                 S T A R T   O F   P R O G R A M   C O D E                *
;                                                                          *
;***************************************************************************
;
;+************************+
;        ALMTIM           *
;+************************+
;
; Sets a terminal's internal clock.
;
; Description:
;
;       Will set the internal clock on an AM65 or Wyse60 terminal to the
;        current system time.
;
; Arguments:
;
;       None
;
; Returned:
;
;       Terminal's internal clock will be set to current system time.
;
; Dependancies:  Must have a terminal with internal clock and
;                must respond to ESC c 8 hh mm code.
;
; Program header.
;
SETALM: PHDR    -1, 0, PH$REU!PH$REE    ; Reusable, Reentrant.

; Allocate our local impure area.
;
       BYP                             ; Bypass white space.
       LIN                             ; User requested something?
       BNE     HELPEM                  ;  Yes..show them help.

; Output code sequence to set internal terminal clock.
;
       TTYI    CODSEQ                  ; Output following code sequence.
       BYTE    $ESC, 'c, '8, 0         ; Escape c 8
       SUB     A2, A2                  ; Output to terminal.
       CLR     D3                      ; Set no Date.
       MOV     #^B001010000000001, D5  ; Set Time, 24hr, no colon.
       CALL    $ODTIM                  ; Set current time to terminal.

       EXIT

HELPEM: CRLF                            ; Bump one line.
       HTYPCR  <%Usage: _ALMTIM_ (cr)>
       CRLF

; Display different usages of HTYP?? macro that uses $HTYP. call.
;
       HTYPSP  <  Sets the internal terminal clock for _AM65_, _Wyse60_>
       HTYPCR  <to the current>
       HTYPSP  <  system time. If terminal is turned _off_, internal>
       HTYPCR  <time must be reset.>
       CRLF
       HTYPSP  <  Press _FancyFunct_ key and _CapLock_ on _AM65_ for>
       HTYPCR  <_Accessory Tool Kit_.>
       CRLF
       HTYPSP  <  Press _Ctrl_ and _Caplock_ on _Wyse60_>
       HTYPCR  <for "WYSEWORKS".>, $QUOTE      ; Use quotes for highlight.

       CRLF

; Notice only one highlight character is used. This leaves the terminal
;  in bright mode on exit.
;
       HTYPCR  <  Courtesy of _James A. Jarboe IV>
       CRLF
       EXIT


;+************************+
;         $HTYP.          *
;+************************+
; Outputs text to terminal in Low intensity and High Intensity.
;
; Modified from QTYPE by Tom Faust on the AMUS Network.
;
; Description:
;       By using "_" as a highlight character, text can easily be defined
;       to be output to a terminal in High or low intensity. Initially
;       output is set to be low intensity. At the occurance of each "_",
;       intensity is reversed. Defined text must be terminated by a null.
;       This routine is be used with JAJUNV defined macros:
;
;               HTTYL   = Output addressed text. (CR terminated will add LF)
;               HTYPE   = Output defined text.
;               HTYPSP  = Output defined text + space.
;               HTYPCR  = Output defined text + CR + LF.
;
; Passed:
;
;       A6      => Indexes text string to output.
;       D6      := Highlight character value.
;
; Returned:
;
;       A6      => Indexes past end of output text.
;
; Dependencies:
;
;               None.
;
; Side Effects:
;
;       All standard nonvolatile registers (D0-D5, A0-A5) are preserved.
;
; Example:
;
;       LEA     A6, THETXT
;       MOVB    #$UL, D6
;       CALL    $HTYP.
;       {continuation of code
;       EXIT
; THETXT:       ASCIZ <This is low. _This is high_>
;
$HTYP.:
       SAVE    A0, D1-D3               ; Save registers we use.
       MOVB    D6, D2                  ; Save highlight flag. D6 gets dest.
       MOV     A6, A0                  ; Get address of text to type.
       CLR     D3                      ; Preclear high intensity flag.

; Initially set low intensity output.
;
10$:    MOVW    #<-1_8.+ 11.>, D1       ; Set (-1,11).
       TCRT                            ; Output TCRT call.

; Do the string of text until a null is found.
;
20$:    MOVB    (A0)+, D1               ; Get next character in string.
       BEQ     99$                     ;   Done at null.
       CMPB    D1, D2                  ; Is this a highlight character?
       BEQ     40$                     ;  Yes..brighten output.

; Output a character. If it was a CR then do a line feed also.
;
30$:    TTY                             ;  No..Output the character.
       CMPB    D1, #$CR                ; Is this a CR?
       BNE     20$                     ;  No..get next character.
       MOVB    #$LF, D1                ;  Yes..set up LF.
       BR      30$                     ; Output character.

40$:    COM     D3                      ; Flag change in intensity.
       BEQ     10$                     ;   if zero, set low
       MOVW    #<-1_8.+ 12.>, D1       ;       else set high
       TCRT                            ; Output intensity.
       BR      20$                     ; Get next character.

; Set A6 to point past end of output text  before returning to caller.
;
99$:    MOV     A0, A6                  ; Index past end of typed string.
       REST    A0, D1-D3               ; Restore registers.
       RTN                             ; Return to caller.

       END