T/S2068 Display Primer

Author(s): Fred Blechman
Publication: Timex Sinclair User
Pub Details: Timex Sinclair User n6 (Volume 1, Issue 6)
Date: November 1983
Pages: 44-48
T/S2068 computer with a portable TV monitor
T/S2068 computer with a portable TV monitor

Author Fred Blechman explains how to get your computer to put things on the screen where you want them to go

YOUR Timex Sinclair 2068 is now hooked up and running, and you’ve practiced using some of the commands. You’ve probably even written a few simple programs with INPUT, PRINT and several other statements. You may have even done some calculations and had the results PRINT on the screen. But you’ve also discovered that computers seem to have a mind of their own about where they put things on the screen. The purpose of this article is to help you get control of your computer and make it put things on the screen where you want them! You’ll also find out how to do some simple graphics.

Display Mode 1

The display looks like a big blank area when there’s nothing on it but the little blinking cursor in the lower left corner. Actually, there are four display “modes” available with the T/S2068 computer. In this article we’ll only be directly involved with Display Mode 1, since using the other modes is fairly sophisticated.

Display Mode 1 provides 24 lines of 32 character locations on each line, with the bottom two lines reserved for INPUT, EDITing and reports. However, you can also PLOT individual points — called “pixels” — in any of 256 locations across, and 176 locations up-and-down! For those of you weaned on the ZX81 or Timex Sinclair 1000 or 1500, this is four times as many locations in each direction, or 16 times more pixel locations (45056 vs. 2816). All these locations are shown in Figure 1.

Character & Pixel Locations

The first thing to understand is that in Display Mode 1 character locations each use eight pixels across by eight pixels high. That’s why there are 256 pixel locations across the screen (32 characters × 8 pixels per character) and 176 pixel locations vertically (22 usable lines × 8 pixels per line). Another thing to understand is that all locations start with the first place designated as 0 rather than 1. That’s why character locations on Figure 1 go from 0 to 31 horizontally and 0 to 21 vertically, and pixel locations run from 0 to 255 across and 0 to 175 vertically. But that isn’t all! Character locations start in the upper left corner, counting across and down. Pixel locations, on the other hand, reflecting the normal Cartesian coordinate standard, start at the lower left corner and count across and up!

Why do you need to know all of this? You don’t — unless you want to control your screen displays. With a few simple commands and Figure 1, you’ll become the master. Read on.

To Scroll or Not to Scroll?

Type in this simple program to print on all 22 screen lines:

10 FOR X=1 TO 22
20 PRINT “Test”
30 NEXT ×

Of course, the FOR, TO, PRINT and NEXT are keywords, not separate characters. Now, when you RUN the program, the word “Test” (without the quotation marks) appears at the left side of the screen on all 22 lines. Simple enough.

Now, just to see what happens when you try to put more than 22 lines on the screen at a crack — or whenever the next printed line would fall below the last user screen line — change the 22 in line 10 to 30. Now RUN and you get “Test” on 22 lines, then a blank line and “scroll?”. Hmmmm. What to do to get the rest? Just press any key (except N, STOP, BREAK or SPACE) and the display continues and then stops with an OK report. Actually, the “scroll?” has been carefully planned to keep you from losing screen data unintentionally by having it scroll up off the screen. If you don’t want the “scroll?” at the end of a full screen, then simply add this line:

15 POKE 23692,255

Now when you RUN, the program goes to the end before it stops. The POKE simply tells the computer to PRINT 255 more lines before “scroll?”. Since you’ve placed this in the program so that it is operative before the PRINT statement, the program is not even limited to 255 lines, since it is reset to 255 every time you go through line 15. This may seem unimportant to you now, but can be critical when printing long tabulations — and “scroll?” will also stop the printer if you’re using one!

Print Formatting Using the Comma and Semi-colon

Two of the easiest-to-use and most powerful formatting commands are the comma and the semi-colon. Just change line 20 by adding a comma after “Test”. Now RUN and you’ll get two columns of the word “Test” running down the left and center of the screen, with 15 in each column. What has happened is that the comma at the end of line 20 moves the printing to the next half-screen width. If you use two commas, that moves the next printing a full screen line. As a matter of fact, just to illustrate how commas can be used to space printing several lines apart (with very little memory use), change the 30 in line 10 to 8, delete line 15, and use six commas at the end of line 20 instead of one comma. Now the program is simply this:

10 FOR × =1 TO 8
20 PRINT “Test”,,,,,,
30 NEXT ×

