CPYPRT – Program to print screens to 24-pin printers

Author(s): Charles Bothner
Publication: Update Magazine
Pub Details: Update January 1994
Date: January 1994
Pages: 9-12

Frank,

This is an assembly language program to copy T/S 2068 screens to an EPSON compatible 24 pin printer. The program resides in the printer buffer area of system RAM and it can copy screens in either the normal 32 column mode or the expanded 64 column mode. It is presently tailored for the EPSON LQ-510 printer which I am presently using, but the ESC codes should be compatible with virtually all 24 pin printers with EPSON graphics compatibility. The program contains its own printer handler to avoid the necessity of having to patch any other resident handlers to accept non-ASCII codes. My present printer port is an AERCO interface residing at port address 127 (7FH).

An assembly code listing is included. The program operates in the 32 column screen copy mode as listed. To convert to the 64 column mode, it is necessary to POKE 4 locations within the code. These locations are:

ADDRESS          FOR 64 COL. MODE   FOR 32 COL. MODE
23366 (5B46H)          2                   3
23474 (5BB2H)          0                  24
23475 (5BB3H)          0                  15
23545 (5BF9H)          4                   3

For the 32 column mode, each of the screen pixels is output in a 3X3 dot expansion to the printer. Since the printer is conditioned for a graphics mode operation of 180 dots/inch vertical and 180 dots/inch horizontal, this results in a display of 60 pixels/inch in both directions. Since there are twice as many bytes output per line in the 64 column mode, the resolution is changed to 3 dots/pixel in the vertical direction and 2 dots/pixel in the horizontal direction. There are a total of 3 ESC code sequences in the program. The first is at address 23534 (5BEEH). This sequences the graphics mode vertical spacing to 180 dots/inch. The second ESC sequence is at 23540 (5BF4H). This sequence sets up the output format for one line of graphics code to 768 vertical columns/line in the 32 character mode and 1024 vertical columns/line in the 64 character mode, since there are 512 pixels/line in this mode. The third ESC sequence starts at 23548 (5BFCH) and this restores the normal printer vertical dimensions after the screen dump is complete. Several spare bytes have been incorporated into each table to allow for patching of these tables if non-EPSON compatible printers are used. The first entry in each table must be the number of characters to be sent to the printer in the ESC sequence.

If a printer interface not using port address 127 (7FH) is used, it will be necessary to patch a total of 3 locations with the correct port address. These addresses are 23521 (5BE1H), 23528 (5BE8H), and 23530 (5BEAH).

I am supplying you with a disk containing both the 32 column and 64 column versions of the program. You will also find samples of both types of screen copys. The program is entered with a RAND USR 23296 command.

Best regards,
Charles G. (Chuck) Bothner

Sample 64 character per line screen dump
Sample 64 character per line screen dump
32 column screen dump: 10 day outdoor temperature graph
32 column screen dump: 10 day outdoor temperature graph

This 32 column screen dump is data from my 2068 data gathering program for a Heathkit Weather Computer Interface.

“CPYPRT.C1” code for screen dumps to 24 pin printers.

