;****
; WAIT.86
; By Pat Anderson
; 8/26/87
; TSR program to intercept formfeeds sent to printer,
; halt output until a key is pressed to allow use of
; cut sheets when printing a formatted file with
; formfeed characters
; SOURCE CODE FOR ASSEMBLY WITH A86 ASSEMBLER
;****
JMP INIT                ;Jump to setup for TSR
;
OLD_VECTOR DW 0,0       ; Data area - 2 words for old printer interrupt vector
;
MSG1 DB 'WAIT! Memory Resident Single Sheet Printer Utility',13,10
LEN_MSG1 EQU $-OFFSET MSG1
MSG1A DB 'Print formatted ASCII text files with COPY FILENAME.DOC PRN',13,10
LEN_MSG1A EQU $-OFFSET MSG1A
MSG1B DB 'Printer will now pause at formfeed to insert a new sheet of paper',13,10
LEN_MSG1B EQU $-OFFSET MSG1B
MSG1C DB 'Strike any key to resume printing',13,10
LEN_MSG1C EQU $-OFFSET MSG1C
MSG2 DB 'Copyright (c) 1987 by Pat Anderson',13,10
LEN_MSG2 EQU $-OFFSET MSG2
MSG3 DB 'License granted to copy, distribute and use for non-commercial purposes',13,10
LEN_MSG3 EQU $-OFFSET MSG3
MSG4 DB 'This program is USER SUPPORTED - suggested contribution $10.00',13,10
LEN_MSG4 EQU $-OFFSET MSG4
MSG5 DB 'Pat Anderson, 5420 - 324th Pl. S.E., Fall City, WA 98024',13,10
LEN_MSG5 EQU $-OFFSET MSG5
;
HANDLER:                ; Routine that intercepts bytes headed to printer
CMP DX,00               ; Printer specified as destination?
JNZ EXIT                ; If not, pass it through to old handler
CMP AH,00               ; Is current request for print character service?
JNZ EXIT                ; If not, pass it through to old handler
CMP AL,0C               ; See if it is a formfeed
JNZ EXIT                ; Exit if not
MOV AH,00               ; Otherwise, wait for a keypress
INT 16H
MOV AH,0D0
IRET                    ; and return from interrupt
;
EXIT:                   ; If not a formfeed, pass character through to
CS JMP OLD_VECTOR F     ; old printer interrupt handler
;
INIT:                   ; Initialization for TSR
MOV AH,35H              ; Get old printer interrupt vector for int 17h
MOV AL,17H              ; using service 35 of int 21
INT 21H
;
MOV OLD_VECTOR, BX      ; Store it
MOV OLD_VECTOR+2,ES
;
MOV DX,OFFSET HANDLER   ; Install vector to this routine in
MOV AH,25H              ; interrupt vector table for int 17
MOV AL,17H              ; using service 25 of int 21
INT 21H
;
MOV AH,40H              ; Service 40h of int 21 - write to device
MOV BX,1                ; DOS pre-assigned device handle for screen
MOV DX,OFFSET MSG1      ; Address of message 1
MOV CX,LEN_MSG1         ; Length of message 1
INT 21H                 ; Display it
;
MOV AH,40H              ; Message 1A
MOV BX,1
MOV DX,OFFSET MSG1A
MOV CX,LEN_MSG1A
INT 21H
;
MOV AH,40H              ; Message 1B
MOV BX,1
MOV DX,OFFSET MSG1B
MOV CX,LEN_MSG1B
INT 21H
;
MOV AH,40H              ; Message 1C
MOV BX,1
MOV DX,OFFSET MSG1C
MOV CX,LEN_MSG1C
INT 21H
;
MOV AH,40H              ; Message 2
MOV BX,1
MOV DX,OFFSET MSG2
MOV CX,LEN_MSG2
INT 21H
;
MOV AH,40H              ; Message 3
MOV BX,1
MOV DX,OFFSET MSG3
MOV CX,LEN_MSG3
INT 21H
;
MOV AH,40H              ; Message 4
MOV BX,1
MOV DX,OFFSET MSG4
MOV CX,LEN_MSG4
INT 21H
;
MOV AH,40H              ; Message 5
MOV BX,1
MOV DX,OFFSET MSG5
MOV CX,LEN_MSG5
INT 21H
;
MOV DX,OFFSET INIT      ; Terminate, leaving the code up to
INT 27H                 ; the initialization portion resident

