Update agb tests and all the examples

This commit is contained in:
Gwilym Kuiper 2022-01-16 21:38:30 +00:00
parent 0d623fc5b0
commit cf9ea504f6
14 changed files with 20 additions and 28 deletions

View file

@ -6,7 +6,7 @@ extern crate alloc;
use alloc::boxed::Box; use alloc::boxed::Box;
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(_gba: agb::Gba) -> ! {
loop { loop {
let b = Box::new(1); let b = Box::new(1);
agb::println!("dynamic allocation made to {:?}", &*b as *const _); agb::println!("dynamic allocation made to {:?}", &*b as *const _);

View file

@ -4,9 +4,7 @@
use agb::sound; use agb::sound;
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(gba: agb::Gba) -> ! {
let gba = agb::Gba::new();
gba.sound.enable(); gba.sound.enable();
let sweep_settings = sound::dmg::SweepSettings::default(); let sweep_settings = sound::dmg::SweepSettings::default();

View file

@ -9,8 +9,7 @@ struct Vector2D {
} }
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let mut bitmap = gba.display.video.bitmap3(); let mut bitmap = gba.display.video.bitmap3();
let vblank = agb::interrupt::VBlank::get(); let vblank = agb::interrupt::VBlank::get();

View file

@ -4,8 +4,7 @@
use agb::display; use agb::display;
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let mut bitmap = gba.display.video.bitmap4(); let mut bitmap = gba.display.video.bitmap4();
let vblank = agb::interrupt::VBlank::get(); let vblank = agb::interrupt::VBlank::get();

View file

@ -35,14 +35,13 @@ fn frame_ranger(count: u32, start: u32, end: u32, delay: u32) -> u16 {
} }
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let map_as_grid: &[[u16; 32]; 32] = unsafe { let map_as_grid: &[[u16; 32]; 32] = unsafe {
(&MAP_MAP as *const [u16; 1024] as *const [[u16; 32]; 32]) (&MAP_MAP as *const [u16; 1024] as *const [[u16; 32]; 32])
.as_ref() .as_ref()
.unwrap() .unwrap()
}; };
let mut gba = agb::Gba::new();
let mut gfx = gba.display.video.tiled0(); let mut gfx = gba.display.video.tiled0();
let vblank = agb::interrupt::VBlank::get(); let vblank = agb::interrupt::VBlank::get();
let mut input = agb::input::ButtonController::new(); let mut input = agb::input::ButtonController::new();

View file

@ -10,8 +10,7 @@ use agb::{include_wav, Gba};
const DEAD_CODE: &[u8] = include_wav!("examples/JoshWoodward-DeadCode.wav"); const DEAD_CODE: &[u8] = include_wav!("examples/JoshWoodward-DeadCode.wav");
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: Gba) -> ! {
let mut gba = Gba::new();
let mut input = ButtonController::new(); let mut input = ButtonController::new();
let vblank_provider = agb::interrupt::VBlank::get(); let vblank_provider = agb::interrupt::VBlank::get();

View file

@ -9,8 +9,7 @@ struct Vector2D {
} }
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let vblank = agb::interrupt::VBlank::get(); let vblank = agb::interrupt::VBlank::get();
let mut input = agb::input::ButtonController::new(); let mut input = agb::input::ButtonController::new();

View file

@ -2,7 +2,7 @@
#![no_main] #![no_main]
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(_gba: agb::Gba) -> ! {
let count = agb::interrupt::Mutex::new(0); let count = agb::interrupt::Mutex::new(0);
agb::add_interrupt_handler!(agb::interrupt::Interrupt::VBlank, |key| { agb::add_interrupt_handler!(agb::interrupt::Interrupt::VBlank, |key| {
let mut count = count.lock_with_key(&key); let mut count = count.lock_with_key(&key);

View file

@ -4,9 +4,7 @@
use agb::display; use agb::display;
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let mut bitmap = gba.display.video.bitmap3(); let mut bitmap = gba.display.video.bitmap3();
let mut input = agb::input::ButtonController::new(); let mut input = agb::input::ButtonController::new();

View file

@ -8,8 +8,7 @@ use agb::{include_wav, Gba};
const LET_IT_IN: &[u8] = include_wav!("examples/JoshWoodward-LetItIn.wav"); const LET_IT_IN: &[u8] = include_wav!("examples/JoshWoodward-LetItIn.wav");
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: Gba) -> ! {
let mut gba = Gba::new();
let vblank_provider = agb::interrupt::VBlank::get(); let vblank_provider = agb::interrupt::VBlank::get();
let mut timer_controller = gba.timers.timers(); let mut timer_controller = gba.timers.timers();

View file

@ -4,8 +4,7 @@
use agb::{display, syscall}; use agb::{display, syscall};
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let mut bitmap = gba.display.video.bitmap3(); let mut bitmap = gba.display.video.bitmap3();
for x in 0..display::WIDTH { for x in 0..display::WIDTH {

View file

@ -4,8 +4,7 @@
use agb::display::example_logo; use agb::display::example_logo;
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let mut gfx = gba.display.video.tiled0(); let mut gfx = gba.display.video.tiled0();
example_logo::display_logo(&mut gfx); example_logo::display_logo(&mut gfx);

View file

@ -13,8 +13,7 @@ struct BackCosines {
} }
#[agb::entry] #[agb::entry]
fn main() -> ! { fn main(mut gba: agb::Gba) -> ! {
let mut gba = agb::Gba::new();
let mut gfx = gba.display.video.tiled0(); let mut gfx = gba.display.video.tiled0();
example_logo::display_logo(&mut gfx); example_logo::display_logo(&mut gfx);

View file

@ -283,7 +283,11 @@ fn panic_implementation(info: &core::panic::PanicInfo) -> ! {
loop {} loop {}
} }
#[cfg(test)]
static mut TEST_GBA: Option<Gba> = None;
#[doc(hidden)] #[doc(hidden)]
#[cfg(test)]
pub fn test_runner(tests: &[&dyn Testable]) { pub fn test_runner(tests: &[&dyn Testable]) {
let mut mgba = mgba::Mgba::new().unwrap(); let mut mgba = mgba::Mgba::new().unwrap();
mgba.print( mgba.print(
@ -292,7 +296,7 @@ pub fn test_runner(tests: &[&dyn Testable]) {
) )
.unwrap(); .unwrap();
let mut gba = Gba::new(); let mut gba = unsafe { TEST_GBA.as_mut() }.unwrap();
for test in tests { for test in tests {
test.run(&mut gba); test.run(&mut gba);
@ -307,7 +311,8 @@ pub fn test_runner(tests: &[&dyn Testable]) {
#[cfg(test)] #[cfg(test)]
#[entry] #[entry]
fn agb_test_main() -> ! { fn agb_test_main(gba: Gba) -> ! {
unsafe { TEST_GBA = Some(gba) };
test_main(); test_main();
#[allow(clippy::empty_loop)] #[allow(clippy::empty_loop)]
loop {} loop {}