Use new music for dungeon puzzler's lament and fix tracker bugs

This commit is contained in:
Gwilym Inzani 2023-08-01 21:41:33 +01:00
parent f3a6bead13
commit f4214b5da8
5 changed files with 266 additions and 15 deletions

View file

@ -52,7 +52,7 @@ dependencies = [
"image", "image",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.27",
] ]
[[package]] [[package]]
@ -61,7 +61,7 @@ version = "0.16.0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.27",
] ]
[[package]] [[package]]
@ -71,7 +71,47 @@ dependencies = [
"hound", "hound",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.27",
]
[[package]]
name = "agb_tracker"
version = "0.16.0"
dependencies = [
"agb",
"agb_tracker_interop",
"agb_xm",
]
[[package]]
name = "agb_tracker_interop"
version = "0.16.0"
dependencies = [
"agb_fixnum",
"proc-macro2",
"quote",
]
[[package]]
name = "agb_xm"
version = "0.16.0"
dependencies = [
"agb_xm_core",
"proc-macro-error",
"proc-macro2",
]
[[package]]
name = "agb_xm_core"
version = "0.16.0"
dependencies = [
"agb_fixnum",
"agb_tracker_interop",
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.27",
"xmrs",
] ]
[[package]] [[package]]
@ -142,7 +182,16 @@ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.27",
]
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
] ]
[[package]] [[package]]
@ -200,6 +249,12 @@ dependencies = [
"byteorder", "byteorder",
] ]
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.26" version = "1.0.26"
@ -216,10 +271,21 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0793f5137567643cf65ea42043a538804ff0fbf288649e2141442b602d81f9bc" checksum = "0793f5137567643cf65ea42043a538804ff0fbf288649e2141442b602d81f9bc"
dependencies = [ dependencies = [
"hashbrown", "hashbrown 0.13.2",
"ttf-parser", "ttf-parser",
] ]
[[package]]
name = "getrandom"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.13.2" version = "0.13.2"
@ -229,6 +295,12 @@ dependencies = [
"ahash", "ahash",
] ]
[[package]]
name = "hashbrown"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
[[package]] [[package]]
name = "hound" name = "hound"
version = "3.5.0" version = "3.5.0"
@ -250,6 +322,22 @@ dependencies = [
"png", "png",
] ]
[[package]]
name = "indexmap"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
dependencies = [
"equivalent",
"hashbrown 0.14.0",
]
[[package]]
name = "libc"
version = "0.2.147"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]] [[package]]
name = "libflate" name = "libflate"
version = "1.4.0" version = "1.4.0"
@ -276,6 +364,12 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.3.7" version = "0.3.7"
@ -341,6 +435,27 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "num_enum"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.27",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.18.0" version = "1.18.0"
@ -359,6 +474,22 @@ dependencies = [
"miniz_oxide 0.3.7", "miniz_oxide 0.3.7",
] ]
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro-crate"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [
"once_cell",
"toml_edit",
]
[[package]] [[package]]
name = "proc-macro-error" name = "proc-macro-error"
version = "1.0.4" version = "1.0.4"
@ -368,6 +499,7 @@ dependencies = [
"proc-macro-error-attr", "proc-macro-error-attr",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109",
"version_check", "version_check",
] ]
@ -400,6 +532,36 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]] [[package]]
name = "rle-decode-fast" name = "rle-decode-fast"
version = "1.0.3" version = "1.0.3"
@ -412,6 +574,35 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "serde"
version = "1.0.179"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde-big-array"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.179"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.27",
]
[[package]] [[package]]
name = "slotmap" name = "slotmap"
version = "1.0.6" version = "1.0.6"
@ -421,6 +612,16 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"unicode-ident",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.27" version = "2.0.27"
@ -437,6 +638,7 @@ name = "the-dungeon-puzzlers-lament"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"agb", "agb",
"agb_tracker",
"proc-macro2", "proc-macro2",
"quote", "quote",
"slotmap", "slotmap",
@ -454,6 +656,23 @@ dependencies = [
"xml-rs", "xml-rs",
] ]
[[package]]
name = "toml_datetime"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
[[package]]
name = "toml_edit"
version = "0.19.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a"
dependencies = [
"indexmap",
"toml_datetime",
"winnow",
]
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.15.2" version = "0.15.2"
@ -472,8 +691,37 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winnow"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bd122eb777186e60c3fdf765a58ac76e41c582f1f535fbf3314434c6b58f3f7"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "xml-rs" name = "xml-rs"
version = "0.8.16" version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1" checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
[[package]]
name = "xmrs"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fa1ec7c01e6bb4c716f84a418f4ced5f4a735b2ae6364f4bb5850da61321d16"
dependencies = [
"bincode",
"libflate",
"num_enum",
"rand",
"serde",
"serde-big-array",
]

View file

@ -9,6 +9,7 @@ edition = "2021"
[dependencies] [dependencies]
agb = { version = "0.16.0", path = "../../agb" } agb = { version = "0.16.0", path = "../../agb" }
slotmap = { version = "1", default-features = false } slotmap = { version = "1", default-features = false }
agb_tracker = { version = "0.16.0", path = "../../tracker/agb-tracker" }
[profile.dev] [profile.dev]
opt-level = 3 opt-level = 3
@ -22,4 +23,4 @@ debug = true
[build-dependencies] [build-dependencies]
tiled = { version = "0.11", default-features = false } tiled = { version = "0.11", default-features = false }
quote = "1" quote = "1"
proc-macro2 = "1" proc-macro2 = "1"

View file

@ -2,8 +2,10 @@ use agb::{
include_wav, include_wav,
sound::mixer::{Mixer, SoundChannel}, sound::mixer::{Mixer, SoundChannel},
}; };
use agb_tracker::{include_xm, Track, Tracker};
const MUSIC: Track = include_xm!("sfx/theme.xm");
const BGM: &[u8] = include_wav!("sfx/bgm.wav");
const BAD_SELECTION: &[u8] = include_wav!("sfx/bad.wav"); const BAD_SELECTION: &[u8] = include_wav!("sfx/bad.wav");
const SELECT: &[u8] = include_wav!("sfx/select.wav"); const SELECT: &[u8] = include_wav!("sfx/select.wav");
const PLACE: &[u8] = include_wav!("sfx/place.wav"); const PLACE: &[u8] = include_wav!("sfx/place.wav");
@ -17,20 +19,20 @@ const SWICTH_TOGGLES: &[&[u8]] = &[include_wav!("sfx/switch_toggle1.wav")];
pub struct Sfx<'a> { pub struct Sfx<'a> {
mixer: &'a mut Mixer<'a>, mixer: &'a mut Mixer<'a>,
tracker: Tracker,
} }
impl<'a> Sfx<'a> { impl<'a> Sfx<'a> {
pub fn new(mixer: &'a mut Mixer<'a>) -> Self { pub fn new(mixer: &'a mut Mixer<'a>) -> Self {
let mut bgm_channel = SoundChannel::new_high_priority(BGM);
bgm_channel.stereo().should_loop();
mixer.play_sound(bgm_channel);
mixer.enable(); mixer.enable();
Self { mixer } let tracker = Tracker::new(&MUSIC);
Self { mixer, tracker }
} }
pub fn frame(&mut self) { pub fn frame(&mut self) {
self.tracker.step(self.mixer);
self.mixer.frame(); self.mixer.frame();
} }

View file

@ -276,7 +276,7 @@ impl TrackerChannel {
} }
PatternEffect::NoteCut(wait) => { PatternEffect::NoteCut(wait) => {
if tick == *wait { if tick == *wait {
channel.volume(0); channel.stop();
self.volume = 0.into(); self.volume = 0.into();
} }
} }

View file

@ -67,7 +67,7 @@ pub fn parse_module(module: &Module) -> TokenStream {
for (sample_index, sample) in instrument.sample.iter().enumerate() { for (sample_index, sample) in instrument.sample.iter().enumerate() {
let should_loop = !matches!(sample.flags, LoopType::No); let should_loop = !matches!(sample.flags, LoopType::No);
let fine_tune = sample.finetune as f64; let fine_tune = sample.finetune as f64 * 128.0;
let relative_note = sample.relative_note; let relative_note = sample.relative_note;
let restart_point = sample.loop_start; let restart_point = sample.loop_start;
let sample_len = if sample.loop_length > 0 { let sample_len = if sample.loop_length > 0 {
@ -301,7 +301,7 @@ pub fn parse_module(module: &Module) -> TokenStream {
0xC => { 0xC => {
if let Some((_, sample)) = maybe_note_and_sample { if let Some((_, sample)) = maybe_note_and_sample {
PatternEffect::Volume( PatternEffect::Volume(
(Num::new(slot.effect_parameter as i16) / 255) * sample.volume, (Num::new(slot.effect_parameter as i16) / 64) * sample.volume,
) )
} else { } else {
PatternEffect::None PatternEffect::None