home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1985 June
/
1985-06.d64
/
sid editor
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
11KB
|
403 lines
100 goto1000:rem ***** 16-bit calculation *****
200 kk=peek(key):ifkk=nullthen200
205 rem key pressed, use vars for speed
210 j=bb:z=peek(h+bb):hh=peek(shft)
215 rem cur-up=7,cur-lft=2,return=1
220 onkkgoto240,250,230,230,230,230,260
230 return:rem no valid key, keep value
240 j=int((z+bb)*k/cc):goto260
245 rem vry fast,larger for higher vals
250 j=k:rem moderate increment
260 z=peek(h)+z*xx+j*((hh=aa)-(hh>aa))
265 rem h set by caller, add incr
266 rem incr is pos if shift key down
270 ifz<aathenz=aa:rem min & max vals
280 ifz>zzthenz=zz
290 gosub930:rem position cursor
295 rem print value if pitch or filter
300 ifdv<>ccthenprintz"[157] ":goto320
305 rem print % of duty cycle
310 printint(z/4.095)/10"[157]% "
315 rem put value in buffer
320 pokeh+bb,z/xx:pokeh,z-int(z/xx)*xx
330 ifdv>ccthen360:rem branch for fltr
335 rem put val in sid, back for more
340 pokeyy,peek(h):pokeyy+bb,peek(h+bb)
350 goto200
355 rem filter is odd; 11-bit value
356 rem stored 3 low, 8 high
360 pokeyy,zand7:pokeyy+bb,z/8
370 goto200:rem ***** 8-bit calculation *****
400 kk=peek(key):ifkk=nullthen400
405 rem key pressed, is it valid?
410 onkkgoto430,430,420,420,420,420,430
415 rem no, return with value kept
420 return
430 hh=peek(shft):bb=sbuf+h
435 rem add increment (same for any
436 rem valid key), pos if shift down
440 z=(peek(bb)andj)/k+(hh=0)-(hh>0)
450 ifz<0thenz=0:rem min & max values
460 ifz>15thenz=15
470 gosub930:printz"[157] ":rem pos & prnt
475 rem mask on to byte
480 z=peek(bb)and255-jorz*k
485 rem insert & go back for more
490 pokebb,z:pokesid+h,z:goto400:rem ***** bit decoding *****
700 yy=peek(sbuf+xx):rem value of byte
710 z=int((yyandj)/k):rem val of bit(s)
715 rem mask values set by caller
720 return:rem ***** bit encoding *****
800 yy=yyand255-jorz*k:rem encode
810 pokesbuf+xx,yy:rem set buffer
820 pokesid+xx,yy:rem set sid
830 return:rem ***** cursor plotter *****
900 pokecx,wx%(ct)+cl:rem word row
910 pokecy,wy%(ct)+ofs:rem & column
920 goto950
930 pokecx,vx%(ct)+cl:rem value row
940 pokecy,vy%(ct):rem & column
950 sysmove:return:rem move cursor
996 rem ** main routine **
1000 gosub 50000:rem initialize ***** key input *****
1100 kk=peek(key):ifkk=nullthen1100
1105 rem key pressed, if shift is
1106 rem down, skip entry level calc
1110 hh=peek(shft):ifhh=1then1500
1115 rem entry level into voices?
1120 ifkk<f1orkk>f5then1500
1125 rem change entry level & clear
1130 el=kk-4:dv=-1:gosub53000:goto1100
1496 rem ***** key dispatch *****
1500 ifkk=fthen2000:rem frequency
1510 ifkk=pthen2000:rem pulse width
1520 ifkk=athen3000:rem attack
1530 ifkk=dthen3000:rem decay
1540 ifkk=sthen3000:rem sustain
1550 ifkk=rthen3000:rem release
1560 ifkk=wthen4000:rem waveform
1570 ifkk=gthen4000:rem gate
1580 ifkk=ithen4000:rem ring
1590 ifkk=ythen4000:rem sync
1600 ifkk=qthen2000:rem filter freq
1610 ifkk=nthen3000:rem resonance
1620 ifkk=vthen3000:rem volume
1630 ifkk=mthen5000:rem mode
1640 ifkk=n1then5000:rem assign
1650 ifkk=n2then5000
1660 ifkk=n3then5000
1670 ifkk=xthen5000
1680 ifkk=othen6000:rem osc3
1690 ifkk=ethen6000:rem env3
1700 ifkk=tthen5000:rem 3 off
1705 rem special functions
1710 ifkk=f1thengosub7000:goto1100
1720 ifkk=f3thengosub7000:goto1100
1730 ifkk=f5thengosub7000:goto1100
1740 ifkk<>f7orhh=0then1800:rem end?
1750 geta$:ifa$<>""then1750:rem clr buf
1760 pokesid+24,0:syscs:end:rem end
1800 dv=-1:gosub53020:rem no valid key
1810 gosub52000:goto1100:rem oops ***** 16-bit evaluation *****
2000 dv=1:ifkk=pthendv=2
2010 ifkk=qthendv=12
2015 rem dv:1=voice freq, 2=pls wdth
2016 rem 12=filter freq, clear old
2017 rem vars used for speed
2018 rem zz=max val, h=sid reg
2020 gosub53020:xx=256:aa=0:bb=1:cc=2
2030 k=29:h=0:zz=65535:j=7
2040 ifdv=2thenzz=4095:h=2
2050 ifdv=12thenzz=2047:h=21:j=0
2055 rem pre-calculate buffer & sid
2056 rem entry points
2060 yy=sid+el*j+h:h=sbuf+el*j+h
2065 rem calc & display values
2066 rem once a non-valid key is found
2067 rem in subroutine, exit with key
2068 rem value intact
2070 gosub200:goto1110:rem ***** 8-bit evaluation *****
3000 dv=4:h=el*7+5:j=240:k=16:rem atck
3005 rem decay, sustain, release?
3010 ifkk=dthendv=5:j=15:k=1
3020 ifkk=sthendv=6:h=el*7+6
3030 ifkk=rthendv=7:h=el*7+6:j=15:k=1
3035 rem resonance or volume?
3040 ifkk=nthendv=13:h=23
3050 ifkk=vthendv=14:h=24:j=15:k=1
3055 rem clear, calc & display values
3056 rem when non-valid key pressed,
3057 rem return with value intact
3060 gosub53020:gosub400:goto1110:rem ***** ctrl byte calculation *****
4000 dv=-1:gosub53020:rem clear
4005 rem set mask values
4010 xx=4+el*7:dv=3:j=240:rem waveform
4020 ifkk=gthendv=8:j=1:rem gate
4030 ifkk=ithendv=9:j=4:rem ring
4040 ifkk=ythendv=10:j=2:rem sync
4050 k=j:ifj=240thenk=16
4055 rem go get value from sid buffer
4056 rem branch if waveform
4060 gosub700:ifdv=3then4110
4066 rem toggle value
4070 z=-(z=0):cl=el*5:ct=dv
4080 ifz=1thenprint"";:rem highlight
4090 gosub53070:goto4190:rem display
4100 rem
4105 rem inc 0->1,1->2,2->4,4->8,8->0
4110 z=(z*2-(z=0))*-(z<8)
4120 ct=dv:cl=el*5:gosub930:rem mve crs
4125 rem display waveform
4130 a$="-":ifz=1thena$="t
4140 [139]z[178]2[167]a$[178]"s
4150 ifz=4thena$="p
4160 [139]z[178]8[167]a$[178]"n
4170 printa$
4180 rem
4190 gosub800:goto1100:rem store & rtrn ***** filt/mode calculation *****
5000 dv=-1:gosub53020:rem clear old
5010 dv=15:ct=dv:cl=0:rem mode
5015 rem filter assignment?
5020 ifkk=n1thendv=16:h=1:goto5500
5030 ifkk=n2thendv=17:h=2:goto5500
5040 ifkk=n3thendv=18:h=4:goto5500
5050 ifkk=xthendv=19:h=8:goto5500
5055 rem 3 off?
5060 ifkk=tthendv=22:goto5200
5070 rem
5075 rem mode increment
5080 xx=24:j=112:k=16:gosub700
5085 rem incr 0->1,1->2,2->4,4->0
5086 rem program modification possible
5087 rem to allow more than one mode
5088 rem at the same time
5090 z=(z*2-(z=0))*-(z<4)
5100 gosub930:rem move cursor
5110 a$=" -":ifz=1thena$="lp
5120 [139]z[178]2[167]a$[178]"bp
5130 ifz=4thena$="hp
5140 [153]a$:[137]5550:[143] display
5150 [143]
5155 [143] turn 3 off
5200 ct[178]dv:xx[178]24:j[178]128:k[178]1:[141]700
5205 [143] mask & toggle
5210 zz[178]128[172][171]((z[175]j)[178]0):h[178]1:[137]5520
5220 [143]
5225 [143] assign filter
5500 ct[178]dv:xx[178]23:j[178]15:k[178]1:[141]700
5510 zz[178]h[172][171]((z[175]h)[178]0):[143] mask & toggle
5520 [139]zz[177]0[167][153]"";
5530 [141]53090:[143] display
5540 z[178]z[175]j[171]h[176]zz
5550 [141]800:[137]1100:[143] store & rtrn ***** i/o insert *****
6000 dv[178][171]1:[141]53020:[143] clear
6005 [143] default to osc
6010 h[178]os:ct[178]20:cl[178]0:[139]kk[178]o[167]6030
6015 [143] envelope
6020 h[178]en:ct[178]21
6030 j[178][194](h):[143] read value
6035 [143] value switch
6036 [143] either 255 (off),0 (voice 1,
6037 [143] low),1 (voice 1, high), or 22
6038 [143] (filter frequency, high)
6040 j[178][171](j[178]0)[171]22[172](j[178]1)[171]255[172](j[178]22)
6050 [151]h,j:[141]930:[143] save & move
6055 [143] calculate display
6060 j[178]1[171](j[177]0)[171](j[177]1)[171](j[177]22)
6070 [153][202]("lhf-",j,1):[137]1100
6996 [143] ***** function keys *****
7000 dv[178][171]1:[141]53020:[143] clear
7005 [143] cannot arrive here unless
7006 [143] shift key was pressed, so
7007 [143] f1=f2,f3=f4,f5=f6
7010 h[178]0:ct[178]8:j[178]1:k[178]1:[143] default
7015 [143] f1(f2)=toggle, f3(f4)=all off
7020 [139]kk[178]f1[176]kk[178]f3[167]7100
7025 [143] f5(f6)=on then off
7026 [143] z=read value, set to 1
7027 [143] will cause a toggle to 0
7028 [143] h serves to adjust z
7030 h[178]1:[141]7100
7040 h[178]2
7095 [143] voice gates at sid+4,11,18
7100 [129]xx[178]4[164]18[169]7
7105 :[143] if f3, set to turn off
7110 :[141]700:[139]kk[178]f3[167]z[178]1
7115 :[143] adjust for f5
7120 :[139]h[177]0[167]z[178]h[171]1
7125 :[143] calculate display row
7130 :cl[178][171]5[172](xx[178]11)[171]10[172](xx[178]18)
7135 :[143] display as on/off
7140 :[145](z[179][177]1)[170]2[141]53060,53070
7150 :z[178][171](z[178]0):yy[178]yy[175]254[176]z
7155 :[143] save in buffer
7160 :[151]sbuf[170]xx,yy
7170 [130