Reduce size of pattern by 4 bytes per slot

This commit is contained in:
Gwilym Inzani 2023-07-17 01:27:22 +01:00
parent 515bcb13ca
commit 652173c08e
3 changed files with 17 additions and 7 deletions

View file

@ -29,8 +29,8 @@ pub struct Pattern {
#[derive(Debug)]
pub struct PatternSlot {
pub speed: Num<u32, 8>,
pub sample: usize,
pub speed: Num<u16, 8>,
pub sample: u16,
pub effect1: PatternEffect,
pub effect2: PatternEffect,
}

View file

@ -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();

View file

@ -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,
});