Classic Computer Magazine Archive COMPUTE! ISSUE 30 / NOVEMBER 1982 / PAGE 118

The World Inside The Computer

Hey, Computer! Wanna Play?

Fred D'Ignazio
Associate Editor

In the September column, I showed you how to develop a computer "friend" program for your child. In the October column, I described computer MAD LIBS® and "dark stories" and included a sample program that encouraged a child to invent his or her own fractured fairy tales. Now, this month, we're going to hook the friend program up to the story-game program – or to any game that will run on your computer.

The entire friend program is included in this column. This new version of the program has been modified and significantly expanded.

The new version of the friend program runs on an Atari 400 or 800 computer. It is written in Atari BASIC and takes up 7217 bytes of memory.

Teaching The Friend To Play Games

The easiest way to teach your computer friend to play games is to make the games part of the friend program.

This seems like a practical solution. You can use empty line numbers 15000 to 32767 for game subroutines. The friend can jump to the games instantly at the child's request.

For short games or for a small number of games, this solution is best. But what happens when you want the friend to play complicated, long games? What happens when you want the friend to know how to play five games, ten games, or more? Then, each time you code a game, you have to code it into the friend. And each time you get a new game, you have to code it, too, into the friend. Pretty soon, your program is no longer a friend; it is a blimp.

The solution I have chosen here is to have the friend know the names of up to 50 game programs. If they are stored on disk, the friend calls them and runs them automatically.

At the end of each disk game, you can add a line or two of code that returns control to the friend When the game is over, the friend automatically wakes up and talks to the child. The friend remembers the child's name and knows he or she has just finished playing a game.

If you have a tape drive (Atari 410 Program Recorder) instead of a disk, you can't easily automate the game-playing process – especially if the child is given the opportunity to select games at random. If each tape contains only one game, the child would have to insert a new tape for each game. If, on the other hand, each tape contained several games, the child would have to wait a long time for a tape indexing program to search through a tape for the chosen game.

Besides, you don't want to completely separate your kids from the computer. Even preschoolers can be taught the basics of operating a tape drive. After all, they need to know only three commands: CSAVE, CLOAD, and RUN. And they need to know only five buttons: REWIND, PLAY, STOP/ EJECT, and RECORD on the recorder, and RETURN on the computer. I believe it is better to teach the kids how to run the recorder and the computer, and let them load the game tapes themselves.

I do recommend one thing, though: buy ten-minute tapes (five minutes to a side) and store only two games per tape – one per side. You can keep the tapes in cases inside the kid's Buster Brown shoe box. Each tape case should have a bright, colorful label on the top. For toddlers, you might use geometric shapes instead of words as labels.

Why use such short tapes? I once asked the same question. That was before I tried to store 25 game programs on a 60-minute tape. Finding and using all the games was a nightmare, even with up-to-date pointers to the game locations. And it took forever. If you try this, your child might, at the beginning of a tape search, be on the seat waiting eagerly for a game, but he won't be at the end. He'll be gone.

Kids don't have the patience to locate and load programs stored on long-playing tapes. And neither should you. Besides, positioning the tape using the tape counter, the REWIND button, the ADVANCE button, and the STOP/EJECT button is hard! It can be a supremely frustrating experience for little kids.

So loosen your purse strings and buy a bag of short tapes. After just a few games, you and your kids will be glad you did.

One more thing. The friend program could have been more automated, even using tapes. On the Atari computer, you can save your game programs onto tape using the SAVE "C:" command. And you can run programs stored this way by typing RUN "C:". These commands can be built right into the friend program and at the tail end of all the game programs.

This method would save children from having to type CLOAD and RUN. They would just have to load a tape into the recorder, rewind the tape to the beginning, and press the PLAY button. The computer would do the rest.

On the other hand, using this method, the programs load much slower than the normal method. (Sometimes it takes them almost twice as long.)

I think speed is critical for a young child. Wherever possible, the child should not be kept waiting while the computer goes about its chores. Thus, in the friend program in this article, I chose the quicker normal method (CSAVE/CLOAD).

A Face Lift For An Old Friend

This section is for those of you who have already loaded the September version of the friend into your Atari computer. There are many changes to the old program, but there is no point in entering in the entire program a second time.

On the other hand, if you haven't loaded the old version of the friend program into your computer, that's fine. The entire program is listed at the end of this column. Just type it in.

Program Documentation (lines 10-95): REM comment lines introduce the friend and describe its major functions.

Dimension Variables (lines 100-130): Delete old line 120. Add new lines 120, 125.

Friend Master (lines 500-600): It is probably better just to retype these few lines. Almost all are changed in some way.

Pay special attention to the new line 510. This line checks to see if the friend has already been called on. If so, the friend locates the child's name in RAM and skips the normal wake-up routine.

The new line 550 calls the game-playing subroutines.

Friend Wake-Up/Talking (lines 1000-3110): This section is almost identical to the old version of the friend program. It causes the friend to wake up and gives the friend the ability to talk using DATA statements stored at the tail end of the program.

