Classic Computer Magazine Archive COMPUTE! ISSUE 34 / MARCH 1983 / PAGE 205

TI Graphics Made Easy

Lyle O. Haga

There is a better way of figuring out pattern-identifier code than that presented in the TI manual.

The TI screen is divided up into a giant grid of 24 rows and 32 columns for graphics. This grid, shown in your TI manual in the CALL CHAR section, makes 768 positions or spaces for you to put your graphics in. Each square of the grid is divided up into an 8×8 grid consisting of 64 dots to be turned on or off. Each 8×8 grid is divided up into a "left block" and a "right block."

Each time you define a pattern-identifier, you use all 64 dots whether or not you so stipulate. Thus, the statement CALL CHAR(100,"FF") covers all 64 dots even though you stipulated only the top row of eight dots to be turned off; the remaining dots stay turned on. This can be seen by a simple little exercise. Make a box outline, 4×4.

On the surface this sounds like a pretty simple exercise, and it is. The problem is that many people probably won't think it through, and will come up with the following:

10 CALL CLEAR
20 CALL CHAR(100, "FF")
30 CALL CHAR(101, "8080808080808080")
40 CALL HCHAR(12,8,100,4)
50 CALL HCHAR(16,8, 100,4)
60 CALL HCHAR(12,8,101,4)
70 CALL HCHAR(12,12,101,4)
80 GOTO 80

No matter what you do, this won't work; there will always be a gap somewhere. Remember that even though you didn't stipulate all 64 dots in CHAR 100, you still have them to deal with.

On top of this you put the following:

You should be able to see where the gap comes in now. When you put CHAR 101 on top of CHAR 100, the dots you left turned on cover the dots you turned off, thus the gap.

Here's one solution to the problem:

10 CALL CLEAR
20 CALL CHAR(100, "00000000000000FF")
30 CALL CHAR(101, "FF")
40 CALL CHAR(102, "8080808080808080")
50 CALL CHAR(103, "0101010101010101")
60 CALL VCHAR(12,8,102,4)
70 CALL VCHAR(12,11,103,4)
80 CALL HCHAR(11,8,100,4)
90 CALL HCHAR(16,8,101,4)
100 GOTO 100

What's the easier way of defining graphics? The new method is one your kids learned in school, called base 16. Using base 16, you write the numbers 8,4,2,1,8,4,2,1 across the top of each 8×8 grid. Let's see how this works in defining the heart; we will make it two positions high and two wide.

If you are planning to do many graphics, you should get some graph paper — this will make it easier. Let each square on the graph paper represent one dot; this gives you 16 squares wide and 16 squares high. Make the outline with a heavy line. Count horizontally from the left 4, 8, and 12 lines; make these heavier than the other lines, and make the eighth line even heavier and have it extend beyond the outline. This will mark off your left and right blocks and one position from another. Now, counting vertically, go down eight and darken this line, going beyond the outline. Across the top, put your base 16 numbers 8, 4, 2, 1, 8, 4, 2, 1, and your paper should look like this:

With this, let's make our heart. First, color in all the squares marking your heart. Then, starting at the top row, add up the numbers over the squares you darkened. If the total is under ten, your pattern code will be that number, and if it is over nine, you use the letters A-F. You do the one complete grid and then move to the right; when you are through, move down to the next line. You should come up with the following results:

Row one has no darkened squares, so the code is zero for both left and right blocks. You get the same results with row two. In row three, a square under the number one is darkened in the left block of grid one, so the code is one. In the right block, squares under the 8 and 4 are darkened, so the code is C. In row four, the squares under the 2 and 1 are darkened; the code is 3. Row four of the right block has darkened squares under 8, 4, and 2, so the code is E. Just keep this up, and you will come up with the following:

CALL CHAR(100, "00001C3E7F7F7F7F")
CALL CHAR(101, "0000387CFEFEFEFE")
CALL CHAR(102, "3F1F0F0703010000")
CALL CHAR(103, "FCF8F0E0C0800000")

Using base 16 is easier.