converter_b_ym2612x2_1b.sdlbas 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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"B60A7540 ;- 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"523131 524119 52511F 526100 527100 528100 529100"
  47. print"523502 52450F 52551F 526500 527500 528506 529500"
  48. print"523975 52490F 52591F 526900 527900 528906 529900"
  49. print"523D08 524D0F 525D1F 526D00 527D00 528D06 529D00"
  50. print"52B136 52A51A 52A1D3 5228F1 "
  51. print"523231 524219 52521F 526200 527200 528200 529200"
  52. print"523602 52460F 52561F 526600 527600 528606 529600"
  53. print"523A75 524A0F 525A1F 526A00 527A00 528A06 529A00"
  54. print"523E08 524E0F 525E1F 526E00 527E00 528E06 529E00"
  55. print"52B236 52A61B 52A22B 5228F2"
  56. print"533031 534019 53501F 536000 537000 538000 539000"
  57. print"533402 53440F 53541F 536400 537400 538406 539400"
  58. print"533875 53480F 53581F 536800 537800 538806 539800"
  59. print"533C08 534C0F 535C1F 536C00 537C00 538C06 539C00"
  60. print"53B036 53A41B 53A05B 5228F4"
  61. print"533131 534119 53511F 536100 537100 538100 539100"
  62. print"533502 53450F 53551F 536500 537500 538506 539500"
  63. print"533975 53490F 53591F 536900 537900 538906 539900"
  64. print"533D08 534D0F 535D1F 536D00 537D00 538D06 539D00"
  65. print"53B136 53A51B 53A1C5 5228F5 "
  66. print"533231 534219 53521F 536200 537200 538200 539200 "
  67. print"533602 53460F 53561F 536600 537600 538606 539600"
  68. print"533A75 534A0F 535A1F 536A00 537A00 538A06 539A00"
  69. print"533E08 534E0F 535E1F 536E00 537E00 538E06 539E00"
  70. print"53B236 53A61C 53A23B 5228F6 61D089"
  71. print"523031 524019 52501F 526000 527000 528000 529000"
  72. print"523402 52440F 52541F 526400 527400 528406 529400"
  73. print"523875 52480F 52581F 526800 527800 528806 529800"
  74. print"523C08 524C0F 525C1F 526C00 527C00 528C06 529C00 "
  75. print"52B036 52A41A 52A084"
  76. print"5228F0 522801 522802 522804 522805 522806"
  77. print"A22208 A22700"
  78. print"A2B4C0 A2B5C0 A2B6C0"
  79. print"A3B4C0 A3B5C0 A3B6C0"
  80. print"A22800 A22801 A22802 A22803 A22804 A22805 A22806"
  81. print"A23131 A24119 A2511F A26100 A27100 A28100 A29100"
  82. print"A23502 A2450F A2551F A26500 A27500 A28506 A29500"
  83. print"A23975 A2490F A2591F A26900 A27900 A28906 A29900"
  84. print"A23D08 A24D0F A25D1F A26D00 A27D00 A28D06 A29D00"
  85. print"A2B136 A2A51A A2A1D3 A228F1 "
  86. print"A23231 A24219 A2521F A26200 A27200 A28200 A29200"
  87. print"A23602 A2460F A2561F A26600 A27600 A28606 A29600"
  88. print"A23A75 A24A0F A25A1F A26A00 A27A00 A28A06 A29A00"
  89. print"A23E08 A24E0F A25E1F A26E00 A27E00 A28E06 A29E00"
  90. print"A2B236 A2A61B A2A22B A228F2"
  91. print"A33031 A34019 A3501F A36000 A37000 A38000 A39000"
  92. print"A33402 A3440F A3541F A36400 A37400 A38406 A39400"
  93. print"A33875 A3480F A3581F A36800 A37800 A38806 A39800"
  94. print"A33C08 A34C0F A35C1F A36C00 A37C00 A38C06 A39C00"
  95. print"A3B036 A3A41B A3A05B A228F4"
  96. print"A33131 A34119 A3511F A36100 A37100 A38100 A39100"
  97. print"A33502 A3450F A3551F A36500 A37500 A38506 A39500"
  98. print"A33975 A3490F A3591F A36900 A37900 A38906 A39900"
  99. print"A33D08 A34D0F A35D1F A36D00 A37D00 A38D06 A39D00"
  100. print"A3B136 A3A51B A3A1C5 A228F5 "
  101. print"A33231 A34219 A3521F A36200 A37200 A38200 A39200 "
  102. print"A33602 A3460F A3561F A36600 A37600 A38606 A39600"
  103. print"A33A75 A34A0F A35A1F A36A00 A37A00 A38A06 A39A00"
  104. print"A33E08 A34E0F A35E1F A36E00 A37E00 A38E06 A39E00"
  105. print"A3B236 A3A61C A3A23B A228F6 61D089"
  106. print"A23031 A24019 A2501F A26000 A27000 A28000 A29000"
  107. print"A23402 A2440F A2541F A26400 A27400 A28406 A29400"
  108. print"A23875 A2480F A2581F A26800 A27800 A28806 A29800"
  109. print"A23C08 A24C0F A25C1F A26C00 A27C00 A28C06 A29C00 "
  110. print"A2B036 A2A41A A2A084"
  111. print"A228F0 A22801 A22802 A22804 A22805 A22806"
  112. lct=0
  113. open finp$ for input as #1
  114. while eof(1)=0
  115. file input #1,txrd$
  116. setcaption("b:"+str$(lct)):lct+=1
  117. if mid$(txrd$,1,1)="[" then:
  118. if mid$(txrd$,2,1)="f" then:
  119. chid=val(mid$(txrd$,3,2))
  120. chid=chid mod 12 'ym2612x2 has 12 channels
  121. chfqv=vldc(lstinf$(txrd$,":","]"))
  122. chfqvo=int(chfqv)
  123. if chfqvo<1 then:chfqvo=1:end if
  124. if chfqvo>8 then:chfqvo=8:end if
  125. chfqvf=chfqv-chfqvo
  126. chfqv3=int(644*2^chfqvf)
  127. chfqv3a=chfqv3 mod 256
  128. chfqv3b=int(chfqv3/256)
  129. chfqv5=(chfqvo*8+chfqv3b)
  130. chfqv2=int(26.6984611843*2^(8-chfqv))
  131. if chfqv2>2047 then:chfqv2=2047:end if
  132. if chfqv2<0 then:chfqv2=0:end if
  133. chchrfq$=right$("000"+hex$(chfqv2),3)
  134. if int(chid/6)=0 then:
  135. txrgo$="52280"+right$("0"+hex$((chid mod 6)),1)
  136. txrgo$+=" 52A4"+right$("00"+hex$(chfqv5),2)
  137. txrgo$+=" 52A0"+right$("00"+hex$(chfqv3a),2)
  138. txrgo$+=" 5228F"+right$("0"+hex$((chid mod 6)),1)
  139. else
  140. txrgo$="A2280"+right$("0"+hex$( (chid mod 6) ),1)
  141. txrgo$+=" A2A4"+right$("00"+hex$(chfqv5),2)
  142. txrgo$+=" A2A0"+right$("00"+hex$(chfqv3a),2)
  143. txrgo$+=" A228F"+right$("0"+hex$((chid mod 6)),1)
  144. end if
  145. print ucase$(txrgo$)
  146. end if
  147. 'if mid$(txrd$,2,1)="v" then:
  148. ' chid=val(mid$(txrd$,3,2))
  149. ' chid=chid mod 12 'ym2612x2 has 12 channels
  150. ' chvlv=vldc(lstinf$(txrd$,":","]"))*0x10
  151. ' chchrvl$=right$("00"+hex$(chvlv),2)
  152. ' txrgo$="A0"+right$("00"+hex$(8+chid),2)+chchrvl$
  153. ' print ucase$(txrgo$)
  154. ' end if
  155. if mid$(txrd$,2,3)="wvb" then:
  156. wvblv=vldc(lstinf$(txrd$,":","]"))
  157. wvblv2=wvblv*44100
  158. wvblv3a=wvblv2 mod 65536
  159. wvblv3b=int(wvblv2/65536)
  160. wvblv3as$=ucase$(right$("0000"+hex$(wvblv3a),4))
  161. for ii=1 to wvblv3b:print"61FFFF":next
  162. print "61"+mid$(wvblv3as$,3,2)+mid$(wvblv3as$,1,2)
  163. end if
  164. end if
  165. wend
  166. print:print "66":print
  167. close #1