;***************************************************************************
;
;                                AUXPRT.LIT
;                               VERSION 1.2
;
;                      Written By: James A. Jarboe IV
;                             1401 19th Street
;                           Huntsville, TX 77340
;                               409-295-5767
;
;                                 02/24/86
;                           REVISED 10/22/88
;
;                    Copyright (c) James A. Jarboe IV
;                                  GR/AM
;****************************************************************************
; Description:  Turns on terminal auxillary port and prints designated file
;               through the auxilliary port on the terminal
;
; What it does: Opens the file selected
;               turns the auxillary port on
;               changes current terminal driver to DUMB.TDV
;               dumps out the file to the terminal through the aux port
;               dumps it a character at a time
;               changes the terminal driver back to the original driver
;               turns the auxillary port off
;               closes the file
;               returns back to AMOS
;
; Requirements: DUMB.TDV must be in the terminal driver section of system
;               memory as:
;
;                TRMDEF PRINTR,AM300=3,DUMB,9600,20,20,20
;
;               or
;
;                TRMDEF AUXPRT,PSEUDO,DUMB,1,1,1
;
;               DUMB.TDV is a driver that just dumps data through
;Example:
;
;       OBJNAM  DUMB.TDV
;
;DUMB:  WORD    0
;       RTN
;       RTN
;       RTN
;       RTN
;       END
;
;
;       DUMB.M68 is on the AMUS system
;
;
; Usage:  AUXPRT filename.ext
;       or
;         AUXPRT (cr)
;         Enter Filename : filename.ext
;
;       Default extension is LST
;
;
; Other requirments:
;       The terminal must be capable of turning on and off the auxilliary port
;       by software. In some instances (such as a file formatted with control
;       characters for printout on a DIABLO printer), the control codes could
;       affect the terminal display screen and other activities. Therefore,
;       it is best to use an auxilliary port on call that also turns off the
;       output to the terminal. This call is usually refered to as
;       "transparent print on" in the TCRT calls or ? TAB(-1,82);.
;       This is also dependent on the terminal driver attached to your
;       terminal. There are two solutions to this :
;       1). If your TCRT calls for your terminal "TAB(-1,82)" does not
;           turn your auxillary port on and your screen off in "transparent
;           print mode" then change your terminal driver to reflect the
;           correct control code to turn the terminal "transparent print"
;           on and off. The terminal manual usually has these control codes
;       2). If your TCRT codes are already set up in the Terminal driver
;           to turn the auxillary port on and the screen off in "transparent
;           print mode" and the TCRT call code I.E."TAB(-1,192)" is different
;           than TAB(-1,82) then change the AXON=82. to AXON=(your call). Do
;           the same for AXOFF=83.
;
;       Since some terminal drivers are different and since TCRT calls are
;       not consistant some alterations may have to be made.
;
;       I have tested this program using SOROC terminals (using simultaneous
;       print mode) and FREEDOM 100 terminals (transparent mode) with OKIDATA,
;       TI810, HP-LASERJET, AND DIABLO printers all work very well, using
;       baud rates at 300, 1200, and 9600, using a straight
;       1-25 = 1-25 DB-25 connector.  Even the DIABLO with a file formatted
;       using SuperVue microspace codes. The only change on the DIABLO was
;       to put it into PTR RDY mode with the DIP switches on the front panel.
;
;       If you would like to substitute a special driver instead of the DUMB.TDV
;       then place it in the place of DUMDVR: at the end of this program
;
;       Any questions, answers, are comments to:
;       James A. Jarboe IV
;       GR/AM
;       409-295-5767
;
;       [101]- sleep 7.5 secends when through printing for auxport running
;               at slower baud rate than main port's baud rate
;               I.E.  MAIN PORT BAUD RATE                    = 9600
;                     AUXILLARY PORT BAUD RATE & PRINTER     = 1200
;       [102]- fixed erroneous error out put of DUMB.DVR
;              it should be DUMB.TDV ( a terminal or printer driver)
;              DUMB should be added to a TRMDEF statement or made on
;              new TRMDEF statement in the .INI file prior to booting system.
;
;                TRMDEF PRINTR,AM300=3,DUMB,9600,20,20,20
;
;               or
;
;                TRMDEF AUXPRT,PSEUDO,DUMB,1,1,1

               ;

       SEARCH SYS                      ; get system goodies
       SEARCH SYSSYM
       SEARCH TRM                      ; get terminal goodies

VMAJOR=1.
VMINOR=0.       ; WRITTEN
VMINOR=1.       ; ADDED SLEEP FOR 7 SECS at end of file in case
               ; OF DIFFERENT BAUD RATEs used
VMINOR=2.        ; Fixed erroneous DUMB.DVR error should be DUMB.TDV
VSUB=0.
VWHO=0.

