ANTIC VOL. 2, NO. 8 / NOVEMBER 1983 / PAGE 28
When you run SOUNDEMO, the first thing youíll see is a menu of sound effects; make your choice by typing the appropriate letter. Donít press [RETURN]; it isnít necessary. Depending on which one youíve chosen, either the sound will start up immediately or youíll be prompted to press the joystick button (the program requires that you have a joystick plugged into Port 1). Some of the selections return to the menu automatically; to terminate the others youíll need to press [START] (any necessary instructions will be displayed on the screen ).
Those of you new to computing will be interested in some of the programming techniques used in the listing. In line 20, the string "Press START to Quit" is a prompt invoked in several places. In line 220, for example, if a PEEK at location 53279 does not revea1 the value of six, the sound generated by line 200 simply continues. Location 53279 monitors the [START] button, and the value of six there means [START] has been pressed, which allows the program to proceed beyond line 220.
Line 40 "opens" the keyboard as an input device. The program expects a GET, as in line 70, and when a key is pressed the computer gets the ATASCII value of the key. These values are listed in your Atari BASIC Reference Manual, but you will find that the values for "a," "b," "c," etc., are sequential from 65. That is why, in line 70, Q is defined as Q-64. Subtract 64 from 6.5 and you get one, while 64 from 66 yields two, etc. In this way, Q becomes a series of integers beginning with one. Then, in line 85, there is a GOTO Q * 100. This multiplication identifies the group of lines that makes the various sounds.
Looking again at line 40, note the TRAP 2000, then look it line 2000. These simply catch any inappropriate key press (one that doesnít produce a value for which there is a sound) and return the program to the menu.
For really high quality sound, connect your computer to your stereo with the "Ultra Sound" cable featured in the February 1983 issue of ANTIC. If you havenít already built one, donít drive yourself crazy looking for PVC cable ñ just cut off one end of a standard stereo jumper cable (the kind with an RCA phono plug on each end), and solder the DIN plug on. I did and it works fine.
With or without the cable, one thing is certain: the more you use SOUNDEMO, the more youíll become convinced that buying an ATARI was a "sound" investment.
10 REM +++++++++ SOUND DEMO +++++++++
20 DIM S$(20):S$="PRESS START TO QUIT"
30 DIM TRIG$(20):TRIG$="PRESS JOYSTK BUTTON"
40 OPEN #1,4,0,"K:" :COL=5:TRAP 2000
50 SOUND 0,0,0,0:SOUND 1,0,0,0:GRAPHICS 1+16:SETCOLOR 0,COL,2:?
#6;"CHOOSE 0NE:":? #6:? #6;"A.BLASTñOFF"
60 ? #6;"B.ENGINE ROOM":? #6;"C.SPACE
MACHINE GUN":? #6;"D.DIESEL HORN":? #6;"E.LASER
GUN"
65 ? #6;"F.BOMBS AWAY!":? #6;"G.RACE
CAR":? #6;"H.CANNON":? #6;"I.THINKING
COMPUTER":? #6;"J."
68 ? #6;"K.":? #6;"L.END"
70 ? #6:? #6;"ENTER SELECTION(A,B,C,ETC.)";:GET #1,Q:Q=Qñ64:COL=Q*2
80 GRAPHICS 1+16:IF Q>2 AND Q<6 OR Q=8 THEN ? #6:? #6;TRIG$:?
#6:? #6;S$
85 GOTO Q*100
90 STOP
100 FOR L=60 TO 1 STEP ñ1
110 SOUND 1,L,0,10
115 FOR L2=1 TO 100:NEXT L2
120 NEXT L
130 GOTO 50
200 SOUND 8,40,4,10
210 ? #6:? #6;S$
220 IF PEEK(53279)<>6 THEN 220
230 GOTO 50
300 LOUD=0:REM machine gun
310 SOUND 0,255,2,LOUD
320 IF STRIG(0)=0 THEN LOUD=14:GOTO 340
330 LOUD=0
340 IF PEEK(53279)=6 THEN 50
350 GOTO 310
400 LOUD=0:REM diesel horn
410 SOUND 0,25,12,LOUD:SOUND 1,27,12,LOUD
420 IF STRIG(0)=0 THEN LOUD=15:GOTO 440
430 LOUD=0
440 IF PEEK(53279)=6 GOTO 50
450 GOTO 410
500 DIS=10
510 IF STRIG(0)<>0 THEN 560
520 FOR L=0 TO 75
530 SOUND S,L,DIS,10
540 NEXT L
550 SOUND 0,0,0,0
560 IF PEEK(53279)<>6 GOTO 510
570 GOTO 50
600 FOR X=10 TO 0 STEP -1
630 SOUND 0,X,10,8
640 SOUND 1,X+1,10,8
650 FOR W-1 TO 50:NEXT W
655 NEXT X
659 POSITION 7,10:PRINT #6"BOOM!í
663 FOR L=10 TO 0 STEP -1
665 SOUND 0,250,1,L
666 SOUND 1,100,8,L
667 SOUND 2,25,3,L
670 FOR Y=1 TO 200 NEXT Y
690 GOTO 50
700 ? #6:? #6;S$
710 SOUND 0,40,12,10
720 IF PEEK (532796)<>6 THEN 720
730 GOTO 50
800 DIS=4:GOTO 510
900 FOR L=255 TO 1 STEP -1
920 SOUND 0,L,10,3
930 SOUND 1,INT(RND(0)*255),10,8
950 NEXT L
960 SOUND 1,1,10,8
970 FOR L=1 TO 50:NEXTL
980 GOTO 50
1200 END
2000 TRAP 2000:GOTO 50
Listing:SNDDEMO.BAS Download