converter_b_ym2612_1b.sdlbas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. function lstinf$(a$,b$,c$)
  2. adra=1:adrb=1:blngt=len(b$):d$=""
  3. while adrb<=blngt
  4. if mid$ (a$,adra,1)=mid$ (b$,adrb,1) then:adrb+=1:end if
  5. adra=adra+1
  6. end while
  7. while mid$(a$,adra,1)<>left$(c$,1)
  8. d$=d$+mid$(a$,adra,1):adra=adra+1
  9. end while
  10. lstinf$=d$
  11. end function
  12. function vldc(a$)
  13. t0$="!"+a$+".0.0.0."
  14. t1$=lstinf$(t0$,"!",".")
  15. t2$=lstinf$(t0$,".",".")
  16. t3=10^(len(t2$))
  17. vldc=val(t1$)+(val(t2$)/t3)
  18. end function
  19. dim chfq[16],chvl[16]
  20. finp$="_.csv"
  21. if argc>2 then:finp$=argv(2):end if
  22. print"56676D20 ;- vgm"
  23. print"FFFFFF0F ;- eof"
  24. print"60010000 ;- version"
  25. print"00000000 ;- 999E3600 ;- sn clock ;- tirar"
  26. print"00000000 ;- "
  27. print"0A080000 ;- gd3"
  28. print"30130800 ;- total samples"
  29. print"67000000 ;- loop offset"
  30. print"00000000 ;- "
  31. print"3C000000 ;- rate"
  32. print"09001000 ;- flag bits"
  33. print"B60A7500 ;- ym2612 clock"
  34. print"00000000 ;- "
  35. print"4C000000 ;- vgm data offset"
  36. print"00000000000000000000000000000000"
  37. print"00000000000000000000000000000000"
  38. print"00000000000000000000000000000000"
  39. print"00000000000000000000000000000000"
  40. print"0000000000000000"
  41. print""
  42. print"522208 522700"
  43. print"52B4C0 52B5C0 52B6C0"
  44. print"53B4C0 53B5C0 53B6C0"
  45. print"522800 522801 522802 522803 522804 522805 522806"
  46. 'print"509F 50BF 50DF 50FF"
  47. print"523131 524119 52511F 526100 527100 528100 529100"
  48. print"523502 52450F 52551F 526500 527500 528506 529500"
  49. print"523975 52490F 52591F 526900 527900 528906 529900"
  50. print"523D08 524D0F 525D1F 526D00 527D00 528D06 529D00"
  51. print"52B136 52A51A 52A1D3 5228F1 "
  52. print"523231 524219 52521F 526200 527200 528200 529200"
  53. print"523602 52460F 52561F 526600 527600 528606 529600"
  54. print"523A75 524A0F 525A1F 526A00 527A00 528A06 529A00"
  55. print"523E08 524E0F 525E1F 526E00 527E00 528E06 529E00"
  56. print"52B236 52A61B 52A22B 5228F2"
  57. print"533031 534019 53501F 536000 537000 538000 539000"
  58. print"533402 53440F 53541F 536400 537400 538406 539400"
  59. print"533875 53480F 53581F 536800 537800 538806 539800"
  60. print"533C08 534C0F 535C1F 536C00 537C00 538C06 539C00"
  61. print"53B036 53A41B 53A05B 5228F4"
  62. print"533131 534119 53511F 536100 537100 538100 539100"
  63. print"533502 53450F 53551F 536500 537500 538506 539500"
  64. print"533975 53490F 53591F 536900 537900 538906 539900"
  65. print"533D08 534D0F 535D1F 536D00 537D00 538D06 539D00"
  66. print"53B136 53A51B 53A1C5 5228F5 "
  67. print"533231 534219 53521F 536200 537200 538200 539200 "
  68. print"533602 53460F 53561F 536600 537600 538606 539600"
  69. print"533A75 534A0F 535A1F 536A00 537A00 538A06 539A00"
  70. print"533E08 534E0F 535E1F 536E00 537E00 538E06 539E00"
  71. print"53B236 53A61C 53A23B 5228F6 61D089"
  72. print""
  73. print"523031 524019 52501F 526000 527000 528000 529000"
  74. print"523402 52440F 52541F 526400 527400 528406 529400"
  75. print"523875 52480F 52581F 526800 527800 528806 529800"
  76. print"523C08 524C0F 525C1F 526C00 527C00 528C06 529C00 "
  77. print"52B036 52A41A 52A084"
  78. print"5228F0 522801 522802 522804 522805 522806"
  79. lct=0
  80. open finp$ for input as #1
  81. while eof(1)=0
  82. file input #1,txrd$
  83. setcaption("b:"+str$(lct)):lct+=1
  84. if mid$(txrd$,1,1)="[" then:
  85. if mid$(txrd$,2,1)="f" then:
  86. chid=val(mid$(txrd$,3,2))
  87. chid=chid mod 6 'ym2612 has 6 channels
  88. chfqv=vldc(lstinf$(txrd$,":","]"))
  89. chfqvo=int(chfqv)
  90. if chfqvo<1 then:chfqvo=1:end if
  91. if chfqvo>8 then:chfqvo=8:end if
  92. chfqvf=chfqv-chfqvo
  93. chfqv3=int(644*2^chfqvf)
  94. chfqv3a=chfqv3 mod 256
  95. chfqv3b=int(chfqv3/256)
  96. chfqv5=(chfqvo*8+chfqv3b)
  97. chfqv2=int(26.6984611843*2^(8-chfqv))
  98. if chfqv2>2047 then:chfqv2=2047:end if
  99. if chfqv2<0 then:chfqv2=0:end if
  100. chchrfq$=right$("000"+hex$(chfqv2),3)
  101. txrgo$="52280"+right$("0"+hex$(chid),1)
  102. txrgo$+=" 52A4"+right$("00"+hex$(chfqv5),2)
  103. txrgo$+=" 52A0"+right$("00"+hex$(chfqv3a),2)
  104. txrgo$+=" 5228F"+right$("0"+hex$(chid),1)
  105. print ucase$(txrgo$)
  106. end if
  107. if mid$(txrd$,2,1)="v" then:
  108. chid=val(mid$(txrd$,3,2))
  109. chid=chid mod 6 'ym2612 has 6 channels
  110. chvlv=vldc(lstinf$(txrd$,":","]"))*0x10
  111. chchrvl$=right$("00"+hex$(chvlv),2)
  112. txrgo$="A0"+right$("00"+hex$(8+chid),2)+chchrvl$
  113. print ucase$(txrgo$)
  114. end if
  115. if mid$(txrd$,2,3)="wvb" then:
  116. wvblv=vldc(lstinf$(txrd$,":","]"))
  117. wvblv2=wvblv*44100
  118. wvblv3a=wvblv2 mod 65536
  119. wvblv3b=int(wvblv2/65536)
  120. wvblv3as$=ucase$(right$("0000"+hex$(wvblv3a),4))
  121. for ii=1 to wvblv3b:print"61FFFF":next
  122. print "61"+mid$(wvblv3as$,3,2)+mid$(wvblv3as$,1,2)
  123. end if
  124. end if
  125. wend
  126. print:print "66":print
  127. close #1