;THIS PROGRAM IS TO SET UP THE LABELS ON LINE 25 OF THE ZENITH TERMINAL
;WHICH INDICATE THE USES OF THE FUNCTION KEYS IN TMAKER
;
;
;  *** NOTE ***   This program is strictly terminal dependent (Z/H-19),
;                 but it may be used as an example of setting
;                 up a terminal status line, and/or the use of
;                 the command line tail  -  If used as is,
;                 TMODIFY must be used to incorporate the function
;                 keys for the indicated uses.
;
;
;Revised 07/12/84 to chain to Tmaker directly.
;
;Revised 11/30/84 to handle Command Line tail
;
BDOS   EQU     5        ; BDOS ENTRY POINT
STROUT EQU     9        ; STRING OUT FUNCTION
RESET  EQU     0        ; RESTARTS CP/M
CHAIN$PROG     EQU 2FH  ; Chain to Program Function
;
CMD$LN EQU     80H      ; CP/M Command line buffer
;
CHN$FLG EQU    0FFH     ; Chain Flag
;
ESC    EQU     27       ; ESCAPE EQUATE
;
       ORG     100H     ; START OF TPA
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,SETUP  ; ENABLE 25TH LINE, REVERSE VIDEO
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,F1     ; FUNCTION 1
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,F2     ; FUNCTION 2
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,F3     ; FUNCTION 3
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,F4     ; FUNCTION 4
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,F5     ; FUNCTION 5
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,BLUE   ; FUNCTION BLUE
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,RED    ; FUNCTION RED
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,GREY   ; FUNCTION GREY
       CALL    BDOS     ; SEND IT
;
       MVI     C,STROUT ; SET UP FOR BDOS CALL
       LXI     D,CLEAN  ; TURN OFF REVERSE VIDEO
       CALL    BDOS     ; SEND IT
;
;      This segment temporarily stores what is in the command
;      line buffer, to reincorporate it later.
;
       LXI     B,TAIL   ; Initialize BC with the data buffer address
       LXI     D,CMD$LN ; Initialize DE with Command Line Buffer address
       LDAX    D        ; Check length byte for zero
       CPI     0
       JZ      NEXT     ; If so, jump out immediately
       INX     D ! INX  D ; Increment twice - past length byte
;                           and initial zero
LOOP1: LDAX    D        ; Load A with character
       CPI     0        ; Compare with terminator character
       JZ      NEXT     ; if so, jump out; otherwise, continue
       STAX    B        ; Store in the buffer
       INX     D        ; Increment the
       INX     B        ;    Pointers
       JMP     LOOP1    ; and continue
;
;      This segment adds a $ to the end of the data buffer
;
NEXT:  MVI     A,'$'    ; Move Terminator character to A,
       STAX    B        ;   and store it
;
;      This segment moves all the info back into the Command Line
;      Buffer, for later execution.
;
       LXI     B,CMD$LN ; Initialize BC with Command Line Buffer address
       LXI     D,PROG1  ; Initialize DE with the program name address
       CALL    LOOP
;
       LXI     D,TAIL   ; Initialize DE with the data buffer address
       CALL    LOOP
;
       LXI     D,PROG2  ; Initialize DE with the program name address
       CALL    LOOP
;
CHAIN: MVI     C,CHAIN$PROG ; Set up for BDOS call
       MVI     E,CHN$FLG
       CALL    BDOS     ; and GO
;
       MVI     C,RESET  ; SET UP FOR BDOS CALL
       CALL    BDOS     ; SEND IT
;
LOOP:  LDAX    D        ; Load A with character
       CPI     '$'      ; Compare with terminator character
       RZ               ; if so, return
       STAX    B        ; Store in the C L B
       INX     D        ; Increment the
       INX     B        ;    Pointers
       JMP     LOOP     ; and continue
;
SETUP: DB      ESC,'x','1'   ; ENABLE 25TH LINE SEQUENCE
       DB      ESC,'p','$'   ; REVERSE VIDEO SEQUENCE
;
F1:    DB      ESC,'Y','8',' '         ; DIRECT CURSOR ADDRESS
       DB      'f1=rdraw','$'          ; f1 FUNCTION
;
F2:    DB      ESC,'Y','8',41          ; DIRECT CURSOR ADDRESS
       DB      'f2=nword','$'          ; f2 FUNCTION
;
F3:    DB      ESC,'Y','8',50          ; DIRECT CURSOR ADDRESS
       DB      'f3=c2buf','$'          ; f3 FUNCTION
;
F4:    DB      ESC,'Y','8',59          ; DIRECT CURSOR ADDRESS
       DB      'f4=m2buf','$'          ; f4 FUNCTION
;
F5:    DB      ESC,'Y','8',68          ; DIRECT CURSOR ADDRESS
       DB      'f5=inbuf','$'          ; f5 FUNCTION
;
BLUE:  DB      ESC,'Y','8',77          ; DIRECT CURSOR ADDRESS
       DB      'Blue=clbuf','$'        ; Blue FUNCTION
;
RED:   DB      ESC,'Y','8',88          ; DIRECT CURSOR ADDRESS
       DB      'Red=stop','$'          ; Red FUNCTION
;
GREY:  DB      ESC,'Y','8',97          ; DIRECT CURSOR ADDRESS
       DB      'Grey=Rmode','$'        ; Grey FUNCTION
;
CLEAN: DB      ESC,'q'                 ; TURN OFF REVERSE VIDEO
       DB      ESC,'H',ESC,'J','$'     ; HOME CURSOR; CLEAR SCREEN
;
PROG1: DB      'TMAKER ','$'           ; First program to chain to
PROG2: DB      '!','CLRLABEL'          ; Second program to chain to
       DB      0,'$'
TAIL:  DS      80H                     ; Storage for command tail
       END
