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

  1. 100 print chr$(147):print " sidplayer":print " music file extraction utility"
  2. 110 print " by craig chamberlain":print
  3. 120 dn=8:sa=780:sx=781:sy=782:sp=783:dim ln(3)
  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):ba=fndp(49)+500:pt=ba+6:dp=pt
  6. 300 f$="":input " load filename";f$:if f$="" or len(f$)>12 goto 300
  7. 310 gosub 600:poke sa,0:poke sx,fnl(ba):poke sy,fnh(ba)
  8. 320 sys 65493:if peek(sp)and1 goto 700
  9. 330 for v=1 to 3:ln(v)=fndp(ba+2*v-2):next
  10. 350 sm=-1:input " starting measure";sm:if sm<-1 or sm>1023 goto 350
  11. 360 em=0:input "   ending measure";em:if em<0 or em>1023 goto 360
  12. 370 print:sl=sm and255:sh=(sm/4 and192)+30:el=em and255:eh=(em/4 and192)+30
  13. 400 for v=1 to 3:print " processing voice";v:db=dp:mp=pt+ln(v):if sm<0 goto 450
  14. 410 if peek(pt)=sh then if peek(pt+1)=sl goto 450
  15. 420 pt=pt+2:if pt<mp goto 410
  16. 430 print " error:starting measure not found":end
  17. 450 p=peek(pt):q=peek(pt+1):if p=eh then if q=el goto 480
  18. 460 poke dp,p:poke dp+1,q:dp=dp+2:pt=pt+2:if pt<mp goto 450
  19. 470 print " note:ran to end of voice":goto 490
  20. 480 poke dp,1:poke dp+1,79:dp=dp+2
  21. 490 poke ba+2*v-2,fnl(dp-db):poke ba+2*v-1,fnh(dp-db):pt=mp:next:print
  22. 500 p=peek(pt):pt=pt+1:poke dp,p:dp=dp+1:if p goto 500
  23. 510 f$="":input " save filename";f$:if f$="" or len(f$)>12 goto 510
  24. 520 gosub 600:poke sa,251:poke 251,fnl(ba):poke 252,fnh(ba)
  25. 530 poke sx,fnl(dp):poke sy,fnh(dp):sys 65496:if peek(sp)and1 goto 700
  26. 540 clr:end
  27. 600 print:poke sa,1:poke sx,dn:poke sy,0:sys 65466:f$=f$+".mus"
  28. 610 for k=1 to len(f$):poke 584+k,asc(mid$(f$,k)):next
  29. 620 poke sa,len(f$):poke sx,73:poke sy,2:sys 65469:return
  30. 700 print " error":end
  31.