Try a new song and add memory support

This commit is contained in:
Gwilym Inzani 2023-07-23 20:54:24 +01:00
parent 1a25268285
commit 0911ca44c5
4 changed files with 15 additions and 6 deletions

Binary file not shown.

View file

@ -6,7 +6,7 @@ use agb::Gba;
use agb_tracker::{include_xm, Track, Tracker};
// Found on: https://modarchive.org/index.php?request=view_by_moduleid&query=36662
const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
const DB_TOFFE: Track = include_xm!("examples/algar_-_ninja_on_speed.xm");
#[agb::entry]
fn main(mut gba: Gba) -> ! {

View file

@ -124,7 +124,7 @@ impl Tracker {
tick: 0,
current_row: 0,
current_pattern: 0,
current_pattern: 2,
}
}

View file

@ -106,6 +106,8 @@ pub fn parse_module(module: &Module) -> TokenStream {
let mut patterns = vec![];
let mut pattern_data = vec![];
let mut effect_parameters = [0; u8::MAX as usize];
for pattern in &module.pattern {
let start_pos = pattern_data.len();
@ -166,6 +168,13 @@ pub fn parse_module(module: &Module) -> TokenStream {
};
}
let effect_parameter = if slot.effect_parameter != 0 {
effect_parameters[slot.effect_type as usize] = slot.effect_parameter;
slot.effect_parameter
} else {
effect_parameters[slot.effect_type as usize]
};
let effect2 = match slot.effect_type {
0x0 => {
if slot.effect_parameter == 0 {
@ -203,7 +212,7 @@ pub fn parse_module(module: &Module) -> TokenStream {
let c4_speed = note_to_speed(Note::C4, 0.0, 0, module.frequency_type);
let speed = note_to_speed(
Note::C4,
slot.effect_parameter as f64,
effect_parameter as f64,
0,
module.frequency_type,
);
@ -216,7 +225,7 @@ pub fn parse_module(module: &Module) -> TokenStream {
let c4_speed = note_to_speed(Note::C4, 0.0, 0, module.frequency_type);
let speed = note_to_speed(
Note::C4,
-(slot.effect_parameter as f64),
-(effect_parameter as f64),
0,
module.frequency_type,
);
@ -229,8 +238,8 @@ pub fn parse_module(module: &Module) -> TokenStream {
PatternEffect::Panning(Num::new(slot.effect_parameter as i16 - 128) / 128)
}
0xA => {
let first = slot.effect_parameter >> 4;
let second = slot.effect_parameter & 0xF;
let first = effect_parameter >> 4;
let second = effect_parameter & 0xF;
if first == 0 {
PatternEffect::VolumeSlide(-Num::new(second as i16) / 16)