Classic Computer Magazine Archive A.N.A.L.O.G. ISSUE 66 / NOVEMBER 1988 / PAGE 54

BITS 'N'
PIECES:
POPS

by Lee S. Brilliant

In the never-ending battle between AMIGA and ST partisans we hear rhetoric like:
    "Well, I've got 4,000 colors to choose from!"
    "Yeah, but how many can you put up at the same time?"
    "But I've got a blitter chip!"
    "So what, I will have one soon too (haha!). Besides, my faster clock speed makes it unnecessary!"
    "Okay. Top this: I've got stereo sound!"
    Uh-oh. How do you respond to that one? You could mention the MIDI interface, but try this retort instead: "Atari gave up that one with the 8-bit machines because no one ever used the feature!"
    "Say what? The old-fashioned, outdated, inferior, 8-bit Atari computers had four-channel stereo sound?"
    "Yes! In fact, they had three-channel sound!"
    "So, how come I never heard about it?"
    "Because until this article, no one ever knew about it!"
    So now you know the subject we will cover this month. Along the way we will rehash some old material about POKEY, cover some new stuff and build the Poly Phonic Sound (POPS) device. So let's rehash!

POKEY revisited
    In the last three installments of "Bits 'n' Pieces," we spent a long time discussing how POKEY performs serial output. Simply stated, POKEY contains a serial input and a serial output shift register whose baud rate is controlled by the sound frequency counters. This is similar in concept to a USART (Universal Synchronous/Asynchronous Receiver/Transmitter). Such devices form the heart of all serial I/O and modem devices. Certain aspects of the POKEY control registers were only glossed over before, and so now is the time to go into slightly greater detail. Let's look at POKEY register number 15 or SKSTAT/SKCTL ($D20F,53775). (See Figure 1.)
    You see that bits 4, 5 and 6 control the USART parameters, determining what input and output modes will be used in various combinations of synchronous/ asynchronous I/O. It is not a very straightforward proposition here, but I will try to simplify it. The key to understanding is to look to the clock lines on the serial bus. There are two: Clock Out (Pin 2) and Clock In (Pin 1).
    Clock Out is relatively straightforward; whatever frequency is driving the Data-Out shift register is also present on the ClockOut line. But the Clock-In line is bidirectional and may accept an external clock signal or act like Clock Out and transmit a POKEY generated clock signal. This allows the input shift register or the output shift register to either accept an outside clock signal or use an internal clock.
    Bits 4, 5 and 6 control the sources of clock pulses for both the In and Out shift registers and the directionality of the bidirectional clock, according to Figure 2. Since POKEY is the internal clock source, the frequencies generated by its dividers also appear on the clock lines.
    Atari chose to use only asynchronous communication and clock the shift registers internally. The OS ignores any external clocks and does not support synchronous I/O even though the hardware can. You can actually disconnect the clock lines in your serial cable and still use your 1050 diskdrive and printer. I cannot say whether all peripherals will work this way but these two will. See the diagrams in Figure 3 for examples of how POKEY can be configured for synchronous or asynchronous communications.


BIT FUNCTION
7    Forces Serial output to 0
6*   Serial port parameter selections
5*      "     "      "         "

4*      "     "      "         "
3    Changes serial out from 1/0 logic to two-tone
2    Changes from normal to fast POT scan
1    Activates keyboard scanning
0    Enables keyboard debounce circuits

 FIGURE 1: SKCTL

    The important thing to learn from Figure 2 is that when only bit 6 is set, POKEY Channel 4 will appear on the Clock-Out line. Here is the potential for four-voice sound in "stereo." Place an amplifier on the Clock-Out line and "play" one voice through the serial port and the others through the TV in "stereo." Moreover, you can have trinaural sound by playing Channels 2 and 4 on separate clock lines through separate amplifiers while playing 1 and 3 together on the regular audio output line via the TV (or the audio output at the 5-pin plug). You need only set bits 5 and 6 of SKCTL. This should make AMIGA fans stand up and take notice. The following information will allow you to produce twoor three-channel sound from your Atari.

  BIT    BIDIRECT SERIN   SEROUT
          CLOCK   CLOCK   CLOCK

