Merge pull request #99 from agbrs/println-macro

add println macro for mgba
This commit is contained in:
Corwin 2021-08-07 14:10:50 +01:00 committed by GitHub
commit 8cd5055e80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -5,7 +5,6 @@ extern crate agb;
#[no_mangle]
pub fn main() -> ! {
let mut gba = agb::Gba::new();
let mut mgba = agb::mgba::Mgba::new().unwrap();
let vblank = gba.display.vblank.get();
@ -13,11 +12,7 @@ pub fn main() -> ! {
loop {
vblank.wait_for_VBlank();
mgba.print(
format_args!("Hello, world, frame = {}", count),
agb::mgba::DebugLevel::Info,
)
.unwrap();
agb::println!("Hello, world, frame = {}", count);
count += 1;
}

View file

@ -78,3 +78,14 @@ impl core::fmt::Write for Mgba {
Ok(())
}
}
#[macro_export]
macro_rules! println {
($( $x:expr ),*) => {
{
if let Some(mut mgba) = $crate::mgba::Mgba::new() {
let _ = mgba.print(format_args!($($x,)*), $crate::mgba::DebugLevel::Info);
}
}
};
}