converter_b_saa1099_1a.sdlbas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. '- frequencies are innacurate
  2. function lstinf$(a$,b$,c$)
  3. adra=1:adrb=1:blngt=len(b$):d$=""
  4. while adrb<=blngt
  5. if mid$ (a$,adra,1)=mid$ (b$,adrb,1) then:adrb+=1:end if
  6. adra=adra+1
  7. end while
  8. while mid$(a$,adra,1)<>left$(c$,1)
  9. d$=d$+mid$(a$,adra,1):adra=adra+1
  10. end while
  11. lstinf$=d$
  12. end function
  13. function vldc(a$)
  14. t0$="!"+a$+".0.0.0."
  15. t1$=lstinf$(t0$,"!",".")
  16. t2$=lstinf$(t0$,".",".")
  17. t3=10^(len(t2$))
  18. vldc=val(t1$)+(val(t2$)/t3)
  19. end function
  20. dim chfq[16],chvl[16]
  21. finp$="_.csv"
  22. if argc>2 then:finp$=argv(2):end if
  23. print"56676D20"
  24. print"FFFFFF00"
  25. print"71010000"
  26. print"0000000000000000"
  27. print"2F023000"
  28. print"34DA3000"
  29. print"0000000000000000"
  30. print"3C000000"
  31. print"000000000000000000000000"
  32. print"AC000000"
  33. print"00000000000000000000000000000000"
  34. print"00000000000000000000000000000000"
  35. print"00000000000000000000000000000000"
  36. print"00000000000000000000000000000000"
  37. print"00000000000000000000000000000000"
  38. print"00000000000000000000000000000000"
  39. print"00000000000000000000000000000000"
  40. print"00000000000000000000000000000000"
  41. print"00000000000000000000000000000000"
  42. print"00127A00"
  43. print"00000000000000000000000000000000"
  44. print"00000000"
  45. print"BD1C01 ;- saa1099: register 1C: frequency reset, sound enable"
  46. print"BD143F ;- saa1099: frequency enable %00111111"
  47. print"BD1500 ;- saa1099: noise enable %00000000"
  48. print"BD1840 ;- saa1099: envelope generator 0"
  49. print"BD1940 ;- saa1099: envelope generator 1"
  50. print"BD0800 ;- saa1099: frequency channel 0"
  51. print"BD0900 ;- saa1099: frequency channel 1"
  52. print"BD0A00 ;- saa1099: frequency channel 2"
  53. print"BD0B00 ;- saa1099: frequency channel 3"
  54. print"BD0C00 ;- saa1099: frequency channel 4"
  55. print"BD0D00 ;- saa1099: frequency channel 5"
  56. print"BD1000 ;- saa1099: octave channels 0 and 1"
  57. print"BD1100 ;- saa1099: octave channels 2 and 3"
  58. print"BD1200 ;- saa1099: octave channels 4 and 5"
  59. print"BD0000 ;- saa1099: volume channel 0"
  60. print"BD0100 ;- saa1099: volume channel 1"
  61. print"BD0200 ;- saa1099: volume channel 2"
  62. print"BD0300 ;- saa1099: volume channel 3"
  63. print"BD0400 ;- saa1099: volume channel 4"
  64. print"BD0500 ;- saa1099: volume channel 5"
  65. lct=0
  66. dim octtm[16]:dim octou[16]
  67. open finp$ for input as #1
  68. while eof(1)=0
  69. file input #1,txrd$
  70. setcaption("b:"+str$(lct)):lct+=1
  71. if mid$(txrd$,1,1)="[" then:
  72. if mid$(txrd$,2,1)="f" then:
  73. chid=val(mid$(txrd$,3,2))
  74. chid=chid mod 6 'saa1099 has 6 channels
  75. chfqv=vldc(lstinf$(txrd$,":","]"))
  76. 'chfqv2=int((chfqv*256)+24)
  77. chfqv2=int((chfqv*256)-256+24) '--- ajustar
  78. chfqvoc=int(chfqv2/256)
  79. chfqvnt=chfqv2 mod 256
  80. octtm[chid]=chfqvoc mod 16
  81. octou[int(chid/2)]=octtm[int(chid/2)*2+1]*16+octtm[int(chid/2)*2]
  82. txrgo$="BD"+right$("00"+hex$(8+chid),2)+right$("00"+hex$(chfqvnt),2)
  83. txrgo$+=" BD"+right$("00"+hex$(16+int(chid/2)),2)+right$("00"+hex$(octou[int(chid/2)]),2)
  84. print ucase$(txrgo$)
  85. end if
  86. if mid$(txrd$,2,1)="v" then:
  87. chid=val(mid$(txrd$,3,2))
  88. chid=chid mod 6 'saa1099 has 6 channels
  89. chvlv=vldc(lstinf$(txrd$,":","]"))*0x10
  90. chvlv=int(chvlv) mod 0x10
  91. chchrvl$=right$("00"+hex$(chvlv*0x11),2)
  92. txrgo$="BD"+right$("00"+hex$(chid),2)+chchrvl$
  93. print ucase$(txrgo$)
  94. end if
  95. if mid$(txrd$,2,3)="wvb" then:
  96. wvblv=vldc(lstinf$(txrd$,":","]"))
  97. wvblv2=wvblv*44100
  98. wvblv3a=wvblv2 mod 65536
  99. wvblv3b=int(wvblv2/65536)
  100. wvblv3as$=ucase$(right$("0000"+hex$(wvblv3a),4))
  101. for ii=1 to wvblv3b:print"61FFFF":next
  102. print "61"+mid$(wvblv3as$,3,2)+mid$(wvblv3as$,1,2)
  103. end if
  104. end if
  105. wend
  106. print:print "66":print
  107. close #1