diff options
Diffstat (limited to 'src/portmod.rs')
-rw-r--r-- | src/portmod.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/portmod.rs b/src/portmod.rs index a271ead..38c353b 100644 --- a/src/portmod.rs +++ b/src/portmod.rs @@ -65,6 +65,51 @@ pub enum Effect NoEffect } +pub enum LoopMode { + NoLoop, + ForwardLoop, + PingPongLoop +} + +pub enum NoteCommand { + NoteOn(u8), + NoteOff, + NoteCut, + NoteFade, +} + +pub struct Cell { + pub note: Option<NoteCommand>, + pub inst: Option<u8>, + pub vol: Effect, + pub efx: Effect +} + +impl Cell +{ + pub fn from_it_cell(cell: &crate::itfile::Cell) -> Cell { + let note = if cell.mask & 0x11 != 0 { + let cmd = match cell.note { + 0xff => NoteCommand::NoteOff, + 0xfe => NoteCommand::NoteCut, + 0x78..0xfe => NoteCommand::NoteFade, + _ => NoteCommand::NoteOn(cell.note) + }; + Some(cmd) + } else { None }; + let inst = if cell.mask & 0x22 != 0 { + Some(cell.inst) + } else { None }; + let vol = if cell.mask & 0x44 != 0 { + Effect::from_it_vol(cell.vol) + } else { Effect::NoEffect }; + let efx = if cell.mask & 0x88 != 0 { + Effect::from_it_efx((cell.efx, cell.fxp)) + } else { Effect::NoEffect }; + Cell{note, inst, vol, efx} + } +} + impl Effect { pub fn from_it_efx(f: (u8, u8)) -> Effect |