6  5  4   IN/OUT  SOURCE  SOURCE*    FUNCTION
----------------------------------------------------------
0  0  0     IN      EXT    EXT      XMIT & RECV RATES SET

                                     BY EXTERNAL SOURCE
                                     AT CLOCK IN
----------------------------------------------------------
0  0  1     IN      CH 4   EXT      XMIT CLOCKED BY EXT,
                                     RECV BY CH4.

                                     ASYNC RECV, SYNC XMIT
----------------------------------------------------------
0  1  0     CH4     CH4    CH4      XMIT & RECV SET BY

            OUT                      CH4. CH4 ON CLOCK IN
----------------------------------------------------------

0  1  1     IN      CH4    CH4      XMIT & RECV SET BY
                                     CH4. **
----------------------------------------------------------

1  0  0     IN      EXT    CH4      XMIT SET BY CH4
                                     RECV BY EXT CLOCK
----------------------------------------------------------

1  0  1     IN      CH4    CH4      XMIT & RECV SET BY
                                     CH4. **
----------------------------------------------------------

1  1  0     CH4     CH4    CH2      RECV SET BY CH4. XMIT
            OUT                      SET BY CH2. CH4 OUT
                                     ON CLOCK IN. ***

----------------------------------------------------------
1  1  1     IN      CH4    CH2      RECV SET BY CH4. XMIT
                                     SET BY CH2. ***
----------------------------------------------------------

NOTES:

EXT MEANS AN EXTERNAL CLOCK CONTROLS THESE SHIFT REGISTERS
AND SETS THEIR BAUD RATES.

16-BIT RESOLUTION CAN BE USED FOR FINE TUNING.
* SAME SIGNAL ALWAYS APPEARS ON CLOCK OUT LINE.
** LABLED AS NOT USEFUL BY HARDWARE MANUAL.

*** TWO-TONE MODE CANNOT BE USED BECAUSE CHANNELS 1 & 2 ARE
USED TO MAKE AUDIO TONES AND WILL CONFLICT.


FIGURE 2: POKEY USART Parameters


Figure 3



The POPS device
    The Poly Phonic Sound (POPS) adapter is really nothing more than three sets of resistors to reduce, balance and control volume for the three audio amplifiers; the rest is done with programming. The two serial port amplifiers incorporate electronic volume controls that are regulated through the joystick ports (PORTA) similar to the POKEY control registers.
    Remember that these sound channels played on the clock lines are logic level signals or five volts. This level of audio will blow away most amps so you need the resistors to drop the voltage to a more reasonable 0.5 volts. The 4066 IC is a bank of electronic switches each of which is connected to a resistor, thus the higher the binary code applied, the more resistors are switched in and the more signal passes through. The desired volume value is placed in PORTA, which is configured for output through the joysticks and controls the volume of POPS left and center channels. Right channel volume and distortion are controlled as usual through AUDC registers.
    I have demonstrated this system to users' groups and it really turns heads, even among people as jaded as Atari users. Electronic volume control allows fade-outs from all voices and can give rise to some interesting spatial sound effects. Listings 3 and 4 give simple demonstrations of the abilities of POPS. I have included a schematic and circuit board for POPS: note part values, size and polarity of capacitors and IC orientation.
    Power is obtained from a nine-volt DC. 500-milliamp wall supply like the one used by Atari video games. They are available in abundance. You may even have one of these at home! Be sure to note the polarity of the power plug: + at the tip and - at the sleeve. POPS is compatible with all 8-bit Atari computers, but the 400 does not have an audio output line, so you can only play the right channel through your TV. Each channel of the amplifier puts out about half a watt, not enough to shatter glass but enough to get your wife upset! If you need more power you can get larger amplifiers and power supplies from Radio Shack.

