Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/sdlbrt
- finp$="MrGoemon_Arcade_02_Stage1.vgm"
- fout2$=finp$+"_vt.txt"
- fout3$=finp$+"_vt_debug.txt"
- frmc=0:frmi=735:frmr=300:trg=0
- ltxtm$="....|..|--- .... ....|--- .... ....|--- .... ...."
- ltxcr$=ltxtm$
- freq0=0:freq1=0:freq2=0
- vol0=0:vol1=0:vol2=0
- freqq=0:debug=0
- patsz=64:patc=0:patid=0
- hdram=0x40:vgmv=0
- dim hdrv[256]
- '- fix: 0x0FE=440hz=A-4
- function nttfrq$(freqb)
- e$= "C-1C#1D-1D#1E-1F-1F#1G-1G#1A-1A#1B-1"
- e$=e$+"C-2C#2D-2D#2E-2F-2F#2G-2G#2A-2A#2B-2"
- e$=e$+"C-3C#3D-3D#3E-3F-3F#3G-3G#3A-3A#3B-3"
- e$=e$+"C-4C#4D-4D#4E-4F-4F#4G-4G#4A-4A#4B-4"
- e$=e$+"C-5C#5D-5D#5E-5F-5F#5G-5G#5A-5A#5B-5"
- e$=e$+"C-6C#6D-6D#6E-6F-6F#6G-6G#6A-6A#6B-6"
- e$=e$+"C-7C#7D-7D#7E-7F-7F#7G-7G#7A-7A#7B-7"
- e$=e$+"C-8C#8D-8D#8E-8F-8F#8G-8G#8A-8A#8B-8"
- tmq=141-(int((log(freqb)/log(2))*12))
- if tmq<1 then:tmq=1:end if
- if tmq>96 then:tmq=96:end if
- return mid$(e$,(tmq*3)-2,3)
- end function
- open finp$ for input as #1
- for i=0 to 255
- hdrv[i]=readbyte(1)
- next
- close #1
- hdram=0x040
- vgmv=hdrv[8]+hdrv[9]*256
- if vgmv>=0x0150 then:hdram=0x080:end if
- if vgmv>=0x0170 then:hdram=0x100:end if
- ttsam=hdrv[0x18]+hdrv[0x19]*256+hdrv[0x1A]*65536+hdrv[0x1B]*16777216
- hsam$="PlayOrder=L0"
- for i=1 to (ttsam/(frmi*patsz))-1
- hsam$=hsam$+","+str$(i)
- next
- open finp$ for input as #1
- open fout2$ for output as #2
- open fout3$ for output as #3
- print #2,"[Module]"
- print #2,"VortexTrackerII=1"
- print #2,"Version=3.6"
- print #2,"Title="
- print #2,"Author="
- print #2,"NoteTable=2"
- print #2,"Speed=1"
- print #2,hsam$
- print #2," "
- print #2,"[Ornament1]":print #2,"L0":print #2," "
- print #2,"[Sample1]":print #2,"Tne +000_ +00_ F_ L":print #2," "
- print #2,"[Pattern0]"
- '- the amount of header bytes depends on vgm format version
- for eee=0 to hdram-1:q0=readbyte(1):next '- read offset byte first
- txou1$=" #("+str$(0)+")"
- while eof(1)=0
- q0=readbyte(1)
- '- delay 1 byte (1..16 samples)
- if bitwiseand(q0,0xF0)=0x70 then
- frmc=frmc+bitwiseand(q0,0xF)+1
- txou1$=" #("+str$(frmc)+")"
- 'print #3,txou1$
- end if
- '- delay 3 bytes (0..65535 samples)
- if q0=0x61 then
- q0=readbyte(1)
- frmc=frmc+q0
- q0=readbyte(1)
- frmc=frmc+(q0*256)
- txou1$=" #("+str$(frmc)+")"
- 'print #3,txou1$
- end if
- '- 1 ntsc frame delay, 735 samples
- if q0=0x62 then
- frmc=frmc+735
- txou1$=" #("+str$(frmc)+")"
- 'print #3,txou1$
- end if
- '- 1 pal frame delay, 882 samples
- if q0=0x63 then
- frmc=frmc+882
- txou1$=" #("+str$(frmc)+")"
- 'print #3,txou1$
- end if
- '- updates frameout pulses
- while frmr<frmc
- '- writes 1F in the first line of the first pattern
- if (patc<1 and patid=0) then
- ltxcr$=replace$(12,ltxcr$,"1F")
- ltxcr$=replace$(26,ltxcr$,"1F")
- ltxcr$=replace$(40,ltxcr$,"1F")
- end if
- '- creates a new pattern
- if patc>(patsz-1) then:
- print #2," "
- patid=patid+1:patc=0
- txou9$="[Pattern"+str$(patid)+"]"
- print #2,txou9$
- end if
- '- writes a pattern line in each frame
- if trg=0 then
- print #3,"--frameout-unchanged--"
- print #2,ltxtm$
- else
- print #3,"--frameout--"
- print #2,ltxcr$
- ltxcr$=ltxtm$
- trg=0
- end if
- frmr=frmr+frmi
- patc=patc+1
- end while
- if q0=0x50 then
- q0=readbyte(1)
- if bitwiseand (q0,128)=0 then
- '- channel 0 - coarse
- if freqq=0 then
- freq0= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq0,0x00F)) )
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(8,ltxtm1$,nttfrq$(freq0))
- ltxcr$=replace$(8,ltxcr$,nttfrq$(freq0))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- '- channel 1 - coarse
- if freqq=1 then
- freq1= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq1,0x00F)) )
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(22,ltxtm1$,nttfrq$(freq1))
- ltxcr$=replace$(22,ltxcr$,nttfrq$(freq1))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- '- channel 2 - coarse
- if freqq=2 then
- freq2= bitwiseor ( (bitwiseand(q0,0x3F))*16,(bitwiseand(freq2,0x00F)) )
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(36,ltxtm1$,nttfrq$(freq2))
- ltxcr$=replace$(36,ltxcr$,nttfrq$(freq2))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- end if
- if bitwiseand (q0,128)=128 then
- '- channel 0 - fine
- if bitwiseand (q0,0xF0)=0x80 then '- tone ch0
- freqq=0
- freq0= bitwiseor ( (bitwiseand(freq0,0xFF0)),(bitwiseand(q0,0x00F)) )
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(8,ltxtm1$,nttfrq$(freq0))
- ltxcr$=replace$(8,ltxcr$,nttfrq$(freq0))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- '- channel 1 - fine
- if bitwiseand (q0,0xF0)=0xA0 then '- tone ch1
- freqq=1
- freq1= bitwiseor ( (bitwiseand(freq1,0xFF0)),(bitwiseand(q0,0x00F)) )
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(22,ltxtm1$,nttfrq$(freq1))
- ltxcr$=replace$(22,ltxcr$,nttfrq$(freq1))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- '- channel 2 - fine
- if bitwiseand (q0,0xF0)=0xC0 then '- tone ch2
- freqq=2
- freq2= bitwiseor ( (bitwiseand(freq2,0xFF0)),(bitwiseand(q0,0x00F)) )
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(36,ltxtm1$,nttfrq$(freq2))
- ltxcr$=replace$(36,ltxcr$,nttfrq$(freq2))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- 'if bitwiseand (q0,0xF0)=0xE0 then '- freq noise
- ' end if
- '- channel 0 - volume
- if bitwiseand (q0,0xF0)=0x90 then '- volume ch0
- 'freqq=0
- vol0=15-bitwiseand(q0,0xF)
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(15,ltxtm1$,ucase$(right$(hex$(0x10+vol0),1)))
- ltxcr$=replace$(15,ltxcr$,ucase$(right$(hex$(0x10+vol0),1)))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- '- channel 1 - volume
- if bitwiseand (q0,0xF0)=0xB0 then '- volume ch1
- 'freqq=1
- vol1=15-bitwiseand(q0,0xF)
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(29,ltxtm1$,ucase$(right$(hex$(0x10+vol1),1)))
- ltxcr$=replace$(29,ltxcr$,ucase$(right$(hex$(0x10+vol1),1)))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- '- channel 2 - volume
- if bitwiseand (q0,0xF0)=0xD0 then '- volume ch2
- 'freqq=2
- vol2=15-bitwiseand(q0,0xF)
- ltxtm1$=ltxtm$
- ltxtm2$=replace$(43,ltxtm1$,ucase$(right$(hex$(0x10+vol2),1)))
- ltxcr$=replace$(43,ltxcr$,ucase$(right$(hex$(0x10+vol2),1)))
- print #3,ltxtm2$+" #("+str$(frmc)+")"
- trg=1
- end if
- 'if bitwiseand (q0,0xF0)=0xF0 then '- volume ch3
- ' end if
- end if
- end if
- wend
- close #1:close #2:close #3
- if debug=0 then:
- shell("rm "+fout3$)
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement