home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette: SID64 / SID64.D64 / utldur.64 (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  69 lines

  1. 100 print chr$(147):print " sidplayer utility duration converter"
  2. 110 print " by craig chamberlain":print
  3. 120 dn=8:sa=780:sx=781:sy=782:sp=783:dim vl(2),va(2)
  4. 130 def fnh(n)=int(n/256):def fnl(n)=n-256*int(n/256)
  5. 140 def fndp(n)=peek(n)+256*peek(n+1)
  6. 150 mv=4436:fm=4548:ex=4602:sh=4858:uc=5160:uo=5161:er=5162
  7. 160 la=fndp(49)+500:mt=fndp(51)-500
  8. 300 f$="":input " load filename";f$:if f$="" or len(f$)>12 goto 300
  9. 310 print:gosub 600:poke sa,0:poke sx,fnl(la):poke sy,fnh(la)
  10. 320 sys 65493:if peek(sp)and1 goto 700
  11. 330 for k=0 to 2:vl(k)=fndp(la+2*k):next:ea=fndp(sx)
  12. 340 va(0)=la+6:va(1)=va(0)+vl(0):va(2)=va(1)+vl(1)
  13. 400 print " 1 expand":print " 2 contract":print " 3 save":print
  14. 402 print " which option? ";
  15. 404 wait 198,15:get g$:if g$="1" then cn=1:print "expand":print:goto 410
  16. 406 if g$="2" then cn=2:print "contract":print:goto 410
  17. 408 if g$="3" then print "save":print:goto 500
  18. 409 goto 404
  19. 410 print " which voice? ";
  20. 412 wait 198,15:get g$:if g$<"1" or g$>"3" goto 412
  21. 414 vn=asc(g$)-49:print g$:print
  22. 420 sm=-1:input " starting measure";sm:if sm>999 goto 420
  23. 422 print:if sm<0 then as=va(vn):goto 430
  24. 424 f=va(vn):t=va(vn)+vl(vn):m=sm:gosub 650
  25. 426 if a=t then print " error: not found":print:goto 420
  26. 428 as=a
  27. 430 em=1000:input "   ending measure";em:if em<0 goto 430
  28. 432 print:if em>999 then ae=va(vn)+vl(vn):goto 440
  29. 434 f=as:t=va(vn)+vl(vn):m=em:gosub 650
  30. 436 if a=t then print " error: not found":print:goto 430
  31. 438 ae=a
  32. 440 print " 1 utl durations":print " 2 utv durations":print
  33. 442 print " which type? ";
  34. 444 wait 198,15:get g$:if g$<"1" or g$>"2" goto 444
  35. 446 un=asc(g$)-48:print g$:print
  36. 450 s=as:l=ea-as:d=mt-l:gosub 675
  37. 460 poke 251,fnl(d):poke 252,fnh(d)
  38. 462 z=d+ae-as:x=fnl(z):y=fnh(z)
  39. 464 poke 253,fnl(as):poke 254,fnh(as)
  40. 470 poke uo,4:poke uc,22:if un=2 then poke uo,36:poke uc,246
  41. 471 if cn=2 goto 475
  42. 472 poke sx,x:poke sy,y:sys ex
  43. 473 if peek(er) then print " error: illegal duration":end
  44. 474 ax=fndp(253):goto 480
  45. 475 poke sx,x:poke sy,y:sys sh
  46. 479 ax=fndp(253)
  47. 480 l=ea-ae:s=mt-l:d=ax:gosub 675
  48. 490 vl(vn)=vl(vn)+(ax-as)-(ae-as)
  49. 492 va(1)=va(0)+vl(0):va(2)=va(1)+vl(1)
  50. 494 ea=ea+(ax-as)-(ae-as)
  51. 496 goto 400
  52. 500 for k=0 to 2:poke la+2*k,fnl(vl(k)):poke la+2*k+1,fnh(vl(k)):next
  53. 510 f$="":input " save filename";f$:if f$="" or len(f$)>12 goto 510
  54. 520 print:gosub 600:poke sa,251:poke 251,fnl(la):poke 252,fnh(la)
  55. 530 poke sx,fnl(ea):poke sy,fnh(ea):sys 65496:if peek(sp)and1 goto 700
  56. 540 print " saved" ea-la "bytes":end
  57. 600 poke sa,1:poke sx,dn:poke sy,0:sys 65466:f$=f$+".mus"
  58. 610 for k=1 to len(f$):poke 584+k,asc(mid$(f$,k)):next
  59. 620 poke sa,len(f$):poke sx,73:poke sy,2:sys 65469:return
  60. 650 poke 251,fnl(f):poke 252,fnh(f)
  61. 652 poke 253,fnl(t):poke 254,fnh(t)
  62. 654 poke sx,fnl(m):poke sy,fnh(m)
  63. 656 sys fm:a=fndp(251):return
  64. 675 poke 251,fnl(s):poke 252,fnh(s)
  65. 676 poke 253,fnl(d):poke 254,fnh(d)
  66. 677 poke sx,fnl(l):poke sy,fnh(l):sys mv:return
  67. 700 if peek(sa)=4 then print " error: file not found":end
  68. 710 print " error":end
  69.