When this is RUN you get “Test” on display line numbers 0, 3, 6, 9, 12, 15, 18 and 21 (refer to Figure 1 for display line numbers). The six commas at the end of the PRINT statement on line 20 of the program have merely created two blank lines each time. After the last line, the “scroll?” appears, since the commas are trying to print two more blank lines.

To see the effect of a semi-colon, just remove the commas from the end of program line 20 and use one semi-colon instead. Now RUN — and all the “Test” words are on one line, with no spaces at all between words! The semi-colon at the end of a PRINT statement simply freezes the printing cursor at that location, unless overridden by PRINT AT or PRINT TAB, which we’ll get to soon.

Figure 1. Video display layout.
Figure 1. Video display layout.

But what about blank spaces? Can they be used to format? Absolutely! Change line 20 of the program to add four blank spaces after the word “Test” but before the closing quotation mark, like this:

20 PRINT “Test “;

When you RUN the program each “Test” is separated by four blank spaces. Any text, including blank spaces, between quotation marks in a PRINT statement, will be printed, even if it forces the printing to the next line. A blank space uses a character space just like any other character!

Learn how to properly use commas, semi-colons and blank spaces, and you’re on your way to “punctuation power”.

Take the TAB Test!

Go back to line 20 in your program and change it to:

20 PRINT TAB 8;”Test”

The TAB function is above the P key. You need to first access the E-cursor, which you get by pressing one of the CAPS SHIFT keys and the SYMBL SHIFT key together. When you RUN this new line 20 (with the old lines 10 and 30), you’ll get eight “Tests” all lined up one above the other, indented in to the eighth character space on each line. Now change the 8 in line 20 to the letter X. When RUN, each line is indented one more space than the previous one, since TAB now takes the value of X, which line 10 of the program increases by one each time through the FOR-NEXT loop (lines 10 and 30).

Multiple TAB statements are common. For example, use this for line 20 in the program:

20 PRINT “Take”; TAB 8;”the”; TAB 16;”TAB”; TAB 24;”test. . .”

RUN and see how nicely each word is spaced. Can you see the value of this in tabulations? Of course, the real value is when you can use variables. Use NEW (the A key) and ENTER to erase the current program in memory, and then type in this program:

10 LET a=1: LET b=2: LET c=3: LET d=4
20 PRINT a; TAB 8;b; TAB 16;c TAB 24;d
30 LET a=a+1: LET b=b+2: LET c=c+3: LET d=d+4
40 GOTO 20

RUN and watch the four columns of figures march down the screen, with the first column counting by one, the second by two, the third by three and the fourth by four — neatly formatted by the TAB statements. Of course, you can combine text with the variables in TAB statements. When the last line prints, the familiar “scroll?” appears. How would you defeat that? Just add: 35 POKE 23692,255

Using PRINT AT

If you think that TAB is something, wait until you get familiar with PRINT AT! You’ll need to refer to Figure 1 again to follow this. PRINT AT simply has the printing start at a location down and across from the upper left corner. You specify the coordinates with line (down) first, and then column (across), like this:

PRINT AT 20,15

This will cause the printing to start on the twenty-first line down and the sixteenth space across. (Remember, zero is a number in computing, and is used where you normally would start with one. Also, “lines” are frequently referred to as “rows”.) To illustrate how PRINT AT can be used, delete your existing program with NEW and ENTER this program:

10 LET y=0:FOR x=0 to 21
20 PRINT AT y,x; “Test”
30 LET y=y+1: NEXT ×

Be sure to use the SYMBL SHIFT and I key to get AT. RUN this and you’ll get a string of “Test” words running diagonally down the screen. But to illustrate how PRINT AT can jump around the screen, and even erase previous printing, add line 40:

40 PRINT AT 11,7; “END OF TEST!”

See how it overprints the twelfth line (screen line 11)? Using blank spaces between the quotes, you can erase anywhere on the screen.

Result of the PRINT AT test program.
Result of the PRINT AT test program.

Displaying the Entire Character Set

You might want to see what each number means to the computer when it’s used in the “character set”. This is accessed with the CHR$ statement. This program can be used to print each CHR$ code on the screen and on the printer. If you don’t have a printer, or it’s not turned on, the LPRINT commands will just be ignored. Type this in after NEW:

10 FOR ×=32 TO 255 STEP 2: POKE 23692,255
20 PRINT ×;” “; CHR$ ×,×+1;” “; CHR$ (×+1)
30 LPRINT ×;” “; CHR$×,×+1;” “; CHR$ (×+1)
40 PRINT : LPRINT : NEXT ×

