koreth@ssyx.ucsc.edu (Steven Grimm) (06/14/88)
Submitted-by: uunet!mcvax!philmds!leo (Leo de Wit) Posting-number: Volume 1, Issue 55 Archive-name: joinprnt The following nice little program (JOINPRNT.PRG) should be placed in the AUTO folder, so that it is made resident at startup time. After pressing ^P (control-P) all screen output (but not the graphic part) is also directed to the printer. In this way every program can have its hardcopy without any trouble. Pressing ^P again toggles back to normal behaviour. A few remarks: A) The BIOS vector is altered to achieve this. This is however done transparently (using the old vector when necessary). B) VT52 escape sequences are not send to the printer (the ESC and the following character are ignored). C) The ^P has to be read first (by whatever program; presumably a shell); this is generally not a problem. D) The program has been used by myself for about a month now, without problems. The program was assembled and linked with the assembler and linker that come with the GST-C compiler, using the commands: ASM.PRG JOINPRNT LINK.PRG JOINPRNT The resulting code was 246 bytes in size. L.J.M. de Wit Nachtegaallaan 7 5731XP Mierlo Holland --------------------- H E R E I T A L L S T A R T S ------------------- MODULE JOINPR SECTION S.CCODE GEMDOS EQU 1 BIOS EQU 13 PTERMRES EQU $31 SETEXC EQU 5 PTERM EQU $4c JOINON EQU 0 HADESC EQU 1 JOINIT MOVE.L #-1,-(SP) MOVE.W #$2D,-(SP) MOVE.W #SETEXC,-(SP) TRAP #BIOS * Save old BIOS vector ADDQ.L #8,SP LEA.L OLDVEC(PC),A0 MOVE.L D0,(A0) PEA JOINPR MOVE.W #$2D,-(SP) MOVE.W #SETEXC,-(SP) TRAP #BIOS * Set new BIOS vector ADDQ.L #8,SP MOVE.L 4(SP),A0 MOVE.L #$100,D0 * Base page ADD.L 12(A0),D0 * + text length ADD.L 20(A0),D0 * + data length ADD.L 28(A0),D0 * + bss length CLR.W -(SP) * Return value: 0 for success MOVE.L D0,-(SP) * # bytes to keep MOVE.W #PTERMRES,-(SP) * Keep process TRAP #GEMDOS * Stops here... * Entry point for 'embedded TRAP #13' in JOINPR OLDTRAP MOVE.W SR,-(SP) * Entry point if not OLDGEM MOVE.L OLDVEC(PC),-(SP) RTS * Altered BIOS routine JOINPR LEA.L FLAGS(PC),A1 * A1 will point to flags block MOVE.L USP,A0 * A0 points to parameters to TRAP #13 BTST #5,(A7) BEQ.S JOINUSER LEA 6(A7),A0 * If called from supervisor mode JOINUSER CMP.W #2,2(A0) * console ? BNE.S OLDGEM CMPI.W #2,(A0) * Bconin? BEQ.S BCONIN CMPI.W #3,(A0) * Not Bconout BNE.S OLDGEM TST.B JOINON(A1) * Flag set? BEQ.S OLDGEM TST.B HADESC(A1) * Escape set? SF HADESC(A1) * reset flag first BNE.S OLDGEM * If flag was set CMP.W #$1B,4(A0) * Escape char? SEQ HADESC(A1) BEQ.S OLDGEM * If escape MOVE.W 4(A0),-(SP) * Make an extra copy of the word to print MOVE.W 4(A0),-(SP) MOVE.W #0,-(SP) MOVE.W #3,-(SP) BSR.S OLDTRAP ADDQ.L #6,SP MOVE.W #2,-(SP) MOVE.W #3,-(SP) BSR.S OLDTRAP ADDQ.L #6,SP RTE BCONIN MOVE.W #2,-(SP) MOVE.W #2,-(SP) BSR.S OLDTRAP ADDQ.L #4,SP CMP.W #'P'-'@',D0 * Control P? BNE.S BCONEND LEA.L FLAGS(PC),A1 * A1 points again to flags block NOT.B JOINON(A1) * Toggle flag BRA JOINPR * This discards current char BCONEND RTE SECTION S.DATA OLDVEC DC.L 0 FLAGS DC.W 0 * Two flag bytes: JOINON and HADESC END