home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette: SID64
/
SID64.D64
/
polycon.64
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
59 lines
100 print chr$(147):print " sidplayer polyphony conversion utility"
110 print " by craig chamberlain":print
120 dn=8:sa=780:sx=781:sy=782:sp=783:dim vl(2),va(2)
130 def fnh(n)=int(n/256):def fnl(n)=n-256*int(n/256)
140 def fndp(n)=peek(n)+256*peek(n+1)
150 mv=4395:fm=4541:py=4629
160 la=fndp(49)+500:mt=fndp(51)-500
300 f$="":input " load filename";f$:if f$="" or len(f$)>12 goto 300
310 gosub 600:poke sa,0:poke sx,fnl(la):poke sy,fnh(la)
320 sys 65493:if peek(sp)and1 goto 700
330 for k=0 to 2:vl(k)=fndp(la+2*k):next:ea=fndp(sx)
400 input " source voice";sv:if sv<1 or sv>3 or sv<>int(sv) goto 400
404 sv=sv-1:print:as=la+6:if sv then for k=0 to sv-1:as=as+vl(k):next
406 sb=as+vl(sv)
410 sm=-1:input " starting measure";sm:sm=int(sm):if sm>999 goto 410
412 if sm<0 then print:goto 420
414 sys fm,as,sb,sm:if fndp(251)=sb then print " error: not found":goto 410
416 as=fndp(251):print
420 em=1000:input " ending measure";em:em=int(em):if em<0 goto 420
422 if em>999 then print:goto 430
424 sys fm,as,sb,em:if fndp(251)=sb then print " error: not found":goto 420
426 sb=fndp(251):print
430 pc=0:for k=0 to 2:print " polyphony on voice" k+1 "[157]? ";
431 wait 198,15:get k$:if k$="y" then print "yes":va(k)=1:pc=pc+1:goto 434
432 if k$<>"n" goto 431
433 print "no":va(k)=0
434 next:print:on pc+1 goto 438,436,440,440
436 if va(sv)=0 then print " warning: not polyphony arrangement":print:goto 440
438 print " error: not enough voices":print:goto 430
440 sl=sb-as:va=la+6:for k=0 to 2:if va(k)=0 or k=sv goto 468
442 pa=va:pb=pa+vl(k):if sm<0 goto 450
444 sys fm,pa,pb,sm:if fndp(251)<>pb then pa=fndp(251):goto 450
446 print " error: voice" k+1 "measure" sm "not found":end
450 if em>999 goto 460
452 sys fm,pa,pb,em:if fndp(251)<>pb then pb=fndp(251):goto 460
454 print " error: voice" k+1 "measure" em "not found":end
460 dm=sl-pb+pa:if ea+dm>mt then print " error: not enough memory":end
462 sys mv,pb,ea-pb,pa+sl
464 vl(k)=vl(k)+dm:ea=ea+dm:if sv>k then as=as+dm:sb=sb+dm
466 sys mv,as,sl,pa:va(k)=pa
468 va=va+vl(k):next:if va(sv) then va(sv)=as
470 if pc=1 goto 480
472 in=1:for k=0 to 2:if va(k) then sys py,va(k),va(k)+sl,pc,in:in=in+1
474 next
480 print " convert another part? ";
482 wait 198,15:get k$:if k$="y" then print "yes":print:goto 400
484 if k$<>"n" goto 482
486 print "no":print
500 for k=0 to 2:poke la+2*k,fnl(vl(k)):poke la+2*k+1,fnh(vl(k)):next
510 f$="":input " save filename";f$:if f$="" or len(f$)>12 goto 510
520 gosub 600:poke sa,251:poke 251,fnl(la):poke 252,fnh(la)
530 poke sx,fnl(ea):poke sy,fnh(ea):sys 65496:if peek(sp)and1 goto 700
540 print " saved" ea-la "bytes":end
600 print:poke sa,1:poke sx,dn:poke sy,0:sys 65466:f$=f$+".mus"
610 for k=1 to len(f$):poke 584+k,asc(mid$(f$,k)):next
620 poke sa,len(f$):poke sx,73:poke sy,2:sys 65469:return
700 if peek(sa)=4 then print " error: file not found":end
710 print " error":end