Education
Burning "Candle" at Both Ends
by Jack Perron and Howard ChanIf you're programming in ATARI BASIC and satisfied with its offerings, this article isn't for you. It's for those who have found ATARI Microsoft BASIC a powerful and versatile programming language. It's also for those who would like to know more about ATARI Microsoft BASIC.
In the December 1982 issue of ANTIC Magazine, there was an interesting ATARI BASIC program called "Candle, Candle, Burning Bright" by Linda M. Schreiber. It dealt with a science experiment which you might recall from school. In the experiment, a burning candle is covered by a jar to show how oxygen keeps a flame lit.
The program offered students hands-on experience with the computer, letting them control the lighting of the candle and the up-and-down movement of the jar. It was an excellent example of the potential for simulations in the science [classroom, and illustrated how easily ATARI graphics can be utilized in educational programs.
Yet it also drew our attention to some interesting differences between ATARI BASIC and ATARI Microsoft BASIC. Take for example, the UP$ and DOWN$ variables packed with machine language codes. Rather then placing the code in strings and using the ADDR command to find them in memory, Microsoft has a special command that reserves memory for code that can then be read in as data. But that's not all. There's also the MOVE command to slide Player/Missile graphics around (which means you no longer even need the UP$ and DOWN$ variables).
For those new to the ATARI Home Computer, you may find using ATARI Microsoft BASIC an exciting way to get to know the world's most versatile home computer. You don't have to know much about the computer's operating system, its memory map, or ANTIC, POKEY, and GTIA/CTIA to utilize your ATARI's fascinating graphics, sound, and color capabilities. Microsoft BASIC gives you highlevel commands for such needs.
In the listing that follows, we have taken Ms. Schreiber's ATARI BASIC program and converted it to ATARI Microsoft BASICÑburning the candle at the other end, so to speak. In doing so, we have tried to leave the overall program intact. We have replaced only the more complex housekeeping and machine language routines with Microsoft's high-level commands. These commands are for reserving memory, inserting and accessing machine language subroutines, and manipulating Player/Missile graphics.
If you refer to your December 1982 ANTIC (p. 52), you can compare the two programs on a line-byline basis. In all fairness to ATARI BASIC, you must remember that even though Microsoft offers highlevel ease and access in programming, you initially require a higher amount of RAM.
The listing that follows is fully commented. These 11 items below detail some of the major differences:
I. First, all REMARKS are offset by Microsoft's exclamation mark (! ). Microsoft also allows the use of the apostrophe (') or REM to offset remarks.
2. LINE #30. Since we will not be using UP$ or DOWN$, we do not need to dimension them. We add the FLAMD array to store the three flame patterns read in LINES #40-43.
3. LINE #80. Here we use the OPTION PLM1 command to reserve memory for Player/Missile graphics. Then VARPTR is used to point to this location and pass that information to PMBASE.
4. In the ATARI BASIC program's LINE #150, provision is made to clear the Player / Missile memory. Microsoft no longer needs this (see LINE #230).
5. LINE #160. PLOT and DRAWTO are replaced by Microsoft's PLOT . . . TO command followed in LINE #170 with FILL . . . TO replacing XIO.
6. LINE #190. Since we now have our flame patterns in an array, we no longer need to use the varying RESTORE to find the data.
7. LINE #230. We draw the jar with a zero in the first and final bytes, to allow it to clear itself as it moves.
8. LINE #260. Microsoft's RND function uses integer values, picking a random number between 1 and the integer value in the parentheses.
9. LINES #430-440. We replace the USR machine language call with the Microsoft command MOVE.
10. LINE #530. The selective reading of flame data is replaced by the FLAMD array.
11. LINES #560-590. The INT routine is no longer needed.
[CODE]
The authors both work for the ATARI Home Computer Division. Jack Perron is Educational Software Reviewerfor the ATARI Program Exchange and writes a regular column for the ATARI CONNECTION. Howard Chan is Project Manager of both ATARI BASIC and ATARI Microsoft BASIC.