Advertisement
Guest User

Vgm2VortexTrackerTxtAy_09.sdlbas

a guest
Feb 24th, 2016
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/sdlbrt
  2. finp$="PenguinAdventure_03_ForestPath.vgm"
  3. fout$=finp$+".txt"
  4. fout2$=finp$+"_debug.txt"
  5.  
  6.  
  7. ltxtf$="....|..|--- .... ....|--- .... ....|--- .... ...."
  8. ltxtm$="....|..|--- .... ....|--- .... ....|--- .... ...."
  9. 'ltxtm$="....|..|--- 1F.. ....|--- 1F.. ....|--- 1F.. ...."
  10. qtx$=ltxtm$
  11. frmc=0:frmi=735:frmr=200
  12. trg=0:freqq=0:debug=0
  13. freq0=0:freq1=0:freq2=0
  14. vol0=0:vol1=0:vol2=0
  15. patam=64:patc=0:patid=0
  16.  
  17.  
  18.  
  19. '- fix: 0x0FE=440hz=A-4
  20. 'a-4 =0x0FE
  21.  
  22. function nttfrq$(freqb)
  23.   e$=   "C-1C#1D-1D#1E-1F-1F#1G-1G#1A-1A#1B-1"
  24.   e$=e$+"C-2C#2D-2D#2E-2F-2F#2G-2G#2A-2A#2B-2"
  25.   e$=e$+"C-3C#3D-3D#3E-3F-3F#3G-3G#3A-3A#3B-3"
  26.   e$=e$+"C-4C#4D-4D#4E-4F-4F#4G-4G#4A-4A#4B-4"
  27.   e$=e$+"C-5C#5D-5D#5E-5F-5F#5G-5G#5A-5A#5B-5"
  28.   e$=e$+"C-6C#6D-6D#6E-6F-6F#6G-6G#6A-6A#6B-6"
  29.   e$=e$+"C-7C#7D-7D#7E-7F-7F#7G-7G#7A-7A#7B-7"
  30.   e$=e$+"C-8C#8D-8D#8E-8F-8F#8G-8G#8A-8A#8B-8"
  31.   tmq=141-(int((log(freqb)/log(2))*12))
  32.   if tmq<1 then:tmq=1:end if
  33.   if tmq>96 then:tmq=96:end if
  34.   return mid$(e$,(tmq*3)-2,3)
  35.   end function
  36.  
  37.  
  38.  
  39.  
  40.  
  41. dim hdrv[256]
  42.  
  43. open finp$ for input as #1
  44. for i=0 to 255
  45.   hdrv[i]=readbyte(1)
  46.   next
  47. close #1
  48.  
  49. open finp$ for input as #1
  50. open fout$ for output as #2
  51. open fout2$ for output as #3
  52.  
  53. print #2,"[Module]"
  54. print #2,"VortexTrackerII=1"
  55. print #2,"Version=3.6"
  56. print #2,"Title="
  57. print #2,"Author="
  58. print #2,"NoteTable=1"
  59. print #2,"Speed=3"
  60. print #2,"PlayOrder=L0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47"
  61. print #2," "
  62. print #2,"[Ornament1]"
  63. print #2,"L0"
  64. print #2," "
  65. print #2,"[Sample1]"
  66. print #2,"tne +000_ +00_ 0_ L"
  67. print #2," "
  68. print #2,"[Pattern0]"
  69.  
  70. '- read 256 dummy bytes from the header - i have to know how to deal with this better later
  71. for eee=0 to 0x7F:q0=readbyte(1):next  '- read offset byte first
  72.  
  73. txou1$="#("+str$(0)+")"
  74.  
  75. while eof(1)=0
  76.  
  77. q0=readbyte(1)
  78.  
  79. if bitwiseand(q0,0x70)=0x70 then
  80.   frmc=frmc+bitwiseand(q0,0xF)+1
  81.   txou1$="#("+str$(frmc)+")"
  82.   print #3,txou1$
  83.   end if
  84.  
  85. if q0=0x61 then
  86.   q0=readbyte(1)
  87.   frmc=frmc+q0
  88.   q0=readbyte(1)
  89.   frmc=frmc+(q0*256)
  90.   txou1$="#("+str$(frmc)+")"
  91.   print #3,txou1$
  92.   end if
  93.  
  94. if q0=0x62 then
  95.   frmc=frmc+735
  96.   txou1$="#("+str$(frmc)+")"
  97.   print #3,txou1$
  98.   end if
  99.  
  100. while frmr<frmc
  101.   if patc<1 then
  102.     'qtx2$=left$(qtx$,12)+"1F"+mid$(qtx$,15,12)+"1F"+mid$(qtx$,29,12)+"1F"+right$(qtx$,7)
  103.     qtx2$=left$(qtx$,12)+"1F.F"+mid$(qtx$,17,10)+"1F.F"+mid$(qtx$,31,10)+"1F.F"+right$(qtx$,5)
  104.     qtx$=qtx2$
  105.     end if
  106.   if patc>(patam-1) then:
  107.     print #2," "
  108.     patid=patid+1:patc=0
  109.     txou9$="[Pattern"+str$(patid)+"]"
  110.     print #2,txou9$
  111.     print #3," "
  112.     end if
  113.   if debug=1 then:print #3,txou1$:end if
  114.   if trg=0 then
  115.     qtx$=ltxtm$
  116.     print #2,qtx$
  117.   else
  118.     print #2,qtx$
  119.     qtx$=ltxtm$
  120.     trg=0
  121.     end if
  122.   frmr=frmr+frmi
  123.   patc=patc+1
  124.   end while
  125.  
  126. if q0=0xA0 then
  127.   q0=readbyte(1)
  128.   if q0=0 then
  129.     q0=readbyte(1)
  130.     freq0= bitwiseor ( (bitwiseand(freq0,0xF00)),(bitwiseand(q0,0x0FF)) )
  131.     ltxtm1$=qtx$
  132.     ltxtm2$=left$(ltxtm1$,8)+ nttfrq$(freq1) +right$(ltxtm1$,38)
  133.     qtx$=ltxtm2$
  134.     ltxtm3$=ltxtm$
  135.     ltxtm2$=left$(ltxtm3$,8)+ nttfrq$(freq1) +right$(ltxtm3$,38)
  136.     print #3,ltxtm4$
  137.     trg=1
  138.     end if
  139.   if q0=1 then
  140.     q0=readbyte(1)
  141.     freq0= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq0,0x0FF)) )
  142.     ltxtm1$=qtx$
  143.     ltxtm2$=left$(ltxtm1$,8)+ nttfrq$(freq1) +right$(ltxtm1$,38)
  144.     qtx$=ltxtm2$
  145.     ltxtm3$=ltxtm$
  146.     ltxtm4$=left$(ltxtm3$,8)+ nttfrq$(freq1) +right$(ltxtm3$,38)
  147.     print #3,ltxtm4$
  148.     trg=1
  149.     end if
  150.   if q0=2 then
  151.     q0=readbyte(1)
  152.     freq1= bitwiseor ( (bitwiseand(freq1,0xF00)),(bitwiseand(q0,0x0FF)) )
  153.     ltxtm1$=qtx$
  154.     ltxtm2$=left$(ltxtm1$,22)+ nttfrq$(freq1) +right$(ltxtm1$,24)
  155.     qtx$=ltxtm2$
  156.     ltxtm3$=ltxtm$
  157.     ltxtm4$=left$(ltxtm3$,22)+ nttfrq$(freq1) +right$(ltxtm3$,24)
  158.     print #3,ltxtm4$
  159.     trg=1
  160.     end if
  161.   if q0=3 then
  162.     q0=readbyte(1)
  163.     freq1= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq1,0x0FF)) )
  164.     ltxtm1$=qtx$
  165.     ltxtm2$=left$(ltxtm1$,22)+ nttfrq$(freq1) +right$(ltxtm1$,24)
  166.     qtx$=ltxtm2$
  167.     ltxtm3$=ltxtm$
  168.     ltxtm4$=left$(ltxtm3$,22)+ nttfrq$(freq1) +right$(ltxtm3$,24)
  169.     print #3,ltxtm4$
  170.     trg=1
  171.     end if
  172.   if q0=4 then
  173.     q0=readbyte(1)
  174.     freq2= bitwiseor ( (bitwiseand(freq2,0xF00)),(bitwiseand(q0,0x0FF)) )
  175.     ltxtm1$=ltxtm$
  176.     ltxtm2$=left$(ltxtm1$,36)+ nttfrq$(freq1) +right$(ltxtm1$,10)
  177.     qtx$=ltxtm2$
  178.     ltxtm3$=ltxtm$
  179.     ltxtm4$=left$(ltxtm3$,36)+ nttfrq$(freq1) +right$(ltxtm3$,10)
  180.     print #3,ltxtm4$
  181.     trg=1
  182.     end if
  183.   if q0=5 then
  184.     q0=readbyte(1)
  185.     freq2= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq2,0x0FF)) )
  186.     ltxtm1$=qtx$
  187.     ltxtm2$=left$(ltxtm1$,36)+ nttfrq$(freq1) +right$(ltxtm1$,10)
  188.     qtx$=ltxtm2$
  189.     ltxtm3$=ltxtm$
  190.     ltxtm4$=left$(ltxtm3$,36)+ nttfrq$(freq1) +right$(ltxtm3$,10)
  191.     print #3,ltxtm4$
  192.     trg=1
  193.     end if
  194.  
  195.   'if q0=6 then
  196.   '  print #2,ltxtm$
  197.   '  end if
  198.  
  199.   'if q0=7 then
  200.   '  q0=readbyte(1)
  201.   '  ltxtm1$=ltxtm$
  202.   '  ltxtm2$=left$(ltxtm1$,31)+  right$(bin$(512+q0),8)  +right$(ltxtm1$,2)
  203.   '  print #2,ltxtm2$
  204.   '  trg=1
  205.   '  end if
  206.  
  207.   if q0=8 then
  208.     q0=readbyte(1)
  209.     vol0= bitwiseand(q0,0xF)
  210.     ltxtm1$=ltxtm$
  211.     ltxtm2$=left$(ltxtm1$,15)+ ucase$( right$(hex$(0x10+vol0),1) ) +right$(ltxtm1$,33)
  212.     qtx$=ltxtm2$
  213.     ltxtm3$=ltxtm$
  214.     ltxtm4$=left$(ltxtm3$,15)+ ucase$( right$(hex$(0x10+vol0),1) ) +right$(ltxtm3$,33)
  215.     print #3,ltxtm4$
  216.     trg=1
  217.     end if
  218.   if q0=9 then
  219.     q0=readbyte(1)
  220.     vol1= bitwiseand(q0,0xF)
  221.     ltxtm1$=qtx$
  222.     ltxtm2$=left$(ltxtm1$,29)+ ucase$( right$(hex$(0x10+vol1),1) ) +right$(ltxtm1$,19)
  223.     qtx$=ltxtm2$
  224.     ltxtm3$=ltxtm$
  225.     ltxtm2$=left$(ltxtm3$,29)+ ucase$( right$(hex$(0x10+vol1),1) ) +right$(ltxtm3$,19)
  226.     print #3,ltxtm4$
  227.     trg=1
  228.     end if
  229.   if q0=10 then
  230.     q0=readbyte(1)
  231.     vol2= bitwiseand(q0,0xF)
  232.     ltxtm1$=qtx$
  233.     ltxtm2$=left$(ltxtm1$,43)+ ucase$( right$(hex$(0x10+vol2),1) ) +right$(ltxtm1$,5)
  234.     qtx$=ltxtm2$
  235.     ltxtm3$=ltxtm$
  236.     ltxtm2$=left$(ltxtm3$,43)+ ucase$( right$(hex$(0x10+vol2),1) ) +right$(ltxtm3$,5)
  237.     print #3,ltxtm4$
  238.     trg=1
  239.     end if
  240.  
  241.   end if
  242. wend
  243. close #1:close #2:close #3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement