pub enum SaveDevice {
None,
Eeprom(Box<[u8]>),
Sram(Box<[u8]>),
Flash(FlashRam),
ControllerPak(Box<[u8]>),
}Expand description
A cartridge save backend, sized + typed from the resolved SaveType.
Variants§
None
No on-cart save.
Eeprom(Box<[u8]>)
Serial EEPROM (joybus), flat backing store (512 B or 2 KiB).
Sram(Box<[u8]>)
Battery SRAM (PI DOM2), flat 32 KiB.
Flash(FlashRam)
FlashRAM (PI DOM2), the erase/program/status machine.
ControllerPak(Box<[u8]>)
Controller Pak (joybus), flat 32 KiB.
Implementations§
Source§impl SaveDevice
impl SaveDevice
Sourcepub fn new(save_type: SaveType) -> Self
pub fn new(save_type: SaveType) -> Self
Construct the backend for a resolved save type (erased/zeroed state).
Sourcepub fn pi_read(&self, addr: u32) -> Option<u8>
pub fn pi_read(&self, addr: u32) -> Option<u8>
PI-bus read (SRAM / FlashRAM) at PI address addr. Returns None for a
backend not on the PI bus, so the caller can fall through to open bus.
Sourcepub fn pi_write(&mut self, addr: u32, val: u8)
pub fn pi_write(&mut self, addr: u32, val: u8)
PI-bus write (SRAM / FlashRAM). The FlashRAM CIR at 0x0801_0000 is a
32-bit command; the Bus assembles the word and calls Self::flash_cir.
Sourcepub fn flash_cir(&mut self, cmd: u32)
pub fn flash_cir(&mut self, cmd: u32)
Write the FlashRAM Command Internal Register (a whole 32-bit word).
Sourcepub fn eeprom_read_block(&self, block: u8, out: &mut [u8; 8])
pub fn eeprom_read_block(&self, block: u8, out: &mut [u8; 8])
Joybus EEPROM read of an 8-byte block (block index) into out.
Sourcepub fn eeprom_write_block(&mut self, block: u8, data: &[u8; 8])
pub fn eeprom_write_block(&mut self, block: u8, data: &[u8; 8])
Joybus EEPROM write of an 8-byte block.
Sourcepub fn cpak_read(&self, addr: u16, out: &mut [u8; 32])
pub fn cpak_read(&self, addr: u16, out: &mut [u8; 32])
Joybus Controller-Pak read of a 32-byte block at addr (byte offset).
Sourcepub fn cpak_write(&mut self, addr: u16, data: &[u8; 32])
pub fn cpak_write(&mut self, addr: u16, data: &[u8; 32])
Joybus Controller-Pak write of a 32-byte block at addr.
Sourcepub fn backing(&self) -> &[u8] ⓘ
pub fn backing(&self) -> &[u8] ⓘ
The persistable backing bytes (for the host save file). FlashRAM exposes
its data array; the others their flat store. Empty for Self::None.
Trait Implementations§
Source§impl Clone for SaveDevice
impl Clone for SaveDevice
Source§fn clone(&self) -> SaveDevice
fn clone(&self) -> SaveDevice
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more