Expand description
PlayStation 1 memory-card driver.
Three layers, each usable on its own:
- Transport – a
Blockdevice exposes the card as 1024 raw 128-byte frames.HardwareCardtalks to a physical card over SIO0 (featurehw, on by default);RamCardis an in-memory image for host tests and virtual saves. - Filesystem –
Cardwraps anyBlockand implements the standard PS1 directory: named files, block allocation with the real link-chain, BIOS-visible title + icon frames, and per-frame XOR checksums. Saves show up in the console’s memory-card manager like any retail game. - Container –
Card::writewraps payloads in a small self-describing header soCard::readcan transparently handle both plain and (featurecompress) LZSS-compressed saves.
§Why talk to SIO0 directly
Like psx_pad, this avoids BIOS syscalls so the same code runs
under an HLE BIOS side-load or a real boot. The card protocol is a fixed
request/response the hardware module drives byte by byte, over the same
shared SIO0 transport the pad driver polls controllers with, so the port has
one owner (the ControllerPort token) however many drivers use it.
§Example
use psx_mc::{Card, HardwareCard, Slot};
// `port` is the `ControllerPort` token (or a `&mut` of it, to keep polling
// pads between saves).
let mut card = Card::new(HardwareCard::on_port(&mut port, Slot::One));
if !card.is_formatted()? {
card.format()?;
}
card.write("BESLES-00000MYGAME01", "MY GAME", &save_bytes)?;
let mut buf = [0u8; 8192];
let len = card.read("BESLES-00000MYGAME01", &mut buf)?;All logic below the transport is pure and covered by host unit tests
(cargo test --no-default-features, optionally --features compress).
Re-exports§
pub use hardware::HardwareCard;pub use hardware::Slot;pub use hardware::TransportFault;pub use hardware::TransportTrace;
Modules§
- compress
- A small, self-contained LZSS codec for save payloads (feature
compress). - hardware
- On-device SIO0 transport for a physical memory card (feature
hw).
Structs§
- Card
- A memory card with the standard PS1 filesystem on top of a
Blockdevice. - Controller
Port - The token a
HardwareCarddrives the port through. The controller and memory-card port. - Entry
- One file as reported by
Card::list. - RamCard
- A 128 KiB card held entirely in memory.
- Save
Icon - A native PS1 memory-card save icon.
Enums§
- Error
- Everything that can go wrong talking to a card or its filesystem.
Constants§
- BLOCK_
COUNT - Total blocks on a standard card (block 0 is the directory).
- CARD_
SIZE - Total card size in bytes (128 KiB).
- DATA_
BLOCKS - Usable save blocks (blocks 1..=15; block 0 holds the directory).
- FRAMES_
PER_ BLOCK - Frames per 8 KiB block.
- FRAME_
COUNT - Total frames on a standard card.
- FRAME_
SIZE - Bytes per frame (the transfer unit of the serial protocol).
- MAX_
NAME Deprecated - Renamed to
MAX_NAME_LEN. - MAX_
NAME_ LEN - Maximum file-name length (region+product code + name), excluding the NUL.
Traits§
- Block
- A card as a flat array of
FRAME_COUNT128-byte frames.
Type Aliases§
- Result
- Convenience alias.