Zappo Use this program by E French of Lancaster to get super sounds for your games. Anyone who has tried to write their own games on the Spectrum will have found the BEEP command very limiting and many people have bought add-ons to raise the Spectrum's sound to that of the BBC micro in versatility as well as volume/ However, for most people £20-£30 is a high price for such a simple task. Fortunately, there is a compromise solution which uses software rather than hardware to achieve special effect sounds such as explosions at negligible cost. There is, of course, the inevitable snag. Unlike the better add-ons, execution of the program stops while the sound is being generated. However, the program does contain three pre-defined sounds: 1) A Zap 2) A Machine gun shot 3) An Explosion. As it stands the program occupies ¼ KByte which is normally reserved for the printer so as to conserve memory. The program is in six parts: the first contains two sub- routines which can produce white norse (for gunshots and explosions) or tones (for sirens and zaps). The second, third and fourth parts produce the pre-defined sounds. The two remaining routines play the user-defined sounds: the first with white noise (a kind of rushing sound) and the other with tones. User defined sounds The BEEP command produces a neat regular waveform reminis- cent of an electric organ which is not very useful to the games programmer. Special effect sounds are not so simple and require more information in order to be produced. With a BEEP command it is necessary to provide only two figures or parameters: the first indicates how long you want the sound to last for and the second indicates the pitch of the resultant sound. A special effect sound can best be thought of as a succession of BEEPs one after another: ___ ___ ___ ___ The BEEP | | | | | | | | command ___| |___| |___| |___| |___ _ __ ____ _____ _ A special | | | | | | | | | | effect sound _| |_| |___| |____| |__| |_ However, special effect sounds cannot be produced by the BASIC BEEP command because the interval between individual BEEPs is too great. This, thankfully, is not an insurmountable problem, be- cause by using machine code routines the delay between BEEPs becomes negligible. If sounds such as explosions are to be produced, succes- sive BEEPs will not suffice. Such sounds are produced with white noise which on its own gives a rushing noise. Now to the practicalities: THERE IS NO NEED FOR THE USER TO KNOW ANYTHING ABOUT MACHINE CODE. All that is required is to follow these instructions: 1. Type in listing one [or LOAD "Zappo" from the TZX]. 2. RUN it. 3. Type SAVE "Sounds"CODE 23296,256 & enter. 4. Rewind the tape and VERIFY ""CODE & enter. 5. If you get the message "Tape loading error" then go to stage 3 [or get a reliable emulator...]. 6. The BASIC program has now done its job and it is safe to NEW. To recover the machine code routine use: LOAD ""CODE. If you have an assembler you should type in listing 2, assemble it and SAVE the code. The next thing you will want to do is to listen to your new sounds. To do this simply enter the followingL 10 PAUSE 0: REM waits for keypress 20 LET (an unused variable)=USR 23375: REM make a ZAP 30 GO TO 10: REM do it again When this is RUN it turns your Spectrum into a ray gun. By changing line 20 to 20 LET (an unused variable)=USR 23386 Now your Spectrum is a machine gun. And making line 20 read: 20 LET (an unused variable)=USR 23398 Now whenever you press a key your Spectrum happily explodes! So to sum up: LET (an unused variable)=USR 23375 produces a Zap. LET (an unused variable)=USR 23386 produces a machine gun shot. LET (an unused variable)=USR 23375 produces an explosion. [ Similar routines, as well as a demonstration of the user- defined sounds described below, are in "Demo" on the TZX. ] The more skilfull will want more than just these three and impressive sounds can be custom made. However, take great care: if you go wrong on this section you might have to wait several days before your machine has finished your sound. So, to produce your own effects you must tell the com- puter the length and pitch of the eight beeps which make up the sound you want to produce. You must also tell it how many times to play each beep. Thus, for each beep there are three parameters: length, pitch and the number of times you want each beep to be produced. So in total there are 24 parameters. The procedure to tell these to the computer is: 10 DATA (length of 1st),(pitch of 1st),(No. of times), (length of 2nd),(pitch of 2nd),(No. of times), ... up to ... (length of 8th),(pitch of 8th),(No. of times) 20 FOR a=23300 TO 23323: READ d: POKE a,d: NEXT a The length of each beep is a number from 1 to 255 and the longest note is 0 [=256]. The pitch of each beep is a number from 1 to 255 where 1 is the hightest pitch (but 0 is the lowest). Similarly, the multiplier (how many times) goes from 1 to 255 (again 0 gives 256 cycles). This program as it stands resides in the printer buffer which for most people is unused. However, if you enter any of the printer commands: LLIST, LPRINT or COPY then the sound will generate a delay followed by NEW, so take care. Once you have provided the machine with the data you will need to know how to play the sounds. For this there are two commands: LET (an unused variable)=USR 23410 this will play your sound with tones LET (an unused variable)=USR 23432 this will play your sound with white noise. [ These are the wrong way around. The first call produces white noise, the second tones. ] Another slight snag encountered with this routine is that when the sounds are produced the border goes white. If you use an assembler to write in this program you can change it to suit your needs. Hints If is a wise idea to make the sounds last for as short as possible because it is then less obvious that the program stops to produce the sound. Also, the volume of the sounds is increased by resting the machine on a hard flat surface such as a desk or table.