Getting To Know Your Atari


Atari BASIC Part II

John Victor

There is no question that the Atari graphics and other machine features make it superior to its predecessors as a personal computer. But these great features would be worth little if programmers could not readily take advantage of them. Atari BASIC makes the use of color graphics and the generation of sound incredibly easy.

A good example of what can be done with Atari BASIC can be found in the December issue of INTERFACE AGE. Al Baker of the Image Producers wrote a short version of the game of SIMON for the Atari 400 (using about 80 instructions). The game used color graphics and musical chords. The player attempts to duplicate a series of notes and colors made by the computer in ever increasing lengths, and his or her entries are made by pushing a joystick. All of the versions of this game that I have seen on other computers have involved some machine language kluges to make them work, but this Atari program is done entirely in BASIC. The only thing here that might give the novice programmer some difficulties is the mathematical relationships of musical notes in a chord. Otherwise, the program is a model of simplicity.

Although Atari BASIC is not Microsoft BASIC, it is pretty much like the BASICs found on Apple, PET, and the TRS-80. The BASIC interpreter resides in a 10K ROM cartridge that plugs into a slot in the front of the Atari 400 or 800. (Both computers use the same BASIC.) Its floating point software computes to 9 place accuracy, it supports multiple statement lines, and it contains the usual compliment of library routines. Its execution speed appears to be a bit slower than Applesoft's, but it seems to be better than TRS-80 Level II. If the BASIC has any deficiencies, it is in the area of string handling logic. It does not support string arrays.

In some ways the BASIC resembles Apple's integer BASIC. This is particularly noticeable to Apple programmers when the computers enters the graphics modes and finds an area at the bottom of the screen with 4 lines of text. Atari BASIC also allows the programmer to use variables in GOTO and GOSUB statements (GOTO A). In addition, the variables can be words, (GOSUB ERRORROUTINE, GOTO CHOICE, etc.), where CHOICE, for example, has a line number as a value.

There is one incredible innovation here that makes Atari BASIC unique. ANY WORD CAN BE USED AS A VARIABLE - EVEN SO-CALLED 'FORBIDDEN' WORDS! The programmer could use the word END or LIST as a variable. This is definitely not allowed in any other version of BASIC. LIST can also be used as a program statement to make the listing of the resident program print out during the running of the program.

Here are some examples of the use of words as variables in Atari BASIC. Note that if a program command is going to be used as a variable, the word LET must precede it when setting its value.

10 LET LISTING = 1000:
LET ERRORCOUNT = 2000:
LET CHOICE = 3000
..
..
120 IF ANSWER$ = CORRECT$ THEN RETURN
130 GOTO CHOICE
..
..

Variable graphics modes can be entered by giving the graphics instruction along with a number. Most of these will have an area at the bottom of the screen for four lines of text. The programmer can eliminate this area by adding 16 to the number of the graphics mode. For example, GRAPHICS 3 has four lines of text, but GRAPHICS 3 + 16 does not. The graphics instruction will clear the screen. This can also be deactivated by adding 32 to the graphics mode number (i.e. GRAPHICS 35 enters GRAPHICS 3 without clearing the screen.)

The following is a brief description of some of the GRAPHICS modes.

Graphics 0

This is the regular text mode for BASIC. The user gets 24 lines of 40 characters, where the characters can be upper or lower case, regular or reversed. In addition, the user can access, by pressing the CONTROL key, a set of pseudo graphics from the keyboard. These special characters can be used to draw pictures (very much like the special characters found on the PET).

The user has the ability to change the background color using the SETCOLOR instruction, The user can change the color designated by color register 2 (which controls background color) with the following instruction: SETCOLOR 2,4,14. The screen will turn light pink, since color register 2 contains the number 4 for red and the number 14 for the luminescence (0 for darkest to 14 for lightest).

