bweh: Add some cool constants

This commit is contained in:
John 2024-07-09 01:45:24 -05:00
parent fb687b9548
commit 8e97961955
2 changed files with 19 additions and 4 deletions

15
src/constants.rs Normal file
View File

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

View File

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