; Printer Driver... 3/15/09 ; !LPT - patches slot to loc 272, container for subs ; CKLPT - reads LPT device and pushes status (0 means not available) ; MSLPT - sets MS out to LPT device (use CONSOLE to undirect) ; +PE - echos all console I/O to printer (see notes below) ; -PE - disables printer echo ; byte >LPT - sends byte to printer ; "string" $LPT - sends string to printer ; NLPT - sends a CRLF to printer ; OCTAL 272 ;address of patch location 20 ;change number to default printer interface slot PUT "LPT slot set to " $PRINT 272 GET PNUM CRLF "Creating !LPT" $PRINT CRLF ; initializer word... ; no ZP vars defined for these, addresses for subs in WA+2 and WA+3 ; to make easy to find in case other code needs to call, that way in ; the future if ZP vectors are needed they can be defined. These words ; access the subs directly using the /K (keep) option of CREATE. CREATE !LPT JMP PPATC jump to patch slots ADOLP DEF DOLPT address of sub to print char in A ACKPR DEF CKPRS address of sub to return status in A PRN EQU 20 dummy value, will be replaced PRSLT EQU 272 where slot is stored * patch slots... PPATC LDA PLSTA get address of patch list in A LDB PRSLT get slot to patch to in B JSB PSUBA,I call the kernel's patch sub JMP END exit * patch list... PLSTA DEF *+1 DEF PRN1 DEF PRN2 DEF PRN3 DEF PRN4 DEF PRN5 OCT 0 * subroutines... * print character in A DOLPT NOP PRN1 OTA PRN PRN2 STC PRN,C PRN3 SFS PRN JMP *-1 PRN4 CLC PRN JMP DOLPT,I * return printer status in A CKPRS NOP PRN5 LIA PRN JMP CKPRS,I END ;the status word - calls CKPRN sub to push status "Creating CKLPT" $PRINT CRLF CREATE CKLPT /K JSB CKPRS call print sub JSB ZSPSH,I push status END ;MSLPT - redirects MS out to printer, CONSOLE to cancel "Creating MSLPT" $PRINT CRLF CREATE MSLPT /K * set MS output redirection to print sub... LDA ADOLP get address of printer out sub STA ZMOUT put in MS out vector END ;+PE - enables console echo to printer ;tricky stuff!!! ZIN must = ZCHIN or HP-IPL/OS supresses prompts ;this saves and redirects ZCHIN and ZCOUT, also setting ZIN/ZOUT ;Suppresses multiple CR's in print stream, probably not necessary but ;avoids double-spaced lines under sim when LPT redirected to a log file. ;Note - all screen control codes, backspaces etc sent to printer, not ;sure how it'll react to this (might back up and overstrike character?) ;only vectors are for char-by-char output, the only way to avoid this ;would be if it maintained its own line buffer in which it could ;apply the edits, which sounds like a bunch more code. Type carefully... ;EXPERIMENTAL - calls status, if 0 returned assumes printer is not ;on-line and does not redirect to avoid locking up. If this doesn't ;work (say if 0 means OK) then comment/nop the first 3 instructions. "Creating +PE" $PRINT CRLF CREATE +PE /K * see if printer is available JSB CKPRS check printer status SZA,RSS skip if A is NOT 0 JMP END if status=0 then exit without doing anything * clear last char printed CLA STA LSTCH * check console out vector LDA ZCOUT get console out vector CPA ACOS already redirected? JMP CCIV yes - check console in vector * console out not redirected, insert COS sub in ZCOUT and ZOUT vectors STA COUTC save original ZCOUT to chain to LDA ACOS get address of console out sub STA ZCOUT save to console out vector STA ZOUT save to general out vector too * check console in vector CCIV LDA ZCHIN get console in vector CPA ACIS already redirected? JMP END yes - exit * console in not redirected, insert CIN sub in ZCHIN and ZIN vectors STA CINC save original ZCHIN vector LDA ACIS get address of console in sub STA ZCHIN save to console in vector STA ZIN save to general in vector too JMP END done COUTC OCT 2 storage for original console out vector CINC OCT 2 storage for original console in vector LSTCH OCT 0 last character printed to suppress double cr's CONCR OCT 15 a CR char to compare to ACOS DEF *+1 address of console out sub COS NOP console out sub CPA CONCR is it a CR? JMP SUPCR yes - suppress double CR's JMP COSP no - print character SUPCR CPA LSTCH last char printed also CR? JMP COSC yes - skip print COSP JSB DOLPT send char to printer STA LSTCH save character COSC JSB COUTC,I call original console out sub JMP COS,I exit sub ACIS DEF *+1 address of console in sub CIS NOP console in sub JSB CINC,I call original console in sub JSB DOLPT send char to printer STA LSTCH save character JMP CIS,I exit sub END ;-PE - disables printer echo ;restarting (2 RUN) also disables echo "Creating -PE" $PRINT CRLF CREATE -PE /K LDA ZCOUT get console out vector CPA ACOS is it pointing to COS sub? JMP UDCOS yes - undirect COS sub JMP CCID no - check console in redirection UDCOS LDA COUTC get original console out vector STA ZCOUT save in console out vector STA ZOUT save in general out vector too CCID LDA ZCHIN get console in vector CPA ACIS is it pointing to CIS sub? JMP UDCIS yes - undirect CIS sub JMP END no - exit UDCIS LDA CINC get original console in vector STA ZCHIN save in console in vector STA ZIN save in general in vector too END ; ; byte >LPT - sends byte to printer CREATE >LPT /K JSB ZSPOP,I JSB DOLPT END ; ; "string" $LPT - sends string to printer DEFINE $LPT $LEN DUP IFZ DROP ELSE #1 SWAP +DO $HEAD >LPT +LOOP $DROP ENDIF END ; ; NLPT - sends CRLF to printer DEFINE NLPT 15 >LPT 12 >LPT END ; ;end the load... "Done" $PRINT CRLF CONSOLE