mirror of
https://github.com/transistorfet/moa.git
synced 2024-06-28 07:29:28 +00:00
47 lines
769 B
Rust
47 lines
769 B
Rust
|
|
#[derive(Debug)]
|
|
pub enum ErrorType {
|
|
Emulator,
|
|
Processor,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
pub err: ErrorType,
|
|
pub native: u32,
|
|
pub msg: String,
|
|
}
|
|
|
|
impl Error {
|
|
pub fn new(msg: &str) -> Error {
|
|
Error {
|
|
err: ErrorType::Emulator,
|
|
native: 0,
|
|
msg: msg.to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn processor(native: u32) -> Error {
|
|
Error {
|
|
err: ErrorType::Processor,
|
|
native,
|
|
msg: "".to_string(),
|
|
}
|
|
}
|
|
}
|
|
|
|
static mut DEBUG_ENABLE: bool = true;
|
|
|
|
pub fn debug_enabled() -> bool {
|
|
unsafe { DEBUG_ENABLE }
|
|
}
|
|
|
|
macro_rules! debug {
|
|
($($arg:tt)*) => ({
|
|
if crate::error::debug_enabled() {
|
|
println!($($arg)*);
|
|
}
|
|
})
|
|
}
|
|
|