5B00 ENTR: E5     PUSH HL      ;save registers
5B01 D5 PUSH DE ;
5B02 C5 PUSH BC
5B03 CD225B CALL OUTP ;set up vert.spacing on printer
5B06 210040 LD HL,4000 ;start addr. of disp.block 0
5B09 CD365B CALL OUTB ;output 1 block of display data
5B0C 210048 LD HL,4800 ;start addr. of block 1
5B0F CD365B CALL OUTB ;output block 1 data
5B12 210050 LD HL,5000 ;start addr. of block 2
5B15 CD365B CALL OUTB ;output last screen block
5B18 21FC5B LD HL,REST ;set up for normal printer space
5B1B CD255B CALL AA ;output the ESC sequence
5B1E C1 POP BC ;restore regs.
5B1F D1 POP DE
5B20 E1 POP HL
5B21 C9 RET ;done
----------------------------------------------------------------
5B22 OUTP: 21EE5B LD HL,SETV ;addr.of printer vert.spc.table
5B25 AA: C5 PUSH BC ;save regs.
5B26 3E0A LD A,0A ;send LF for new line
5B28 CDD65B CALL OTPR ;
5B2B 7E LD A,(HL) ;get # of chars.to be output
5B2C 47 LD B,A ;store in B reg.
5B2D BB: 23 INC HL ;point to next character
5B2E 7E LD A,(HL) ;get next char.
5B2F CDD65B CALL OTPR ;send it to printer
5B32 10F9 DJNZ, BB ;continue until done
5B34 C1 POP BC ;restore regs.
5B35 C9 RET ;done
----------------------------------------------------------------
5B36 OUTB: 0608 LD B,08 ;8 lines/block
5B38 CC: 0E20 LD C,20 ;32 chars./line
5B3A E5 PUSH HL ;save the address
5B3B 21F45B LD HL,OTFM ;graphics setup for 1 line
5B3E CD255B CALL AA ;output the ESC sequence
5B41 E1 POP HL ;restore address
5B42 DD: C5 PUSH BC ;save char.& line counters
5B43 EE: 1680 LD D,80 ;mask bit for horiz.scan byte
5B45 FF: 3E03 LD A,03 ;3 horiz.bits per pixel
5B47 GG: F5 PUSH AF ;save the count
5B48 1E00 LD E,00 ;clear the storage reg.
5B4A E5 PUSH HL ;save the address
5B4B 7E LD A,(HL) ;get the byte & test pixel
5B4C A2 AND A,D ; for ink or paper
5B4D 2802 JR Z,HH ;jump if its paper
5B4F 1EE0 LD E,E0 ;if ink,set 3 upper bits
5B51 HH: CDCF5B CALL GTNX ;get next line of char.
5B54 2804 JR Z,II ;jump if pixel=0
5B56 7B LD A,E ;get the partial data byte
5B57 C61C ADD A,1C ;add next 3 bits
5B59 5F LD E,A ;store the partial result
5B5A II: CDCF5B CALL GTNX ;get next line of char.
5B5D 2804 JR Z,JJ ;jump if pixel=0
5B5F 7B LD A,E ;get partial data byte
5B60 C603 ADD A,03 ;set the last 2 bits
5B62 5F LD E,A ;store completed data byte
5B63 JJ: 7B LD A,E ;get the first of 3 bytes/col.
5B64 CDD65B CALL OTPR ;sent it to printer
5B67 CB43 BIT 0,E ;see if LSB was set on last byte
5B69 1E00 LD E,00 ;clear the storage register
5B6B 2802 JR Z,KK ;jump if the LSB=0
5B6D 1E80 LD E,80 ;set MSB in next byte
5B6F KK: CDCF5B CALL GTNX ;get next line of character
5B72 2804 JR Z,LL ;jump if the pixel=0
5B74 7B LD A,E ;get the partial data byte
5B75 C670 ADD A,70 ;set the next 3 bits
5B77 5F LD E,A ;store partial data byte
5B78 LL: CDCF5B CALL GTNX ;get next line of character
5B7B 2804 JR Z,MM ;jump if pixel=0
5B7D 7B LD A,E ;get partial data byte
5B7E C60E ADD A,0E ;set the next 3 bits
5B80 5F LD E,A ;store partial data byte
5B81 MM: CDCF5B CALL GTNX ;get next line of character
5B84 2801 JR Z,NN ;jump if pixel=0
5B86 1C INC E ;set LSB otherwise
5B87 NN: 7B LD A,E ;get completed data byte
5B88 CDD65B CALL OTPR ;send it to printer
5B8B CB43 BIT 0,E ;test LSB of last byte
5B8D 1E00 LD E,00 ;clear the storage register
5B8F 2802 JR Z,OO ;jump if the LSB=0
5B91 1EC0 LD E,C0 ;set 2 highest bits otherwise
5B93 OO: CDCF5B CALL GTNX ;get next line of character
5B96 2804 JR Z,PP ;jump if pixel=0
5B98 7B LD A,E ;store partial data byte
5B99 C638 ADD A,38 ;set next 3 bits
5B9B 5F LD E,A ;store the byte again
5B9C PP: CDCF5B CALL GTNX ;get last line of character
5B9F 2804 JR Z,QQ ;jump if pixel=0
5BA1 7B LD A,E ;get partial data byte
5BA2 C607 ADD A,07 ;set the last 3 bits
5BA4 5F LD E,A ;store completed data byte
5BA5 QQ: 7B LD A,E ;get completed byte
5BA6 CDD65B CALL OTPR ;sent it to printer
5BA9 E1 POP HL ;restore original disp.file addr
5BAA F1 POP AF ;restore bit counter
5BAB 3D DEC A ;decrement counter
5BAC 2099 JRNZ,GG ;send 3 sets of same bytes
5BAE CB3A SRL D ;shift bit mask
5BB0 3093 JR NC,FF ;cont.until char. is complete
5BB2 180F JR,SS ;jump if 32 character mode
5BB4 7C LD A,H ;get upper byte of address
5BB5 FE5A CP A,5A ;test location of address
5BB7 3006 JR NC,RR ;jump if not chunk 2
5BB9 3E20 LD A,20 ;offset to 2nd display file
5BBB 84 ADD A,H ;point to addr. in chunk 3
5BBC 67 LD H,A ;
5BBD 1884 JR,EE ;dump same char. pos.from file 2
----------------------------------------------------------------
5BBF RR: 7C LD A,H ;get high byte of address
5BC0 D620 SUB A,20 ;convert back to chunk 2 addr.
5BC2 67 LD H,A ;
5BC3 SS: 23 INC HL ;bump character address
5BC4 C1 POP BC ;get line & char. counters
5BC5 0D DEC C ;decrement character count
5BC6 C2425B JP NZ,DD ;cont. until done with 32 or 64
5BC9 1001 DJNZ,TT ;cont. for all lines in block
5BCB C9 RET ;done with display block
----------------------------------------------------------------
5BCC TT:C3385B JP CC ;do next line in block
----------------------------------------------------------------
5BCF GTNX: 010001 LD BC,0100 ;256 byte offset to next line
5BD2 09 ADD HL,BC ;update address pointer
5BD3 7E LD A,(HL) ;get the pixel byte
5BD4 A2 AND A,D ;test designated pixel
5BD5 C9 RET ;return with Z bit status
----------------------------------------------------------------
5BD6 OTPR: F5 PUSH AF ;save registers
5BD7 C5 PUSH BC ;
5BD8 4F LD C,A ;save the char. in C reg.
5BD9 UU: CD0920 CALL 2009 ;test for BREAK
5BDC 3802 JR C,VV ;jump if no BREAK
5BDE CF RST 08 ;return with BREAK message
5BDF 14 DEFB ;
----------------------------------------------------------------
5BE0 VV: DB7F IN A,(7F) ;read printer port
5BE2 CB67 BIT 4,A ;test BUSY bit
5BE4 20F3 JR NZ,UU ;loop back if BUSY
5BE6 79 LD A,C ;get character back
5BE7 D37F OUT (7F),A ;send it to printer
5BE9 DB7F IN A,(7F) ;reset AERCO port
5BEB C1 POP BC ;restore registers
5BEC F1 POP AF ;
5BED C9 RET ;done
----------------------------------------------------------------
5BEE SETV: 03 DEFB ;3 chars. to be output
5BEF 1B DEFB ;ESC char.
5BF0 2B DEFB ;"+"set graphics mode
5BF1 30 DEFB ; to 180 dots/inch vertical
5BF2 FF DEFB ;spare bytes
5BF3 FF DEFB ;
----------------------------------------------------------------
5BF4 OTFM: 05 DEFB ;5 chars. to be output
5BF5 1B DEFB ;ESC char.
5BF6 2A DEFB ;"*"set for 180 dots/inch horiz.
5BF7 27 DEFB ; 768 vert.columns per line
5BF8 00 DEFB ;lo byte
5BF9 03 DEFB ;hi byte
5BFA FF DEFB ;spare bytes
5BFB FF DEFB
----------------------------------------------------------------
5BFC REST: 02 DEFB ;2 chars. to be output
5BFD 1B DEFB ;ESC char.
5BFE 32 DEFB ;restore normal vert. mode
5BFF FF DEFB ;spare byte

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.