A couple of things are significant here. For one thing, most numbers under 32 represent “control codes”. Not only will they not print out, some will stop the program — so start with 32, which is a blank space. Another significant thing is that the numbers and letters are standard ASCII (pronounced ASK-ee, and stands for American Standard Code for Information Exchange), unlike the T/S1000, 1500,ZX81. This is of prime importance when interfacing the computer to peripherals, such as printers, plotters, modems and so forth. When you RUN the program, the comma in lines 20 and 30 “zones” the printer so you get two columns, each one-half screen width. Notice the graphics from 128 (blank space, like 32) to 143. What appear to be a repeat of upper-case letters A to U (numbers 144 to 164) are actually locations where you can design and program any character shape to fit into an 8 x 8 matrix — but that’s another whole subject! Notice that the keywords run from 165 to 255; did you realize there were so many?

High Resolution Graphics

There are three ways to produce graphics with the T/S2068. The “low-resolution graphics” are those available directly from the keyboard — the eight squares on number keys 1 to 8, and their inverse video counterparts (when the SYMBL SHIFT key is held down, or INV.VIDEO is used.) The so-called “high-resolution graphics” are the pixels referred to earlier. The “ultra-high” resolution color graphics are only available in Display Mode 4, not covered in this article.

Getting Pixel-ated

Figure 1 (again!) shows the coordinates used for pixels (picture elements — individual dots). The important thing here is that pixel coordinates are specified just like conventional graphs, with the x-axis horizontal, running left to right, and the y-axis being the left vertical side, running upwards. This is entirely different from the PRINT AT coordinates. This takes some getting used to, but makes sense when you think of it this way: PRINT AT is intended for text, which extends from top to bottom, left to right; pixels, on the other hand, are graphical in nature, and follow x-y graph convention.

Furthermore, since there are 64 pixels (8 x 8) in each character space the numbering system is entirely different. To illustrate the use of pixels, delete the existing program with NEW and type in this program:

10 LET y=0: FOR x=1 TO 175
20 PLOT x,y
30 LET y=y+1: NEXT ×
40 LET y=0: FOR x=1 TO 175
50 PLOT INVERSE 1;x,y
60 LET y=y+1: NEXT ×
70 GOTO 10

When you RUN this program, a thin line is drawn, one pixel at a time, from the lower left corner of the display to the top of the display (but only 176 pixel locations to the right, not the entire 256 spaces), and then the line is erased, pixel by pixel. (The T/S2068 does not have the UNPLOT statement used in the T/S1000,1500,ZX81, but “PLOT INVERSE 1;” amounts to the same thing, though a little trickier to use).

Just for a little fun with sound (although it will slow down the program) add this:

45 BEEP .1×/8

Okay, Pardner — DRAW!

Just to give you a taste of the power of just one other graphical command, press the A key (NEW) and ENTER. Now type and ENTER this short program:

10 PLOT 0,0: DRAW 175,175
30 PLOT INVERSE 1;0,0: DRAW INVERSE 1;175,175
50 GOTO 10

Very simply stated, PLOT putteth and PLOT INVERSE taketh away. DRAW almost instantly creates a line from the PLOT starting point to an ending point x pixels to the right and y pixels up. Zap! PLOT INVERSE and DRAW INVERSE act like erasers. Press R for RUN and ENTER and you get a flashing line in exactly the same position as the previous program! Actually, the line is being “drawn” and erased so quickly it appears to be flashing. To slow it down, so you can see how fast the DRAW command is, put in the following two lines:

20 PAUSE 30
40 PAUSE 30

The PAUSE is just that. The computer counts to itself the number of television frames going by (60 per second) and does nothing new in between — so PAUSE 30 gives you about a half-second delay. (Don’t depend on PAUSE for precise timing, however, since computing time is involved, as well as television frames . . . )

Pixel Power

There is really hardly any limit to the detailed graphics you can design with the fine resolution of the T/S2068 in Display Mode 1. We haven’t even touched on color (there are eight of those with two BRIGHTness levels for each), and have only mentioned special character shapes, of which there can be a choice (are you ready for this???) of 18 billion-billion possible shapes in each character space! Consider also that in Display Mode 2 you can have 64 characters or 512 pixels on a line! Now, let’s see, 18 billion-billion possible shapes in each of 64 characters on a line, times 22 lines . . . hmmmmm . . . that’s a lot of possible different screens!

Note: This article is an excerpt from the author’s new book, “Timex 2000 Beginner/Intermediate Guide” (Howard W. Sams and Co. Book #22225).