In GRAPHICS 0 the user cannot mix the color of the type, which can only be a darker or lighter version of the background color. By setting color register 1 with a luminescence of 0, we get a dark type against a light background. SETCOLOR 1,0,14 plus SETCOLOR 2,0,0 will produce a dark grey background with light characters. Using the luminescences, the user has a choice of about 120 different shades of colors.

Graphics 1 And Graphics 2

There are the "large type" modes, with GRAPHICS 2 producing the largest type. In this mode the characters can be put on the screen in a variety of ways - they can be PLOTed on like graphics, or PRINTed on. Different color characters can be made by defining the characters as upper case, lower case, or reversed characters. When the type appears on the screen, it appears as all capitals, but the color of the characters is different. A word printed as lower case may appear on the screen as upper case red characters, while a word printed as reverse capitals may be blue. For example, PRINT #6; "BLUE green" produces 2 "all-capital" words in two different colors.

Graphics 3 To Graphics 11

These are the real graphics modes where the computer PLOTs points at a given screen location. GRAPHICS 3 has the largest points, and the size goes down as the mode number increases. GRAPHICS 11 is a high resolution mode. The color of the points is taken from the color register indicated by the user. COLOR 3 tells the computer to make the point the same color as specified in color register 3.

To make plotting easier, the graphics modes use a DRAWTO instruction which will automatically plot a line from any given point to any other point on the screen, even if the line is a diagonal. There is also a technique to fill in a predetermined area of the screen to make a square of a specific color.

Sound

The user has a choice of four sound generators which can be used to produce sounds or musical tones. The sound generators can also he used simultaneously to make chords. Once turned on, each sound generator stays on until the program reaches and END statement or the program shuts it off. SOUND 0, 121, 10, 8 plays middle C on sound register 0.

Control Characters

Screen and cursor control functions can be put in a BASIC program in PRINT statements as control characters. lf the user wants to clear the screen he or she can press the Clear Screen key. This can also be done in the program by making a PRINT statement and then pressing the ESCAPE key. When the user hits the Clear Screen key, a special control character is printed. When the program is run and the PRINT statement is executed, the screen will be cleared. The statement will appear like this: PRINT "crooked arrow".

Editing And Error Messages

The screen editor on the Atari is the best I've seen. On the Apple, for example, the user cannot move type around the editor field, but on the Atari this can be done with simple keyboard inputs. The user does not need to worry about hidden errors, or relisting since all changes are immediately visible. If the user is making a line too long, a bell rings a warning (just as it does on a typewriter).

If a syntax error is made while entering or editing a line, the BASIC interpreter gives an immediate error message at the carriage return. This saves quite a hit of debugging time when entering a program. Unfortunately, for errors encountered during a program run, the user gets a numbered error message that must be checked in the manual. There are several of these messages, so they are not going to be easily memorized.

Computer I/O

In order to get FCC approval for the computer (so it could be plugged into a regular TV set) Atari had to get approval for all of its peripheral devices at the same time. So the computer and its peripherals were designed as one package. This is reflected in the ease of access to peripherals from the BASIC. There are specific instructions to access disk, joysticks, printers and the cassette machine directly from BASIC. In addition to these, the user can define peripherals using an OPEN instruction. For example: OPEN #2, 8, 0, "C:" opens the cassette machine for special operations. The cassette player is now specified by #2. PUT #2, A outputs the value of A to the cassette player. The user can use INPUT, PRINT, GET, PUT, etc. as I/O instructions to peripherals.

BASIC can also treat the video screen and the keyboard as I/O devices for certain kinds of operations.

Atari BASIC, like any other version of BASIC, suffers from some deficiencies when considering it for some special application. However, in the area of graphics and manipulation of text displays, this version of BASIC is, in my opinion, hands down superior to Apple, PET or TRS-80 BASIC. Its functions are complex, but the user will find the BASIC relatively easy to use compared to some other forms of BASIC.


Return to Table of Contents | Previous Section | Next Section