/* A mod. reader * * By, James Atwill * * Works with most standard MOD. formats. * * Will Identify David Whittaker modules (kind of). * Recognizes, but doesn't parse MED modules. (Will tell Module Type) * Works with NoiseTracker modules. * Works with ProTracker Modules. * Will Identify name, but not tracks / samples of Old SoundTracker Modules. * Will Identify name and author of FTM mods. * Works on XPK mods. Displays type and uncompressed size in []'s. * Automatically add filecomments to module. (Use: rx ModNAme F) * List Sample Names. (Use: rx ModNAme V) * (To use both: rx ModName VF) * */ parse arg modname verb verb=strip(upper(verb),'B') if pos('V',verb)>0 then verbose=1 else verbose=0 fcomment=0 if pos('F',verb)>0 then fcomment=1 if ~exists(modname) then exit 5 call open('fp',modname,'r') txt=readch('fp',20) modfilename=modname DidXPK=0 if left(txt,4)="XPKF" then do siz=substr(txt,13,4) XPKorigsize=c2d(siz) XPKtype=upper(strip(substr(txt,9,4),'B')) call close('fp') call rename(modname,modname||".1") ADDRESS "COMMAND" 'xpack >NIL: FILE='||modname||'.1 SUFFIX=.1' DidXPK=1 call open('fp',modname,'R') txt=readch('fp',20) End OutText="Unknown Mod Format" /* Is it? I looked at a few, and they all started with this.. */ if left(txt,5)="Hgq~a" then do outtext="David Whittaker Module" call DoExit End if left(txt,3)="MMD" then do if substr(txt,4,1)="0" then do outtext="Old Style MED Module" call DoExit End if Substr(txt,4,1)="1" then do outtext="New Style MED Module" call DoExit End outtext="MED Module - Unknown Version" call DoExit End If left(txt,4)="FTMN" then do tit=strip(substr(txt,17,100),'B') txt2=readch('fp',28) tit=tit||txt2 tit=strip(tit,'B') aut=strip(readch('fp',29),'B') tit=strip(compress(tit,'0'x),'B') aut=strip(compress(aut,'0'x),'B') outtext="FTM: Title: "||tit||" Author: "||aut call DoExit end txt=strip(compress(txt,'0'x),'B') modname=txt samples=0 do i = 1 to 31 txt=readch('fp',22) txt=strip(compress(txt,'0'x),'B') /* Trim padding NULs */ if left(txt,1)='f0'x then do outtext= "Name: `"||modname||"' -> Old SoundTracker Module." call DoExit End txt=left(txt,22) len=readch('fp',2) x=readch('fp',6) /* FineTune, Volume, RepeatRate, Repeat Length */ len2=c2d(len) len2=len2*2 /* Stored in WORDs */ if len2>0 then do if verbose then say "Sample #"||right(i,2)||": "||txt||" Bytes: "||len2 samples=samples+1 End End part2: len=c2d(readch('fp',1)) /* Song Length, 1-128 */ x=readch('fp',129) /* '127', Song positions, IDCode. */ if samples=0 | len=0 then call DoExit outtext= "Name: "||modname||" Samps: "||left(samples,3)||" Trks: "||len call close('fp') DoExit: call close('fp') if DidXPK=1 then do call delete(modfilename) call rename(modfilename||".1",modfilename) outtext="["||XPKtype||" "||XPKorigsize||"] "||outtext End if fcomment=1 then do pout="" do i = 1 to length(outtext) x=substr(outtext,i,1) if x='"' then x='*"' pout=pout||x End cmd="" cmd='filenote '||modfilename||' "'||pout||'"' ADDRESS "COMMAND" cmd End say outtext exit