mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Merge pull request #99 from agbrs/println-macro
add println macro for mgba
This commit is contained in:
commit
8cd5055e80
|
@ -5,7 +5,6 @@ extern crate agb;
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn main() -> ! {
|
pub fn main() -> ! {
|
||||||
let mut gba = agb::Gba::new();
|
let mut gba = agb::Gba::new();
|
||||||
let mut mgba = agb::mgba::Mgba::new().unwrap();
|
|
||||||
|
|
||||||
let vblank = gba.display.vblank.get();
|
let vblank = gba.display.vblank.get();
|
||||||
|
|
||||||
|
@ -13,11 +12,7 @@ pub fn main() -> ! {
|
||||||
loop {
|
loop {
|
||||||
vblank.wait_for_VBlank();
|
vblank.wait_for_VBlank();
|
||||||
|
|
||||||
mgba.print(
|
agb::println!("Hello, world, frame = {}", count);
|
||||||
format_args!("Hello, world, frame = {}", count),
|
|
||||||
agb::mgba::DebugLevel::Info,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,3 +78,14 @@ impl core::fmt::Write for Mgba {
|
||||||
Ok(())
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue