Set the default instrument on psg channel if you attempted to set an invalid instrument on it before and it failed

master
Ashley N. 2023-08-28 23:38:15 -04:00
parent 811cc1cea9
commit 01da82a428
1 changed files with 11 additions and 0 deletions

View File

@ -311,6 +311,17 @@ fn get_events_for_channel( channels: &mut [Channel], active_channel: usize, row:
channels[ active_channel ].active_instrument = Some( *instrument ); channels[ active_channel ].active_instrument = Some( *instrument );
} else { } else {
print_warning( "attempted to set an fm instrument on a psg channel, or vice versa. the instrument was not set - your soundtrack may sound different than expected." ); print_warning( "attempted to set an fm instrument on a psg channel, or vice versa. the instrument was not set - your soundtrack may sound different than expected." );
// Now if current channel is PSG1 through PSG4, it's gonna need an instrument set on it.
if channels[ active_channel ].active_instrument.is_none() && ( ESF_PSG_1..=ESF_PSG_4 ).contains( &channels[ active_channel ].id ) {
print_warning( "this is a psg channel, seting the default psg instrument so your note can still play..." );
if row.note.is_some() {
// Set "__reskit_default_psg_instrument"
let instrument = instrument_set.default_psg_id.ok_or( "internal error: no default psg instrument to apply" )?;
events.push( vec![ ESF_SET_INSTRUMENT | channels[ active_channel ].id, instrument as u8 ] );
channels[ active_channel ].active_instrument = Some( instrument );
}
}
} }
} }
} else { } else {