From 54a31934b20e33a3fa2593cfb4ffff9b6ad51168 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 28 Aug 2024 16:43:59 +0100 Subject: [PATCH] Add support for retrigger command --- tracker/agb-tracker-interop/src/lib.rs | 2 ++ tracker/agb-tracker/src/lib.rs | 5 +++++ tracker/agb-xm-core/src/lib.rs | 11 +++++++++++ tracker/desktop-player/tests/retrigger.xm | Bin 0 -> 16769 bytes 4 files changed, 18 insertions(+) create mode 100644 tracker/desktop-player/tests/retrigger.xm diff --git a/tracker/agb-tracker-interop/src/lib.rs b/tracker/agb-tracker-interop/src/lib.rs index eee21c00..ad8a9b66 100644 --- a/tracker/agb-tracker-interop/src/lib.rs +++ b/tracker/agb-tracker-interop/src/lib.rs @@ -94,6 +94,7 @@ pub enum PatternEffect { PitchBend(Num), Jump(Jump), SampleOffset(u16), + Retrigger(u8), } #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)] @@ -403,6 +404,7 @@ impl quote::ToTokens for PatternEffect { quote! { Jump(#jump) } } PatternEffect::SampleOffset(offset) => quote! { SampleOffset(#offset) }, + PatternEffect::Retrigger(ticks) => quote! { Retrigger(#ticks) }, }; tokens.append_all(quote! { diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index 527766bf..500f067f 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -613,6 +613,11 @@ impl TrackerChannel { self.current_pos = Some(*offset); } } + PatternEffect::Retrigger(ticks) => { + if tick % *ticks as u32 == 0 { + self.current_pos = Some(0); + } + } } } diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index 018aa540..c96063ba 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -439,6 +439,17 @@ pub fn parse_module(module: &Module) -> agb_tracker_interop::Track { PatternEffect::GlobalVolumeSlide(Num::new(first as i32) / 0x40) } } + // R + 0x1B => { + let first = effect_parameter >> 4; + let second = effect_parameter & 0xF; + + if first != 0 { + eprintln!("Unsupported retrigger effect volume {first}"); + } + + PatternEffect::Retrigger(second) + } e => { let effect_char = char::from_digit(e as u32, 36) .unwrap_or('?') diff --git a/tracker/desktop-player/tests/retrigger.xm b/tracker/desktop-player/tests/retrigger.xm new file mode 100644 index 0000000000000000000000000000000000000000..e44bfbe0b4f2a9487df990f6290bc9826e9c4ac7 GIT binary patch literal 16769 zcmeI1$&Mt+dFRc|%-4v>tSojn8q@+F=R}ZzPCDtLqfXKb5Mmz$5)wd+W;8bfdIw$f zR(ga11W?WDs$3$%-Ob(H^!tAvS=Cyg(NP#xbXSDC*|+az`Nx0rKfn3QpMUf7AN|Q+ z{rsH zD)&GB?c)EhD?j<9*dP6a`}NnmQGWctfA+sVZTuH}^2)d>=*t!4+y9kPs>)YotNgZk z$4j;4()g{oyoRAIIk@Y2PE!t{s!Cbc4MN^K03a3W3KY?-yf07*(fOdKLQ;#gEK!R0 zRScU8C0D_3YYBnvyjBe>(J%A5rc&1sDmicP@xd({6tja?fq>}yN>m{hy-6wBRmrPX zLkKa33Q$RfLeR-PgRPGcC$o5c_75;`Ov=V@!ZI=MFFSgqZ$j5uyx zW%Rt&`C6jOP5W}~VqSggr|heBYomS&!kpZ4@Gr|yV;S#Qbqa`Toy(fK9s?ofeD=e1 z3C+AjH~X%2C7oTI-9vb(`+2JG-6h3}2->P9UlQT5mHM#Zf6xi5guS9-rw&`Fd39^- zQG|Go*SW>{OVgyqH(hzT5(#a$<>mP@++&BToK9(q&Nb^)b%)+vr*@m`a#@evwk_+S z*$#(HCRA-dUxv5-U1`tDU7TFow&}Za%qit6$GV#HFyx=%i5*o z?jb#`O~i$zy6Z0Qn|r^xetzzT@sitv!zd;Drnw+%`N#8@-Me|H`)-ZZ`?V_pljkm8 z7tC?kM*k*UV(ZTzrr|U!-%Y27`N`EWEL)ter#EFLlCzuEySs8(YCl(NeV8AUJopk3 z=IC*MNd!YK!KZ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