Schematic
    To produce stereo sound you must do the following things:
    1) Plug POPS into the serial bus and the audio output, and then connect the amplifiers to three speakers and turn on the power. The right channel will come out the "normal" audio line so you can use your TV for one of the amplifiers on a 400.
    2) Set AUDCTL for the proper values for the kind of sound you want to produce (ie., 16-bit or different master clock). Try 0 for starters (standard setting).
    3) Set the bits of SCKTL; 67 (3+[bit 6]64) for two-channel. Without the +3, the keyboard won't work, and you will need RESET to recover from POKE 53775 64.
    4) Set your AUDC and AUDF values for volume and distortion on all audio channels. Keep in mind that the signals on the clock lines are taken off before the control circuits, so the audio control registers have no effect. You cannot control the noise content of the audio, but for most music this is just fine. The actual value poked into AUDC2/4 is not important, except you want the volume component to be 0, so you won't hear these channels play on the audio line or TV: A 0 works great. You control volume by poking the volume level (0-15) into PORTA. Remember that the value to POKE into 54016 is the left volume +16*center value. The channels which come out the normal audio line do use the AUDC registers and can be used with noises for percussion sounds or special effects. You cannot use the BASIC SOUND statement because it resets the special values POKEd into AUDCTL. Build your POPS, connect it and try this simple program:

1 REM PLAYS 2 POKEY CHANNELS IN STER
EO THROUGH THE AUDIO CHANNEL (OR TV)
AND SERIAL PORT PIN 2.
2 P=PEEK(54018):POKE 54018,P-4:POKE
54016,255:POKE 54018,P:REM INIT POR
TA
5 DELAY=100:POKE 53761,174: POKE 53
767,0:REM INITIALIZE AUDC1&4
10 POKE 53768,0:POKE 53775,67:REM I
NITIALIZE AUDCTL AND SKCTL FOR STER
EO
20 POKE 53760,60:REM PLAY A NOTE ON
 R CHANNEL
25 GOSUB DELAY:POKE 53760,0:REM TUR
N OFF
30 POKE 53766,91:PLAY A NOTE ON L C
HANNEL
35 GOSUB DELAY:POKE 53766,0
40 POKE 53760,72:POKE 53766,121:REM
 STEREO!
50 GOSUB DELAY:GOSUB DELAY:END
100 FOR S=1 TO 300:NEXT S:RETURN

    When you POKE SKCTL with 67, you get Voice 4 from the left channel and 1, 2 and 3 from the right. You can combine values for 16-bit resolution with half on right and three-quarters on left. If you follow the same steps for two-channel sound, except you POKE SKCTL with 99 ([Bits 5+6=96]+3), you will get three-channel sound. Now Voice 2 will play through the left channel, Voice 4 through the center channel and Voices 1 and 3 on the right channel. You can combine 3 and 4 to good advantage here. Figure 4 is a block diagram of POKEY configuration with both two- and three-channel modes.

Figure 4

Putting it all together
    To use the POPS device you need a good player program. I will make no bones about it, my programs are only modifications to Enhanced POKEY Player. I chose to modify this program because the player is in BASIC and machine language; so I could easily disassemble it and modify it. (Why reinvent the wheel?) Enhanced POKEY Player has been around a long time and was obtainable in the past from the ANTIC catalog (AP 0147), but has not been listed lately. You may have to ask for it specially. The following programs are published with the author's permission.
    After you obtain your Enhanced POKEY Player, make a duplicate to work from and put the original away. Never use the original disk with POPS! You will also need a separate work disk. Listing 1 is the main program and consists of a BASIC routine to load the music files and display titles. Then there is the Player itself, which is contained in a large string array, PP$, and some fixed locations in page 6. One section of the player string is essentially blank which allows us to insert our different routines for mono, stereo or trinaural sound generation (CH1$, CH2 and CH3$).
    Listing 2 creates these complex strings. Type in and save both Listings 1 and 2 on the separate work disk, and then run Listing 2 and save as LIST "D:TEMP," 2000,2300. Load back Listing 1 and ENTER "D:TEMP." Now resave to your working POKEY Player disk as "D:PLAY ER:" This new program replaces the original Player and will list all available music files and flag them as three-channel (*), two-channel (+) or one-channel. Music files on the original POKEY Player disk are all labeled *.V, but this new program requires files with extenders V1C, .V2C, or V3C to denote one-, two- or threechannel music files. You will need to work through DOS to change the extenders according to Table 1. The player is now able to tell which mode to use and automatically adjust itself according to the filename extenders.

