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

Part I

An Atari For Christmas

Brenda Balch
Redondo Beach, CA

How to build the world's most intelligent Christmas card. This program involves several of the Atari's special features to attract young people and involve them right away in the computer they're getting as a present. This two-part article concludes in the December issue with an expanded version of the program.

An Atari 400 is on sale, and Seymour Papert's ideas on educating children are still floating in my head. A quick call to my sister confirms that she would love a computer for Christmas and would spend time with her daughters learning how to use it. Who knows? My nieces may be hidden computer geniuses, just waiting for the chance.

The thing I need now is a friendly, personalized introductory program. ("Turtle graphics" can come later.) Given the graphics and music strengths of the Atari, everyone seeing the computer on Christmas day should have a personalized picture and melody (at least as many as will fit in 16K).

Getting Started

I begin to verbalize the dialog I would like my friendly computer to have:

Merry Christmas (something graphic would be nice)

I am your friendly computer.

Will you talk to me?

(yes – I'm glad, no – You must have gotten out of the wrong side of bed this morning, none of the above – Any answer is a good sign)

My name is Atari

What is your name?

(name not found in table – – Hmmm… I don't know you. Are you sure you spelled your name right? – and go back to "what is your name",

name confusing (such as Mom) – There are too many ---'s here. Try again. – and go back to "what is your name",

name found – name, I know something about you. – goto subroutine for each person – show picture and play song (only one voice to save memory).

Check if I have talked to everyone. (Don't count the same person twice)

(no – I haven't talked to everyone yet. I hope someone else wants to talk to me. – and go back to "what is your name",

yes – It has been nice talking to everyone. Merry Christmas.).

So far, so good. Nothing seems too difficult. I'll assign line numbers to my framework:

100 – General Subroutines (subroutines run faster at the beginning)

1000 – Initialization

2000 – Greeting

2900 – Begin dialog

3000 – "What is your name"

31 × 0 – DATA for recognizing names

11000 – Subroutine for person 1

12000 – Subroutine for person 2

20000 – Subroutine for person 10

I should make it easy to add or subtract people. Someone might come for Christmas at the last minute. Two things can help this:

PEOPLE – a variable for the number of people expected (see lines 1000, 3060 and 3070) GOSUB espression instead of ON GOSUB in line 3050.

Now to add a person all I need to do is add 1 to PEOPLE (line 1000), add a data statement at 31×0 for names, and add the appropriate subroutine.

The Wonderful RESTORE Command

Is there any problem with the flow? People's names will come in any order; therefore, each subroutine must be self-contained and independent of the general order. Graphics and sound routines often use DATA statements. But DATA statements are read in order. Back to the manual! Saved. "RESTORE" takes an argument to set the start of data for the next read. Now the data in the subroutines can be used in any order. The manual says "this statement permits repetitive use of the same data," but it will solve my problem nicely anyway. (I'll find a need to re-use data later.) In fact, the "RESTORE" command makes this whole program structure possible.


Now for my first picture; something should be on the screen the first time anyone sees it. A Christmas tree with blinking lights seems appropriate. I may not have enough memory, so graphics mode 3 (or 19) will have to do. What do those tables on "COLOR," "SETCOLOR," and graphics modes mean? It takes me four or five tries to get it right. But this is how it works out.

Each color is made up of a hue and a luminance:

Color 0, Setcolor 4: provides hue and luminance (color) for the graphics area background (top of the screen).

Color 3, Setcolor 2: provides one graphics color; also the color of the text area background (bottom of the screen), and the hue of the text.

Color 2, Setcolor 1: provides one graphics color; also the luminance of the text.

Color 1, Setcolor 0: provides one graphics color.

I would like a green tree, with red or yellow blinking lights, and fixed lights of the other color. Blinking can be done by changing one color to background color and back. I would also like the text to be light on dark. Experimenting with colors, I find that both the red and green I like have dark luminances. Therefore, yellow must be "Color 2, Setcolor 1" in order to provide light text. This implies that yellow cannot blink, or the text area would blink also. Therefore, red must blink and be "Color 1, Setcolor 2" (or else the text background would blink). This leaves "Color 3, Setcolor 2" as green, and my text background is green.

What Does FILL Do Anyway?

My next step is to mark off a Christmas tree on graph paper. I add yellow and red lights. This could all be plotted using data statements of x, y coordinates and lengths, but that is a lot of data. Wasn't there a FILL command somewhere? Back to the manual.

Now I need a lot of experimenting. Although triangles draw easily, I want to understand how FILL works for future uses. My final hypothesis is that X10 18 … draws a line from the last plotted point to the cursor position, using the current plotting color. Then, starting at each point on this line, top to bottom, left to right, it fills in with the color stored in location 765. This color does not have to be the one you were plotting with. The short Program 1 shows an example. Note that XIO 18 … leaves the last plotted point in the lower right corner. Also, when no non-zero point is found on the right end, the fill starts again on the left.

Explanation Of Program 2

Line 10:

Skips subroutines and goes to initialization.

Line 200:

Subroutine PPLOT to plot a list of points preceded by a count.

Lines 700 – 720:

Subroutine CHECKI to check the input string against a table of acceptable values, and return an INDEX value for which string was found. An INDEX of zero indicates not found.

Line 960:

Subroutine LDELAY to delay long enough for a first grader to read one or two lines. (I hope.)

Lines 1000 – 1040:

Initialization. All initialization is included even though some of it is not used until PART II.

Lines 2000-2300:

Greeting and blinking Christmas tree.

Colors used are:

Setcolor x,3,4 - red

Setcolor x,13,12 - yellow

Setcolor x,12,2 - green

Setcolor x,0,0 - black

(These colors work on my TV. The yellow may be too green on a color monitor or some other TVs.)

Lines 2900-2960:

Initial dialog as outlined earlier.

Lines 3000 - 3090:

Remaining dialog and call of individual subroutines. The NAME array is used to keep track of those I've talked to and still allow them to look at their picture twice.

Lines 3110 – 3300:

Data for recognizing names, with alternate spellings (nicknames, etc.).

Lines 11000 – 20010:

Skeleton for individual subroutines. These subroutines will execute correctly and will print out the preamble. Later I will add a picture and melody for each.

Note: "Merry Christmas" in line 2010 and "Atari" in line 2950 are in inverse video.

Finally the framework works!

Part II of this article will fill in the subroutines for each person. For example, it will cover simple animation, more pictures, and music.

My thanks to the people at HW Computers in Redondo Beach for the use of their printer.