mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Fix a bunch of bugs after playing with different tracks
This commit is contained in:
parent
a4df095031
commit
25ee876932
|
@ -6,7 +6,7 @@ use agb::Gba;
|
||||||
use agb_tracker::{include_xm, Track, Tracker};
|
use agb_tracker::{include_xm, Track, Tracker};
|
||||||
|
|
||||||
// Found on: https://modarchive.org/index.php?request=view_by_moduleid&query=36662
|
// Found on: https://modarchive.org/index.php?request=view_by_moduleid&query=36662
|
||||||
const DB_TOFFE: Track = include_xm!("examples/algar_-_ninja_on_speed.xm");
|
const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||||
|
|
||||||
#[agb::entry]
|
#[agb::entry]
|
||||||
fn main(mut gba: Gba) -> ! {
|
fn main(mut gba: Gba) -> ! {
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl Tracker {
|
||||||
tick: 0,
|
tick: 0,
|
||||||
|
|
||||||
current_row: 0,
|
current_row: 0,
|
||||||
current_pattern: 0x10,
|
current_pattern: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,14 +106,13 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
let mut patterns = vec![];
|
let mut patterns = vec![];
|
||||||
let mut pattern_data = vec![];
|
let mut pattern_data = vec![];
|
||||||
|
|
||||||
let mut effect_parameters = [0; u8::MAX as usize];
|
|
||||||
|
|
||||||
for pattern in &module.pattern {
|
for pattern in &module.pattern {
|
||||||
let start_pos = pattern_data.len();
|
let start_pos = pattern_data.len();
|
||||||
|
let mut effect_parameters: [u8; 255] = [0; u8::MAX as usize];
|
||||||
|
let mut tone_portamento_directions = vec![0.0; module.get_num_channels()];
|
||||||
|
let mut note_and_sample = vec![None; module.get_num_channels()];
|
||||||
|
|
||||||
for row in pattern.iter() {
|
for row in pattern.iter() {
|
||||||
let mut note_and_sample = vec![None; module.get_num_channels()];
|
|
||||||
|
|
||||||
for (i, slot) in row.iter().enumerate() {
|
for (i, slot) in row.iter().enumerate() {
|
||||||
let channel_number = i % module.get_num_channels();
|
let channel_number = i % module.get_num_channels();
|
||||||
|
|
||||||
|
@ -162,6 +161,12 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
.map(|note_and_sample| note_and_sample.1.volume)
|
.map(|note_and_sample| note_and_sample.1.volume)
|
||||||
.unwrap_or(1.into()),
|
.unwrap_or(1.into()),
|
||||||
),
|
),
|
||||||
|
0x60..=0x6F => {
|
||||||
|
PatternEffect::VolumeSlide(-Num::new((slot.volume - 0x60) as i16) / 64)
|
||||||
|
}
|
||||||
|
0x70..=0x7F => {
|
||||||
|
PatternEffect::VolumeSlide(Num::new((slot.volume - 0x70) as i16) / 64)
|
||||||
|
}
|
||||||
0x80..=0x8F => PatternEffect::FineVolumeSlide(
|
0x80..=0x8F => PatternEffect::FineVolumeSlide(
|
||||||
-Num::new((slot.volume - 0x80) as i16) / 64,
|
-Num::new((slot.volume - 0x80) as i16) / 64,
|
||||||
),
|
),
|
||||||
|
@ -169,7 +174,7 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
Num::new((slot.volume - 0x90) as i16) / 64,
|
Num::new((slot.volume - 0x90) as i16) / 64,
|
||||||
),
|
),
|
||||||
0xC0..=0xCF => PatternEffect::Panning(
|
0xC0..=0xCF => PatternEffect::Panning(
|
||||||
Num::new(slot.volume as i16 - (0xC0 + (0xCF - 0xC0) / 2)) / 64,
|
Num::new(slot.volume as i16 - (0xC0 + (0xCF - 0xC0) / 2)) / 8,
|
||||||
),
|
),
|
||||||
_ => PatternEffect::None,
|
_ => PatternEffect::None,
|
||||||
};
|
};
|
||||||
|
@ -242,15 +247,27 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
PatternEffect::Portamento(portamento_amount.try_change_base().unwrap())
|
PatternEffect::Portamento(portamento_amount.try_change_base().unwrap())
|
||||||
}
|
}
|
||||||
0x3 => {
|
0x3 => {
|
||||||
if let Some((previous_note, sample)) = previous_note_and_sample {
|
if let (Some((note, sample)), Some((prev_note, _))) =
|
||||||
// we want to pitch slide to at most the current note by the parameter amount
|
(maybe_note_and_sample, previous_note_and_sample)
|
||||||
let c4_speed = note_to_speed(Note::C4, 0.0, 0, module.frequency_type);
|
{
|
||||||
|
let target_speed = note_to_speed(
|
||||||
|
*note,
|
||||||
|
sample.fine_tune,
|
||||||
|
sample.relative_note,
|
||||||
|
module.frequency_type,
|
||||||
|
);
|
||||||
|
|
||||||
let direction = if (previous_note as usize) < slot.note as usize {
|
let direction = match (prev_note as usize).cmp(&(*note as usize)) {
|
||||||
-1.0
|
std::cmp::Ordering::Less => 1.0,
|
||||||
} else {
|
std::cmp::Ordering::Equal => {
|
||||||
1.0
|
tone_portamento_directions[channel_number]
|
||||||
|
}
|
||||||
|
std::cmp::Ordering::Greater => -1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tone_portamento_directions[channel_number] = direction;
|
||||||
|
|
||||||
|
let c4_speed = note_to_speed(Note::C4, 0.0, 0, module.frequency_type);
|
||||||
let speed = note_to_speed(
|
let speed = note_to_speed(
|
||||||
Note::C4,
|
Note::C4,
|
||||||
effect_parameter as f64 * direction,
|
effect_parameter as f64 * direction,
|
||||||
|
@ -260,13 +277,6 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
|
|
||||||
let portamento_amount = speed / c4_speed;
|
let portamento_amount = speed / c4_speed;
|
||||||
|
|
||||||
let target_speed = note_to_speed(
|
|
||||||
slot.note,
|
|
||||||
sample.fine_tune,
|
|
||||||
sample.relative_note,
|
|
||||||
module.frequency_type,
|
|
||||||
);
|
|
||||||
|
|
||||||
PatternEffect::TonePortamento(
|
PatternEffect::TonePortamento(
|
||||||
portamento_amount.try_change_base().unwrap(),
|
portamento_amount.try_change_base().unwrap(),
|
||||||
target_speed.try_change_base().unwrap(),
|
target_speed.try_change_base().unwrap(),
|
||||||
|
|
Loading…
Reference in a new issue