FSONA   .V2C  MINUET2 .V2C  SLP3    .V3C
ANVIL   .VlC  GLAD    .V2C  MUSETTE .V2C
SLP4    .V3C  BC5     .V2C  GMARCH  .V2C
NELLIE  .V1C  SLPS    .V3C  BLUES   .V2C
GOLDV1  .V2C  PRELUDE .V3C  SLP6    .V2C
BMINOR  .V3C  GOTHOS  .V3C  PRESTO  .V2C
SOLDIER .V3C  CALLIOPE.V2C  GSONA   .V2C
RIGAUDON.V3C  SWISS   .V3C  CANTATA .V3C
HBDAY   .V2C  SABRE   .V2C  THEMEVAR.V3C
CAPRICIO.V3C  HOLST   .V1C  SCAR    .V3C
TPIAM   .V2C  CLAV    .V3C  HUMORESK.V3C
SCHERZAD.V3C  TPIBF   .V2C  COURANTE.V2C
ITALIAN .V2C  SCIPIO  .V3C  TPIF    .V2C
CSONATA .V3C  LITTLE  .V3C  SLP1    .V3C
WILLTELL.V3C  DMARCH  .V2C  LONDON  .V3C
SLP2    .V3C  WSOLDIER.V2C  FEAST   .V3C
MINUET1 .V1C


TABLE 1: Extender List


Notes about Enhanced
POKEY Player
    Writing music with the POKEY Player editor requires a couple of notes. POKEY Player has only three voices, naturally labeled 1, 2 and 3. POKEY Player Voice 1 uses POKEY chip's Voice 1 and will be the right channel in POPS. POKEY Player Voice 2 similarly is POKEY Voice 2 and is the left channel in three-channel mode, but in stereo it will come out the right channel along with Voice 1. POKEY Player Voice 3 is POKEY Voices 3 and 4 combined in 16-bit fashion and comes out from the center channel in three-channel mode and the left side in stereo.
    Only voices from the right channel use the distortion abilities of POKEY, so you can always use Voice 1 for percussion or special effects, but in stereo you can also use Voice 2. Voice 3 (3/4) usually carries the melody line because it has the widest range of note values and can also be used for really deep bass lines. Not all features of the POKEY Player editor can be used by POPS, and for some reason some three-voice music will not play properly on POPS' three-channel mode, but will do okay in stereo. Some two-voice programs can only be played in mono. The list of files on Enhanced POKEY Player are in Table 1 with their proper extenders.

schematics


Parts list
    The 13-pin Atari Serial Plug (#83-360) is available from MCM Electronics, 2582 East River Road, Moraine, Ohio 45439; (800) 858-4330. The resistors, volume controls, capacitors, joystick cables and amplifiers are available at Radio Shack. Not all resistor values are available at Radio Shack, however. You may need to combine resistors such as 220K plus 470K to approximate 800K. Actual values are completely non-critical. The RCA phono jacks, speakers and cables are also available at Radio Shack. The 4066 ICs may be ordered specially through Radio Shack. Ask them to special order SK4066B. Finally, the power supply is Radio Shack's # 273-1455.

 


Listing 1:
BASIC


SI 10 REM POKEY PLAYER BY CRAIG CHAMBERLA
   IN.  MODIFIED BY LEE BRILLIANT M.D.
MF 30 GOSUB 1000
FX 100 IF PEEK(764)<>255 THEN POKE 764,25
   5:POKE 1536,0
KL 110 IF PEEK(1536)=1 THEN 100
IV 120 U=USR(PP+156):GOSUB 1090:GOTO 100
NS 1000 GOSUB 2000:POKE 675,0:POKE 676,1:
   POKE 677,0:POKE 678,8:POKE 679,0:POKE
   65,0
HQ 1010 RESTORE 2300:FOR N=1606 TO 1648:R
   EAD D:POKE N,D:NEXT N:REM NON-RELOCATB
   LE CODE
CW 1020 POKE 752,1:TRAP 1900:? "----MULT
   I CHANNEL MUSIC PLAYER----":OPEN #l,6,
   0,"D:*.V?C":K=0
TF 1030 INPUT #1,R$:IF R$(2,2)<>" " THEN
   1070
YS 1040 ? R$(3,10);:IF R$(12,12)="3" THEN
    ? "*";
KH 1050 IF R$(12,12)="2" THEN ? "+";
MS 1060 ? CHR$(127);:K=K+1:GOTO 1030
OJ 1070 CLOSE #1:POKE 703,4:POKE 752,0:?
   "";
KG 1080 IF K=0 THEN ? "NO MUSIC FILES ON
   THIS DISK":FOR DE=1 TO 500:NEKT DE
TF 1090 TRAP 1950:? "YOUR REQUEST";:INPU
   T R$:IF R$="" THEN POKE 703,24:GOTO 10
   20
CU 1100 F$="D:":F$(3)=R$:FS(LENCF$)+1)="*
   .V?C":OPEN #1,6,0,F$
PF 1110 INPUT #1,R$:IF R$(12,12)="1" THEN
    PP$(181,254)=CH1$
YD 1120 IF R$(12,12)="2" THEN PP$(181,254
   )=CH2$
AR 1130 IF R$(12,12)="3" THEN PP$(181,254
   )=CH3$
SS 1140 CLOSE #1:OPEN #1,4,0,F$:A=BUFF
FG 1150 FOR K=0 TO 2: GET #l,LO:GET #1,HI:
   L=LO+256*HI
WY 1160 U=USR(CIO,A,L):IF U>127 THEN POKE
    195,U:CLOSE #1:GOTO 1910
TG 1170 U=USR(PP+94,K,A):A=A+L:NEXT K
BJ 1180 FOR N=1601 TO 1604:POKE N,0:NEXT
   N:? ""
IZ 1190 TRAP 1200:INPUT #1,R$:? :? R$;:GO
  
TO 1190
WT 1200 IF PEEK(195)<>136 THEN 1950
TK 1210 TRAP 1950:CLOSE #1
CZ 1220 U=USR(PP,PP+180,PP+267,PP+473,PP+
   819,PP+625):POKE 1536,1
AM 1230 RETURN
CJ 1900 IF PEEK(195)=170 THEN ? "I DON'T
   KNOW THAT SONG.":CLOSE #1:GOTO 1090
QW 1950 ? "ERROR ";PEEK(195):A=USR(PP+15
   6)
NN 1999 CLR :END
QP 2000 DIM PP$(892) CH1$(74),CH2$(74),CH
   3$(74),CIO$(34),R$(40),F$(16),BUFF$(FR
   E(0)-500)
NS 2005 PP=ADR(PP$):BUFF=ADR(BUFF$):CIO=A
   DR(CIO$)
OS 2240 PP$(876,876)=CHR$(155):RETURN
MI 2300 DATA 12,24,36,48,244,232,220,208,
   1,2,3,4,5,6,7,0,255,254,253,252,251,25
   0,249,108,2,6,108,4,6,108,6,6,160,0
GE 2310 DATA 177,203,230,203,208,2,230,20
   4,96


Listing 2:
BASIC


Blue indicates inverse video

BR 90 OPEN #1,4,0,"K:"
PZ 100 ? "":LINE=2000:FOR N=1 TO 948:REA
   D D
DU 110 IF D<0 THEN GOSUB 400:? "":LINE=L
   INE+10:POSITION 2,3:? LINE;" PP$(";(AB
   S(D));")=";CHR$(34);:READ D
IL 120 ? CHR$(D);:NEXT N:GOSUB 400
UT 130 RESTORE 900:? CHR$(125):POSITION 2
   ,3:? "2200 CH1$=";CHR$(34);:FOR N=1 TO
    74:READ D:? CHR$(D);:NEXT N:GOSUB 400
ID 140 ? CHR$(125):POSITION 2,3:? "2210 C
   H2$=";CHR$(34);:FOR N=1 TO 75:READ D:?
    CHR$(D);:NEXT N:GOSUB 400
LC 150 ? CHR$(125):POSITION 2,3:? "2220 C
   H3$=";CHR$(34);:FOR N=1 TO 75:READ D:?
    CHR$(D);:NEXT N:GOSUB 400
FG 160 ? CHR$(125):POSITION 2,3:? "2230 C
   IO$=";CHR$(34);:FOR N=1 TO 39:READ D:?
    CHR$(D);'NEXT N:GOSUB 400
ZZ 170 ? "PRESS RETURN TO:":? "LIST 'D:T
   EMP',2000,2300"
WO 180 GET #1,K:IF K<>155 THEN 180
EX 190 LIST "D:TEMP",2000,2300:END
NY 400 ? :? :? "CONT":POSITION 2,0:POKE 8
   42,13:STOP
SH 410 POKE 842,12:RETURN
BR 500 DATA -1,104,164,141,3,6,104,141,2,
   6,104,141,5,6,104,141,4,6,104,141,7,6,
   104,141,6,6,104
KS 510 DATA 141,14,6,104,141,10,6,104,141
   ,15,6,104,141,11,6,169,0,141,0,6,141,1
   ,6,141,54,6
XV 520 DATA 169,144,162,5,27,157,54,6,74,
   202,208,249,169,12,141,60,6,169,40,141
   ,69,6,173,36,2,141,8
AJ 530 DATA 6,173,37,2,141,9,6,169,7,162,
   6,160,-91,93,76,92,228,104,104,104,170
   ,104,27,157,21,6,27,157,27,27
CN 540 DATA 6,104,27,157,18,6,27,157,24,6
   ,169,0,27,157,39,6,27,157,42,6,27,157,
   51,6,168,169,1,27,157,33,6,169
SK 550 DATA 36,224,2,208,3,169,48,200,27,
   157,36,6,152,27,157,27,30,6,169,166,27
   ,157,45,6,169,7,27,157,48,6,96
VX 560 DATA 104,169,7,174,9,6,172,8,6,32,
   92,228,169,0,162,7,27,157,0,210,234,20
   2,16,249,96,-181,0
JH 570 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   ,0,0,0,0,0,0,0,0,0,0,0
JJ 580 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   ,0,0,0,0,0,0,0,0,0,0,0
IF 590 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   ,0,0,0,0,0,0,162,0,32,96,6,232
MO 600 DATA 224,3,208,248,lOB,8,6,189,18,
   6,-271,133,203,189,21,6,133,204,222,33
   ,6,240,27,27,189,42,6,208
SF 610 DATA 18,189,33,6,221,48,6,176,10,1
   89,65,6,41,15,240,3,222,65,6,96,32,99,
   6,32,102,6
IO 620 DATA 133,207,41,248,201,128,208,18
   ,165,207,41,7,168,185,70,6,24,27,125,3
   6,6,27,157,36,6,24,144,227
LP 630 DATA 165,207,41,7,240,218,168,136,
   185,54,6,27,157,33,6,188,27,30,6,185,1
   0,6,133,205,185,-362,14,6,133
