2021-06-06 19:53:16 +10:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
extern crate agb;
|
|
|
|
|
2021-06-06 21:44:32 +10:00
|
|
|
use agb::sound::mixer::SoundChannel;
|
|
|
|
use agb::Gba;
|
2021-06-26 06:53:42 +10:00
|
|
|
use agb::input::{ButtonController, Tri};
|
|
|
|
use agb::number::Num;
|
2021-06-06 19:53:16 +10:00
|
|
|
|
2021-06-06 19:54:59 +10:00
|
|
|
// Music - "I will not let you let me down" by Josh Woodward, free download at http://joshwoodward.com
|
2021-06-06 20:28:35 +10:00
|
|
|
const I_WILL_NOT_LET_YOU_LET_ME_DOWN: &[u8] = include_bytes!("i-will-not-let-you-let-me-down.raw");
|
2021-06-06 19:53:16 +10:00
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn main() -> ! {
|
2021-06-06 21:44:32 +10:00
|
|
|
let mut gba = Gba::new();
|
2021-06-26 06:53:42 +10:00
|
|
|
let mut input = ButtonController::new();
|
2021-06-06 21:44:32 +10:00
|
|
|
let vblank_provider = gba.display.vblank.get();
|
|
|
|
|
|
|
|
let mut mixer = gba.mixer.mixer();
|
2021-06-06 19:53:16 +10:00
|
|
|
mixer.enable();
|
|
|
|
|
2021-06-06 21:44:32 +10:00
|
|
|
let channel = SoundChannel::new(I_WILL_NOT_LET_YOU_LET_ME_DOWN);
|
2021-06-26 06:53:42 +10:00
|
|
|
let channel_id = mixer.play_sound(channel).unwrap();
|
2021-06-06 19:53:16 +10:00
|
|
|
|
2021-06-06 21:44:32 +10:00
|
|
|
loop {
|
2021-06-26 06:53:42 +10:00
|
|
|
input.update();
|
|
|
|
|
|
|
|
{
|
2021-06-26 06:54:12 +10:00
|
|
|
if let Some(channel) = mixer.get_channel(&channel_id) {
|
|
|
|
let half: Num<i16, 4> = Num::new(1) / 2;
|
|
|
|
let half_usize: Num<usize, 8> = Num::new(1) / 2;
|
|
|
|
match input.x_tri() {
|
|
|
|
Tri::Negative => channel.panning(-half),
|
|
|
|
Tri::Zero => channel.panning(0.into()),
|
|
|
|
Tri::Positive => channel.panning(half),
|
|
|
|
};
|
|
|
|
|
|
|
|
match input.y_tri() {
|
|
|
|
Tri::Negative => channel.playback(half_usize.change_base() + 1),
|
|
|
|
Tri::Zero => channel.playback(1.into()),
|
|
|
|
Tri::Positive => channel.playback(half_usize),
|
|
|
|
};
|
|
|
|
}
|
2021-06-26 06:53:42 +10:00
|
|
|
}
|
|
|
|
|
2021-06-06 21:44:32 +10:00
|
|
|
vblank_provider.wait_for_VBlank();
|
|
|
|
mixer.vblank();
|
|
|
|
}
|
2021-06-06 19:53:16 +10:00
|
|
|
}
|