123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- '- frequencies are innacurate
- function lstinf$(a$,b$,c$)
- adra=1:adrb=1:blngt=len(b$):d$=""
- while adrb<=blngt
- if mid$ (a$,adra,1)=mid$ (b$,adrb,1) then:adrb+=1:end if
- adra=adra+1
- end while
- while mid$(a$,adra,1)<>left$(c$,1)
- d$=d$+mid$(a$,adra,1):adra=adra+1
- end while
- lstinf$=d$
- end function
- function vldc(a$)
- t0$="!"+a$+".0.0.0."
- t1$=lstinf$(t0$,"!",".")
- t2$=lstinf$(t0$,".",".")
- t3=10^(len(t2$))
- vldc=val(t1$)+(val(t2$)/t3)
- end function
- dim chfq[16],chvl[16]
- finp$="_.csv"
- if argc>2 then:finp$=argv(2):end if
- print"56676D20"
- print"FFFFFF00"
- print"71010000"
- print"0000000000000000"
- print"2F023000"
- print"34DA3000"
- print"0000000000000000"
- print"3C000000"
- print"000000000000000000000000"
- print"AC000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00000000000000000000000000000000"
- print"00127A40"
- print"00000000000000000000000000000000"
- print"00000000"
- print"BD1C01 ;- saa1099: register 1C: frequency reset, sound enable"
- print"BD143F ;- saa1099: frequency enable %00111111"
- print"BD1500 ;- saa1099: noise enable %00000000"
- print"BD1840 ;- saa1099: envelope generator 0"
- print"BD1940 ;- saa1099: envelope generator 1"
- print"BD0800 ;- saa1099: frequency channel 0"
- print"BD0900 ;- saa1099: frequency channel 1"
- print"BD0A00 ;- saa1099: frequency channel 2"
- print"BD0B00 ;- saa1099: frequency channel 3"
- print"BD0C00 ;- saa1099: frequency channel 4"
- print"BD0D00 ;- saa1099: frequency channel 5"
- print"BD1000 ;- saa1099: octave channels 0 and 1"
- print"BD1100 ;- saa1099: octave channels 2 and 3"
- print"BD1200 ;- saa1099: octave channels 4 and 5"
- print"BD0000 ;- saa1099: volume channel 0"
- print"BD0100 ;- saa1099: volume channel 1"
- print"BD0200 ;- saa1099: volume channel 2"
- print"BD0300 ;- saa1099: volume channel 3"
- print"BD0400 ;- saa1099: volume channel 4"
- print"BD0500 ;- saa1099: volume channel 5"
- print"BD9C01 ;- saa1099: register 1C: frequency reset, sound enable"
- print"BD943F ;- saa1099: frequency enable %00111111"
- print"BD9500 ;- saa1099: noise enable %00000000"
- print"BD9840 ;- saa1099: envelope generator 0"
- print"BD9940 ;- saa1099: envelope generator 1"
- print"BD8800 ;- saa1099: frequency channel 0"
- print"BD8900 ;- saa1099: frequency channel 1"
- print"BD8A00 ;- saa1099: frequency channel 2"
- print"BD8B00 ;- saa1099: frequency channel 3"
- print"BD8C00 ;- saa1099: frequency channel 4"
- print"BD8D00 ;- saa1099: frequency channel 5"
- print"BD9000 ;- saa1099: octave channels 0 and 1"
- print"BD9100 ;- saa1099: octave channels 2 and 3"
- print"BD9200 ;- saa1099: octave channels 4 and 5"
- print"BD8000 ;- saa1099: volume channel 0"
- print"BD8100 ;- saa1099: volume channel 1"
- print"BD8200 ;- saa1099: volume channel 2"
- print"BD8300 ;- saa1099: volume channel 3"
- print"BD8400 ;- saa1099: volume channel 4"
- print"BD8500 ;- saa1099: volume channel 5"
- lct=0
- dim octtm[16]:dim octou[16]
- open finp$ for input as #1
- while eof(1)=0
- file input #1,txrd$
- setcaption("b:"+str$(lct)):lct+=1
- if mid$(txrd$,1,1)="[" then:
- if mid$(txrd$,2,1)="f" then:
- chid=val(mid$(txrd$,3,2))
- chid=chid mod 12 'saa1099x2 has 12 channels
- chfqv=vldc(lstinf$(txrd$,":","]"))
- freq=16.35159783129*2^chfqv
- chfqvoc=8-int( log(15625/freq)/log(2) )
- chfqvnt=511-int(((15625 *(2^chfqvoc) )/freq))
- octtm[chid]=chfqvoc mod 16
- octou[int(chid/2)]=octtm[int(chid/2)*2+1]*16+octtm[int(chid/2)*2]
- if int (chid/6)=0 then
- txrgo$="BD"+right$("00"+hex$(8+(chid mod 6)),2)+right$("00"+hex$(chfqvnt),2)
- txrgo$+=" BD"+right$("00"+hex$(16+int((chid mod 6)/2)),2)+right$("00"+hex$(octou[int(chid/2)]),2)
- else
- txrgo$="BD"+right$("00"+hex$(128+8+(chid mod 6)),2)+right$("00"+hex$(chfqvnt),2)
- txrgo$+=" BD"+right$("00"+hex$(128+16+int((chid mod 6)/2)),2)+right$("00"+hex$(octou[int(chid/2)]),2)
- end if
- print ucase$(txrgo$)
- end if
- if mid$(txrd$,2,1)="v" then:
- chid=val(mid$(txrd$,3,2))
- chid=chid mod 12 'saa1099x2 has 12 channels
- chvlv=vldc(lstinf$(txrd$,":","]"))*0x10
- chvlv=int(chvlv) mod 0x10
- chchrvl$=right$("00"+hex$(chvlv*0x11),2)
- if int (chid/6)=0 then
- txrgo$="BD"+right$("00"+hex$(chid mod 6),2)+chchrvl$
- else
- txrgo$="BD"+right$("00"+hex$(128+(chid mod 6)),2)+chchrvl$
- end if
- print ucase$(txrgo$)
- end if
- if mid$(txrd$,2,3)="wvb" then:
- wvblv=vldc(lstinf$(txrd$,":","]"))
- wvblv2=wvblv*44100
- wvblv3a=wvblv2 mod 65536
- wvblv3b=int(wvblv2/65536)
- wvblv3as$=ucase$(right$("0000"+hex$(wvblv3a),4))
- for ii=1 to wvblv3b:print"61FFFF":next
- print "61"+mid$(wvblv3as$,3,2)+mid$(wvblv3as$,1,2)
- end if
- end if
- wend
- print:print "66":print
- close #1
- 'from Simon Owen
- ' freq=(15625*(2^octave))/(511-note)
- ' octave=8-int(log2(15625/freq))
- ' note=511-int(((15625<<octave)/freq))
- 'octave=8-int( log(15625/freq)/log(2) )
- 'note=511-int(((15625 *(2^octave) )/freq))
- '16.35159783129*2^((9/12)+4) = 440hz
|