From 652173c08e78ebbe1b264696a417f9b130f64236 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Mon, 17 Jul 2023 01:27:22 +0100 Subject: [PATCH] Reduce size of pattern by 4 bytes per slot --- tracker/agb-tracker-interop/src/lib.rs | 4 ++-- tracker/agb-tracker/src/lib.rs | 16 +++++++++++++--- tracker/agb-xm-core/src/lib.rs | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tracker/agb-tracker-interop/src/lib.rs b/tracker/agb-tracker-interop/src/lib.rs index a1a094b7..cd015246 100644 --- a/tracker/agb-tracker-interop/src/lib.rs +++ b/tracker/agb-tracker-interop/src/lib.rs @@ -29,8 +29,8 @@ pub struct Pattern { #[derive(Debug)] pub struct PatternSlot { - pub speed: Num, - pub sample: usize, + pub speed: Num, + pub sample: u16, pub effect1: PatternEffect, pub effect2: PatternEffect, } diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index 69bd6b37..a96cd08c 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -80,12 +80,22 @@ impl Tracker { for (channel, pattern_slot) in self.channels.iter_mut().zip(pattern_slots) { if pattern_slot.sample != 0 && self.tick == 0 { - let sample = &self.track.samples[pattern_slot.sample - 1]; + let sample = &self.track.samples[pattern_slot.sample as usize - 1]; channel.play_sound(mixer, sample); } - channel.apply_effect(mixer, &pattern_slot.effect1, self.tick, pattern_slot.speed); - channel.apply_effect(mixer, &pattern_slot.effect2, self.tick, pattern_slot.speed); + channel.apply_effect( + mixer, + &pattern_slot.effect1, + self.tick, + pattern_slot.speed.change_base(), + ); + channel.apply_effect( + mixer, + &pattern_slot.effect2, + self.tick, + pattern_slot.speed.change_base(), + ); } self.increment_step(); diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index 3722861f..f02e9370 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -229,8 +229,8 @@ pub fn parse_module(module: &Module) -> TokenStream { ); pattern_data.push(agb_tracker_interop::PatternSlot { - speed, - sample, + speed: speed.try_change_base().unwrap(), + sample: sample as u16, effect1, effect2, });