aboutsummaryrefslogtreecommitdiff
path: root/src/portmod.rs
blob: 52c27eef77403ebced540bb3e53afe58e6e436e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub enum Effect
{
    SetSpeed(u8),
    PosJump(u8),
    PattBreak(u8),
    PattLoopStart,
    PattLoop(u8),
    PattDelay(u8),
    SetTempo(u8),
    TempoSlideDown(u8),
    TempoSlideUp(u8),
    NoEffect
}

impl Effect
{
    pub fn from_it_efx(f: (u8, u8)) -> Effect
    {
        let (efx, fxp) = f;
        match (efx as char, fxp)
        {
            ('A', _) => Effect::SetSpeed(fxp),
            ('B', _) => Effect::PosJump(fxp),
            ('C', _) => Effect::PattBreak(fxp),
            ('S', 0xb0) => Effect::PattLoopStart,
            ('S', _) if fxp & 0xf0 == 0xb0 => Effect::PattLoop(fxp & 0x0f),
            ('S', _) if fxp & 0xf0 == 0xe0 => Effect::PattDelay(fxp & 0x0f),
            ('T', _) if fxp & 0xf0 == 0x00 => Effect::TempoSlideDown(fxp & 0x0f),
            ('T', _) if fxp & 0xf0 == 0x10 => Effect::TempoSlideUp(fxp & 0x0f),
            ('T', _) => Effect::SetTempo(fxp),
            _ => Effect::NoEffect
        }
    }
}