Chapter 6: Graphics Commands for 9-Pin Printers54
Programming Graphics in BASIC
One important thing to remember when you're programming graphics is not to include
extraneous line feeds in your programs. Using a semicolon after the data in an LPRINT
statement will keep the print position on the same line.
However, there is an additional complication: by default, BASIC assigns to all printers a
maximum line length of 80 characters. After the printer has received 80 bytes of data, it will
automatically perform a carriage return and line feed. Since graphics data typically consists of
many bytes, it's quite easy to exceed this limit. The resulting output will be garbled. You can
work around this problem by setting the line length to the maximum allowable value, 255. Put
one of these statements at the beginning of your program:
For parallel printers:
WIDTH “LPT1:”,255
For serial printers that have been opened as #1:
WIDTH #1,255
Graphics Density Selection Commands (IBM/E)
⻬ ML320 E/I, ML321 E/I ⻬ ML320 Turbo, ML321 Turbo ⻬ ML520, ML521
Function ASCII Dec Hex
Begin Single Density
Graphics
ESC K L
n
H
n
[data] 27 75 L
n
H
n
[data] 1B 4B L
n
H
n
[data]
Double Density
Graphics Command
ESC L L
n
H
n
[data] 27 76 L
n
H
n
[data] 1B 4C L
n
H
n
[data]
Double Speed/
Double Density
Graphics Command
ESC Y L
n
H
n
[data] 27 89 L
n
H
n
[data] 1B 59 L
n
H
n
[data]
Quadruple Density
Graphics Command
ESC Z L
n
H
n
[data] 27 90 L
n
H
n
[data] 1B 5A L
n
H
n
[data]
These graphics modes correspond to the 8-pin modes and are supported by most current
DOS-based graphics software.
Parameters L
n
and H
n
These parameters tell the printer how many bytes of graphics data to expect. Eight-pin graphics
have one byte of data per column. To calculate the values for L
n
and H
n
, first determine how
many columns of dots there will be in your graphics image. Divide this number by 256 and
assign the whole number result to H
n
; assign the remainder to L
n
.