diff --git a/Cargo.toml b/Cargo.toml index 43ee005..84c72d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gba" description = "A crate for making GBA games with Rust." -version = "0.4.0" +version = "0.5.0-alpha.0" authors = ["Lokathor ", "Thomas Winwood "] repository = "https://github.com/rust-console/gba" readme = "README.md" diff --git a/examples/test_savegame.rs b/examples/test_savegame.rs index f2448e0..f815194 100644 --- a/examples/test_savegame.rs +++ b/examples/test_savegame.rs @@ -7,7 +7,7 @@ // blue at the end. use core::cmp; -use gba::prelude::*; +use gba::{fatal, prelude::*, warning}; fn set_screen_color(r: u8, g: u8, b: u8) { const SETTING: DisplayControl = DisplayControl::new().with_display_mode(3).with_display_bg2(true); diff --git a/src/debugging.rs b/src/debugging.rs index b27e7ef..8ae54b3 100644 --- a/src/debugging.rs +++ b/src/debugging.rs @@ -15,88 +15,6 @@ use voladdress::*; pub mod mgba; pub mod nocash; -/// Delivers a fatal message to the emulator debug output, and crashes -/// the the game. -/// -/// This works basically like `println`. You should avoid null ASCII values. -/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. -/// -/// This has no effect outside of a supported emulator. -macro_rules! fatal { - ($($arg:tt)*) => {{ - use $crate::debug; - if !debug::is_debugging_disabled() { - debug::debug_print(debug::DebugLevel::Fatal, &format_args!($($arg)*)).ok(); - } - debug::crash() - }}; -} -pub(crate) use fatal; - -/// Delivers a error message to the emulator debug output. -/// -/// This works basically like `println`. You should avoid null ASCII values. -/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. -/// -/// This has no effect outside of a supported emulator. -macro_rules! error { - ($($arg:tt)*) => {{ - use $crate::debug; - if !debug::is_debugging_disabled() { - debug::debug_print(debug::DebugLevel::Error, &format_args!($($arg)*)).ok(); - } - }}; -} -pub(crate) use error; - -/// Delivers a warning message to the emulator debug output. -/// -/// This works basically like `println`. You should avoid null ASCII values. -/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. -/// -/// This has no effect outside of a supported emulator. -pub macro_rules! warning { - ($($arg:tt)*) => {{ - use $crate::debug; - if !debug::is_debugging_disabled() { - debug::debug_print(debug::DebugLevel::Warning, &format_args!($($arg)*)).ok(); - } - }}; -} -//pub(crate) use warning; - -/// Delivers an info message to the emulator debug output. -/// -/// This works basically like `println`. You should avoid null ASCII values. -/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. -/// -/// This has no effect outside of a supported emulator. -macro_rules! info { - ($($arg:tt)*) => {{ - use $crate::debug; - if !debug::is_debugging_disabled() { - debug::debug_print(debug::DebugLevel::Info, &format_args!($($arg)*)).ok(); - } - }}; -} -pub(crate) use info; - -/// Delivers a debug message to the emulator debug output. -/// -/// This works basically like `println`. You should avoid null ASCII values. -/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. -/// -/// This has no effect outside of a supported emulator. -macro_rules! debug { - ($($arg:tt)*) => {{ - use $crate::debug; - if !debug::is_debugging_disabled() { - debug::debug_print(debug::DebugLevel::Debug, &format_args!($($arg)*)).ok(); - } - }}; -} -pub(crate) use debug; - /// A cross-emulator debug level. #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[allow(missing_docs)] diff --git a/src/lib.rs b/src/lib.rs index 5d3a071..bb2443f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(asm, global_asm, pub_macro_rules, isa_attribute)] +#![feature(asm, global_asm, isa_attribute)] //! This crate helps you write GBA ROMs. //! @@ -27,8 +27,6 @@ pub mod prelude { #[cfg(target_arch = "arm")] pub use crate::bios::*; #[cfg(target_arch = "arm")] - pub use crate::debugging::warning; - #[cfg(target_arch = "arm")] pub use crate::debugging::*; #[cfg(target_arch = "arm")] pub use crate::mmio_addresses::*; @@ -48,6 +46,9 @@ pub mod bios; pub mod art; +#[cfg(target_arch = "arm")] +pub mod macros; + #[cfg(target_arch = "arm")] pub mod sync; diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..864d77f --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,81 @@ +/// Delivers a fatal message to the emulator debug output, and crashes +/// the the game. +/// +/// This works basically like `println`. You should avoid null ASCII values. +/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. +/// +/// This has no effect outside of a supported emulator. +#[macro_export] +macro_rules! fatal { + ($($arg:tt)*) => {{ + use $crate::debugging; + if !debugging::is_debugging_disabled() { + debugging::debug_print(debugging::DebugLevel::Fatal, &format_args!($($arg)*)).ok(); + } + debugging::crash() + }}; +} + +/// Delivers a error message to the emulator debug output. +/// +/// This works basically like `println`. You should avoid null ASCII values. +/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. +/// +/// This has no effect outside of a supported emulator. +#[macro_export] +macro_rules! error { + ($($arg:tt)*) => {{ + use $crate::debugging; + if !debugging::is_debugging_disabled() { + debugging::debug_print(debugging::DebugLevel::Error, &format_args!($($arg)*)).ok(); + } + }}; +} + +/// Delivers a warning message to the emulator debug output. +/// +/// This works basically like `println`. You should avoid null ASCII values. +/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. +/// +/// This has no effect outside of a supported emulator. +#[macro_export] +macro_rules! warning { + ($($arg:tt)*) => {{ + use $crate::debugging; + if !debugging::is_debugging_disabled() { + debugging::debug_print(debugging::DebugLevel::Warning, &format_args!($($arg)*)).ok(); + } + }}; +} + +/// Delivers an info message to the emulator debug output. +/// +/// This works basically like `println`. You should avoid null ASCII values. +/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. +/// +/// This has no effect outside of a supported emulator. +#[macro_export] +macro_rules! info { + ($($arg:tt)*) => {{ + use $crate::debugging; + if !debugging::is_debugging_disabled() { + debugging::debug_print(debugging::DebugLevel::Info, &format_args!($($arg)*)).ok(); + } + }}; +} + +/// Delivers a debug message to the emulator debug output. +/// +/// This works basically like `println`. You should avoid null ASCII values. +/// Furthermore on mGBA, there is a maximum length of 255 bytes per message. +/// +/// This has no effect outside of a supported emulator. +#[macro_export] +macro_rules! debug { + ($($arg:tt)*) => {{ + use $crate::debugging; + if !debugging::is_debugging_disabled() { + debugging::debug_print(debugging::DebugLevel::Debug, &format_args!($($arg)*)).ok(); + } + }}; +}