Support for effect Dxx (breaking pattern)
parent
33b16767db
commit
ce41fc43a8
|
@ -2,7 +2,7 @@ use std::{collections::HashMap, cmp::{max, min}, error::Error};
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use samplerate::convert;
|
use samplerate::convert;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use crate::reskit::{soundtrack::{formats::dmf::{DmfModule, ECHO_EWF_SAMPLE_RATE}, types::{InstrumentType, SampleFormat, Channel, PatternRow}}, utility::{print_warning, Ring}};
|
use crate::reskit::{soundtrack::{formats::dmf::{DmfModule, ECHO_EWF_SAMPLE_RATE}, types::{InstrumentType, SampleFormat, Channel, PatternRow, Effect}}, utility::{print_warning, Ring, print_info}};
|
||||||
use super::engine::{EchoFormat, ESF_FM_1, ESF_FM_2, ESF_FM_3, ESF_FM_4, ESF_FM_5, ESF_FM_6, ESF_PSG_1, ESF_PSG_2, ESF_PSG_3, ESF_PSG_4, EchoEvent, get_events_for_row, compact_delays, ESF_SET_LOOP, ESF_GO_TO_LOOP, ESF_STOP};
|
use super::engine::{EchoFormat, ESF_FM_1, ESF_FM_2, ESF_FM_3, ESF_FM_4, ESF_FM_5, ESF_FM_6, ESF_PSG_1, ESF_PSG_2, ESF_PSG_3, ESF_PSG_4, EchoEvent, get_events_for_row, compact_delays, ESF_SET_LOOP, ESF_GO_TO_LOOP, ESF_STOP};
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,36 +312,55 @@ impl EchoFormat for DmfModule {
|
||||||
// Recall items are stored as self.channel_patterns[ channel ][ row_number ]
|
// Recall items are stored as self.channel_patterns[ channel ][ row_number ]
|
||||||
let mut all_events: Vec<EchoEvent> = Vec::new();
|
let mut all_events: Vec<EchoEvent> = Vec::new();
|
||||||
let total_rows: u32 = self.channel_patterns[ 0 ].len() as u32;
|
let total_rows: u32 = self.channel_patterns[ 0 ].len() as u32;
|
||||||
|
let mut ignore_row_counter: u32 = 0;
|
||||||
for row_number in 0..total_rows {
|
for row_number in 0..total_rows {
|
||||||
let events_this_row: Vec<EchoEvent> = get_events_for_row(
|
if ignore_row_counter > 0 {
|
||||||
&mut channels,
|
// Ignore these rows while this is set (for Effect::JumpToNextPattern)
|
||||||
&self.instruments,
|
ignore_row_counter -= 1;
|
||||||
{
|
} else {
|
||||||
let mut columns: Vec<&PatternRow> = Vec::new();
|
let mut columns: Vec<&PatternRow> = Vec::new();
|
||||||
for channel in 0..10 {
|
for channel in 0..10 {
|
||||||
columns.push( &self.channel_patterns[ channel ][ row_number as usize ] );
|
columns.push( &self.channel_patterns[ channel ][ row_number as usize ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
let events_this_row: Vec<EchoEvent> = get_events_for_row(
|
||||||
|
&mut channels,
|
||||||
|
&self.instruments,
|
||||||
|
columns.clone(),
|
||||||
|
if row_number % 2 == 0 {
|
||||||
|
self.speed_a * self.time_base
|
||||||
|
} else {
|
||||||
|
self.speed_b * self.time_base
|
||||||
|
},
|
||||||
|
self.instruments.len() as u8
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Is this the pattern matrix row that we repeat to?
|
||||||
|
// If so, insert an ESF_LOOP_SET here.
|
||||||
|
if let Some( repeat_row ) = self.loop_at {
|
||||||
|
if row_number == repeat_row {
|
||||||
|
all_events.push( vec![ ESF_SET_LOOP ] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
columns
|
// Transfer ESF events to the main stream
|
||||||
},
|
all_events.extend( events_this_row );
|
||||||
if row_number % 2 == 0 {
|
|
||||||
self.speed_a * self.time_base
|
|
||||||
} else {
|
|
||||||
self.speed_b * self.time_base
|
|
||||||
},
|
|
||||||
self.instruments.len() as u8
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Is this the pattern matrix row that we repeat to?
|
// Was there an Effect::JumpToNextPattern here? If so, set a counter to ignore the next n rows
|
||||||
// If so, insert an ESF_LOOP_SET here.
|
// Use the first one encountered (u r big dum dum if you set more than one in a single row, that DOES NOT MAKE SENSE stahp)
|
||||||
if let Some( repeat_row ) = self.loop_at {
|
for column in columns {
|
||||||
if row_number == repeat_row {
|
if let Some( jump_effect ) = column.effects.iter().find( | effect | matches!( effect, Effect::JumpToNextPattern{ start_row: _ } ) ) {
|
||||||
all_events.push( vec![ ESF_SET_LOOP ] );
|
if let Effect::JumpToNextPattern { start_row } = jump_effect {
|
||||||
|
let rows_elapsed = row_number % self.rows_per_pattern;
|
||||||
|
let remaining_rows_in_pattern = self.rows_per_pattern - rows_elapsed - 1;
|
||||||
|
ignore_row_counter = remaining_rows_in_pattern + *start_row as u32;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
return Err( "get_esf: wtf happened here??" )?
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer ESF events to the main stream
|
|
||||||
all_events.extend( events_this_row );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compact sequences of delays to save rom space
|
// Compact sequences of delays to save rom space
|
||||||
|
|
|
@ -540,6 +540,9 @@ fn apply_effects_to_channel( channel: &mut Channel, effects: &LinkedHashSet<Effe
|
||||||
Effect::PositionJump { pattern: _ } => {
|
Effect::PositionJump { pattern: _ } => {
|
||||||
// Nothing to do - handled as we iterate through the rows.
|
// Nothing to do - handled as we iterate through the rows.
|
||||||
},
|
},
|
||||||
|
Effect::JumpToNextPattern { start_row } => {
|
||||||
|
// Nothing to do - handled as we iterate through the rows.
|
||||||
|
},
|
||||||
unsupported_effect => print_warning( &format!( "effect unsupported: {:?}. your soundtrack may sound different than expected.", unsupported_effect ) )
|
unsupported_effect => print_warning( &format!( "effect unsupported: {:?}. your soundtrack may sound different than expected.", unsupported_effect ) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue