What Is It?

by Larry W. Linson


What Is It? is an activity that I began writing for my first grade class, in the fall of 1982. It's a reading/spelling activity in which you are asked to identify a series of seven random pictures. The program is similar to the reading workbooks children use in the primary grades. The child simply needs to type in the picture-word that corresponds with the picture. For example, if a picture of a HOUSE appears, then the word "HOUSE" should be typed in. In What Is It? there are four levels of difficulty. Level 1 offers a single clue, the name of the picture. Level 2 gives the picture word and two distracting clues which are not similar to the picture word. Level 3 gives the picture word and three other similar distractors such as HOUSE, HORSE, MOUSE and HOWLS. Level 4 gives no hints at all; the word must be typed in from the child's memory. The program keeps score and reports it after each correct answer. The program keeps score and reports it after each correct answer. I've now had close to fifty children test this program, and most of the "bugs" have been worked out, with many new features added to the original program.

Error trapping

Children working on Atari computers have the most trouble with accidentally pressing the BREAK key when they want the BACK SPACE key, which is right "next door." I avoided this problem by OPENing the keyboard, rather than using the INPUT command. By using this technique, if a mistake is made and BACK SPACE is pressed, then the program clears the student's response and waits for another. An undesired response can be cleared at any time by pressing either the SPACE BAR or the BACK SPACE key.

The BREAK key was disabled to prevent the program from being stopped prematurely. This was accomplished by using POKE 16,64 and POKE 53774,64. I used a short subroutine at Line 13000 for this, since the POKE must be repeated after each graphics mode change. I also used various TRAP statements for "catching" errors. In this way, the program doesn't halt if an error is detected. The children in my classes have been rather inventive in finding ways to "break" or "crash" programs. To date, What Is It? hasn't been crashed by any of my first graders. I didn't protect against SYSTEM RESET. This key is not pressed accidentally very often (except during games!). I also felt it might be advantagous to be able to stop the program if desired.

Memory-saving tricks

In the program, I have used various methods to save memory (RAM). One of these is to substitute variables for commonly employed numbers. For example, in the program, I have used the numeric variable Q1 to equal 1, and Q1+Q1 to equal 2, and so on. Atari BASIC uses up seven bytes every time a number is entered. By substituting a numeric variable, such as Q1, only one byte of memory is needed. This may initially make the program seem a little difficult to decipher, but just read "Q1" as "1" and you won't have any problem. I used this same technique to label POKE locations and subroutines. The command GOTO PICK sends the program to the picture shuffling routine. POKE OFF, Q1 is used to turn off the cursor. The number held by OFF is 752. POKEing 752 with a 1 (entered as POKE 752,1) tells the cursor to disappear.

Another way of saving RAM was to utilize many statements on the same line, employing the same numeric variables over and over. In this way, What Is It? will run on a 16K 400 or 600XL. Any more RAM-saving stunts, and the program would have been virtually unreadable and much more frustrating to type in!

Program flow

The program is set up rather logically -- to my way of thinking, anyway! What Is It? begins with a title page and then asks for your name. You select the level you wish to try, and a series of seven random pictures follows. Having only eleven pictures in the program's library may not seem like very many, but I believe that my students enjoy the familiarity and reinforcernent they achieve with this library of pictures. Since each picture is picked at random, and the program will not pick the same picture twice, there are over one and one-half million different combinations of the eleven pictures! Check it yourself try this on your Atari: PRINT(11*10*9*8*7*6*5). The results are staggering, aren't they?

After each picture word is correctly answered, a short reward sequence is initiated. After the seventh picture, an overall score is given, and you are asked if you would like to try again. Many of the techniques that I have used in What Is It? have been borrowed from other programmers. The idea of using numeric variables comes from Jerry White; the picture-shuffling routine in Lines 4000-4010 is from James Korenthal; and the practice of using DATA staternents to READ numbers to PLOT and DRAWTO for graphics, I learned from Elaine Garringer. I have found that the best way to learn how to program is to type in programs, such as this one, RUN it and then study the code to see how the author achieved different effects. I've learned more from doing this than from any book I have purchased!

Variable table

