PAGE 50,132
TITLE PRTSC_2 - DUMP SCREEN GRAPHICS TO PRINTER
;               PROLOG - MODULE DESCRIPTION
;This subroutine dumps the displayed screen graphics to the printer.
;It will print either 320x200 or 640x200 graphics.  Both are
;printed with the printer in 480 mode, and are rotated 90 degrees.
;Final size is 6.6"x8.9" .
;  All registers are preserved.
CSEG    SEGMENT PARA PUBLIC 'CODE'
PRTSC_1 PROC    FAR
        ASSUME  CS:CSEG
        PUBLIC  PRTSC_1
        PUSH    DS
        PUSH    AX
        PUSH    BX
        PUSH    CX
        PUSH    DX
        MOV     AX,0B800H       ;screen segment
        MOV     DS,AX
        MOV     AX,0141H        ;send ESC A 8 to printer for
        MOV     BL,8            ; 8/72" linefeeds
        CALL    ESC_SEQ
        MOV     BX,1EF0H
        PUSH    BX
ROW     LABEL   NEAR
        PUSH    BX
        MOV     AX,024BH        ;ESC K n1 n2
        MOV     BX,400          ;n1=144, n2=1 (256)
        CALL    ESC_SEQ
        POP     BX
        MOV     CX,100
R1      LABEL   NEAR
        MOV     AL,[BX+2000H]
        XOR     AH,AH
        XOR     DX,DX
        INT     17H
        XOR     AH,AH
        INT     17H
        MOV     AL,[BX]
        XOR     AH,AH
        INT     17H
        XOR     AH,AH
        INT     17H
        SUB     BX,50H
        LOOP    R1
        MOV     AX,000AH        ;linefeed to printer
        XOR     DX,DX
        INT     17H
        TEST    AH,1
        JNZ     PRTSC_RET
        POP     BX
        INC     BX
        PUSH    BX
        CMP     BL,40H
        JNZ     ROW
        POP     BX
        MOV     AX,0032H        ;send ESC 2 to printer
        CALL    ESC_SEQ         ;sets printer to 6 lines/inch
PRTSC_RET       LABEL   NEAR
        POP     DX
        POP     CX
        POP     BX
        POP     AX
        POP     DS
        RET
PRTSC_1 ENDP
SUBTTL SUBROUTINE TO SEND ESC SEQUENCE TO PRINTER
        PAGE
;           PROLOG - MODULE DESCRIPTION
;This subroutine sends an ascii ESC character to the printer followed by the
;character in AL.  AH specifies the number of characters to follow the first
;two (0 if none, 1, or 2).  The first of these is in BL and the second in BH.
;All registers except AX are preserved.  AH contains printer status on return.
;The routine returns immediately on a timeout error.
ESC_SEQ PROC    NEAR
        PUSH    BX
        PUSH    CX
        PUSH    DX
        MOV     CX,AX           ;Save AX
        XOR     DX,DX           ;DX=0 indicates printer 1
        MOV     AX,001BH        ;AL='ESC'
        INT     17H             ;printer_io
        TEST    AH,1            ;timeout?
        JNZ     ESC_RET
        MOV     AL,CL           ;retrieve character
        MOV     AH,0
        INT     17H
        TEST    AH,1
        JNZ     ESC_RET
E1      LABEL   NEAR
        MOV     AL,CH
        CMP     AL,0            ;anymore characters to send?
        JZ      ESC_RET         ;return if done
        MOV     AL,BL           ;get next character
        MOV     AH,0
        INT     17H
        TEST    AH,1
        JNZ     ESC_RET
        MOV     BL,BH           ;put next character in BL
        DEC     CH
        JMP     E1              ;do until all characters sent
ESC_RET LABEL   NEAR
        POP     DX
        POP     CX
        POP     BX
        RET
ESC_SEQ ENDP
CSEG    ENDS
        END
