aboutsummaryrefslogtreecommitdiff
path: root/src/portmod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/portmod.rs')
-rw-r--r--src/portmod.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/portmod.rs b/src/portmod.rs
new file mode 100644
index 0000000..52c27ee
--- /dev/null
+++ b/src/portmod.rs
@@ -0,0 +1,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
+ }
+ }
+}