Advertisement
Guest User

Vgm2VortexTrackerTxtAy_03b.sdlbas

a guest
Feb 25th, 2016
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/sdlbrt
  2. finp$="Nemesis_msx_02_Challenger1985.vgm"
  3. fout$=finp$+"_vortextracker_pre.txt"
  4.  
  5. frmc=0
  6. frmi=735
  7. frmr=300
  8. trg=0
  9. ltxtm$="....|..|--- .... ....|--- .... ....|--- .... ...."
  10. freq0=0
  11. freq1=0
  12. freq2=0
  13. vol0=0
  14. vol1=0
  15. vol2=0
  16. freqq=0
  17. debug=1
  18.  
  19. '- fix: 0x0FE=440hz=A-4
  20. function nttfrq$(freqb)
  21.   e$=   "C-1C#1D-1D#1E-1F-1F#1G-1G#1A-1A#1B-1"
  22.   e$=e$+"C-2C#2D-2D#2E-2F-2F#2G-2G#2A-2A#2B-2"
  23.   e$=e$+"C-3C#3D-3D#3E-3F-3F#3G-3G#3A-3A#3B-3"
  24.   e$=e$+"C-4C#4D-4D#4E-4F-4F#4G-4G#4A-4A#4B-4"
  25.   e$=e$+"C-5C#5D-5D#5E-5F-5F#5G-5G#5A-5A#5B-5"
  26.   e$=e$+"C-6C#6D-6D#6E-6F-6F#6G-6G#6A-6A#6B-6"
  27.   e$=e$+"C-7C#7D-7D#7E-7F-7F#7G-7G#7A-7A#7B-7"
  28.   e$=e$+"C-8C#8D-8D#8E-8F-8F#8G-8G#8A-8A#8B-8"
  29.   tmq=141-(int((log(freqb)/log(2))*12))
  30.   if tmq<1 then:tmq=1:end if
  31.   if tmq>96 then:tmq=96:end if
  32.   return mid$(e$,(tmq*3)-2,3)
  33.   end function
  34.  
  35.  
  36. open finp$ for input as #1
  37. open fout$ for output as #2
  38.  
  39. '- read 256 dummy bytes from the header - i have to know how to deal with this better later
  40. for eee=0 to 0x7F:q0=readbyte(1):next  '- read offset byte first
  41.  
  42. txou1$="    #("+str$(0)+")"
  43.  
  44. while eof(1)=0
  45.  
  46. q0=readbyte(1)
  47.  
  48. if bitwiseand(q0,0x70)=0x70 then
  49.   frmc=frmc+bitwiseand(q0,0xF)+1
  50.   txou1$="    #("+str$(frmc)+")"
  51.   'print #2,txou1$
  52.   end if
  53.  
  54. if q0=0x61 then
  55.   q0=readbyte(1)
  56.   frmc=frmc+q0
  57.   q0=readbyte(1)
  58.   frmc=frmc+(q0*256)
  59.   txou1$="    #("+str$(frmc)+")"
  60.   'print #2,txou1$
  61.   end if
  62.  
  63. if q0=0x62 then
  64.   frmc=frmc+735
  65.   txou1$="    #("+str$(frmc)+")"
  66.   'print #2,txou1$
  67.   end if
  68.  
  69.  
  70. while frmr<frmc
  71.   if trg=0 then
  72.     print #2,"--frameout-unchanged--"
  73.   else
  74.     print #2,"--frameout--"
  75.     trg=0
  76.     end if
  77.   frmr=frmr+frmi
  78.   end while
  79.  
  80.  
  81.  
  82. if q0=0xA0 then
  83.   q0=readbyte(1)
  84.  
  85.   if q0=0 then
  86.     q0=readbyte(1)
  87.     freq0= bitwiseor ( (bitwiseand(freq0,0xF00)),(bitwiseand(q0,0x0FF)) )
  88.     ltxtm1$=ltxtm$
  89.     ltxtm2$=left$(ltxtm1$,8)+ nttfrq$(freq0) +right$(ltxtm1$,38)+txou1$
  90.     print #2,ltxtm2$
  91.     trg=1
  92.     end if
  93.  
  94.   if q0=1 then
  95.     q0=readbyte(1)
  96.     freq0= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq0,0x0FF)) )
  97.     ltxtm1$=ltxtm$
  98.     ltxtm2$=left$(ltxtm1$,8)+nttfrq$(freq0) +right$(ltxtm1$,38)+txou1$
  99.     print #2,ltxtm2$
  100.     trg=1
  101.     end if
  102.  
  103.   if q0=2 then
  104.     q0=readbyte(1)
  105.     freq1= bitwiseor ( (bitwiseand(freq1,0xF00)),(bitwiseand(q0,0x0FF)) )
  106.     ltxtm1$=ltxtm$
  107.     ltxtm2$=left$(ltxtm1$,22)+ nttfrq$(freq1) +right$(ltxtm1$,24)+txou1$
  108.     print #2,ltxtm2$
  109.     trg=1
  110.     end if
  111.  
  112.   if q0=3 then
  113.     q0=readbyte(1)
  114.     freq1= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq1,0x0FF)) )
  115.     ltxtm1$=ltxtm$
  116.     ltxtm2$=left$(ltxtm1$,22)+ nttfrq$(freq1) +right$(ltxtm1$,24)+txou1$
  117.     print #2,ltxtm2$
  118.     trg=1
  119.     end if
  120.  
  121.   if q0=4 then
  122.     q0=readbyte(1)
  123.     freq2= bitwiseor ( (bitwiseand(freq2,0xF00)),(bitwiseand(q0,0x0FF)) )
  124.     ltxtm1$=ltxtm$
  125.     ltxtm2$=left$(ltxtm1$,36)+ nttfrq$(freq2) +right$(ltxtm1$,10)+txou1$
  126.     print #2,ltxtm2$
  127.  
  128.     trg=1
  129.     end if
  130.  
  131.   if q0=5 then
  132.     q0=readbyte(1)
  133.     freq2= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq2,0x0FF)) )
  134.     ltxtm1$=ltxtm$
  135.     ltxtm2$=left$(ltxtm1$,36)+ nttfrq$(freq2) +right$(ltxtm1$,10)+txou1$
  136.     print #2,ltxtm2$
  137.     trg=1
  138.     end if
  139.  
  140.   if q0=6 then
  141.     print #2,ltxtm$
  142.     end if
  143.  
  144.   'if q0=7 then
  145.   '  q0=readbyte(1)
  146.   '  ltxtm1$=ltxtm$
  147.   '  ltxtm2$=left$(ltxtm1$,31)+  right$(bin$(512+q0),8)  +right$(ltxtm1$,2)+txou1$
  148.   '  print #2,ltxtm2$
  149.   '  trg=1
  150.   '  end if
  151.  
  152.   if q0=8 then
  153.     q0=readbyte(1)
  154.     vol0= bitwiseand(q0,0xF)
  155.     ltxtm1$=ltxtm$
  156.     ltxtm2$=left$(ltxtm1$,15)+ ucase$( right$(hex$(0x10+vol0),1) ) +right$(ltxtm1$,33)+txou1$
  157.     print #2,ltxtm2$
  158.     trg=1
  159.     end if
  160.  
  161.   if q0=9 then
  162.     q0=readbyte(1)
  163.     vol1= bitwiseand(q0,0xF)
  164.     ltxtm1$=ltxtm$
  165.     ltxtm2$=left$(ltxtm1$,29)+ ucase$( right$(hex$(0x10+vol1),1) ) +right$(ltxtm1$,19)+txou1$
  166.     print #2,ltxtm2$
  167.     trg=1
  168.     end if
  169.  
  170.   if q0=10 then
  171.     q0=readbyte(1)
  172.     vol2= bitwiseand(q0,0xF)
  173.     ltxtm1$=ltxtm$
  174.     ltxtm2$=left$(ltxtm1$,43)+ ucase$( right$(hex$(0x10+vol2),1) ) +right$(ltxtm1$,5)+txou1$
  175.     print #2,ltxtm2$
  176.     trg=1
  177.     end if
  178.  
  179.   end if
  180.  
  181.  
  182.  
  183. wend
  184.  
  185. close #1:close #2
  186.  
  187. 'setdisplay(320,240,32,1):paper(8^8-1):ink(0):pen(0):cls
  188. 'loadimage("pic1.png",1):pasteicon(0,0,1)
  189. 'grab(1,0,0,320,240):saveimage("pic1b.bmp",1)
  190. 'waitkey
  191.  
  192.  
  193. 'a-4 =0x0FE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement