MOD Infomation Code

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

MOD Infomation Code

Post by BackupUser »

Restored from previous forum. Originally posted by Inner.

Another famiour tracker format, only does (M.K.) (Mahoney & Kaktus), I don't know about the other forms, haven't been game enough to have a look at it.

as always, the pattern data isn't read out, because it's beond me, I did have a stab at it, but it didn't work.

Code: Select all

;-----------------------------------------------------------------------------
;
; MOD - File Reader (M.K.) (Mahoney & Kaktus)
;
; ToDo:
; Pattern Decoding
;
; Based on:
; steinarm@ifi.uio.no (Steinar Midtskogen)
;
; Code : T.J.Roughton / (A.K.A) Innner
;
;-----------------------------------------------------------------------------
Dim notetable.s(256)
Dim smptable.l(32)
;  ByteSwap Returns Word, Cheated how ?, used the module file a buffer!
Procedure ByteSwap(*memptr,offset)
    hib=PeekB(*memptr+offset) : lob=PeekB(*memptr+offset+1)
    PokeB(*memptr+offset,lob) : PokeB(*memptr+offset+1,hib) ; Byte Swap  )*2
            WriteStringN("-------------------------------------------------")
            WriteStringN("Sample No.                  : "+Str(i))   ; NOT PART OF THE FORMAT!
            WriteStringN("Sample Name                 : "+smpname)
            WriteStringN("Sample Length               : "+Str(smplength))
            WriteStringN("Sample Fine Tune            : "+Str(smpfinetune))
            WriteStringN("Sample Volume               : "+Str(smpvol))
            WriteStringN("Sample Loop Start           : "+Str(smploops))
            WriteStringN("Sample Loop End             : "+Str(smploope))
            smpblock_length+smplength
            smptable(i)=smplength
            smpi+30
        Next
        WriteStringN("--------------------------- Patterns ---------------------------")
        pati=950
        songlength=PeekB(*memptr+pati)
        songlengthold=PeekB(*memptr+pati+1)
        pati=952
        For i=0 To songlength-1 ; 127
            songposts=PeekB(*memptr+pati+i)
            songp.s+Str(songposts)+","
        Next
        smpdata_start=fsize-smpblock_length
        moduletype.s=PeekS(*memptr+1080,4)
        WriteStringN("Song Length                 : "+Str(songlength))
        WriteStringN("Song Length Old             : "+Str(songlengthold))
        WriteStringN("Song Positions              : "+songp)
        WriteStringN("Module Type                 : "+moduletype)
        For i=0 To 30
            If(smptable(i)0) And (i=0)
                WriteStringN("No."+Str(i)+" Sample Offset          : "+Str(smpdata_start))
            ElseIf(smptable(i)0) And (i>0)
                smpdata_start+smptable(i-1)
                WriteStringN("No."+Str(i)+" Sample Offset          : "+Str(smpdata_start))
            EndIf
        Next
        CloseFile(0)
        ;WriteStringN("                            : "+Str())
        FreeMemory(0)
    EndIf
CloseConsole()
DataSection
    notes:
    Data.s "C ","C#","D ","D#","E ","F ","F#","G ","G#","A ","A#","B "
EndDataSection