Gotoflamelocation: Drawflame image: Go to stirrer location: Draw stirrer image: Loop back
The stand alone flickering flame routine consistent with the previous loop will have to be in the form:-
Go to flame location: Draw a flame image: Loop back
The delay is deliberately introduced so that the routine can be tested independent of the stiner and drop routines to be added later. Those routines will later replace the delay, but it is needed now so that we can be sure that the independent routine will be easily integrated with the others. Now we cannot draw the same image of a flame each time through the loop or it will not flicker. We could blank out the flame image on alternate passes to make it flicker, but the result would be rather dull. The CHEMUTIL-2 method is to overprint nine different flame images rapidly. The loop will not be of the form:-
Go to flame location: Draw flame ( 1): Delay: Go to flame location: Draw flame (2): Delay: etc.
After nine flame images have been drawn, the loop starts over again.ยท
Finally; we do not want the loops to be endless. There must be some way to turn off the flame. It could be done by stopping the execution of the code after a predetermined number of times through the loop. More generally useful is to us a keystroke to terminate it. The advantage of that is that the code now allows easy introduction of alternatives depending upon which key is struck. For example, striking the S-key could stop the animation and tum off the flame, while striking the C-key could leave the flame on but start the stirrer, too. The point is not that we intend to use the C-key in that way, but that we allow for that possibility before starting to write code. In a complex animation it is not easy to add additional features after coding without undesirable effects appearing.
A BASIC program to show a flickering flame can now be written. The following one is for Apple II+, He or lie microcomputers and will show the flame on the text screen.
10 Home
20 For I = 97 to 105
30 VTAB 10 : HTAB 10
40 PRINT CHR$(1)
50 X Peek(-16384):POKE(-16368),0: IF X=211
THEN I= 105:GOTO 80
60 NEXTI
70 GOT020
80 VTAB 10: HTAB 10:
PRINTCCCC
90 VTAB 20 : END
The flame image is made up of successive images from ASCII(33) through ASCII(41). Line 50 stops the illusion when the S-keyis struck and Line 80 extinguishes the flame. lf CHEMUTIL-2 is available, BLOAD it and replace line 10 by CALL 25042:PRINT "&". The routine will show a true flame on the graphics
screen.
BASIC is not the best language for this routine. A satisfactory illusion is obtained here only because the routine has no other tasks. The only delays are the usual ones as the computer reads and interprets each line. If even a small. delay loop is added -to simulate an additional task, the illusion is lost. For example, add the line:-
55 FOR K = 1 to 30 :
NEXT K
Upon execution, the routine shows each character clearly and is unacceptable. Yet this delay is too short to allow the introduction of the stirrer and falling drop loops. We must resort to 6502 machine language code.
The source code shown was generated using the Toolkit Assembler (2) and used CHEMUTIL-2 to print the flame images contained in character set 2. To see this program in action you will need to enter the monitor (CALL-151) and enter the program directly. e.g. 7C10: A9 OB 8D 00 7C A9 09 etc. Exit the monitor and BSAVE FLAME, A$7COO, L$8E then, with CHEMUTIL-2 in place, run the following BASIC program.
10 CALL 25042 : CALL 31760 :END
In the next part of this series, I will discuss and show a listing of a routine which shows a rotating stirrer bar suitable for combining with this flame sequence. Subsequent parts of this series will all require CHEMUTIL-2 for the successful execution of the code.
(1) Bendall, V. "CHEMUTIL-2, A chemistry Programming Utility"; Project SERAPHIM, NSFScience Education; Department of Chemistry, Eastern Michigan University, Ypsilanti, MI 48197, 1985.
(2) '"Applesoft Tool Kit"; Apple Computer, Inc., 20525 Mariani Avenue, Cupertino, CA 95014.