diff --git a/Cargo.toml b/Cargo.toml index 64b3f49..43ee005 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,11 +10,12 @@ edition = "2018" license = "Zlib OR Apache-2.0 OR MIT" [features] -default = ["serial"] +default = [] serial = ["embedded-hal", "nb"] [dependencies] voladdress = { version = "0.4" } +# embedded-hal = { version = "0.2.4", optional = true } nb = { version = "1", optional = true } diff --git a/examples/irq.rs b/examples/irq.rs index ec1fa37..34c8e65 100644 --- a/examples/irq.rs +++ b/examples/irq.rs @@ -2,7 +2,7 @@ #![no_main] #![feature(isa_attribute)] -use gba::{prelude::*, warn}; +use gba::prelude::*; const BLACK: Color = Color::from_rgb(0, 0, 0); const RED: Color = Color::from_rgb(31, 0, 0); @@ -70,7 +70,6 @@ fn main() -> ! { flags = flags.with_timer1(true); } - warn!("IM = {:?}", flags); unsafe { IE.write(flags) }; // Puts the CPU into low power mode until a VBlank IRQ is received. This diff --git a/examples/test_savegame.rs b/examples/test_savegame.rs index 8affb7c..f2448e0 100644 --- a/examples/test_savegame.rs +++ b/examples/test_savegame.rs @@ -7,7 +7,7 @@ // blue at the end. use core::cmp; -use gba::{fatal, prelude::*, save::*, warn}; +use gba::prelude::*; fn set_screen_color(r: u8, g: u8, b: u8) { const SETTING: DisplayControl = DisplayControl::new().with_display_mode(3).with_display_bg2(true); @@ -74,7 +74,7 @@ fn get_timer_secs() -> f32 { macro_rules! output { ($($args:tt)*) => { // we use warn so it shows by default on mGBA, nothing more. - warn!("{:7.3}\t{}", get_timer_secs(), format_args!($($args)*)) + warning!("{:7.3}\t{}", get_timer_secs(), format_args!($($args)*)) }; } diff --git a/src/debug.rs b/src/debugging.rs similarity index 97% rename from src/debug.rs rename to src/debugging.rs index 85fbb62..b27e7ef 100644 --- a/src/debug.rs +++ b/src/debugging.rs @@ -1,3 +1,5 @@ +#![allow(unused_macros)] + //! Special utilities for debugging ROMs on various emulators. //! //! This is the underlying implementation behind the various print macros in @@ -20,7 +22,6 @@ pub mod nocash; /// 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::debug; @@ -30,6 +31,7 @@ macro_rules! fatal { debug::crash() }}; } +pub(crate) use fatal; /// Delivers a error message to the emulator debug output. /// @@ -37,7 +39,6 @@ macro_rules! fatal { /// 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::debug; @@ -46,6 +47,7 @@ macro_rules! error { } }}; } +pub(crate) use error; /// Delivers a warning message to the emulator debug output. /// @@ -53,8 +55,7 @@ macro_rules! error { /// 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! warn { +pub macro_rules! warning { ($($arg:tt)*) => {{ use $crate::debug; if !debug::is_debugging_disabled() { @@ -62,6 +63,7 @@ macro_rules! warn { } }}; } +//pub(crate) use warning; /// Delivers an info message to the emulator debug output. /// @@ -69,7 +71,6 @@ macro_rules! warn { /// 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::debug; @@ -78,6 +79,7 @@ macro_rules! info { } }}; } +pub(crate) use info; /// Delivers a debug message to the emulator debug output. /// @@ -85,7 +87,6 @@ macro_rules! info { /// 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::debug; @@ -94,6 +95,7 @@ macro_rules! debug { } }}; } +pub(crate) use debug; /// A cross-emulator debug level. #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/src/debug/mgba.rs b/src/debugging/mgba.rs similarity index 100% rename from src/debug/mgba.rs rename to src/debugging/mgba.rs diff --git a/src/debug/nocash.rs b/src/debugging/nocash.rs similarity index 96% rename from src/debug/nocash.rs rename to src/debugging/nocash.rs index 953dc64..5c63fc8 100644 --- a/src/debug/nocash.rs +++ b/src/debugging/nocash.rs @@ -4,10 +4,8 @@ //! you've got some older version of things there might be any number of //! differences or problems. -use crate::{ - debug::{DebugInterface, DebugLevel}, - sync::InitOnce, -}; +use super::{DebugInterface, DebugLevel}; +use crate::prelude::InitOnce; use core::fmt::{Arguments, Write}; use voladdress::*; diff --git a/src/lib.rs b/src/lib.rs index f517fad..5d3a071 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(asm, global_asm, isa_attribute)] +#![feature(asm, global_asm, pub_macro_rules, isa_attribute)] //! This crate helps you write GBA ROMs. //! @@ -24,11 +24,18 @@ pub mod prelude { pub use crate::mmio_types::*; - #[cfg(target_arch = "arm")] - pub use crate::mmio_addresses::*; - #[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::*; + #[cfg(target_arch = "arm")] + pub use crate::save::*; + #[cfg(target_arch = "arm")] + pub use crate::sync::*; } pub mod mmio_types; @@ -48,7 +55,7 @@ pub mod sync; pub mod save; #[cfg(target_arch = "arm")] -pub mod debug; +pub mod debugging; /* extern "C" {