Move old line 1010 to 2012.

Move old line 2006 to 2011.

Delete old line 2005.

Add new line 2010.

New lines 2010 and 2011 turn this subroutine into a general-purpose "friend-talker." The friend can now get "talk" messages (DATA statements) at any location.

Subroutines that call the "friend-talk" subroutines point them to the right location. For example, the game subroutine points the friend to lines 12000-12999 to talk about games. The wakeup subroutine points the friend to lines 10000-10999 to give its wake-up greetings. If the friend is already awake, another subroutine points the friend to lines 11000-11999 to greet the child after a game. The tape-load subroutine points the friend to lines 13000-13999 so the friend can tell the child' how to load a game tape.

Whenever you add new messages for the friend to tell the child, just add the messages at an unoccupied set of line numbers (anywhere from 14000 on up), and remember to call the friend-talk subroutine at line 2010. But before you call the subroutine, set the individual-message pointer, N, to 1; and set the type-of-message pointer, DATNUM, to the line number where you've added new messages (e.g., DATNUM = 14000).

On line number 2033, I changed the delay loop from 800 to 200. This adjusts the amount of time a single friend message will remain on the TV screen. You can decide how long the messages should stay, based on the reading level of your child.

Friend Asks a Question (lines 3200-3620): Several lines have changed, so it's easiest to delete all old lines, from 3200-3390. Then type in all new lines, from 3200-3620. These new lines convert the subroutines into general-purpose question-askers.

Also, they add a significant improvement to the old friend program. When children type in an answer – say their name – and make a mistake typing, they can now type the DELETE key, erase the erroneous characters, and type their answer correctly.

Wake-Up Bell/Friend Voice (lines 4000-4880): These subroutines are almost identical to the old version of the friend program.

Delete old lines 4625 and 4770. These lines are fossils from a much older friend program that is now extinct.

Friend's Face (lines 5000-5550): Identical to the old version of the friend program. (So no face lift is required, after all!)

These subroutines draw the friend's face. They animate its eyes for sleeping, winking, and waking. They animate its mouth for talking.

Lines 6000 and Up: This part of the program is completely new, with one exception: the old DATA statements, lines 6000-6022. Renumber statements 6010-6022 to 10010-10022 by changing the "6's" to "10's".

Next change line 6000 to 10005.

Add new line 10000.

Remember to add new lines 10030-10032.

Friend's Games (lines 6000-7070): On lines 6000-6220 the friend asks the child to play a game. If the child wants to play, the friend displays the list of up to 50 games you have placed (at ten-line intervals) on lines 12030 to 12520.

The friend displays the name of each game and waits to see if the child wants to play the game. If not, the friend goes on to the next game. If the child doesn't like any of the games, the friend prints an "I'm sorry" message and says good-bye.

If the child does want one of the games, the friend goes to the subroutine at 6310 and stores the child's name in a secure spot in the computer's memory. Then it goes to the subroutine at 6410 to see if the child needs help loading the game tape. If the child needs help, the friend explains the steps the child must follow to load a tape. The friend goes over the instructions until the child has them all straight. Then the friend says good-bye.

After playing a game, the child reloads and runs the friend program. On line 510, the friend automatically checks to see if it has spoken to the child earlier. If so, the friend jumps to the subroutine at line 7010 and retrieves the child's name. The friend appears on the screen already awake and greets the child by name. Then it goes back to the friend master to see if the child wants to play another game (see line 550), or to do some future activity (empty lines 560-999) that you can add. later on.

Friend Messages (lines 10000-10341): The wake-up messages are on lines 10000-10032.

The friend's greeting messages after the child returns from a game are on lines 11000-11015.

The friend's list of games and its "I'm sorry" message are on lines 12000-12536.

The friend's instructions for loading a tape are on lines 13000-13041.

The messages are structured as in the old friend program. A new message begins on every tenth line number. The message begins with a DATA statement and a single number (like 1, 2, 5, or 6). The number indicates the number of screens (see SNUM on line 2012) in the current message.

Following the DATA statement with the number of screens are the DATA statements which contain the message text. Each DATA statement contains one screen of messages: from one to four message lilies, each line containing a maximum of nine characters. Each DATA statement (screen) ends with a marker – a minus one (-1). The child's name can be included in the message by placing the asterisk token (*) at the appropriate place. (For example, see lines 10022 and 12531.)

When you are building messages, a good rule of thumb is to display only one word on each line. This makes it easier for the child to read the message, and makes the screen look simpler and less cluttered. You do this by following each word with a comma. For example, the command DATA I, HOPE,YOU,-1 will cause the friend to display one screen with only one word per line.

Returning From A Fairy Tale

Last month's column included a "fractured fairy tale" program for you and your kids to try. The program ran independently of the computer friend. Now I'm going to show you how to modify the program so it can point the child back to the computer friend.

First, delete the old lines beginning with 1435. Then add the following lines:

1435 GRAPHICS 0
1436 REM ***
1437 REM *** RETURN TO FRIEND
1438 REM *** PROGRAM--ON TAPE1439 REM ***
1440 PRINT "TIME TO WAKE UP YOUR FRIEND!": PRINT
1442 PRINT "DO YOU NEED INSTRUCTIONS" ;: INPUT ANSWER$
1443 IF ANSWER$ = "N" THEN GRAPHICS O: GOTO 1530
1445 IF ANSWER$ <> "Y" THEN 1435
1446 GRAPHICS O
1450 PRINT "PUT 'FRIEND' TAPE INTO"
146O PRINT "PROGRAM RECORDER."
1465 PRINT
1470 PRINT "REWIND TAPE TO BEGINNING."
1475 PRINT
1490 PRINT "TYPE 'CLOAD' AND PRESS ."
1495 PRINT
1496 PRINT "PRESS  BUTTON"
1497 PRINT "ON THE PROGRAM RECORDER."
1498 PRINT
1499 PRINT "PRESS  AGAIN."
1500 PRINT
1505 "WHEN COMPUTER IS FINISHED"
1506 PRINT "LOADING THE 'FRIEND' TAPE,"
1508 "THE COMPUTER WILL TYPE 'READY'."
1509 PRINT
1510 PRINT "THEN YOU TYPE 'RUN'"
1515 PRINT "AND PRESS ."
152O PRINT
1530 END

The above commands help the child exit from the fairy-tale program and reload the computer friend – if the friend and the fairy tale are stored on tape.

On the other hand, if you have a disk drive, you can make all transfers to and from the friend automatic. The friend can start games automatically. And the games can automatically reload and run the friend.

To modify the friend program is simple.

First, you change line 90 to read:

90 REM *** DISK VERSION OF FRIEND

Second, you change line 6180 to read:

6180 IF M$(1,1) = "Y" THEN GOSUB 6310:GOTO 6410

Third, you delete old lines 6400-6470 and add the following new lines:

6350 RETURN
6400 REM ***  VERSION OF FRIEND
6405 REM ***
6408 REM *** SELECT GAME PROGRAM/EXIT FRIEND
6410 GOTO 641O + Z * 10
6420 RUN "D: TELLTALE"

The only game program currently referenced is "Telltale," at line 6420. Telltale is the name I have given the fairy-tale program (from last month's column) that is stored on disk.

You can have the friend automatically run up to 50 game programs by adding their full (English) names to the friend's game list on lines 12030-12520. You add each new game after an interval of ten lines (12040, 12050, 12060, etc.). The format you follow is the same as in the fairy-tale game, Telltale, listed at lines 12030 and 12031:

12030 DATA 1
12031 DATA STORY, GAME?,-1

At 12030, the Data statement tells the message-display subroutine at line 2010 that there is only one screen in this message. At 12031 is the English name of the game as it will be displayed on the screen by the computer friend. The game name is followed by a question mark since the friend is asking if the child wants to play this particular game.

Next, so the friend can actually load and run the new game, you need to add the game's program name to lines 6430 and up. You separate each program name by ten lines (6430, 6440, 6450, etc.). You follow the same format as the fairy-tale program, Telltale, on line 6420:

6420 RUN "D:TELLTALE"

Remember, you can add up to 50 game programs for the friend to automatically run.

Calling On A Friend

Now you know how the computer friend automatically loads and runs a game. But how does a game reload and run the friend?

You can learn how by changing the fairy-tale program, Telltale. First, delete old lines 1460 and 1470. Second, add the following new lines:

1480 REM ***
1490 REM *** RETURN TO FRIEND
1500 REM *** PROGRAM--ON DISK
1510 REM ***
1520 RUN "D: FRIEND"

As you can see, it's simple. The only real command you add is RUN "D : FRIEND".

By following the instructions above, you can add dozens of games to your computer friend's repertoire. The friend runs the games automatically, and the games automatically return control to the friend when your child is through playing them.

Acknowledgments And Predictions

I admit I haven't been too good about predicting where this column is going each month. Like a faced weather forecaster, I apologize for the times my predictions haven't come true.

Unlike the weather forecasters, I am going to stop making long-range forecasts. I'm going to stick to the near-term – namely, next month. Next month I plan to show you how to teach the computer friend how to remember things. After you modify the program, the friend will remember facts at itself (its name, shape, hair color, favorite jokes, etc.) and facts about the child. When the child tells the friend something important, the friend will remember.

I'd like to thank Bruce Mitchell for his valuable programming assistance. Bruce is the chief "big-person" programmer at the Small World Preschool and Kindergarten in Durham, North Carolina.

MAD LIBS® is a registered trademark of Price/Stern/Sloan, Publishers, Inc., Los Angeles, CA.

Fred D'Ignazio is a computer enthusiast and author of several books on computers for young people. He is presently working on two major projects: he is writing a series of books on how to create graphics-and-sound adventure games.

He is also working on a computer mystery-and-adventure series for young people.

As the father of two young children, Fred has become concerned with introducing the computer to children as a wonderful tool rather than as a forbidding electronic device. His column appears monthly in COMPUTE!