PK 640 DATA 206,165,207,74,74,74,41,15,20
   8,10,27,157,65,6,169,1,27,157,42,6,208
   ,78,168,136,185,78,6,24
DC 650 DATA 27,125,36,6,27,157,36,6,168,1
   89,45,6,27,157,65,6,177,205,24,27,125,
   39,6,27,157,61,6,224,2,208,13
OO 660 DATA 152,24,105,97,168,177,205,141
   ,64,6,24,144,26,189,45,6,41,240,201,16
   0,208,17,189,36,6,201
KG 670 DATA 50,144,10,189,45,6,41,15,9,-4
   52,192,27,157,65,6,165,207,41,128,27,1
   57,42,6,165,203,27,157,18,6,165
LB 680 DATA 204,27,157,21,6,96,160,0,165,
   207,41,120,208,21,189,51,6,240,5,222,5
   1,6,240,10,189,24,6
GD 690 DATA 133,203,189,27,27,6,133,204,9
   6,201,8,208,13,32,102,6,27,157,45,6,32
   ,102,6,27,157,48,6,96,201
GD 700 DATA 16,208,17,32,102,6,27,157,51,
   6,165,203,27,157,24,6,165,204,27,157,2
   7,27,6,96,201,24,208,-544,7,32,102
HX 710 DATA 6,27,157,39,6,96,201,32,208,2
   2,160,6,177,203,153,54,6,136,16,248,16
   9,7,24,101,203,133,203
DD 720 DATA 144,2,230,204,96,201,40,208,7
   ,32,102,6,141,1,6,96,201,48,208,7,32,1
   02,6,141,69,6
MH 730 DATA 96,201,56,208,7,32,102,6,27,1
   57,27,30,6,96,201,64,208,7,32,102,6,27
   ,157,36,6,96,140,0,6
AQ 740 DATA 96,209,223,237,251,9,27,30,44
   ,65,-634,79,100,121,149,165,189,217,24
   5,17,59,87,129,27,157,199,241,41,75
JF 750 DATA 121,177,233,33,117,173,1,57,1
   41,225,81,165,21,133,245,101,241,97,9,
   149,61,229,141,81,21,245
NC 760 DATA 213,209,205,1,27,253,49,101,2
   09,61,165,42,234,170,162,154,2,250,98,
   202,162,122,75,84,212,84,68
IQ 770 DATA 52,4,244,196,148,68,244,150,1
   68,168,168,136,104,8,232,136,40,136,23
   2,72,0,-724,0,8,8,1,1
XF 780 DATA 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2
   ,2,2,3,3,3,3,3,4,4,4,5
RL 790 DATA 5,5,5,6,6,7,7,7,8,8,9,10,10,1
   1,11,12,13,14,14,15,16,17,19,19,21,22
JR 800 DATA 23,25,26,27,28,27,29,27,31,33
   ,35,38,39,42,44,47,50,53,56,59,63,67,7
   1,76,79,84,89,95,100
UC 810 DATA 106,112,119,27,126,134,142,15
   2,-814,27,159,169,179,190,201,213,1,3,
   6,9,12,15,18,22,23,25,26,27,28,27,29
SD 820 DATA 27,31,33,35,37,40,42,45,47,50
   ,53,57,60,64,68,72,76,81,85,91,96,102,
   108,114,121,128,136
OC 830 DATA 144,153,162,173,182,193,264,2
   17,230,243,27,255,110,116,122,131,137,
   146,27,0,167,173,185,197,206,221,233
BW 840 DATA 245,87,91,97,102,108,115,121,
   130
FE 900 DATA 234,234,234,234,234,234,173,0
   ,6,240,73,216,169,3,141,50,2,141,15,21
   0,173,61,6,141,0
WH 910 DATA 210,173,65,6,141,1,210,173,62
   ,6,141,2,210,173,66,6,141,3,210,173,63
   ,6,141,4,210
