diff --git a/src/reskit/soundtrack.rs b/src/reskit/soundtrack.rs index 1c3f1ad..ab77793 100644 --- a/src/reskit/soundtrack.rs +++ b/src/reskit/soundtrack.rs @@ -14,13 +14,14 @@ pub enum FrameMode { } pub struct DmfModule { + platform: u8, version: u8, time_base: u8, speed_a: u8, speed_b: u8, frame_mode: FrameMode, rows_per_pattern: u32, - patterns: u8 + patterns: Vec> } fn get_string( bytes: &mut Iter<'_, u8>, take: usize ) -> Result> { @@ -125,14 +126,41 @@ impl DmfModule { println!( "Rows/pattern:\t{}", rows_per_pattern ); - let patterns = get_u8( bytes.by_ref() )?; + let patterns_count = get_u8( bytes.by_ref() )?; - println!( "Patterns:\t{}", patterns ); + println!( "Patterns:\t{}", patterns_count ); + + println!( "\nPattern Matrix:" ); + let system_total_channels = if platform == DMF_MD { + println!( "FM1 FM2 FM3 FM4 FM5 FM6 SN1 SN2 SN3 SN4" ); + 10 + } else { + println!( "FM1 FM2 OP1 OP2 OP3 OP4 FM4 FM5 FM6 SN1 SN2 SN3 SN4" ); + 13 + }; + + let mut patterns: Vec> = vec![vec![0; system_total_channels]; patterns_count.into()]; + for channel in 0..system_total_channels { + for pattern in 0..patterns_count { + let channel: usize = channel.into(); + let pattern: usize = pattern.into(); + patterns[ pattern ][ channel ] = get_u8( bytes.by_ref() )?; + } + } + + for pattern in &patterns { + for channel in pattern { + print!( "{:#04X?} ", channel ); + } + print!( "\n" ); + } + + print!( "\n" ); // TODO !! Ok( - DmfModule { version, time_base, speed_a, speed_b, frame_mode, rows_per_pattern, patterns } + DmfModule { platform, version, time_base, speed_a, speed_b, frame_mode, rows_per_pattern, patterns } ) }