VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "clsRJPSong" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Option Compare Binary Option Base 0 Private Type SubSong Sequence1 As Byte Sequence2 As Byte Sequence3 As Byte Sequence4 As Byte End Type Private Type Sequence ptrData As Long Patterns() As Byte patternCount As Long End Type Private Type Pattern ptrData As Long Data() As Byte End Type Public Name As String Public Instruments As clsObjectArray Private subSongs() As SubSong Public subSongCount As Long Private Sequences() As Sequence Public sequenceCount As Long Private Patterns() As Pattern Public patternCount As Long Public Sub loadFrom(ByRef Bits As clsBitStreamRead) Dim A As Long Dim blockSize As Long Dim blockStart As Long Dim patternIndex As Long Dim Count As Long Dim Instrument As clsRJPInstrument Dim noteData1 As Byte, notedata2 As Byte If Left$(Bits.getString(8), 3) <> "RJP" Then Exit Sub ' Instruments blockSize = Bits.getLong Count = blockSize / 32 Set Instruments = New clsObjectArray For A = 0 To Count - 1 Set Instrument = New clsRJPInstrument Instrument.loadFrom Bits Instruments.Add Instrument Next A ' Unknown block 2, skip blockSize = Bits.getLong Bits.skipBytes blockSize ' Subsongs blockSize = Bits.getLong subSongCount = blockSize / 4 ReDim subSongs(subSongCount - 1) For A = 0 To subSongCount - 1 subSongs(A).Sequence1 = Bits.getByte subSongs(A).Sequence2 = Bits.getByte subSongs(A).Sequence3 = Bits.getByte subSongs(A).Sequence4 = Bits.getByte Next A ' Sequences blockSize = Bits.getLong sequenceCount = blockSize / 4 ReDim Sequences(sequenceCount - 1) For A = 0 To sequenceCount - 1 Sequences(A).ptrData = Bits.getLong Next A ' Patterns blockSize = Bits.getLong patternCount = blockSize / 4 ReDim Patterns(patternCount - 1) For A = 0 To patternCount - 1 Patterns(A).ptrData = Bits.getLong Next A ' Sequence data blockSize = Bits.getLong blockStart = Bits.getAddress For A = 0 To sequenceCount - 1 Bits.seekTo blockStart + Sequences(A).ptrData Do patternIndex = Bits.getByte If patternIndex = 0 Then Exit Do With Sequences(A) ReDim Preserve .Patterns(.patternCount) .patternCount = .patternCount + 1 .Patterns(.patternCount - 1) = patternIndex End With Loop Next A ' Debug.Print sequenceCount, patternCount, subSongCount ' ' Pattern data ' Dim B As Long, bLen As Long ' Bits.skipBytes 4 ' blockStart = Bits.getAddress ' For A = 0 To patternCount - 2 ' Bits.seekTo blockStart + Patterns(A).ptrData ' bLen = Patterns(A + 1).ptrData - Patterns(A).ptrData ' For B = 0 To bLen - 1 ' noteData1 = Bits.getByte ' 'notedata2 = Bits.getByte ' ' Debug.Print noteData1 & Chr$(9); ' ' 'If noteData1 = 255 And notedata2 = 132 Then Exit Do ' Next B ' Debug.Print ' ' Next A ' ' End End Sub