home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette: SID64
/
SID64.D64
/
extract.64
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
1KB
|
31 lines
100 print chr$(147):print " sidplayer":print " music file extraction utility"
110 print " by craig chamberlain":print
120 dn=8:sa=780:sx=781:sy=782:sp=783:dim ln(3)
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):ba=fndp(49)+500:pt=ba+6:dp=pt
300 f$="":input " load filename";f$:if f$="" or len(f$)>12 goto 300
310 gosub 600:poke sa,0:poke sx,fnl(ba):poke sy,fnh(ba)
320 sys 65493:if peek(sp)and1 goto 700
330 for v=1 to 3:ln(v)=fndp(ba+2*v-2):next
350 sm=-1:input " starting measure";sm:if sm<-1 or sm>1023 goto 350
360 em=0:input " ending measure";em:if em<0 or em>1023 goto 360
370 print:sl=sm and255:sh=(sm/4 and192)+30:el=em and255:eh=(em/4 and192)+30
400 for v=1 to 3:print " processing voice";v:db=dp:mp=pt+ln(v):if sm<0 goto 450
410 if peek(pt)=sh then if peek(pt+1)=sl goto 450
420 pt=pt+2:if pt<mp goto 410
430 print " error:starting measure not found":end
450 p=peek(pt):q=peek(pt+1):if p=eh then if q=el goto 480
460 poke dp,p:poke dp+1,q:dp=dp+2:pt=pt+2:if pt<mp goto 450
470 print " note:ran to end of voice":goto 490
480 poke dp,1:poke dp+1,79:dp=dp+2
490 poke ba+2*v-2,fnl(dp-db):poke ba+2*v-1,fnh(dp-db):pt=mp:next:print
500 p=peek(pt):pt=pt+1:poke dp,p:dp=dp+1:if p goto 500
510 f$="":input " save filename";f$:if f$="" or len(f$)>12 goto 510
520 gosub 600:poke sa,251:poke 251,fnl(ba):poke 252,fnh(ba)
530 poke sx,fnl(dp):poke sy,fnh(dp):sys 65496:if peek(sp)and1 goto 700
540 clr: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 print " error":end