Skip to main content

Cart

Struct Cart 

Source
pub struct Cart { /* private fields */ }
Expand description

PI cart + PIF/CIC + save state — the concrete board.

Implementations§

Source§

impl Cart

Source

pub fn new() -> Self

Construct an empty cart at power-on.

Source

pub fn load(raw: &[u8]) -> Result<Self, CartError>

Load + normalize a raw ROM image of any supported byte order.

§Errors

CartError::UnknownFormat for an unrecognized magic, or CartError::ShortHeader for a truncated header.

Source

pub fn reattach_rom(&mut self, rom: Vec<u8>)

Re-attach a ROM image after a save-state restore (which deserializes an empty ROM — the ROM field is #[serde(skip)]’d). The rom bytes are the normalized big-endian image (what Cart::load stores, i.e. what rom_image returns); the frontend keeps the loaded image and re-inserts it here so cart/PI reads resolve again. All other cart state (save, PIF, header) came from the snapshot and is left untouched.

Source

pub fn rom_image(&self) -> &[u8]

The normalized (big-endian) ROM image, for the frontend to stash so it can Cart::reattach_rom after a restore.

Source

pub const fn pif_ram(&self) -> &[u8; 64]

The PIF’s 64-byte RAM (the SI DMA copies it to/from RDRAM).

Source

pub fn pif_load(&mut self, bytes: &[u8; 64])

Load the whole PIF RAM (an SI 64-byte write from RDRAM).

Source

pub fn pif_read(&self, off: usize) -> u8

A CPU direct read/write byte of PIF RAM.

Source

pub const fn pif_write(&mut self, off: usize, val: u8)

Write a CPU direct byte of PIF RAM.

Source

pub fn pif_execute(&mut self, controllers: &[u32; 4])

Execute the pending joybus frame (on an SI read), using the four packed controller port words and the cart’s save backend.

Source

pub fn pif_load_boot_rom(&mut self, bytes: &[u8])

Install the PIF boot ROM (IPL1/IPL2) for the real-PIF boot path.

Source

pub fn pif_boot_rom_read(&self, off: usize) -> u8

Read a byte of the PIF boot ROM (0x1FC0_0000 + off); 0 when absent (HLE).

Source

pub const fn pif_has_boot_rom(&self) -> bool

Is a real PIF boot ROM installed (real-PIF boot path active)?

Source

pub const fn pif_set_boot_checksum(&mut self, checksum: [u8; 6])

Register the CIC’s IPL2 checksum for the real-PIF boot verify.

Source

pub fn pif_boot_command(&mut self) -> bool

Process a reset-mode PIF command-byte write (real-PIF boot); returns true if the checksum verify failed and the CPU must be NMI-halted.

Source

pub const fn pif_reset_boot(&mut self)

Warm-reset the transient PIF boot state (unlock the ROM, drop the latched checksum) so a reset can re-run IPL1→IPL2.

Source

pub const fn header(&self) -> &RomHeader

The parsed cartridge header.

Source

pub fn save(&self) -> &[u8]

The persistable save backing bytes (empty for SaveType::None).

Source

pub fn save_device_mut(&mut self) -> &mut SaveDevice

Mutable access to the save device (the joybus module drives EEPROM/Pak).

Source

pub fn pi_write_word(&mut self, addr: u32, word: u32)

A whole-word PI write (direct-I/O or DMA). Routes the FlashRAM Command Internal Register (0x0801_0000) as a 32-bit command; other DOM2-window writes fall to the byte path. ROM-window writes are ignored (read-only).

Source

pub fn tick(&mut self)

Advance one unit of cart time (PI/SI DMA progress).

Trait Implementations§

Source§

impl Cartridge for Cart

Source§

fn pi_read(&mut self, addr: u32) -> u8

PI-side read from the cartridge address space ($1000_0000..).
Source§

fn pi_write(&mut self, addr: u32, val: u8)

PI-side write into the cartridge address space (save SRAM/FlashRAM, regs).
Source§

fn save_type(&self) -> SaveType

The active save backend for this cartridge.
Source§

fn si_exchange(&mut self, _channel: u8, _tx: &[u8], _rx: &mut [u8])

SI-side joybus exchange (controllers + Controller Pak). Default no-op.
Source§

fn notify_cpu_cycle(&mut self)

Per-CPU-cycle hook (counter-driven cart hardware). Default no-op.
Source§

impl Debug for Cart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cart

Source§

fn default() -> Cart

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Cart

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Cart

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Cart

§

impl RefUnwindSafe for Cart

§

impl Send for Cart

§

impl Sync for Cart

§

impl Unpin for Cart

§

impl UnsafeUnpin for Cart

§

impl UnwindSafe for Cart

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,