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;
#[agb::entry]
fn main() -> ! {
fn main(_gba: agb::Gba) -> ! {
loop {
let b = Box::new(1);
agb::println!("dynamic allocation made to {:?}", &*b as *const _);

View file

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

View file

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

View file

@ -4,8 +4,7 @@
use agb::display;
#[agb::entry]
fn main() -> ! {
let mut gba = agb::Gba::new();
fn main(mut gba: agb::Gba) -> ! {
let mut bitmap = gba.display.video.bitmap4();
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]
fn main() -> ! {
fn main(mut gba: agb::Gba) -> ! {
let map_as_grid: &[[u16; 32]; 32] = unsafe {
(&MAP_MAP as *const [u16; 1024] as *const [[u16; 32]; 32])
.as_ref()
.unwrap()
};
let mut gba = agb::Gba::new();
let mut gfx = gba.display.video.tiled0();
let vblank = agb::interrupt::VBlank::get();
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");
#[agb::entry]
fn main() -> ! {
let mut gba = Gba::new();
fn main(mut gba: Gba) -> ! {
let mut input = ButtonController::new();
let vblank_provider = agb::interrupt::VBlank::get();

View file

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

View file

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

View file

@ -4,9 +4,7 @@
use agb::display;
#[agb::entry]
fn main() -> ! {
let mut gba = agb::Gba::new();
fn main(mut gba: agb::Gba) -> ! {
let mut bitmap = gba.display.video.bitmap3();
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");
#[agb::entry]
fn main() -> ! {
let mut gba = Gba::new();
fn main(mut gba: Gba) -> ! {
let vblank_provider = agb::interrupt::VBlank::get();
let mut timer_controller = gba.timers.timers();

View file

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

View file

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

View file

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

View file

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