pub struct CartridgeMemory {
pub prg_ram: Vec<u8>,
pub prg_rom: Vec<u8>,
pub chr_ram: Vec<u8>,
pub chr_rom: Vec<u8>,
pub nametable_arrangement: NametableArrangement,
}Expand description
Contains all memory in the cartridge that isn’t mapper-specific.
Contains PRG/CHR ROM/RAM. Does not contain any latches, banks, or dividers used by mappers.
Fields§
§prg_ram: Vec<u8>Program RAM (PRG RAM) of the cartridge
prg_rom: Vec<u8>Program ROM (PRG ROM) of the cartridge
chr_ram: Vec<u8>Character RAM (CHR RAM) of the cartridge
chr_rom: Vec<u8>Character ROM (CHR ROM) of the cartridge
nametable_arrangement: NametableArrangementNametable arrangement of the cartridge, read when parsing the file. May be changed by the mapper, use Mapper::nametable_arrangement to get the current nametable arrangement being used
Implementations§
Source§impl CartridgeMemory
impl CartridgeMemory
Sourcepub fn read_chr(&self, addr: usize) -> u8
pub fn read_chr(&self, addr: usize) -> u8
Read a byte from CHR ROM or (if CHR ROM is empty) CHR RAM.
This is really a convience function, since most cartridges either are all CHR ROM or CHR RAM. So this could be interpreted as just “Read CHR from whatever format the cartridge using”
Sourcepub fn read_prg_ram(&self, addr: usize) -> u8
pub fn read_prg_ram(&self, addr: usize) -> u8
Read a byte from PRG RAM
Read from the PRG RAM on the cartridge, wrapping around the end if addr is too large
Sourcepub fn write_prg_ram(&mut self, addr: usize, value: u8)
pub fn write_prg_ram(&mut self, addr: usize, value: u8)
Write a byte to PRG RAM
Write to PRG RAM, wrapping around the end if addr is too large
Sourcepub fn read_prg_rom(&self, addr: usize) -> u8
pub fn read_prg_rom(&self, addr: usize) -> u8
Read a byte from PRG ROM
Read from PRG ROM, wrapping around the end if addr is too large
Trait Implementations§
Source§impl Clone for CartridgeMemory
impl Clone for CartridgeMemory
Source§fn clone(&self) -> CartridgeMemory
fn clone(&self) -> CartridgeMemory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for CartridgeMemory
impl<'de> Deserialize<'de> for CartridgeMemory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CartridgeMemory
impl RefUnwindSafe for CartridgeMemory
impl Send for CartridgeMemory
impl Sync for CartridgeMemory
impl Unpin for CartridgeMemory
impl UnwindSafe for CartridgeMemory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.