DEFINE  CRTF    X                       ; define an easy way
       MOVW    X+177400,D1             ; to print
       TCRT                            ; TAB(-1,?);
       ENDM

       ASECT


DDB:    BLKB    D.DDB
PRTDVR: BLKB    8.
WASDVR: BLKB    8.
       EVEN
       ENDIMP=.
       PSECT

AXON=82.
AXOFF=83.

       PHDR    -1,0,PH$REE!PH$REU


       GETIMP  ENDIMP,A5,QUIT2         ; get starting address
       BYP                             ; bypass spaces
       LIN                             ; input line from start ?
       BNE     OPE                     ; yes .. then let's process
       TYPE    <Enter Filename : >     ; no.. then ask for it
       KBD     QUIT2                   ; get keyboard input
       BYP                             ; bypass spaces
       LIN                             ; get line
       JEQ     QUIT2                   ; no input..ok, you quit
OPE:
       BYP                             ; still bypassing space
       FSPEC   DDB(A5),LST             ; default ext is .LST
       INIT    DDB(A5)                 ; initialize the file buffer
       OPENI   DDB(A5)                 ; open the file
NEWDVR:
       JOBIDX  A0                      ; job index to a0
       MOV     JOBTRM(A0),A1           ;
       MOV     T.TDV(A1),A1            ; point to current driver
       SUB     #4,A1                   ;
       LEA     A2,WASDVR(A5)           ; give it to wasdriver
       UNPACK                          ; unload rad50
       UNPACK                          ; to ascii

AGN:
       TYPESP  Original terminal driver is
       TTYL    WASDVR(A5)
       CRLF
       MOV     TRMTDC,D0               ; address of first terminal driver
10$:                                    ; in memory
       CTRLC   EOF                     ; if ^C then quit
       MOV     D0,A3                   ; move address to A3
       CMM     4(A3),DUMDVR            ; compare it to DUMB.TDV
       BEQ     AUXON                   ; found it ? ..
       MOV     @A3,D0                  ; no..get address of next driver
       BNE     10$                     ; do it again
;[102]
       TYPECR  DUMB.TDV must be in on a .INI TRMDEF statement to function correctly.
       JMP     QUIT                    ; wow..let's quit
AUXON:
       TYPECR
       TYPE    <Terminal AUX Port is>
       CRTF    #21.                    ; make it blink
       TYPE    <ON>                    ; tell me it's on
       CRTF    #22.                    ; no blink
       CRTF    #AXON                   ; turn aux port on
       JOBIDX  A0
       MOV     JOBTRM(A0),A1           ; point to terminal driver place
       ADD     #10,A3                  ; add 10 to it
       MOV     A3,T.TDV(A1)            ; put new driver in action
10$:
       CTRLC   EOF
       FILINB  DDB(A5)                 ; get file input
       TST     DDB+D.SIZ(A5)           ; test for end of file
       BEQ     EOF                     ; if it is then lets head home
       TTY                             ; dump it
       BR      10$                     ; do it again
EOF:
       MOVB    #12.,D1                 ; send a form feed to auxport
       TTY

AUXOFF:
       LEA     A2,WASDVR(A5)           ; point to original driver
       LEA     A1,PRTDVR(A5)           ; point to new place
       PACK                            ; repack it since
       PACK                            ; we unpacked it to see it
       MOV     TRMTDC,D0               ; tell us where Term drivers are
10$:
       MOV     D0,A3
       CMM     4(A3),PRTDVR(A5)        ; compare memory to chosen driver
       BEQ     CHON                    ; found it ? ..
       MOV     @A3,D0                  ; no..get address of next driver
       BNE     10$                     ; do it again
       TYPECR  Driver Could not be found
       JMP     EXIT                    ; get new input
CHON:
       JOBIDX  A0                      ;
       MOV     JOBTRM(A0),A1           ;
       ADD     #10,A3                  ;
       MOV     A3,T.TDV(A1)            ; put original driver back in
       CRTF    #AXOFF                  ; aux port off
EXIT:
       CRTF    #21.                    ; blink on
       CRTF    #5.                     ; backspace
       TCRT                            ; one more
       TCRT                            ; and once more
       TYPE    <FF>                    ; print port off
       CRTF    #22.                    ; blink off
QUIT:
       CLOSE   DDB(A5)                 ; close the file
       CRLF
QUIT2:
       SLEEP   #75000.                 ; sleep 7.5 sec [101]
                                       ; just in case auxport baud rate
                                       ; is slower than main port baud rate
                                       ; can comment out or increase or
                                       ; decrease time according to your
                                       ; specs
       EXIT                            ; quit

DUMDVR: RAD50   /DUMB/                  ; if you want to use a different
       RAD50   /TDV/                   ; driver change data in DUMDVR
       EVEN                            ; even memory
       END