Variable
Usage
NAME$
stores user's name
REWARD$
holds a reward message for end of program
TEMP$
holds correct picture word to match to answer
G$
user's answer for picture shown
T$
large blank space used for clearing out area
Q1,Q2,Q3,Q6,Q10,Q20,Q1=1 etc.
numeric variables
CUE
routine that asks question
CLUE
gives clues depending upon level
PICK
shuffle routine that selects picture
PICTURE
holds the beginning line number of the picture subroutine that was chosen for display
BRK
subroutine that blocks out BREAK key
LWL
sends program to get the set of CLUEs for the appropriate level
PN & POOL
used in shuffle routine
RA
# of Right Answers
WA
# of Wrong Answers
SPOT
used as a return point in setting up TRAP statement
LV
the selected level
HOU,STA,BOX,KIT,BOO,TV,TRU,FOOT,FAC,CON,LOL
used in subroutine that weeds out pictures already used, so the same picture is not shown twice
COUNT
Keeps track of the number of pictures shown.
OFF
stores POKE location 752, turns off cursor
KOLOR
holds the RANDOM number used to POKE into locations 710 & 712, which control the background and text window colors.

The rest of the variables are used as simple counters, for delay statements or PLOT and DRAWTO routines.

Take-apart

Lines 0-5
Sends program to initialize variables at Line 15000.
Lines 6-19
Displays title page and gets child's name.
Lines 20-35
Child selects level of difficulty and program assigns variables for the appropriate level.
Lines 40-90
The routine that draws the pictures and stores the correct answer for the computer to compare to the child's response.
Line 95
Sends program to the subroutine to display clues assigned to that level, and then on to the input routine.
Lines 100-1110
DATA for the eleven pictures.
Lines 1500-1512
The answer INPUT routine.
Lines 1950-1960
Reward sequence.
Line 1962
Selects random number for background color and text window.
Line 1963
Sends program to randomly select a new picture.
Lines 2000-2005
Incorrect answer sequence, sends program back for clues so child can enter the correct answer.
Lines 4000-4030
Sequence to randomly select a picture and check to see if picture has already been used, if so program goes back to select another.
Lines 4060-4079
Ending sequence based on performance, selects an overall rating and asks if child would like to try again.
Lines 5000-5100
Clues for Level 1.
Lines 6000-6100
Clues for Level 2.
Lines 7000-7100
Clues for Level 3.
Line 8000
Level 4 offers no clues, so program is returned to answer input routine.
Line 13000
Routine to POKE out BREAK key, which must be done after each graphics mode change.
Line 13500
TRAPS keyboard errors and returns program to the proper SPOT.
Line 14000
Sets graphics mode and screen color for pictures, turns off cursor.
Listing 1

WHATISIT.LST is available in ATASCII format.

This BASIC listing uses an image to display special characters







Checksum Data
0 DATA 890,841,269,928,121,895,855,674
,815,647,244,785,377,17,670,9028
27 DATA 960,695,908,269,165,174,742,74
2,745,164,671,51,60,790,775,7911
65 DATA 776,390,59,480,567,619,998,630
,40,526,680,692,64,689,662,7872
115 DATA 973,695,694,418,35,422,363,32
8,426,51,355,41,845,434,591,6671
601 DATA 620,118,205,175,656,438,541,6
41,387,222,969,313,730,95,404,6514
806 DATA 270,577,591,459,217,446,331,8
29,27,912,651,885,375,227,736,7533
940 DATA 794,959,744,393,54,751,661,30
4,64,895,166,747,176,984,898,8590
1028 DATA 724,995,111,727,295,890,730,
681,641,527,516,529,393,679,33,8471
1110 DATA 725,344,209,215,30,994,325,9
0,254,761,392,236,356,794,709,6434
1954 DATA 157,713,801,194,129,631,243,
378,31,620,256,854,854,846,861,7568
4019 DATA 832,576,886,808,795,824,849,
425,805,740,626,210,726,820,588,10510
4076 DATA 337,352,556,241,48,480,770,7
67,3,136,466,256,509,719,937,6577
6010 DATA 686,903,898,259,119,501,927,
612,667,557,685,749,248,440,996,9247
7050 DATA 880,838,402,739,427,161,94,6
40,871,239,338,743,583,526,61,7542
16000 DATA 330,390,104,853,982,44,2703

Previous | Contents | Next

Original text copyright 1984 by ANALOG Computing. Reprinted with permission by the Digital ANALOG Archive.