;*************************** AMUS Program Label ******************************
; Filename: AUXSBR.M68 Date: 22-Sep-89
; Category: SBR Hash Code: 702-253-572-175 Version: 1.1(102)
; Initials: GR/AM Name: James A. Jarboe IV
; Company: Educational Filmstrips & Video Telephone #: 4092955767
; Related Files: DUMB.M68, DUMB.TDV
; Min. Op. Sys.: 1.2 Expertise Level: BEG
; Special: Get AUXSBR.BAS to help set up auxiliary port on terminal.
; Description: Processes a file through a terminal's auxiliary port. Does
; all file opening, closing, turning aux port on and off.
;*****************************************************************************
;*; Updated on 22-Sep-89 at 8:17 AM by James A. Jarboe IV; edit time: 6:39:11
;***************************************************************************
;
; AUXSBR.SBR
; VERSION 1.1(102)
;
; Written By: James A. Jarboe IV
; 1401 19th Street
; Huntsville, TX 77340
; 409-295-5767
;
; Updated 22-Sep-89
;
; 10/02/88
; Copyright (c) James A. Jarboe IV
; GR/AM
;****************************************************************************
;
; Also Get:
; AUXSBR.BAS -> Basic program to test Auxiliary Port.
; AUXSBR.DOC -> Documentation on AUXSBR usage.
; DUMB.M68 -> Dumb driver.
;
; Description: Turns on terminal auxillary port and prints designated file
; through the auxilliary port on the terminal, from within
; a BASIC program
;
; 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 BASIC
;
; Requirements: DUMB.TDV must be in the terminal driver section of system
; memory as
; TRMDEF PRINTER,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:
;-------------------------------------------------
;;**************
;;** DUMB.M68
;;**************
;;
;; OBJNAM DUMB.TDV
;;
;;DUMB: WORD 0 ; No attributes.
;; RTN
;; RTN
;; RTN
;; RTN
;; END
;-------------------------------------------------
;
; USAGE: XCALL AUXSBR, filename.ext, Flag
;
; Default extension is LST
;
; WHERE:
; filename.ext = a String variable
; flag = a 1 BINARY NUMBER returned to basic program
;
; EXAMPLE:
; MAP1 FILENAME,S,24
; MAP1 FLAG,B,1 ! 0 = All ok & printed.
; ! 1 = Filename not found.
; ! 2 = Filename is a RANDOM file.
; ! 3 = DUMB.TDV not on a TRMDEF Statement.
; ! 4 = File is in use (LOKSER)
; ! 5 = All other File service system errors.
;
; 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 AX.ON=82. to AX.ON=(your call). Do
; the same for AX.OFF=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) and
; AM65 terminals with OKIDATA, TI810, HP-LASERJET, AND DIABLO
; printers and all work very well, using baud rates at 300, 1200,
; 9600, and 19200 using proper cableing.
; 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, or comments to:
; James A. Jarboe IV
; GR/AM
; 409-295-5767
;
; WORKS ON AMOS 1.2 - 1.3x OPERATING SYSTEMS
;
; Sleep 7.5 seconds 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
;
; [1.1] 22-Sep-89 Minor changes and comments make program more efficient,
; to fix up some bugs and to cover previous programming
; sins. [JAJ]
;
; [102] 22-Sep-89 - Fixed problem with offset error if Binary variable was
; mapped on uneven boundary. Now it doesn't matter.
; Thanks to Steve Light for finding problem.
; Changed PRTTAB macro to be efficient.
; Added LOKSER compatibility. [JAJ]
;
; [100] 02-Oct-88 - Written [JAJ]
;
VMAJOR = 1 ; Written 02-Oct-88
VMINOR = 1 ; Cleaned up 22-Sep-89
VEDIT = 102. ;
OBJNAM AUXSBR.SBR ; Amos xcall subroutine.
SEARCH SYSSYM
SEARCH SYS
SEARCH TRM
;**************************************************************************
; *
; M A C R O D E F I N I T I O N S *
; *
;**************************************************************************
;
;****************
; PRTTAB *
;****************
; Description:
;
; Do a PRINT TAB statement.
;
; Where:
;
; ROW = Row number or TCRT set up.
; COL = Column number or TCRT call.
;
; Effects:
;
; Sets row and column or processes TCRT code.
;
; D1 is destroyed.
;
DEFINE PRTTAB ROW, COL ;
MOVW #<ROW_8.+ COL> ,D1 ; Set Row and column.
TCRT ; Process TCRT.
ENDM
;**************************************************************************
; *
; U S E R C O N S T A N T S *
; *
;**************************************************************************
;
S..VAR = 2 ; Total number of arguments.
S..SLP = 75000. ; Time to Sleep.
S..BUF = 512. ; Size of DDB buffer.
;**************************************************************************
; *
; U S E R I M P U R E A R E A *
; *
;**************************************************************************
;
OFINI
OFDEF XP.TOP, 2 ; Number of xcall arguments.
OFDEF TYPE1, 2 ; Argument 1 type.
OFDEF ADDR1, 4 ; Argument 1 address.
OFDEF SIZE1, 4 ; Argument 1 size.
OFDEF TYPE2, 2 ; Argument 2 type.
OFDEF ADDR2, 4 ; Argument 2 address.
OFDEF SIZE2, 4 ; Argument 2 size.
OFDEF DVRADR, 4 ; Original driver address.
OFDEF DMBADR, 4 ; Replacement driver address.
OFDEF AREA, D.DDB ; Input file DDB.
OFDEF BUFFER, S..BUF ; Input file buffer.
OFDEF TRMBUF, TC.SIZ ; Terminal characteristics buffer.
OFSIZ ENDIMP ; End of impure area.
;**************************************************************************
; *
; S T A R T O F P R O G R A M *
; *
;**************************************************************************
;
;****************
; AUXSBR *
;****************
; Description:
; Program can read physical blocks, is reentrant and reusable.
; Program is a BASIC XCALL subroutine.
;
AUXSBR: PHDR -1,PV$RPD,PH$REE!PH$REU ; Read phy blocks, rent, reuse.
PAGE
;****************
; SETUP *
;****************
; Description:
;
; Check for and set up XCALL variables.
;
; Where:
;
; A3 -> Subroutine impure area.
;
SETUP: CMPW XP.TOP(A3), #S..VAR ; Are there enough variables?
JNE QTYVAR ; No..tell them.
CMPW TYPE1(A3), #XC$STR ; Is first one a string?
JNE STRVAR ; No..tell them.
CMPW TYPE2(A3), #XC$BIN ; Is second variable a binary 1?
JNE BINNUM ; No..tell them.
MOV ADDR1(A3), A6 ; Set up address of first variable.
CMPB @A6,#0 ; Is variable 1 empty?
BNE STRDVR ; No..then process continues.
MOVB #ER$NFN, D6 ; Set no file found error.
JMP SETERR ; Set error flag & return to BASIC.
PAGE
;****************
; STRDVR *
;****************
; Description:
;
; Store the current terminal driver's address. Find replacement
; terminal or printer driver. (DUMDVR:)
; Where:
; A3 -> XCALL impure area.
;
; Effects:
;
; A2 = Address of replacement driver.
; DVRADR(A3) = Stored original Terminal driver address.
;
; D0, A2, A6 are destroyed.
;
STRDVR: JOBIDX ; Index this JCB.
MOV JOBTRM(A6), A6 ; Point to terminal goodies.
MOV T.TDV(A6), DVRADR(A3) ; Save current driver address.
MOV TRMTDC, D0 ; Point to first terminal driver.
20$: CTRLC 30$ ; if ^C then quit
MOV D0, A2 ; Move terminal link.
CMM 4(A2), DUMDVR ; Is this DUMB.TDV?
BEQ 40$ ; Yes..save address.
MOV @A2, D0 ; No..get address of next driver.
BNE 20$ ; Do it again.
MOVB #ER$DNF, D6 ; Set driver not found error.
CALL SETERR ; Set error flag.
30$: RTN ; Return to basic.
40$: ADD #8., A2 ; Get to driver address.
MOV A2, DMBADR(A3) ; Save replacement driver address.
PAGE
;****************
; OPEN *
;****************
; Description:
;
; Finds file, checks for file in use, outputs data to terminal.
;
; Where:
;
; A3 -> XCALL impure area.
;
; Returned/Side effects:
;
; A4 -> Input DDB.
;
; D1, A4, A2 are destroyed.
;
;
OPEN: LEA A4, AREA(A3) ; Point to DDB.
CLEAR @A4,D.DDB ; Clear out DDB.
LEA A6, BUFFER(A3) ; Point to internal buffer.
MOV A6, D.BUF(A4) ; Link buffer to DDB.
MOVB #<D$INI!D$ERC!D$BYP>, D.FLG(A4) ; Set INITed flag.
MOV ADDR1(A3), A2 ; Point to filename.
FSPEC @A4, LST ; Get filename into DDB.
CLR D.DVR(A4) ; Clear driver address.
LOOKUP @A4 ; Is file there?
BEQ 10$ ; Yes..process through terminal.
MOVB #ER$NFN, D6 ; Set file not found error.
JMP SETERR ; Set error flag & return to BASIC.
; Check for random file.
;
10$: CMPW D.WRK+6(A4), #-1 ; Is file random?
BNE 20$ ; No..process.
MOVB #ER$RND, D6 ; Set random file error.
JMP SETERR ; Set error flag & return to BASIC.
; Open sequential file.
;
20$: OPENI @A4 ; Open file as sequential.
BEQ 40$ ; If no errors, then process.
; If error is result of a LOKSER file in use then set flag and return
; to BASIC.
;
CMPB D.ERR(A4), #D$EFIU ; Is error file in use?
BNE 30$ ; No..report error.
MOVB #ER$LOK, D6 ; Set file in use error.
JMP SETERR ; Set error flag & return to BASIC.
; All other file service errors will be reported on terminal screen,
; and the error flag will be set to 5. To remain compatible with the
; previous versions of AUXSBR.SBR this method was chosen over actually
; returning the file service error code since flags 0-3 where already
; used to report all ok and other errors.
;
30$: CALL LSTROW ; Set up last row.
ERRMSG D.ERR(A4), OT$TRM!OT$LDQ; Report file error.
CALL INAUX ; Report program and sleep.
MOVB #ER$OTH, D6 ; Set file service system error.
JMP SETERR ; Set error flag & return to BASIC.
; Finally turn aux port on.
;
40$: CALL AUXON ; Turn aux port on.
; Output data until file is empty.
;
50$: CTRLC EOF ; EOF on control C.
FILINB @A4 ; Get next byte.
TST D.SIZ(A4) ; End of file?
BEQ EOF ; Yes..close up operation.
TTY ; Output character.
BR 50$ ; Do until file is empty.
PAGE
;****************
; EOF *
;****************
; Description:
;
; End of file condition is reached. Close file, clear error flag,
; return to basic.
;
; Where:
;
; A4 -> Opened DDB.
;
; Effects:
;
; File is closed., Auxiliary port is turned off, error flag =0
; returned to basic program.
;
; D1, is destroyed.
;
EOF: MOVB #$FF, D1 ; Set up form feed character.
TTY ; Output form feed to aux port.
CLOSE @A4 ; Close the file.
CALL AUXOFF ; Turn aux port off.
SLEEP #S..SLP ; 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
MOV #ER$AOK, D6 ; Set all ok error.
JMP SETERR ; Set error flag & return to BASIC.
PAGE
;****************
; AUXOFF *
;****************
; Description:
;
; Reset original Terminal driver, then turn off Aux port.
;
; Where:
;
; A3 -> XCALL impure area.
;
; Effects:
;
; Original terminal driver address is restored.
; Auxiliary port is turned off.
;
AUXOFF: JOBIDX ; Index this job.
MOV JOBTRM(A6), A6 ; Point to terminal goodies.
MOV DVRADR(A3), T.TDV(A6) ; Restore original terminal driver.
PRTTAB -1, AX.OFF ; Turn aux port off.
RTN ; Return.
PAGE
;****************
; AUXON *
;****************
; Description:
;
; Turn Auxiliary Port on then change terminal drivers.
;
; Where:
;
; A3 -> XCALL impure area.
;
; Effects:
;
; Places replacement terminal driver address into T.TDV
;
AUXON: PRTTAB -1, AX.ON ; Turn aux port on with tcrt call.
JOBIDX ; Index this job.
MOV JOBTRM(A6), A6 ; Point to terminal goodies.
MOV DMBADR(A3), T.TDV(A6) ; Put new driver in action.
RTN ; Return to caller.
PAGE
;****************
; LSTROW *
;****************
; Description:
;
; Cursor is moved to last possible row as set by terminal driver.
;
; Where:
;
; A3 -> XCALL impure area.
;
; Effects:
;
; Cursor is placed at last row, first column on terminal.
;
; D1, is destroyed.
;
LSTROW: TRMCHR TRMBUF(A3) ; Get terminal characteristics.
MOVW TRMBUF+TC.ROW(A3), D1 ; Get number of terminal rows.
LSLW D1, #8. ; Shift row.
MOVB #1, D1 ; Set column.
TCRT ; Process row & column.
RTN
; Return to caller.
PAGE
;****************
; SETERR *
;****************
; Description:
;
; Error flags are set to return to basic program.
;
; Where:
;
; A3 -> XCALL impure area.
; D6 = Error code to return.
;
; Effects:
;
; Error code placed at second argument address.
;
SETERR: MOV ADDR2(A3), A6 ; Point to error flag.
MOVB D6, @A6 ; Set error.
RTN ; Return to caller.
;**************************************************************************
; *
; E R R O R R E P O R T I N G S *
; *
;**************************************************************************
;
;****************
; QTYVAR *
;****************
; Description:
;
; Must pass a minimum of variables.
;
QTYVAR: CALL LSTROW ; Set last row.
PRTTAB -1, 11. ; Dim.
TYPE <Must pass >
PRTTAB -1, 12. ; Bright.
MOV #S..VAR, D1 ; Set number of variables.
DCVT 0, OT$TRM!OT$TSP ; Output decimal number.
PRTTAB -1, 11. ; Dim.
TYPE <variables >
JMP INAUX ; Display sbr name.
PAGE
;****************
; BINNUM *
;****************
; Description:
;
; Second variable must be a Binary 1.
;
BINNUM: CALL LSTROW ; Set up last row.
TYPE <Second > ;
PRTTAB -1, 11. ; Dim.
TYPE <variable must be > ;
PRTTAB -1, 12. ; Bright.
TYPE <BINARY 1 > ;
BR INAUX ; Display program.
PAGE
;****************
; STRVAR *
;****************
; Description:
;
; First variable must be a string.
;
STRVAR: CALL LSTROW ; Set up last row.
TYPE <First > ;
PRTTAB -1, 11. ; Dim.
TYPE <Variable must be a >
PRTTAB -1, 12. ; Bright.
TYPE <STRING >
PAGE
;****************
; INAUX *
;****************
; Description:
;
; Display subroutine name with error. Pause awhile, clear error,
; then return.
;
INAUX: PRTTAB -1, 11. ; Dim.
TYPE <in >
PRTTAB -1, 12. ; Bright.
TYPE <AUXSBR.SBR >
SLEEP #S..SLP/2 ; Sleep to see errors.
CALL LSTROW ; Set up last row.
PRTTAB -1, 9. ; Clear out error display.
RTN ; Return to caller.
;**************************************************************************
; *
; D R I V E R N A M E *
; *
;**************************************************************************
;
; If the user wishes to use a different driver change the data in
; DUMDVR to reflect the terminal driver or printer driver of choice.
; The only requirement is that the terminal or printer driver must be
; located on a TRMDEF statement at bootup time.
;
DUMDVR: RAD50 /DUMB/ ; If you want to use a different
RAD50 /TDV/ ; Driver, change data in DUMDVR.