Fill The Screen With Your Message: Generating Large Multi-Colored Characters Using Apple Low-Resolution Graphics
Francis A. Harvey
Rosann W. Collins
Theodore C. Hines
School of Education
University of North Carolina at Greensboro
Greensboro, North Carolina 27412
Programs written by beginning programmers can often be distinguished from more elaborate "commercial" programs by the fact that the commercial programs make such extensive use of color and graphics. Computers such as the Apple and Atari have very good graphics capability, but many users lack the time or programming background, or both, to take full advantage of these capabilities. As a result their programs, while they may be carefully designed and interesting, lack the pizzazz that children expect from computers as a result of their experiences with commercial programs and computer games at home and in game rooms.
As part of a series of utilities of this kind, we have developed a set of subroutines in Applesoft which will display the characters in any string on the screen as large, colorful letters. With these subroutines program instructions, prompts, positive reinforcement, and negative responses to user input can look just like those in "real" computer games. Very little modification of an existing program is required to convert screen output to this form.
Each character is defined (with a combination of PLOT, VLIN, and HLIN commands) on a matrix which uses seven blocks in the vertical dimension and which varies in width depending on the shape of the character. With the character set defined in this way, each line of text can have between six and nine characters, and a total of four lines of text can be displayed. Each letter is approximately one-fifth as high as the screen and about one-eighth of a screen wide.
10 REM ---- LETTER MATCH --- 20 REM ---- 10/20/80 VERSION-- 30 REM -------- BY --------- 40 REM ---- FRANCIS A. HARVEY - 50 REM ---- ROSANN W. COLLINS - 60 REM -- & THEODORE C. HINES - 65 REM --- COPYRIGHT 1980 ----- 70 HOME : GR : GOSUB 5020 80 REM -------TITLE PAGE------- 90 Y = 3:A$ = "MATCH": GOSUB 6010 100 Y = Y + 12:A$ = "THE": GOSUB 6010 110 Y = Y + 12:A$ = "LETTERS": GOSUB 6010 120 PRINT : PRINT : PRINT 130 FOR I = 1 TO 1000: NEXT I 141 PRINT "BY FRANCIS A. HARVEY" 142 PRINT " ROSANN W. COLLINS" 143 PRINT " THEODORE C. HINES" 145 FOR I = 1 TO 2500: NEXT I 146 PRINT : PRINT : PRINT 160 A$ = "COPYRIGHT OCTOBER 1980": GOSUB 4020 170 FOR I = 1 TO 4000: NEXT 180 PRINT : PRINT : PRINT : REM --CLEAR TEXT 190 E = 5: REM --- FOR DEMO PURPOSES 200 REM :E IS NUMBER OF ATTEMPTS 210 REM --- USER INSTRUCTIONS--- 220 GR : GOSUB 5020 230 X = 0:Y = 0: REM --RESETS LETTER POSITION 240 A$ = "I TYPE": GOSUB 6010 250 Y = Y + 12 260 A$ = "A": GOSUB 6010 270 Y = Y + 12:A$ = "LETTER.": GOSUB 6010 280 FOR I = 1 TO 5000: NEXT I: GR 290 GOSUB 5020 300 Y = 3 310 A$ = "YOU TYPE": GOSUB 6010 320 Y = Y + 9 330 A$ = "THE SAME" 340 GOSUB 6010 345 Y = Y + 9:A$ = "LETTER.": GOSUB 6000 350 FOR I = 1 TO 4000: NEXT I 360 Y = Y + 10 370 A$ = "READY?": GOSUB 6000 380 HOME 390 INPUT "STRIKE ‘RETURN’ WHEN RÉADY.";A$ 400 REM 410 REM ******************* 420 REM ---BEGIN MAIN PROGRAM--- 430 L = RND (1) * 26 + 1 440 C1 = C1 + 1: REM --COUNTS LETTERS TRIED 450 L = INT (L) + 64 460 Y = 3 470 A$ = CHR$ (L): GR : GOSUB 5020: GOSUB 6010 480 HOME 490 PRINT "TYPE THE SAME LETTER." 500 GET B$ 510 REM ---DISABLE RETURN KEY 520 IF ASC (B$) = 13 THEN 500 530 REM ---DISABLE SPACE BAR 540 IF ASC (B$) = 32 THEN 500 550 Y = Y + 8 560 A$ = B$: GOSUB 6010 570 FOR K = 1 TO 500: NEXT 580 IF B$ = CHR$ (L) THEN GOSUB 2010 590 IF B$ < > CHR$ (L) THEN GOSUB 1010:Y = 3: GOTO 500 600 FOR I = 1 TO 2000: NEXT I 610 IF C1 < E THEN 420 620 GR : GOSUB 5000:Y =3 630 HOME 640 A$ = "THAT'S": GOSUB 6010 650 Y = Y + 12 660 A$ = "ALL": GOSUB 6010 670 Y = Y + 12 680 A$ = "FOR NOW.": GOSUB 6010 690 FOR I = 1 TO 2000 : NEXT I 700 GR : GOSUB 5000 : REM —CLEARS SCREEN 710 Y = 3 720 A$ = "NEXT" : GOSUB 6000 730 Y = Y + 12 : A$ = "PERSON," : GOSUB 6000 740 Y = Y + 12 : A$ = "PLEASE." : GOSUB 6000 745 FOR I = 1 TO 2000 : NEXT I 750 PRINT 760 PRINT "TYPE" : FLASH : PRINT "S"; : NORMAL : PRINT " TO STOP." 770 PRINT "STRIKE ANY KEY TO GO ON." 780 GET Z$ : IF Z$ < > "S" THEN C1 = 0 : GR : GOTO 380 790 GR : GOSUB 5000 : Y = 3 800 HOME 810 A$ = "OK!" : GOSUB 6000 820 Y = Y + 12 : A$ = "GOODBYE" 830 GOSUB 6000 840 Y = Y + 12 : A$ = "FOR NOW." : GOSUB 6000 899 END 1000 REM 1010 REM ---SUBROUTINE FOR WRONG ANSWERS 1020 Y = Y + 8 1030 A$ = "TRY IT" : GOSUB 6010 1040 Y = Y + 8 : A$ = "AGAIN." : GOSUB 6010 1050 FOR I = 1 TO 1500 : NEXT I 1060 Y = 11 : GOSUB 3000 1070 RETURN 2000 REM 2010 REM ---SUBROUTINE FOR RIGHT ANSHERS 2020 Y = Y + 12 2030 M = INT < RND (1) * 5 ) + 1 2040 ON M GOTO 2050, 2060, 2070, 2090, 2100 2050 A$ = "RIGHT!" : GOSUB 6000 : RETURN 2060 A$ = "OK!2 : GOSUB 6010 : RETURN 2070 A$ = "YOU ARE" : GOSUB 6010 2080 Y = Y + 8 : A$ = "SHARP!" : GOSUB 6010 : RETURN 2090 A$ = "GREAT! 2 : GOSUB 6010 : RETURN 2100 A$ = "SUPER!" : GOSUB 6010 : RETURN 2110 RETURN 3000 REM ---BLANKS REST OF SCREEN 3010 COLOR = 0 3020 FOR T = Y TO 39 3030 HLIN 0, 39 AT T 3040 NEXT 3050 GOSUB 5020 3060 RETURN 4000 REM 4010 REM ******************** 4020 REM ---CENTERS AND PRINTS 4030 REH ---REGULAR TEXT --- 4040 Z = (40 - LEN (A$)) / 2 4050 HTAB Z : PRINT A$ 4060 RETURN 5000 REM 5010 REM ******************************** 5020 REM --PICKS RANDOM COLOR--- 5030 COLOR = INT ( RND (1) * 15) + 1 5040 RETURN 6000 REM ********************************* 6010 REM -LARGE PRINT SUBROUTINE 6020 REM ---A$ IS STRING TO---- 6030 REM --- BE PRINTED ------ 6040 REM ----- CENTERS TEXT --- 6050 X = ABS (20 - LEN (A$) * 2.5) 6060 FOR W = 1 To LEN (A$) 6070 IF ASC ( MID$ (A$, W, 1)) = 32 THEN X = X + 2 : GOTO 6160 6080 IF MID$ (A$, W, 1) = "?" THEN GOSUB 8010 : GOTO 6160 6090 IF MID$ (A$, W, 1) = "!" THEN GOSUB 8080 : GOTO 6160 6100 IF MID$ (A$, W, 1) = "," THEN GOSUB 8130 : GOTO 6160 6110 IF MID$ (A$, W, 1) = "." THEN GOSUB 8180 : GOTO 6160 6120 IF MID$ (A$, W, 1) = "/" THEN GOSUB 8230 : GOTO 6160 6125 IF MID$ (A$, W, 1) = ";" THEN GOSUB 8270 : GOTO 6160 6130 P = ASC (MID$ (A$, W, 1)) - 64 6140 ON P GOSUB 6200, 6270, 6350, 6420, 6490, 6560, 6620, 6700, 6750, 6810, 6860, 6900, 6950, 7010, 7070, 7130, 7190, 7270, 7360, 7440, 7480, 7530, 7590, 7650, 7700, 7750 6150 X = X + 6 6160 NEXT 6170 GOSUB 5020 6180 RETURN 6200 REM ---------PRINTS LETTER A 6210 PLOT X + 2, Y 6220 PLOT X + 1, Y + 1 : PLOT X + 3, Y + 1 6230 VLIN Y + 2, Y + 6 AT X + 4 6240 HLIN X, X + 4 Y + 4 6250 VLIN Y + 2, Y + 6 AT X 6260 RETURN 6270 REM ---PRINTS B 6280 VLIN Y, Y + 6 AT X 6290 VLIN X, X + 2 AT Y 6300 HLIN X, X + 2 AT Y + 3 6310 HLIN X, X + 2 AT Y + 6 6320 VLIN Y + 1, Y + 2 AT X + 3 6330 VLIN Y + 4, Y + 5 AT X + 3 6340 IF X > 0 THEN X = X - 1 : RETURN 6350 REM -----PRINTS C 6360 VLIN Y, Y + 6 AT X 6370 HLIN X, X + 3 AT Y + 6 6380 HLIN X, X + 3 AT Y 6390 PLOT X + 3, Y + 1 6400 PLOT X + 3, Y + 5 6410 X = X - 1 : RETURN 6420 REM -------PRINTS D 6430 VLIN Y, Y + 6 AT X 6440 VLIN Y + 1, Y + 5 AT X + 3 6450 VLIN X, X + 2 AT Y 6460 HLIN X, X + 2 AT Y + 6 6470 X = X - 1 : RETURN 6480 PRINT "1799" : END 6490 REM ----------PRINTS E 6500 VLIN Y, Y + 6 AT X 6510 HLIN X, X + 3 AT Y 6520 HLIN X, X + 2 AT Y + 3 6530 HLIN X, X + 3 AT Y + 6 6540 X = X - 1 6550 RETURN 6560 REM ------PRINTS F 6570 VLIN Y, Y + 6 AT X 6580 HLIN X, X + 3 AT Y 6590 HLIN X, X + 2 AT Y + 3 6600 X = X - 1 6610 RETURN 6620 REM ----------PRINTS G 6630 VLIN Y, Y + 6 AT X 6640 HLIN X, X + 3 AT Y + 6 6650 HLIN X, X + 3 AT Y 6660 PLOT X + 3, Y + 5 : PLOT X + 3, Y + 4 6670 PLOT X + 2, Y + 4 6680 X = X - 1 6690 RETURN 6700 REM ---------PRINTS H 6710 VLIN Y, Y + 6 AT X 6720 VLIN Y, Y + 6 AT X + 3 6730 HLIN X, X + 3 AT Y + 3 6740 X = X - 1 : RETURN 6750 REM ------------PRINT I 6760 HLIN X, X + 2 AT Y 6770 HLIN X, X + 2 AT Y + 6 6780 VLIN Y, Y + 6 AT X + 1 6790 X = X - 2 6800 RETURN 6810 REM --------PRINTS J 6820 HLIN X, X + 4 AT Y 6830 VLIN Y, Y + 5 AT X + 3 6840 PLOT X, Y + 5 : HLIN X + 1, X + 2 AT Y + 6 6850 RETURN 6860 REM ---------PRINTS K 6870 VLIN Y, Y + 6 AT X 6880 PLOT X + 3, Y + 1 : PLOT X + 2, Y + 2 : PLOT X + 1, Y + 3 : PLOT X + 1, Y + 4 : PLOT X + 2, Y + 5 : PLOT X + 3, Y + 6 6890 X = X - 1 : RETURN 6900 REM --------PRINTS L 6910 VLIN Y, Y + 6 AT X 6920 HLIN X, X + 3 AT Y + 6 6930 X = X 1 : RETURN 6940 RETURN 6950 REM ------------PRINTS M 6960 VLIN Y, Y 6 AT X 6970 VLIN Y, Y 6 AT X + 4 6980 PLOT X + 1, Y 1 : PLOT X + 3, Y + 1 6990 PLOT X + 2, Y + 2 7000 RETURN 7010 REM -----------PRINTS N 7020 VLIN Y, Y + 6 AT X 7030 VLIN Y, Y + 6 AT X + 4 7040 PLOT X + 1, Y + 1 : PLOT X + 2, Y + 2 : PLOT X + 2, Y + 3 : PLOT X + 3, Y + 4
Color can be set within the program or randomly selected each time a line of characters is displayed. The upper-left corner of the matrix is defined as (X, Y), and each character is "drawn" from this reference point.
Each line of characters is passed to the subroutine as the string A$. An initial value of X, the horizontal beginning point of each character, is calculated which will center the characters on the line, and the characters are drawn one at a time.
The subroutines that draw each character automatically increment the value of X the appropriate number of spaces to the right. Messages longer than one line (e.g., "You are sharp!") can be subdivided; the value of the string A$ is set to the contents of each line, and Y is incremented by at least nine before calling the subroutine which centers and plots the characters.
The sample program listed demonstrates two ways in which these techniques can be used. The program, LETTERMATCH, was developed to familiarize primary school students with the letters of the alphabet and the computer keyboard. A randomly selected letter is displayed on the screen, and the user is asked to type the same letter. The GET command is used for input and all non-letter keys, the RETURN key, and space bar are disabled.
If the student enters the wrong letter, the computer responds with a large "TRY IT AGAIN," then clears the screen of the student's response and redisplays the original letter. The student responds until the correct letter is selected. When the student does enter the correct letter, the computer responds (again, in large, multi-colored letters) with one of five randomly selected positive responses, such as "RIGHT!" or "YOU ARE SHARP!". Each student is asked to identify five letters correctly.
We have found that LET-TERMATCH provides an excellent introduction to computers for quite young children. It can be modified (for example, by considerably shortening the delay loops) for use to introduce other users to computers and to sharpen keyboarding skills of users of any age.
LETTERMATCH occupies about 6400 bytes of memory. The subroutines which format and plot the characters (beginning in line 5000) occupy about 3700 bytes. Thus, any Applesoft program which leaves 3700 bytes of memory free when loaded can be modified to give large, multi-colored responses by merging these subroutines with the existing program (using the Apple RENUMBER program), making minor changes in the main program (adding GR, selecting colors, etc.), then modifying each PRINT statement to use the subroutine. For example, the line "200 PRINT "VERY GOOD!" would be changed to "200 A$ = "VERY GOOD!": GOSUB 6000."
The character set as developed includes the upper case letters A to Z and the question mark, exclamation point, comma, period, single quotation marks, and semicolon. The set could easily be expanded to include lower case letters, numerals, and other punctuation. The program randomly selects the color of each line of characters.
Copies of LETTERMATCH on diskette or cassette are available from the authors at the above address for the cost of duplication. While we reserve all commercial rights to these programs, we offer them free to any user for any noncommercial educational purpose. Other utilities of this kind which we have developed include routines for adding sound effects and music to programs, additional graphics (such as screen borders), and others. These will appear in later issues of COMPUTE! We hope that teachers and other computer users will find these procedures a useful addition to their program collection.