SHARE
TWEET

Vgm2VortexTrackerTxtAy_06.sdlbas

a guest Feb 23rd, 2016 95 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.  
  5. ltxtm$="....|..|--- .... ....|--- .... ....|--- .... ...."
  6. qtx$=ltxtm$
  7. frmc=0:frmi=735:frmr=200
  8. trg=0:freqq=0:debug=0
  9. freq0=0:freq1=0:freq2=0
  10. vol0=0:vol1=0:vol2=0
  11. patam=64:patc=0:patid=0
  12.  
  13. '- fix: 0x0FE=440hz=A-4
  14. 'a-4 =0x0FE
  15. function nttfrq$(b)
  16.   a$=   "3424,3232,3050,2880,2714,2562,2418,2282,2154,2034,1922,1814,"
  17.   a$=a$+"1712,1616,1525,1440,1357,1281,1209,1141,1077,1017, 961, 907,"
  18.   a$=a$+" 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453,"
  19.   a$=a$+" 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226,"
  20.   a$=a$+" 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113,"
  21.   a$=a$+" 107, 101,  95,  90,  85,  80,  75,  71,  67,  63,  60,  56,"
  22.   a$=a$+"  53,  50,  47,  45,  42,  40,  37,  35,  33,  31,  30,  28,"
  23.   a$=a$+"  26,  25,  23,  22,  21,  20,  18,  17,  16,  15,  15,  14,"
  24.   fl=0:tmpr=0
  25.   for c=1 to 96
  26.     d=val(mid$(a$,((c-1)*5)+1,4))
  27.     if ((b<(d+(d/35)))and(b>(d-(d/35)))and(fl=0)) then:fl=1:tmpr=c:end if:next
  28.   if b=0 then:tmpr=0:end if
  29.   '- correct notation?
  30.   e$="B-8C-2C#2D-2D#2E-2F-2F#2G-2G#2A-2A#2B-2"
  31.   e$=e$+"C-3C#3D-3D#3E-3F-3F#3G-3G#3A-3A#3B-3"
  32.   e$=e$+"C-4C#4D-4D#4E-4F-4F#4G-4G#4A-4A#4B-4"
  33.   e$=e$+"C-5C#5D-5D#5E-5F-5F#5G-5G#5A-5A#5B-5"
  34.   e$=e$+"C-6C#6D-6D#6E-6F-6F#6G-6G#6A-6A#6B-6"
  35.   e$=e$+"C-7C#7D-7D#7E-7F-7F#7G-7G#7A-7A#7B-7"
  36.   e$=e$+"C-8C#8D-8D#8E-8F-8F#8G-8G#8A-8A#8B-8"
  37.   tmpz$=mid$(e$,(tmpr*3)+1,3):nttfrq$=tmpz$:end function
  38.  
  39. dim hdrv[256]
  40.  
  41. open finp$ for input as #1
  42. for i=0 to 255
  43.   hdrv[i]=readbyte(1)
  44.   next
  45. close #1
  46.  
  47. open finp$ for input as #1
  48. open fout$ for output as #2
  49.  
  50. print #2,"[Module]"
  51. print #2,"VortexTrackerII=1"
  52. print #2,"Version=3.6"
  53. print #2,"Title="
  54. print #2,"Author="
  55. print #2,"NoteTable=1"
  56. print #2,"Speed=3"
  57. 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"
  58. print #2," "
  59. print #2,"[Ornament1]"
  60. print #2,"L0"
  61. print #2," "
  62. print #2,"[Sample1]"
  63. print #2,"Tne +000_ +00_ D- L"
  64. print #2," "
  65. print #2,"[Pattern0]"
  66.  
  67. '- read 256 dummy bytes from the header - i have to know how to deal with this better later
  68. for eee=0 to 0x7F:q0=readbyte(1):next  '- read offset byte first
  69.  
  70. txou1$="    #("+str$(0)+")"
  71.  
  72. while eof(1)=0
  73.  
  74. q0=readbyte(1)
  75.  
  76. if bitwiseand(q0,0x70)=0x70 then
  77.   frmc=frmc+bitwiseand(q0,0xF)+1
  78.   txou1$="    #("+str$(frmc)+")"
  79.   end if
  80.  
  81. if q0=0x61 then
  82.   q0=readbyte(1)
  83.   frmc=frmc+q0
  84.   q0=readbyte(1)
  85.   frmc=frmc+(q0*256)
  86.   txou1$="    #("+str$(frmc)+")"
  87.   end if
  88.  
  89. if q0=0x62 then
  90.   frmc=frmc+735
  91.   txou1$="    #("+str$(frmc)+")"
  92.   end if
  93.  
  94. while frmr<frmc
  95.   if patc>(patam-1) then:
  96.     print #2," "
  97.     patid=patid+1:patc=0
  98.     txou9$="[Pattern"+str$(patid)+"]"
  99.     print #2,txou9$
  100.     end if
  101.   if debug=1 then:print #2,txou1$:end if
  102.   if trg=0 then
  103.     qtx$=ltxtm$
  104.     print #2,qtx$
  105.   else
  106.     print #2,qtx$
  107.     qtx$=ltxtm$
  108.     trg=0
  109.     end if
  110.   frmr=frmr+frmi
  111.   patc=patc+1
  112.   end while
  113.  
  114. if q0=0xA0 then
  115.   q0=readbyte(1)
  116.   if q0=0 then
  117.     q0=readbyte(1)
  118.     freq0= bitwiseor ( (bitwiseand(freq0,0xF00)),(bitwiseand(q0,0x0FF)) )
  119.     ltxtm1$=qtx$
  120.     ltxtm2$=left$(ltxtm1$,8)+ nttfrq$(freq1) +right$(ltxtm1$,38)
  121.     qtx$=ltxtm2$
  122.     trg=1
  123.     end if
  124.   if q0=1 then
  125.     q0=readbyte(1)
  126.     freq0= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq0,0x0FF)) )
  127.     ltxtm1$=qtx$
  128.     ltxtm2$=left$(ltxtm1$,8)+ nttfrq$(freq1) +right$(ltxtm1$,38)
  129.     qtx$=ltxtm2$
  130.     trg=1
  131.     end if
  132.   if q0=2 then
  133.     q0=readbyte(1)
  134.     freq1= bitwiseor ( (bitwiseand(freq1,0xF00)),(bitwiseand(q0,0x0FF)) )
  135.     ltxtm1$=qtx$
  136.     ltxtm2$=left$(ltxtm1$,22)+ nttfrq$(freq1) +right$(ltxtm1$,24)
  137.     qtx$=ltxtm2$
  138.     trg=1
  139.     end if
  140.   if q0=3 then
  141.     q0=readbyte(1)
  142.     freq1= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq1,0x0FF)) )
  143.     ltxtm1$=qtx$
  144.     ltxtm2$=left$(ltxtm1$,22)+ nttfrq$(freq1) +right$(ltxtm1$,24)
  145.     qtx$=ltxtm2$
  146.     trg=1
  147.     end if
  148.   if q0=4 then
  149.     q0=readbyte(1)
  150.     freq2= bitwiseor ( (bitwiseand(freq2,0xF00)),(bitwiseand(q0,0x0FF)) )
  151.     ltxtm1$=ltxtm$
  152.     ltxtm2$=left$(ltxtm1$,36)+ nttfrq$(freq1) +right$(ltxtm1$,10)
  153.     qtx$=ltxtm2$
  154.     trg=1
  155.     end if
  156.   if q0=5 then
  157.     q0=readbyte(1)
  158.     freq2= bitwiseor ( (bitwiseand(q0*256,0xF00)),(bitwiseand(freq2,0x0FF)) )
  159.     ltxtm1$=qtx$
  160.     ltxtm2$=left$(ltxtm1$,36)+ nttfrq$(freq1) +right$(ltxtm1$,10)
  161.     qtx$=ltxtm2$
  162.     trg=1
  163.     end if
  164.  
  165.   'if q0=6 then
  166.   '  print #2,ltxtm$
  167.   '  end if
  168.  
  169.   'if q0=7 then
  170.   '  q0=readbyte(1)
  171.   '  ltxtm1$=ltxtm$
  172.   '  ltxtm2$=left$(ltxtm1$,31)+  right$(bin$(512+q0),8)  +right$(ltxtm1$,2)
  173.   '  print #2,ltxtm2$
  174.   '  trg=1
  175.   '  end if
  176.  
  177.   if q0=8 then
  178.     q0=readbyte(1)
  179.     vol0= bitwiseand(q0,0xF)
  180.     ltxtm1$=ltxtm$
  181.     ltxtm2$=left$(ltxtm1$,15)+ ucase$( right$(hex$(0x10+vol0),1) ) +right$(ltxtm1$,33)
  182.     qtx$=ltxtm2$
  183.     trg=1
  184.     end if
  185.   if q0=9 then
  186.     q0=readbyte(1)
  187.     vol1= bitwiseand(q0,0xF)
  188.     ltxtm1$=qtx$
  189.     ltxtm2$=left$(ltxtm1$,29)+ ucase$( right$(hex$(0x10+vol1),1) ) +right$(ltxtm1$,19)
  190.     qtx$=ltxtm2$
  191.     trg=1
  192.     end if
  193.   if q0=10 then
  194.     q0=readbyte(1)
  195.     vol2= bitwiseand(q0,0xF)
  196.     ltxtm1$=qtx$
  197.     ltxtm2$=left$(ltxtm1$,43)+ ucase$( right$(hex$(0x10+vol2),1) ) +right$(ltxtm1$,5)
  198.     qtx$=ltxtm2$
  199.     trg=1
  200.     end if
  201.  
  202.   end if
  203. wend
  204. close #1:close #2
RAW Paste Data
Top