.TITLE LAP - Printer setup .IDENT /01/ ;+ ; AUTHOR Sel Ellis APRIL 1987 ; VERSION 1.4 ; Sets up LA50 page length, width etc and prints a nominated file. ; There are no default file types. ; Altered 4/86 to execute set tt single EMT when getting printer ; status and set tt nosingle EMT immediatly after. ; 5/86. Added line counter and expansion of form feed to required ; number of line feeds to fool the dopey RT11 tt: handler. ; 4/87. Corrected problem which caused the printing to mave up the ; paper by one interline space each page. ;- ;+ ; Macro calls ;- .MCALL .CSIGEN,.EXIT,.GTLIN,.PRINT,.READW,.TTYIN,.WRITW ;+ ; Character definitions and constants ;- ESC = 33 ;Escape YES = 131 ;Y NO = 116 ;N LF = 12 ;LF CR = 15 ;CR ;+ ; Alter this variable to alter page length. ;- PGELEN = 70. ;Page length ;+ ; Alter this variable to alter page skip. ;- PGSKIP = 4 ;Page skip ERRBYT = 52 ;Error byte location JSW = 44 ;Job status word location RMON = 54 ;Base of RMON SYSGEN = 372 ;Offset for SYSMON ST: JMP START .EVEN ;+ ; Storage and data ;- .SBTTL DATA - Storage and text .PSECT DATA CON .NLIST BEX DEFEXT: .WORD 0,0,0,0 IFIL: .BYTE 124,124,72,75 ;TT:= IFIL1: .BLKB 81. ;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .EVEN SESING: .BYTE 0,152 .WORD 'S SENOSI: .BYTE 0,152 .WORD 'T LINBUF: .BLKW 41. LIST: .BLKW 5 BUFF: .WORD 0 BUFFB: .WORD 0 LCOU: .WORD 0 LFCOU: .WORD 0 IBUF: .WORD 0 CBUF: .WORD 0 CHBUF: .WORD 0 EBUF: .WORD 0 INBLK: .WORD 0 DEFMES: .ASCII /Use default settings ? /<200> COLMES: .ASCII \132 column ? [Y/N] \<200> WIDMES: .ASCII \Double width ? [Y/N] \<200> ENHMES: .ASCII \Enhanced density ? [Y/N] \<200> FILMES: .ASCII /File ? /<200> PRIPOW: .ASCII /[?15n/<200> ;Pinter status ? PRION: .ASCII /[5i/<200> ;Controller mode on PRIOFF: .ASCII /[4i/<200> ; " " off COL132: .ASCII /[4w/<200> ;132 columns COL80: .ASCII /[1w/<200> ;80 columns DWIDTH: .ASCII /[5w/<200> ;Double width ENHDEN: .ASCII /[2"z/<200> ;Enhanced density NORDEN: .ASCII /[1"z/<200> ;Normal density ;+ ; Alter this string to alter page length recognised by LA50 ; see LA%0 programmers ref. ;- LIN70: .ASCII /[70t/<200> ;70 lines per page YNERR: .ASCIZ /LAP-W-Syntax error, use Y or N/ SE: .ASCIZ /LAP-W-Syntax error, use A-Z & 0-9/ TOOL: .ASCIZ /LAP-W-Name too long/ NULENT: .ASCIZ /LAP-W-Nothing entered ???/ INERR: .ASCIZ /LAP-F-Read error/ WTERR: .ASCIZ /LAP-F-Write error/ PRIERR: .ASCIZ /LAP-F-Printer not ready/ .EVEN ;+ ; Accepts terminal inputs to set up options in yes/no answer form. ; Input is checked for validity ie. Y or N ; Name of file to be printed is requested and checked for syntax. ; Required control codes are issued to the printer and the ; file copied block by block. ; Finally, the printer is reset before the program exits. ;- .SBTTL MAIN .PSECT MAIN CON START: .ENABL LC .GTLIN #IBUF,#DEFMES ;Prompt for use of defaults TST IBUF BEQ START ;Nothing entered, try again CMP #YES,IBUF ;Is it yes BEQ 4$ ;continue 1$: .GTLIN #CBUF,#COLMES ;Prompt for 80 or 132 MOV CBUF,R2 ;Store in R2 CALL VALID ;Test input TST R2 ;Is it OK. R2 is cleared if not BNE 2$ ;Yes JMP 1$ ;No, try again 2$: CMP #YES,CBUF ;Is it 132 col. BEQ 3$ ;Yes, can't have double width also .GTLIN #CHBUF,#WIDMES ;Prompt for double width MOV CHBUF,R2 CALL VALID ;Test TST R2 BNE 3$ ;OK, continue JMP 2$ ;No, try again 3$: .GTLIN #EBUF,#ENHMES ;Prompt for enhanced density MOV EBUF,R2 CALL VALID ;Test TST R2 BNE 4$ ;OK, continue JMP 3$ ;No, try again 4$: .DSABL LC ;Convert to upper case .GTLIN #IFIL1,#FILMES ;Get file name from terminal .ENABL LC ;Return to pass l.c. for file CALL SYNTAX ;Check syntax TST R0 ;Is R0 set BNE 4$ ;Yes, try again CLR LINBUF MOV SP,R2 ;Save stack pointer .CSIGEN #DSPACE,#DEFEXT,#IFIL,#LINBUF MOV R0,BUFF ;R0 has first free location, store CLR R0 ;and clear MOV R2,SP ;Restore stack pointer MOV RMON,R1 ;Point to location of RMON TST SYSGEN(R1) ;Are we running under TSX BPL 5$ ;No, go to bit set MOV #SESING,R0 ;Point to argument block EMT 375 ;Set single character for TSX 5$: BIS #10000,@#JSW ;Set bit 12 in JSW to allow single ;char activation (all we need for RT11) MOV #5,R2 ;Set up loop counter .PRINT #PRIPOW ;Request printer status PRISTA: .TTYIN ;Get character of response code SOB R2,PRISTA ;Look for fifth character MOV R0,R2 ;Save it .TTYIN ;Get last character BIC #10000,@#JSW ;Clear bit 12 in JSW TST SYSGEN(R1) ;Are we under TSX BPL 1$ ;No, continue MOV #SENOSI,R0 ;Point to argument block EMT 375 ;Set nosingle 1$: CMP R2,#60 ;Is fifth 0 ie. $[?10n = printer ready BEQ 2$ ;Yes, continue .PRINT #PRIERR ;Print error message JMP EXT ;and exit 2$: .PRINT #PRION ;Turn printer on CLR R0 ;+ ; This .PRINT statement prints the command line at the top of the first ; page of the file. It can be commented out if this feature is not ; required. ;- .PRINT #LINBUF ;Print command line CMP #YES,CBUF ;Test for 132 col BNE 3$ ;No, continue CLR R0 .PRINT #COL132 ;Set 132 columns 3$: CMP #YES,CHBUF ;Test for double width BNE 4$ ;No, continue .PRINT #DWIDTH ;Set double width 4$: CMP #YES,EBUF ;Test for enhanced density BNE 5$ ;No, continue .PRINT #ENHDEN ;Set enhanced density 5$: .PRINT #LIN70 ;Set 70 lines per page CLR R0 CLR R2 CLR INBLK ;Input block number MOV #LIST,R5 ;EMT argument list MOV #PGSKIP,LCOU ;Initialise line counter READ: .READW R5,#3,BUFF,#256.,INBLK ;Read a block BCC 1$ ;Branch if no errors TSTB @#ERRBYT ;EOF error BEQ EOF ;Yes, go to normal exit MOV #INERR,R2 ;Error message BR EOF ;and exit 1$: MOV BUFF,R1 ;Point R1 to buffer MOV BUFF,BUFFB ;and set up for write location MOV #512.,R2 ;Set up counter MOV #PGSKIP,LFCOU ;Initialise line feed counter 2$: CMPB (R1),#12 ;Is character LF BNE 3$ ;No, continue BR 4$ ;Yes, count line 3$: CMPB (R1),#14 ;Is it FF BNE 7$ ;No, continue MOV #12,(R1) ;Replace it with LF MOV #PGELEN,R3 ;Set up for subtraction SUB LCOU,R3 ;Find lines remaining on page MOV R3,LFCOU ;Store ADD #PGSKIP,LFCOU ;Add page break BR 5$ ;and print ;+ ; This may get into trouble if file is paginated at PGELEN lines per page ; with auto form feed followed by form feed in text. ;- 4$: INC LCOU ;Increment line counter CMP LCOU,#PGELEN ;70 lines per page BLT 7$ ;Not yet 5$: MOV #PGSKIP,LCOU ;Yes, reset line counter ADD #1,R1 ;Set up for subtraction SUB BUFFB,R1 ;Gives bytes examined ASR R1 ;Convert to word offset .WRITW R5,#0,BUFFB,R1,INBLK ;Write the page ASL R1 ;Convert back to byte ADD R1,BUFFB ;Location of start of next page MOV BUFFB,R1 ;Point R1 to it MOV LFCOU,R3 ;6$: .PRINT #LF ;Space between pages 6$: .PRINT #15 ;Else slip interline space on each page SOB R3,6$ ;Print required number MOV #PGSKIP,LFCOU ;Reset line feed counter 7$: INC R1 ;Increment location DEC R2 ;Decrement counter BEQ 8$ ;Block finished JMP 2$ ;No, return for next character 8$: SUB BUFFB,R1 ;Characters to be printed ASR R1 ;Convert to word offset .WRITW R5,#0,BUFFB,R1,INBLK ;And print them BCC NOERR ;Branch if no error MOV #WTERR,R2 ;Error message BR EOF ;and exit NOERR: INC INBLK ;Increment block number JMP READ ;and go for next EOF: .PRINT #COL80 ;Reset printer .PRINT #NORDEN .PRINT #PRIOFF ;and turn off TST R2 ;Is there an error message BEQ EXT ;No, exit MOV R2,R0 ;Yes .PRINT ;Print it EXT: .EXIT ;and exit ;+ ; Validates responses to options queries ;_ .SBTTL VALID - Validates options VALID: MOV #YES,R0 ;Input is in R2 CMP R0,R2 ;Is it yes BEQ 1$ ;Yes, continue MOV #NO,R0 CMP R0,R2 ;Is it no BEQ 1$ ;Yes, continue CLR R2 ;No, clear R2 .PRINT #YNERR ;display error message 1$: RETURN ;+ ; Checks filenames for correct syntax. Valid characters are A_Z ; 0-9 '.' and ':'. File names can be DEV:FILNAM.TYP ; Modified from G.J. Berry. ;- .SBTTL SYNTAX - Checks file names SYNTAX: MOV R1,-(SP) ;Save R1 MOV R2,-(SP) ;and R2 MOV #IFIL1,R1 ;Point R1 to file name CLR R2 ;Character counter 1$: TSTB (R1) ;Is character a null BEQ 5$ ;Yes INC R2 ;No, count it CMPB (R1),#132 ;Upper case Z BGT 4$ ;Can't be greater CMPB (R1),#101 ;Upper case A BLT 2$ ;Check numbers INC R1 ;Is alpha, move to next character BR 1$ ;and start again 2$: CMPB (R1),#72 ;a : BGT 4$ ;Can't be greater(and not alpha) CMPB (R1),#60 ;Zero BLT 3$ ;Not numeric, check '.' INC R1 ;Numeric, move to next character BR 1$ ;and start again 3$: CMPB (R1)+,#56 ;'.' (and move to next character) BGE 1$ ;Start again 4$: .PRINT #SE ;Syntax error message BR 7$ ;and set up for return 5$: CMP R2,#15. ;Length of name BLE 6$ ;OK .PRINT #TOOL ;Too long error message BR 7$ ;and set up for return 6$: CLR R0 TST R2 ;Is it first character BNE 8$ ;No, all OK .PRINT #NULENT ;Yes, nothing entered error 7$: .TTYIN .TTYIN MOV #1,R0 ;Set error flag in R0 8$: MOV (SP)+,R2 ;Restore registers MOV (SP)+,R1 RETURN ;and return .EVEN DSPACE=. ;Handlers can be loaded above here .END START