Compucolor.org – Virtual Media

Listing of file='SNDGEN.BAS;01' on disk='vmedia/joystick_sound-sector.ccvf'

10 REM  *** SOUND DESIGNER FOR AY-3-8910 SOUND GENERATOR ***
15 REM
20 PLOT 6,6,14,12:PRINT "SOUND DESIGNER FOR AY-3-8910"
25 PLOT 6,2,15
30 REM  SETUP ALL THE NECESSARY DATA
40 DIM  FQ(3),AM(3),V(3)
50 FC =  1.7897725E06:REM  CLOCK FREQUENCY FOR AY-3-8910
60 NP =  0:NN =  0:M =  0:EF =  10:ES =  8:NE =  3
65 REM  SETUP THE I/O PORT ADDRESSES FOR SOUND CHIP
70 SA= 176:SC= 177:REM  INTECOLOR 3650 (USE 48,49 FOR CCII)
75 REM  #### NOTE #### DO NOT USE 48 AND 49 ON 3650 !
80 OUT SA,7:OUT SC,56:REM  CHANNELS 'A,B,C' ONLY
90 GOSUB  10000
95 GOTO  110
100 PRINT :INPUT "CHANGE TONE FREQUENCIES (Y/N) ? ";C$
105 IF  C$< > "Y" GOTO  130
110 INPUT  "TONE FREQUENCIES : ";FQ(0),FQ(1),FQ(2)
115 IF FQ(0)< = 0THEN END
120 INPUT  "AMPLITUDES (1-15): ";AM(0),AM(1),AM(2)
125 AM(0)= AM(0)AND 15:AM(1)= AM(1)AND 15:AM(2)= AM(2)AND 15
130 FOR  I= 0 TO  2
132 IF  FQ(I)< = 0 THEN  V(I+ 1) =  0:GOTO  165
133 REM          ELSE
134 V(I+ 1)= AM(I)
135 TP= INT (FC/ (16* FQ(I))+ 0.5)
140 PH= INT (TP/ 256):PL= TP- 256* PH
145 PH= PHAND 15
150 OUT SA,2* I:OUT SC,PL
155 OUT SA,2* I+ 1:OUT SC,PH
160 PRINT "TONE ";I+ 1,"HIGH BYTE = ";PH,"LOW BYTE = ";PL
165 NEXT  I
170 INPUT  "ENVELOPE CONTROL (Y/N) ? ";C$
180 IF  C$< > "Y" GOTO  300
185 INPUT  "CHANGE ENVELOPE SETTINGS (Y/N) ? ";C$
187 IF  C$< > "Y" GOTO  220
190 INPUT  "ENVELOPE FREQUENCY : ";EF
200 INPUT  "ENVELOPE SHAPE/CYCLE CODE (0-15): ";ES
210 INPUT  "NUMBER OF CHANNELS FOR CONTROL (1-3): ";NE
220 EP =  INT (FC/ (256* EF)+ 0.5)
230 EH =  INT (EP/ 256)
240 EL =  EP- 256* EH
250 EH= EHAND 255
260 FOR  I= 1 TO  NE:V(I) =  16:NEXT  I
270 OUT SA,11:OUT SC,EL:OUT SA,12:OUT SC,EH
280 OUT SA,13:OUT SC,ES
290 PRINT  "ENVELOPE HIGH BYTE = ";EH,"LOW BYTE = ";EL
300 INPUT "SUPERIMPOSED NOISE (Y/N) ? ";C$
310 IF  C$< > "Y" GOTO  800
320 INPUT  "CHANGE NOISE SETTINGS (Y/N) ? ";C$
330 IF  C$< > "Y" GOTO  390
340 INPUT  "NOISE PERIOD (0-31): ";NP
350 INPUT  "NUMBER OF CHANNELS FOR NOISE (1-3): ";NN
360 M =  (8- 2^ NN)* 8
390 OUT SA,7:OUT SC,M:OUT SA,6:OUT SC,NP
800 GOSUB  10030
850 REM
870 INPUT  "HIT <RETURN> TO STOP ";C$
880 GOSUB  10000
890 OUT SA,7:OUT SC,56
900 GOTO  100
10000 REM  *** STOP SOUND ON ALL CHANNELS ***
10010 REM
10020 V(1) =  0:V(2) =  0:V(3) =  0
10030 OUT SA,8:OUT SC,V(1):OUT SA,9:OUT SC,V(2):OUT SA,10:OUT SC,V(3)
10040 RETURN
10050 REM  *** START SOUND ON ALL CHANNELS ***
10060 REM
10070 V(1) =  15:V(2) =  15:V(3) =  15:GOTO  10030