fix macros.

This commit is contained in:
Lokathor 2021-05-01 19:45:55 -06:00
parent 6a709689ed
commit 127f31ecf2
5 changed files with 87 additions and 87 deletions

View file

@ -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 <zefria@gmail.com>", "Thomas Winwood <twwinwood@gmail.com>"]
repository = "https://github.com/rust-console/gba"
readme = "README.md"

View file

@ -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);

View file

@ -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)]

View file

@ -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;

81
src/macros.rs Normal file
View file

@ -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();
}
}};
}