home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_07_1985_Transactor_Publishing.d64
/
tele-tone 64
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
4KB
|
103 lines
0 rem the transactor volume 6 issue 02 page 52
100 rem save"@0:tele-tone 64",8
105 rem ** rte/85 - synthetic touch tone sounds via the 64's sid chip
110 :
115 key=203: num=198: rem ** which key / # chars in keybuf
120 zp$="000000": rem ** for timed loop later
125 :
130 dim pd$(2,3)
135 pd$(0,0)="697"+"1209": rem 1
140 pd$(1,0)="697"+"1336": rem 2
145 pd$(2,0)="697"+"1477": rem 3
150 pd$(0,1)="770"+"1209": rem 4
155 pd$(1,1)="770"+"1336": rem 5
160 pd$(2,1)="770"+"1477": rem 6
165 pd$(0,2)="852"+"1209": rem 7
170 pd$(1,2)="852"+"1336": rem 8
175 pd$(2,2)="852"+"1477": rem 9
180 pd$(0,3)="941"+"1209": rem #
185 pd$(1,3)="941"+"1336": rem 0
190 pd$(2,3)="941"+"1477": rem *
195 :
200 xt$(0)="697"+"1633": rem fo - extra
205 xt$(1)="770"+"1633": rem f - extra
210 xt$(2)="852"+"1633": rem i - extra
215 xt$(3)="941"+"1633": rem p - extra
220 :
225 dt$="350"+"440": rem dial tone
230 rg$="440"+"480": rem audible ringing: 2 seconds on, 4 seconds off
235 lb$="480"+"620": rem line busy: interrupted at 60 int/minute
240 ro$="480"+"620": rem re-order : interrupted at 120 int/minute
245 :
250 sd=54272: rem start address of sid chip
255 fc=16.40426: rem frequency multiplying constant
260 pt=64: rem voice type: pulse
265 for i=0 to 24: poke sd+i,0: next: rem initialise sid chip
270 poke sd+2,0: poke sd+3,8: rem 50/50 square wave voice #1
275 poke sd+9,0: poke sd+10,8: rem 50/50 square wave voice #2
280 poke sd+5,0: rem attack=0: decay=0 voice #1
285 poke sd+6,240: rem sustain=infinite, release=immediate
290 poke sd+12,0: rem attack=0: decay=0 voice #2
295 poke sd+13,240: rem sustain=infinite, release=immediate
300 poke sd+24,15: rem set volume to max
305 :
310 print chr$(147)chr$(14)"** [212]ouch [212]one 64 **"
315 print "[208]ress 0-9 [206]ormal [196]ial [212]ones"
320 print "[208]ress #, * [211]pecial [198]or [194]usiness"
325 print "[208]ress a-d [197]xtra [212]ones [198]o, [198], [201], [208]"
330 print "[208]ress ([194]) [204]ine [194]usy"
335 print "[208]ress ([196]) [196]ial [212]one"
340 print "[208]ress ([207]) [210]e-[207]rder"
345 print "[208]ress ([210]) [193]udible [210]inging"
350 print "[208]ress ([211]hift) ([195]lr/[200]ome) [198]or [195]lear"
355 :
360 get p$: if p$="" then 360: rem get request
365 :
370 sid$="": spec=0: rem init sid string + set condition flag
375 if p$<"0" or p$>"9" then 395: rem leave room for numeric check
380 p=val(p$): if p=0 then sid$=pd$(1,3): goto 450
385 p=p-1: x%=p/3: y=p-3*x%: sid$=pd$(y,x%)
390 :
395 if p$="#" then sid$=pd$(0,3)
400 if p$="*" then sid$=pd$(2,3)
405 if p$=>"a" and p$<="d" then sid$=xt$(asc(p$)-65)
410 if p$="[194]" then sid$=lb$: spec=1: rem busy
415 if p$="[196]" then sid$=dt$ : rem dial tone
420 if p$="[207]" then sid$=ro$: spec=2: rem re-order
425 if p$="[210]" then sid$=rg$: spec=3: rem ringing
430 if p$=chr$(147) then 310: rem clear the display
435 if len(sid$)=0 then poke num,0: goto 360: rem wrong key, try again
440 :
445 rem ** time to start touch toning **
450 print p$;
455 lf=val(mid$(sid$,1,3))*fc: hf=val(mid$(sid$,4))*fc: rem set freq/voice
460 poke sd+4,pt: poke sd+11,pt: rem gate voice #1 and #2 off
465 hi%=lf/256: lo=lf-hi%*256: rem calc lo/hi freq voice #1
470 poke sd,lo: poke sd+1,hi%: rem set up freq voice #1
475 hi%=hf/256: lo=hf-hi%*256: rem calc lo/hi freq voice #2
480 poke sd+7,lo: poke sd+8,hi%: rem set up freq voice #2
485 poke sd+4,pt+1: poke sd+11,pt+1: rem gate voice #1 and #2 on
490 ct=0: ti$=zp$: rem set for timed loop if needed
495 :
500 if spec=0 then 570: rem nothing special to do
505 :
510 if spec<3 then 530: rem #3 = audible ringing
515 if ct=0 and ti=>120 then gosub 595: rem flip ct, re-set ti$, gate off
520 if ct and ti=>240 then gosub 600: rem flip ct, re-set ti$, gate on
525 :
530 if spec<>2 then 550: rem #2 = re-order signal
535 if ct=0 and ti=>15 then gosub 595
540 if ct and ti=>15 then gosub 600
545 :
550 if spec>1 then 570: rem #1 = busy signal
555 if ct=0 and ti=>30 then gosub 595
560 if ct and ti=>30 then gosub 600
565 :
570 wch=peek(key): if wch<>64 then 500: rem wait till no key pressed
575 poke sd+4,pt: poke sd+11,pt: rem gate both voices off
580 poke sd,0: poke sd+1,0: poke sd+7,0: poke sd+8,0: rem set freq's low
585 goto 360: rem go for next key press
590 :
595 ti$=zp$: ct=not ct: poke sd+4,pt: poke sd+11,pt: return: rem gate off
600 ti$=zp$: ct=not ct: poke sd+4,pt+1: poke sd+11,pt+1: return: rem gate on