converter_b_ym2151_1b.sdlbas 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. dim wlt[16]
  21. wlt[0]=0 '
  22. wlt[1]=1
  23. wlt[2]=3 '
  24. wlt[3]=4
  25. wlt[4]=5 '
  26. wlt[5]=7 '
  27. wlt[6]=8
  28. wlt[7]=9 '
  29. wlt[8]=11
  30. wlt[9]=12 '
  31. wlt[10]=13
  32. wlt[11]=15 '
  33. wlt[12]=15
  34. wlt[13]=15
  35. wlt[14]=15
  36. wlt[15]=15
  37. ' 0 2 3 4 6 7 8 10 11 12 14 15
  38. finp$="_.csv"
  39. if argc>2 then:finp$=argv(2):end if
  40. print"56676D20"
  41. print"FFFFFF0F"
  42. print"60010000"
  43. print"0000000000000000"
  44. print"D50B0000"
  45. print"50D80400"
  46. print"67000000"
  47. print"00000000"
  48. print"3C000000"
  49. print"0000000000000000"
  50. print"999E3600"
  51. print"4C000000"
  52. print"00000000000000000000000000000000"
  53. print"00000000000000000000000000000000"
  54. print"00000000000000000000000000000000"
  55. print"00000000000000000000000000000000"
  56. print"0000000000000000"
  57. print""
  58. print";- registers reset?"
  59. print"540102 541800 541B00 5419FF 54197F "
  60. print"540800 5420C0 54607F 54687F 54707F 54787F "
  61. print"540801 5421C0 54617F 54697F 54717F 54797F "
  62. print"540802 5422C0 54627F 546A7F 54727F 547A7F "
  63. print"540803 5423C0 54637F 546B7F 54737F 547B7F "
  64. print"540804 5424C0 54647F 546C7F 54747F 547C7F "
  65. print"540805 5425C0 54657F 546D7F 54757F 547D7F "
  66. print"540806 5426C0 54667F 546E7F 54767F 547E7F "
  67. print"540807 5427C0 54677F 546F7F 54777F 547F7F"
  68. print""
  69. print";-?"
  70. print"C002007F C003007F C00A007F C00B007F"
  71. print"C012007F C013007F C01A007F C01B007F"
  72. print"C022007F C023007F"
  73. print""
  74. print";- instruments?"
  75. print"544032 54601D 54800E 54A00E 54C000 54E04A"
  76. print"544851 546816 54880E 54A80E 54C800 54E83A"
  77. print"545051 547019 549014 54B000 54D000 54F00A"
  78. print"545831 54781E 549814 54B802 54D801 54F83A"
  79. print"5420FB 543800 540878 542800 543000"
  80. print"544132 54611D 54810E 54A10E 54C100 54E14A"
  81. print"544951 546916 54890E 54A90E 54C900 54E93A"
  82. print"545151 547119 549114 54B100 54D100 54F10A"
  83. print"545931 54791E 549914 54B902 54D901 54F93A"
  84. print"5421FB 543900 540879 54290E 543100"
  85. print"544232 54621D 54820E 54A20E 54C200 54E24A"
  86. print"544A51 546A16 548A0E 54AA0E 54CA00 54EA3A"
  87. print"545251 547219 549214 54B200 54D200 54F20A"
  88. print"545A31 547A1E 549A14 54BA02 54DA01 54FA3A"
  89. print"5422FB 543A00 54087A 542A1E 543200"
  90. print"544332 54631D 54830E 54A30E 54C300 54E34A"
  91. print"544B51 546B16 548B0E 54AB0E 54CB00 54EB3A"
  92. print"545351 547319 549314 54B300 54D300 54F30A"
  93. print"545B31 547B1E 549B14 54BB02 54DB01 54FB3A"
  94. print"5423FB 543B00 54087B 542B2E 543300"
  95. print"544432 54641D 54840E 54A40E 54C400 54E44A"
  96. print"544C51 546C16 548C0E 54AC0E 54CC00 54EC3A"
  97. print"545451 547419 549414 54B400 54D400 54F40A"
  98. print"545C31 547C1E 549C14 54BC02 54DC01 54FC3A"
  99. print"5424FB 543C00 54087C 542C3E 543400"
  100. print"544532 54651D 54850E 54A50E 54C500 54E54A"
  101. print"544D51 546D16 548D0E 54AD0E 54CD00 54ED3A"
  102. print"545551 547519 549514 54B500 54D500 54F50A"
  103. print"545D31 547D1E 549D14 54BD02 54DD01 54FD3A"
  104. print"5425FB 543D00 54087D 542D4E 543500"
  105. print"544632 54661D 54860E 54A60E 54C600 54E64A"
  106. print"544E51 546E16 548E0E 54AE0E 54CE00 54EE3A"
  107. print"545651 547619 549614 54B600 54D600 54F60A"
  108. print"545E31 547E1E 549E14 54BE02 54DE01 54FE3A"
  109. print"5426FB 543E00 54087E 542E5E 543600"
  110. print"544732 54671D 54870E 54A70E 54C700 54E74A "
  111. print"544F51 546F16 548F0E 54AF0E 54CF00 54EF3A "
  112. print"545751 547719 549714 54B700 54D700 54F70A "
  113. print"545F31 547F1E 549F14 54BF02 54DF01 54FF3A "
  114. print"5427FB 543F00 54087F 542F6E 543700"
  115. lct=0
  116. open finp$ for input as #1
  117. while eof(1)=0
  118. file input #1,txrd$
  119. setcaption("b:"+str$(lct)):lct+=1
  120. if mid$(txrd$,1,1)="[" then:
  121. if mid$(txrd$,2,1)="f" then:
  122. chid=val(mid$(txrd$,3,2))
  123. chid=chid mod 8 'ym2151 has 8 channels
  124. chfqv=vldc(lstinf$(txrd$,":","]"))
  125. chfqv-=(2/12) '- <- c
  126. chfqvo=int(chfqv)
  127. 'if chfqvo<1 then:chfqvo=1:end if
  128. 'if chfqvo>8 then:chfqvo=8:end if
  129. chfqvf=chfqv-chfqvo
  130. chfqv1a1=chfqvf*12
  131. chfqv1a2=int(chfqv1a1)
  132. 'chfqv1a2b=chfqv1a2+int((chfqv1a2+2)/3) '- <-
  133. chfqv1a2b=wlt[chfqv1a2] '- <-
  134. chfqv1a3=chfqv1a1-chfqv1a2
  135. chfqv1a3b=(int(chfqv1a3*64))*4
  136. 'chfqv3=int(644*2^chfqvf)
  137. 'chfqv3a=chfqv3 mod 256
  138. 'chfqv3b=int(chfqv3/256)
  139. 'chfqv5=(chfqvo*8+chfqv3b)
  140. 'chfqv2=int(26.6984611843*2^(8-chfqv))
  141. 'if chfqv2>2047 then:chfqv2=2047:end if
  142. 'if chfqv2<0 then:chfqv2=0:end if
  143. 'chchrfq$=right$("000"+hex$(chfqv2),3)
  144. txrgo$="54080"+right$("0"+hex$(chid),1)
  145. txrgo$+=" 54087"+right$("0"+hex$(8+chid),1)
  146. txrgo$+=" 542"+right$("0"+hex$(8+chid),1)+right$("0"+hex$(chfqvo),1)+right$("0"+hex$(chfqv1a2b),1)
  147. txrgo$+=" 543"+right$("0"+hex$(chid),1)+right$("00"+hex$(chfqv1a3b),2)
  148. 'txrgo$+=" 54A4"+right$("00"+hex$(chfqv5),2)
  149. 'txrgo$+=" 54A0"+right$("00"+hex$(chfqv3a),2)
  150. 'txrgo$+=" 5428F"+right$("0"+hex$(chid),1)
  151. print ucase$(txrgo$)
  152. end if
  153. 'if mid$(txrd$,2,1)="v" then:
  154. ' chid=val(mid$(txrd$,3,2))
  155. ' chid=chid mod 8 'ym2151 has 8 channels
  156. ' chvlv=vldc(lstinf$(txrd$,":","]"))*0x10
  157. ' chchrvl$=right$("00"+hex$(chvlv),2)
  158. ' txrgo$="A0"+right$("00"+hex$(8+chid),2)+chchrvl$
  159. ' print ucase$(txrgo$)
  160. ' end if
  161. if mid$(txrd$,2,3)="wvb" then:
  162. wvblv=vldc(lstinf$(txrd$,":","]"))
  163. wvblv2=wvblv*44100
  164. wvblv3a=wvblv2 mod 65536
  165. wvblv3b=int(wvblv2/65536)
  166. wvblv3as$=ucase$(right$("0000"+hex$(wvblv3a),4))
  167. for ii=1 to wvblv3b:print"61FFFF":next
  168. print "61"+mid$(wvblv3as$,3,2)+mid$(wvblv3as$,1,2)
  169. end if
  170. end if
  171. wend
  172. print:print "66":print
  173. close #1
  174. '
  175. ' 0 1 2 3 4 5 6 7 8 9 10 11
  176. ' -2 0 1 2 4 5 6 8 9 10 12 13
  177. ' 0 2 3 4 6 7 8 10 11 12 14 15
  178. ' 0 1 1 1 2 2 2 3 3 3 4 4
  179. ' n+int((n+2)/3)
  180. '