AC 920 DATA 173,67,6,141,7,210,173,64,6,1
   41,6,210,173,68,6,141,5,210,173,69,6,1
   41,8,210
VK 930 DATA 234,234,234,234,234,234,234,2
   34,234,234,234,234,234,234,173,0,6,240
   ,65,216,169,67,141,15,210
NG 940 DATA 162,6,160,3,185,61,6,27,157,0
   ,210,202,202,136,16,245,173,65,6,141,1
   ,210,173,66,6,141
MV 950 DATA 3,210,173,67,6,41,15,141,0,21
   1,169,0,141,5,210,141,7,210,173,69,6,1
   41,8,210
VB 960 DATA 234,234,234,234,234,234,173,0
   ,6,240,73,216,169,99,141,15,210,162,6,
   160,3,185,61,6,27,157
GS 970 DATA 0,210,202,202,136,16,245,173,
   65,6,141,1,210,173,66,6,41,15,133,0,17
   3,67,6,10,10
PA 980 DATA 10,10,5,0,141,0,211,169,0,141
   ,3,210,141,5,210,141,7,210,173,69,6,14
   1,8,210
HX 990 DATA 104,162,16,169,7,27,157,66,3,
   104,27,157,69,3,104,27,157,68,3,104,27
   ,157,73,3,104,27,157,72
PK 1000 DATA 3,32,86,228,132,212,169,0,13
   3,213,96


Listing 3:
BASIC


OM 5 GOSUB 300
GJ 30 FOR S=0 TO 81:READ A,B:POKE 54016,A
   :POKE 53761,B:NEXT S
ZP 99 END
RV 100 DATA 15,160,15,160,15,160,31,160,4
   7,160,63,160,79,160,95,160,111,160,127
   ,160,142,160,157,160,172,160,187,160
HJ 110 DATA 202,160,217,160,232,160,247,1
   60,246,160,245,160,244,160,243,160,242
   ,160,241,160,240,161,224,162,208,163
TJ 120 DATA 192,164,176,165,160,166,144,1
   67,128,168,112,169,96,170,80,171,64,17
   2,48,173,32,174,16,175,0,175,0,175
AZ 130 DATA 0,175,0,175,16,175,32,174,48,
   173,64,172,80,171,96,170,112,169,128,1
   68,144,167,160,166,176,165,192,164
RP 140 DATA 208,163,224,162,240,161,241,1
   60,242,160,243,160,244,160,245,160,246
   ,160,247,160,232,160,217,160,202,160
TN 150 DATA 187,160,172,160,157,160,142,1
   60,127,160,111,160,95,160,79,160,63,16
   0,47,160,31,160,15,160,15,160,15,160
FR 300 P=PEEK(54018):POKE 54018,P-4:POKE
   54016,255:POKE 54018,P
KD 310 SOUND 0,200,10,0:SOUND 1,200,10,0:
   SOUND 3,200,10,0
GZ 320 POKE 53775,99:RETURN


Listing 4:
BASIC


OM 5 GOSUB 300
FJ 10 PITCH=INT(RND(0)*100)+15:CH=INT(RND
   (0)*3)+1
FE 20 ON CH GOSUB 100,120,140:FOR DE=1 TO
    50:NEKT DE:POKE 54016,0:POKE 53761,0
SM 30 FOR DE=1 TO 50:NEXT DE:GOTO 10
JL 100 POKE 53760,PITCH:POKE 53761,174:RE
   TURN
YG 120 POKE 53766,PITCH:POKE 54016,240:RE
   TURN
OZ 140 POKE 53762,PITCH:POKE 54016,15:RET
   URN
FW 300 P=PEEK(54018):POKE 54018,P-4:POKE
   54016,255:POKE 54018,P:REM JOYSTICKS F
   OR OUTPUT
UJ 310 POKE 53775,99:POKE 53768,0:RETURN