home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1985 June / 1985-06.d64 / sid editor (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1985-01-01  |  10.8 KB  |  403 lines

  1. 100 goto1000:rem                         ***** 16-bit calculation *****
  2. 200 kk=peek(key):ifkk=nullthen200
  3. 205 rem key pressed, use vars for speed
  4. 210 j=bb:z=peek(h+bb):hh=peek(shft)
  5. 215 rem cur-up=7,cur-lft=2,return=1
  6. 220 onkkgoto240,250,230,230,230,230,260
  7. 230 return:rem no valid key, keep value
  8. 240 j=int((z+bb)*k/cc):goto260
  9. 245 rem vry fast,larger for higher vals
  10. 250 j=k:rem moderate increment
  11. 260 z=peek(h)+z*xx+j*((hh=aa)-(hh>aa))
  12. 265 rem h set by caller, add incr
  13. 266 rem incr is pos if shift key down
  14. 270 ifz<aathenz=aa:rem min & max vals
  15. 280 ifz>zzthenz=zz
  16. 290 gosub930:rem position cursor
  17. 295 rem print value if pitch or filter
  18. 300 ifdv<>ccthenprintz"[157] ":goto320
  19. 305 rem print % of duty cycle
  20. 310 printint(z/4.095)/10"[157]%  "
  21. 315 rem put value in buffer
  22. 320 pokeh+bb,z/xx:pokeh,z-int(z/xx)*xx
  23. 330 ifdv>ccthen360:rem branch for fltr
  24. 335 rem put val in sid, back for more
  25. 340 pokeyy,peek(h):pokeyy+bb,peek(h+bb)
  26. 350 goto200
  27. 355 rem filter is odd; 11-bit value
  28. 356 rem stored 3 low, 8 high
  29. 360 pokeyy,zand7:pokeyy+bb,z/8
  30. 370 goto200:rem                          ***** 8-bit calculation *****
  31. 400 kk=peek(key):ifkk=nullthen400
  32. 405 rem key pressed, is it valid?
  33. 410 onkkgoto430,430,420,420,420,420,430
  34. 415 rem no, return with value kept
  35. 420 return
  36. 430 hh=peek(shft):bb=sbuf+h
  37. 435 rem add increment (same for any
  38. 436 rem valid key), pos if shift down
  39. 440 z=(peek(bb)andj)/k+(hh=0)-(hh>0)
  40. 450 ifz<0thenz=0:rem min & max values
  41. 460 ifz>15thenz=15
  42. 470 gosub930:printz"[157]  ":rem pos & prnt
  43. 475 rem mask on to byte
  44. 480 z=peek(bb)and255-jorz*k
  45. 485 rem insert & go back for more
  46. 490 pokebb,z:pokesid+h,z:goto400:rem     ***** bit decoding *****
  47. 700 yy=peek(sbuf+xx):rem value of byte
  48. 710 z=int((yyandj)/k):rem val of bit(s)
  49. 715 rem mask values set by caller
  50. 720 return:rem                           ***** bit encoding *****
  51. 800 yy=yyand255-jorz*k:rem encode
  52. 810 pokesbuf+xx,yy:rem set buffer
  53. 820 pokesid+xx,yy:rem set sid
  54. 830 return:rem                           ***** cursor plotter *****
  55. 900 pokecx,wx%(ct)+cl:rem word row
  56. 910 pokecy,wy%(ct)+ofs:rem & column
  57. 920 goto950
  58. 930 pokecx,vx%(ct)+cl:rem value row
  59. 940 pokecy,vy%(ct):rem     & column
  60. 950 sysmove:return:rem move cursor
  61. 996 rem                                  ** main routine **
  62. 1000 gosub 50000:rem initialize          ***** key input *****
  63. 1100 kk=peek(key):ifkk=nullthen1100
  64. 1105 rem key pressed, if shift is
  65. 1106 rem down, skip entry level calc
  66. 1110 hh=peek(shft):ifhh=1then1500
  67. 1115 rem entry level into voices?
  68. 1120 ifkk<f1orkk>f5then1500
  69. 1125 rem change entry level & clear
  70. 1130 el=kk-4:dv=-1:gosub53000:goto1100
  71. 1496 rem                                 ***** key dispatch *****
  72. 1500 ifkk=fthen2000:rem frequency
  73. 1510 ifkk=pthen2000:rem pulse width
  74. 1520 ifkk=athen3000:rem attack
  75. 1530 ifkk=dthen3000:rem decay
  76. 1540 ifkk=sthen3000:rem sustain
  77. 1550 ifkk=rthen3000:rem release
  78. 1560 ifkk=wthen4000:rem waveform
  79. 1570 ifkk=gthen4000:rem gate
  80. 1580 ifkk=ithen4000:rem ring
  81. 1590 ifkk=ythen4000:rem sync
  82. 1600 ifkk=qthen2000:rem filter freq
  83. 1610 ifkk=nthen3000:rem resonance
  84. 1620 ifkk=vthen3000:rem volume
  85. 1630 ifkk=mthen5000:rem mode
  86. 1640 ifkk=n1then5000:rem assign
  87. 1650 ifkk=n2then5000
  88. 1660 ifkk=n3then5000
  89. 1670 ifkk=xthen5000
  90. 1680 ifkk=othen6000:rem osc3
  91. 1690 ifkk=ethen6000:rem env3
  92. 1700 ifkk=tthen5000:rem 3 off
  93. 1705 rem special functions
  94. 1710 ifkk=f1thengosub7000:goto1100
  95. 1720 ifkk=f3thengosub7000:goto1100
  96. 1730 ifkk=f5thengosub7000:goto1100
  97. 1740 ifkk<>f7orhh=0then1800:rem end?
  98. 1750 geta$:ifa$<>""then1750:rem clr buf
  99. 1760 pokesid+24,0:syscs:end:rem end
  100. 1800 dv=-1:gosub53020:rem no valid key
  101. 1810 gosub52000:goto1100:rem oops        ***** 16-bit evaluation *****
  102. 2000 dv=1:ifkk=pthendv=2
  103. 2010 ifkk=qthendv=12
  104. 2015 rem dv:1=voice freq, 2=pls wdth
  105. 2016 rem 12=filter freq, clear old
  106. 2017 rem vars used for speed
  107. 2018 rem zz=max val, h=sid reg
  108. 2020 gosub53020:xx=256:aa=0:bb=1:cc=2
  109. 2030 k=29:h=0:zz=65535:j=7
  110. 2040 ifdv=2thenzz=4095:h=2
  111. 2050 ifdv=12thenzz=2047:h=21:j=0
  112. 2055 rem pre-calculate buffer & sid
  113. 2056 rem entry points
  114. 2060 yy=sid+el*j+h:h=sbuf+el*j+h
  115. 2065 rem calc & display values
  116. 2066 rem once a non-valid key is found
  117. 2067 rem in subroutine, exit with key
  118. 2068 rem value intact
  119. 2070 gosub200:goto1110:rem               ***** 8-bit evaluation *****
  120. 3000 dv=4:h=el*7+5:j=240:k=16:rem atck
  121. 3005 rem decay, sustain, release?
  122. 3010 ifkk=dthendv=5:j=15:k=1
  123. 3020 ifkk=sthendv=6:h=el*7+6
  124. 3030 ifkk=rthendv=7:h=el*7+6:j=15:k=1
  125. 3035 rem resonance or volume?
  126. 3040 ifkk=nthendv=13:h=23
  127. 3050 ifkk=vthendv=14:h=24:j=15:k=1
  128. 3055 rem clear, calc & display values
  129. 3056 rem when non-valid key pressed,
  130. 3057 rem return with value intact
  131. 3060 gosub53020:gosub400:goto1110:rem    ***** ctrl byte calculation *****
  132. 4000 dv=-1:gosub53020:rem clear
  133. 4005 rem set mask values
  134. 4010 xx=4+el*7:dv=3:j=240:rem waveform
  135. 4020 ifkk=gthendv=8:j=1:rem gate
  136. 4030 ifkk=ithendv=9:j=4:rem ring
  137. 4040 ifkk=ythendv=10:j=2:rem sync
  138. 4050 k=j:ifj=240thenk=16
  139. 4055 rem go get value from sid buffer
  140. 4056 rem branch if waveform
  141. 4060 gosub700:ifdv=3then4110
  142. 4066 rem toggle value
  143. 4070 z=-(z=0):cl=el*5:ct=dv
  144. 4080 ifz=1thenprint"";:rem highlight
  145. 4090 gosub53070:goto4190:rem display
  146. 4100 rem
  147. 4105 rem inc 0->1,1->2,2->4,4->8,8->0
  148. 4110 z=(z*2-(z=0))*-(z<8)
  149. 4120 ct=dv:cl=el*5:gosub930:rem mve crs
  150. 4125 rem display waveform
  151. 4130 a$="-":ifz=1thena$="t
  152. 4140 [139]z[178]2[167]a$[178]"s
  153. 4150 ifz=4thena$="p
  154. 4160 [139]z[178]8[167]a$[178]"n
  155. 4170 printa$
  156. 4180 rem
  157. 4190 gosub800:goto1100:rem store & rtrn  ***** filt/mode calculation *****
  158. 5000 dv=-1:gosub53020:rem clear old
  159. 5010 dv=15:ct=dv:cl=0:rem mode
  160. 5015 rem filter assignment?
  161. 5020 ifkk=n1thendv=16:h=1:goto5500
  162. 5030 ifkk=n2thendv=17:h=2:goto5500
  163. 5040 ifkk=n3thendv=18:h=4:goto5500
  164. 5050 ifkk=xthendv=19:h=8:goto5500
  165. 5055 rem 3 off?
  166. 5060 ifkk=tthendv=22:goto5200
  167. 5070 rem
  168. 5075 rem mode increment
  169. 5080 xx=24:j=112:k=16:gosub700
  170. 5085 rem incr 0->1,1->2,2->4,4->0
  171. 5086 rem program modification possible
  172. 5087 rem to allow more than one mode
  173. 5088 rem at the same time
  174. 5090 z=(z*2-(z=0))*-(z<4)
  175. 5100 gosub930:rem move cursor
  176. 5110 a$=" -":ifz=1thena$="lp
  177. 5120 [139]z[178]2[167]a$[178]"bp
  178. 5130 ifz=4thena$="hp
  179. 5140 [153]a$:[137]5550:[143] display
  180. 5150 [143]
  181. 5155 [143] turn 3 off
  182. 5200 ct[178]dv:xx[178]24:j[178]128:k[178]1:[141]700
  183. 5205 [143] mask & toggle
  184. 5210 zz[178]128[172][171]((z[175]j)[178]0):h[178]1:[137]5520
  185. 5220 [143]
  186. 5225 [143] assign filter
  187. 5500 ct[178]dv:xx[178]23:j[178]15:k[178]1:[141]700
  188. 5510 zz[178]h[172][171]((z[175]h)[178]0):[143] mask & toggle
  189. 5520 [139]zz[177]0[167][153]"";
  190. 5530 [141]53090:[143] display
  191. 5540 z[178]z[175]j[171]h[176]zz
  192. 5550 [141]800:[137]1100:[143] store & rtrn  ***** i/o insert *****
  193. 6000 dv[178][171]1:[141]53020:[143] clear
  194. 6005 [143] default to osc
  195. 6010 h[178]os:ct[178]20:cl[178]0:[139]kk[178]o[167]6030
  196. 6015 [143] envelope
  197. 6020 h[178]en:ct[178]21
  198. 6030 j[178][194](h):[143] read value
  199. 6035 [143] value switch
  200. 6036 [143] either 255 (off),0 (voice 1,
  201. 6037 [143] low),1 (voice 1, high), or 22
  202. 6038 [143] (filter frequency, high)
  203. 6040 j[178][171](j[178]0)[171]22[172](j[178]1)[171]255[172](j[178]22)
  204. 6050 [151]h,j:[141]930:[143] save & move
  205. 6055 [143] calculate display
  206. 6060 j[178]1[171](j[177]0)[171](j[177]1)[171](j[177]22)
  207. 6070 [153][202]("lhf-",j,1):[137]1100
  208. 6996 [143]                                 ***** function keys *****
  209. 7000 dv[178][171]1:[141]53020:[143] clear
  210. 7005 [143] cannot arrive here unless
  211. 7006 [143] shift key was pressed, so
  212. 7007 [143] f1=f2,f3=f4,f5=f6
  213. 7010 h[178]0:ct[178]8:j[178]1:k[178]1:[143] default
  214. 7015 [143] f1(f2)=toggle, f3(f4)=all off
  215. 7020 [139]kk[178]f1[176]kk[178]f3[167]7100
  216. 7025 [143] f5(f6)=on then off
  217. 7026 [143] z=read value, set to 1
  218. 7027 [143] will cause a toggle to 0
  219. 7028 [143] h serves to adjust z
  220. 7030 h[178]1:[141]7100
  221. 7040 h[178]2
  222. 7095 [143] voice gates at sid+4,11,18
  223. 7100 [129]xx[178]4[164]18[169]7
  224. 7105 :[143] if f3, set to turn off
  225. 7110 :[141]700:[139]kk[178]f3[167]z[178]1
  226. 7115 :[143] adjust for f5
  227. 7120 :[139]h[177]0[167]z[178]h[171]1
  228. 7125 :[143] calculate display row
  229. 7130 :cl[178][171]5[172](xx[178]11)[171]10[172](xx[178]18)
  230. 7135 :[143] display as on/off
  231. 7140 :[145](z[179][177]1)[170]2[141]53060,53070
  232. 7150 :z[178][171](z[178]0):yy[178]yy[175]254[176]z
  233. 7155 :[143] save in buffer
  234. 7160 :[151]sbuf[170]xx,yy
  235. 7170 [130]
  236. 7175 [143] move to sid quickly
  237. 7180 [129]xx[178]4[164]18[169]7
  238. 7190 :[151]sid[170]xx,[194](sbuf[170]xx)
  239. 7200 [130]:[142]:[143]                     ** initialize **
  240. 49995 [143] * put in system routines *
  241. 49996 [143] * cursor plot routine *
  242. 50000 move[178]679:cx[178]251:cy[178]252
  243. 50010 [129]xx[178]move[164]move[170]7
  244. 50020 :[135]yy:[151]xx,yy
  245. 50030 [130]:[143]                           interrupt routine
  246. 50040 [129]xx[178]712[164]760
  247. 50050 :[135]yy:[151]xx,yy
  248. 50060 [130]:[143]                           ***** variable assignment *****
  249. 50100 key[178]203:shft[178]653:null[178]64
  250. 50105 [143] peek(key)=val of current
  251. 50106 [143] key down, peek(shft)>0 if
  252. 50107 [143] shift,c=,or ctrl pressed
  253. 50108 [143] peek(key)=null means no key
  254. 50110 up[178]7:fa[178]2:lo[178]1:xx[178]0:yy[178]0:zz[178]0:z[178]0
  255. 50115 [143] up=cursor up/down=slow
  256. 50116 [143] fa=crsr lft/rght=moderate
  257. 50117 [143] lo=return=fast
  258. 50118 [143] no shift=down, shift=up
  259. 50120 kk[178]0:hh[178]0:h[178]0:j[178]0:k[178]0:dv[178]0:ct[178]0
  260. 50125 [143] kk holds current key value
  261. 50126 [143] hh>0 if shift down
  262. 50127 [143] dv,ct,cl are display values
  263. 50130 cl[178]0:aa[178]0:bb[178]0:cc[178]0:sid[178]54272
  264. 50135 [143] op=move interrupt,cs=restore
  265. 50140 sbuf[178]move[170]8:op[178]712:cs[178]725
  266. 50145 [143] highlighted key values
  267. 50150 f1[178]4:f3[178]5:f5[178]6:f7[178]3
  268. 50160 f[178]21:p[178]41:w[178]9:a[178]10:d[178]18:s[178]13:r[178]17
  269. 50170 g[178]26:i[178]33:y[178]25:q[178]62:n[178]39:m[178]36
  270. 50180 v[178]31:n1[178]56:n2[178]59:n3[178]8
  271. 50185 [143] en,os used in i/o
  272. 50190 x[178]23:o[178]38:e[178]14:t[178]22:en[178]254:os[178]253
  273. 50196 [143]                                ***** read screen data *****
  274. 50200 [134]wx%(22),wy%(22):[143] word x,y
  275. 50210 [134]vx%(22),vy%(22):[143] value x,y
  276. 50220 [134]wrd$(22):[143] display strings
  277. 50230 [129]xx[178]0[164]22
  278. 50240 :[135]wx%(xx),wy%(xx)
  279. 50250 :[135]vx%(xx),vy%(xx)
  280. 50260 :[135]wrd$(xx)
  281. 50270 [130]:[143]                           ***** display screen *****
  282. 50300 [153]"loadwaitcont  sid editor - press a highlighted key
  283. 50310 print"crsr:[u/d]=slow,[l/r]=med, [return]=fast
  284. 50320 [129]xx[178]0[164]10[169]5:[143] voices 1-3
  285. 50325 :[143] 0=f1,5=f3,10=f5
  286. 50330 :a$[178][201]([196](2[172]xx[173]5[170]1),1)
  287. 50335 :[143] move cursor
  288. 50340 :ct[178]0:cl[178]xx:ofs[178][171]3:[141]900
  289. 50345 :[143] print "voice"
  290. 50350 :[153]"f"a$"cont "wrd$(0)xx[173]5[170]1
  291. 50355 :[143] z determines display type
  292. 50360 :[129]yy[178]1[164]10:z[178]1[171](yy[179]8)[171](yy[178]3)
  293. 50370 : ct[178]yy:ofs[178]0:[141]900
  294. 50380 : [153]wrd$(yy)" "[202](" 0-",z,1)
  295. 50390 :[130]
  296. 50400 [130]
  297. 50410 [143]
  298. 50415 [143] filter & volume stuff
  299. 50420 ct[178]11:cl[178]0:[141]900
  300. 50430 [153]wrd$(11)
  301. 50440 [129]xx[178]12[164]22:[139]xx[179][177]16[167]50460
  302. 50445 :[143] additional prompt
  303. 50450 :[153]"             assign filter
  304. 50455 :rem a$=default display
  305. 50460 :a$="":ifxx<15thena$=" 0
  306. 50470 :[139]xx[178]15[176]xx[178]20[176]xx[178]21[167]a$[178]" -
  307. 50480 :ct=xx:gosub900:rem move cursor
  308. 50490 :printwrd$(xx)a$
  309. 50500 next:print
  310. 50510 print" f2[154]=toggle f4[154]=all off f6[154]=on/off f8[154]=quit";
  311. 50515 rem display values default
  312. 50520 el=0:oel=el:dv=-1:odv=dv
  313. 50598 rem                                ***** insert i/o into interrupt *****
  314. 50600 pokeen,255:pokeos,255:sysop
  315. 50996 rem                                ***** clear sid & buffer *****
  316. 51000 forxx=sidtosid+28
  317. 51020 :  pokexx,0
  318. 51030 :  pokesbuf+xx-sid,0
  319. 51040 next
  320. 51050 return:rem                         ***** error buzz ****
  321. 52000 pokesid+23,0:rem no filter
  322. 52010 pokesid+24,15:rem full vol
  323. 52020 pokesid+1,10:rem voice 1
  324. 52030 pokesid+5,0:rem no a/d
  325. 52040 pokesid+6,240:rem full sus
  326. 52050 pokesid+4,0:rem gate off
  327. 52060 pokesid+4,33:rem saw on
  328. 52070 forxx=1to80:next:rem delay
  329. 52075 rem restore old values
  330. 52080 pokesid+23,peek(sbuf+23)
  331. 52090 pokesid+24,peek(sbuf+24)
  332. 52100 pokesid+1,peek(sbuf+1)
  333. 52110 pokesid+5,peek(sbuf+5)
  334. 52120 pokesid+6,peek(sbuf+6)
  335. 52130 pokesid+4,peek(sbuf+4)
  336. 52140 return:rem                         ***** highlight current entry *****
  337. 52995 rem line 53000 clears old voice
  338. 52996 rem line 53010 highlights new
  339. 52997 rem line 53020 clears old entry
  340. 52998 rem line 53040 highlights new
  341. 52999 rem
  342. 53000 ct=0:cl=5*oel*-(ct<11):gosub53070
  343. 53005 rem cl=row offset
  344. 53010 cl=5*el*-(dv<11):gosub53060
  345. 53020 ct=odv:cl=5*oel*-(ct<11)
  346. 53030 gosub53070
  347. 53040 oel=el:odv=dv
  348. 53050 ct=odv:cl=5*oel*-(ct<11)
  349. 53060 print"";
  350. 53065 rem no change for these values
  351. 53066 rem gate, ring, etc
  352. 53070 ifct<0orct>14then53110
  353. 53080 ifct=3orct=11then53110
  354. 53090 gosub900:rem plot
  355. 53100 print wrd$(ct)
  356. 53110 print"[146]";:return:rem               ***** program data *****
  357. 59998 rem cursor move routine
  358. 59999 rem
  359. 60000 data24,166,251,164,252,76,240,255
  360. 60096 rem
  361. 60097 rem
  362. 60098 rem interrupt routine
  363. 60099 rem
  364. 60100 data120,169,226,141,20,3,169
  365. 60110 data2,141,21,3,88,96,120,169
  366. 60120 data49,141,20,3,169,234,141
  367. 60130 data21,3,88,96,166,253,48,6
  368. 60140 data173,27,212,157,0,212,166
  369. 60150 data254,48,6,173,28,212,157
  370. 60160 data0,212,76,49,234
  371. 62992 rem
  372. 62993 rem
  373. 62994 rem screen display data
  374. 62995 rem
  375. 62996 rem word start x, word start y,
  376. 62997 rem value start x, value start y,
  377. 62998 rem word
  378. 62999 rem
  379. 63000 data3,4,3,4,voice
  380. 63010 data3,13,3,23,"f[154]requency:
  381. 63020 [131]4,13,4,23,"pcontls width:
  382. 63030 data5,14,5,24,"w[154]aveform:
  383. 63040 [131]3,30,3,37,"acontttack:
  384. 63050 data4,31,4,37,"d[154]ecay:
  385. 63060 [131]5,29,5,37,"scontustain:
  386. 63070 data6,29,6,37,"r[154]elease:
  387. 63080 [131]6,13,6,13,"gcontate
  388. 63090 data6,18,6,18,"ri[154]ng
  389. 63100 [131]6,23,6,23,"sycontnc
  390. 63110 data19,1,19,1,filter/out
  391. 63120 data19,13,19,23,"freq[154]uency:
  392. 63130 [131]20,13,20,23,"resoncontance:
  393. 63140 data19,30,19,37,"v[154]olume:
  394. 63150 [131]20,32,20,37,"mcontode:
  395. 63160 data21,27,21,27,"1[154]
  396. 63170 [131]21,29,2,29,"2cont
  397. 63180 data21,31,21,31,"3[154]
  398. 63190 [131]21,33,21,33,"excontt
  399. 63200 data22,13,22,18,"o[154]sc3
  400. 63210 [131]22,21,22,26,"econtnv3
  401. 63220 data22,29,22,29,"t[154]urnoff 3
  402. 63230 [143]                                *** end of program ***
  403.