diff --git a/src/constants.rs b/src/constants.rs new file mode 100644 index 0000000..67a727e --- /dev/null +++ b/src/constants.rs @@ -0,0 +1,15 @@ +/// The size of a ROM bank +pub const ROM_BANK: usize = 0x4000; +/// The size of a RAM bank +pub const RAM_BANK: usize = 0x2000; + +// Memory map +pub const A_ROM_LO: usize = 0x0000; +pub const A_ROM_HI: usize = 0x4000; +pub const A_VRAM: usize = 0x8000; +pub const A_EXT_RAM: usize = 0xa000; +pub const A_WRAM_LO: usize = 0xc000; +pub const A_WRAM_HI: usize = 0xd000; +pub const A_ECHO: usize = 0xe000; +pub const A_OAM_RAM: usize = 0xfe00; +pub const A_MMIO: usize = 0xff00; diff --git a/src/lib.rs b/src/lib.rs index 08d3986..114e5f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ pub mod error { #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Error { - kind: ErrorKind, + pub kind: ErrorKind, // any other information about an error } @@ -65,6 +65,8 @@ pub mod cpu; pub mod audio; +pub mod constants; + #[cfg(test)] mod tests { use crate::memory::{io::*, Cart}; @@ -86,9 +88,7 @@ mod tests { let cart = Cart::from(rom); let mut cksum = 0u8; for index in 0x134..0x14d { - cksum = cksum - .wrapping_sub(cart.read(index).unwrap()) - .wrapping_sub(1) + cksum = cksum.wrapping_sub(cart.read(index).unwrap()).wrapping_sub(1) } assert_eq!(cksum, cart.headercksum().unwrap()) }