Pin Pattern Calculation

You will use the one-line array that you just created to generate a two-dimensional pattern. This technique results in a significant saving of memory compared to the method of generating an array that we used in the last chapter.

Two patterns are used in each pass of the print head. P is the pattern formed by the seven vertical dots at the start of each print line, and PO is its black/white reverse image. The program prints the pattern P in each column that is headed by a black dot. Pattern PO is printed in the other columns.

The pin patterns are created this way:

140 FOR PASS=0 TO LAST: P=0: PRINT "PASS";PASS;"OF";LAST

160 FOR DOT=@ TO H170 IF A(7*PASS+DOT+1)=1 THEN P=P+2^(6-DOT)180 NEXT DOT
190 P0=127-P: IF PASS=LAST THEN P0=P0+1-2^(7-R)

For each pass of the print head (zero to LAST), the program calculates the pin patterns, seven dots at a time. Line 170 calculates P, and line

190calculates its complement, PO.
Appendix F discusses problem codes and the P variable.
Adjust the line spacing to match the y-dot passes:
120 LPRINT CHR$(27)"1";
If this spacing produces slight gaps between rows, adjust it with
CHR$(27)"3"CHR$(20).

The length of the array depends entirely on the variables in line 20. The following lines adjust the pin patterns (I’ and PO) for the last pass of the print head if the array length is not a multiple of seven. Add:

130 LAST=INT(C/7): R=C-7*LAST150 H=6: IF PASS=LAST THEN H=R-1

On the last pass, R represents the number of pins used, and H is set to one less than the number of pins to be fired.

192