Mike’s Notebook: BITS

Author(s): Michael DiRienzo
Publication: The Plotter
Pub Details: The Plotter v8 n7-8 (Volume 8, Issue 7-8)
Date: July - August 1990
Pages: 2-3

(NOTE: REPRINTING OR REPRODUCING THIS COLUMN IS PROHIBITED WITHOUT THE EXPRESS WRITTEN PERMISSION OF THE AUTHOR. TO OBTAIN PERMISSION, WRITE TO THE AUTHOR IN CARE OF THE PLOTTER.)

I like to work with computer graphics on the TS2068 and I frequently need to look up bit patterns for User Defined Graphics characters. Knowing the bit patterns of a specific byte can also help to better understand machine code among the many other uses. The following BASIC program will print out all 256 bit patterns, their hexadecimal and decimal equivalent. A zero is represented as a blank box and a one is a filled box. In fact, the UDG “A” and “B” are poked with their pre-planned bit patterns in lines 300 to 340. To see what I mean, just type in the following program which will fill up the page then prompt you to Quit, COPY to 2040 printer or CONTINUE. If you want to copy to full sized printers then change line 240 and add your own printer driver to COPY the screen. I always have a copy of all the bit patterns handy while programming. I added line 115 and changed line 120 to increase the pattern print speed by 65%. Make sure that you use UDG graphics “A” in line 140 and UDG “B” in 150. Lines 300 to 340 POKE the UDG’s with the proper bytes.

Happy TIMEXing…

“BITS” By Michael Di Rienzo

  10 GO SUB 300
20 POKE 23658,8: LET n=0
30 LET h$="0123456789ABCDEF"
40 FOR c=1 TO 2
50 IF c=1 THEN LET c1=0: LET c2=4: LET c3=7
60 IF c=2 THEN LET c1=17: LET c2=21: LET c3=24
70 PRINT AT 0,c1;"Dec";TAB c2;"Hex";TAB c3+1;"Binary"
80 FOR z=1 TO 21
90 LET s=INT (n/16)
100 PRINT AT z,c1;n;TAB c2;h$(1+s);h$(1+n-16*s);TAB c3;
110 FOR b=7 TO 0 STEP -1
115 LET l=1: FOR w=1 TO b: LET l=l*2: NEXT w
120 LET x=INT (n/l)
130 LET t=x-INT (x/2)*2
140 IF t=1 THEN PRINT "A";
150 IF t=0 THEN PRINT "B";
160 NEXT b
170 PRINT
180 LET n=n+1
190 IF n=256 THEN GO TO 220
200 NEXT z
210 NEXT c
220 PRINT #1;AT 1,0;"(C)opy, (Q)uit,ENTER to Continue"
230 LET q=CODE INKEY$
240 IF q=67 THEN COPY : LPRINT : IF n<256 THEN CLS : GO TO 40
250 IF q=81 THEN STOP
260 IF q=13 AND n=256 THEN STOP
270 IF q=13 THEN CLS : GO TO 40
280 GO TO 230
300 FOR n=USR "A" TO USR "A"+15
310 READ a: POKE n,a
320 NEXT n
330 RETURN
340 DATA 0,0,126,126,126,126,126,0,0,0,126,66,66,66,126,0

EDITORS NOTE: readers may have difficulty with lines 115 and 120 as the difference between 1 and l is not clear. LET l=1, LET l=l*2, INT (n/l).

Users of printer graphics can take advantage of this program by mentally rotating the print-outs so the left end of the graphic line is top, corresponding to the coding of most dot matrix printers with 8 pins in use.

Source Code

 10 GO SUB 300
 20 POKE 23658,8: LET n=0
 30 LET h$="0123456789ABCDEF"
 40 FOR c=1 TO 2
 50 IF c=1 THEN LET c1=0: LET c
 2=4: LET c3=7
 60 IF c=2 THEN LET c1=17: LET
 c2=21: LET c3=24
 70 PRINT AT 0,c1;"Dec";TAB c2;"Hex";TAB c3+1;"Binary"
 80 FOR z=1 TO 21
 90 LET s=INT (n/16)
 100 PRINT AT z,c1;n;TAB c2;h$(1+s);h$(1+n-16*s);TAB c3;
 110 FOR b=7 TO 0 STEP -1
 115 LET l=1: FOR w=1 TO b: LET l=l*2: NEXT w
 120 LET x=INT (n/l)
 130 LET t=x-INT (x/2)*2
 140 IF t=1 THEN PRINT "A";
 150 IF t=0 THEN PRINT "B";
 160 NEXT b
 170 PRINT
 180 LET n=n+1
 190 IF n=256 THEN GO TO 220
 200 NEXT z
 210 NEXT c
 220 PRINT #1;AT 1,0;"(C)opy,(Q)uit,ENTER to Continue"
 230 LET q=CODE INKEY$
 240 IF q=67 THEN COPY : LPRINT: IF n<256 THEN CLS : GO TO 40
 250 IF q=81 THEN STOP
 260 IF q=13 AND n=256 THEN STOP
 270 IF q=13 THEN CLS : GO TO 40
 280 GO TO 230
 300 FOR n=USR "A" TO USR "A"+15
 310 READ a: POKE n,a
 320 NEXT n
 330 RETURN
 340 DATA 0,0,126,126,126,126,126,0,0,0,126,66,66,66,126,0

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