|
Wondercard
v0.2.1
A fully virtual emulation of the protocol used by Memory Cards for the PlayStation.
|
Represents a virtual PS1 Memory Card. More...
#include <MemoryCard.hpp>

Public Types | |
| typedef std::span< Byte, BLOCK_SIZE > | Block |
| A non-owning view of an entire save Block on the MemoryCard. | |
| typedef std::span< Byte, SECTOR_SIZE > | Sector |
| A non-owning view of a Sector on the MemoryCard. | |
Public Member Functions | |
| MemoryCard () | |
| Initialises card data to all zeroes. More... | |
| MemoryCard (std::span< Byte, MemoryCard::CARD_SIZE > data) | |
| Populates card data with that of the supplied span. More... | |
| bool | power_on () |
| Simulates powering up the card, e.g. when inserted into slot. More... | |
| bool | power_off () |
| Simulates powering down the card, e.g. when removed from slot. More... | |
| bool | send (TriState command, TriState &data) |
| Attempts to send a command and receive data from the card. More... | |
| Block | get_block (std::size_t index) |
| Sector | get_sector (std::size_t index) |
Public Attributes | |
| const bool & | powered_on |
| Read-only flag indicating whether the card is powered on or not. | |
| std::span< Byte, CARD_SIZE > | bytes |
| writable accessor for the MemoryCard data bytes | |
Static Public Attributes | |
| static constexpr std::size_t | CARD_BLOCK_COUNT = 16u |
| static constexpr std::size_t | BLOCK_SECTOR_COUNT = 64u |
| static constexpr std::size_t | SECTOR_SIZE = 128u |
| static constexpr std::size_t | BLOCK_SIZE = BLOCK_SECTOR_COUNT * SECTOR_SIZE |
| static constexpr std::size_t | CARD_SIZE = CARD_BLOCK_COUNT * BLOCK_SIZE |
Represents a virtual PS1 Memory Card.
| com::saxbophone::wondercard::MemoryCard::MemoryCard | ( | ) |
Initialises card data to all zeroes.
| com::saxbophone::wondercard::MemoryCard::MemoryCard | ( | std::span< Byte, MemoryCard::CARD_SIZE > | data | ) |
Populates card data with that of the supplied span.
| data | The data to initialise the card data with |
| MemoryCard::Block com::saxbophone::wondercard::MemoryCard::get_block | ( | std::size_t | index | ) |
| index | The index of the Block to retrieve ({0..15}) |
index is not currently validated References BLOCK_SIZE.
| MemoryCard::Sector com::saxbophone::wondercard::MemoryCard::get_sector | ( | std::size_t | index | ) |
| index | The index of the Sector to retrieve ({0..1023}) |
index is not currently validated References SECTOR_SIZE.
| bool com::saxbophone::wondercard::MemoryCard::power_off | ( | ) |
Simulates powering down the card, e.g. when removed from slot.
Cards know when they have been re-inserted, so they have some way of tracking when they are plugged in and out, presumably this must be done by tracking when the card is powered on and off.
false if card is already powered down. true if card has been powered off by the method call. Referenced by com::saxbophone::wondercard::MemoryCardSlot::remove_card().

| bool com::saxbophone::wondercard::MemoryCard::power_on | ( | ) |
Simulates powering up the card, e.g. when inserted into slot.
Cards know when they have been re-inserted, so they have some way of tracking when they are plugged in and out, presumably this must be done by tracking when the card is powered on and off.
false if card is already powered on. true if card has been powered on by the method call. References powered_on.
Referenced by com::saxbophone::wondercard::MemoryCardSlot::insert_card().

Attempts to send a command and receive data from the card.
| command | Command to send to the card (set empty for High Impedance/Z-state, indicating don't care) |
| data | Destination to store response data from card in (set empty for High Impedance/Z-state, indicating no data) |
true if the card responds with an ACK false if we time out waiting for an ACK from the card References powered_on.
|
staticconstexpr |
Number of Sectors in a Block
|
staticconstexpr |
Number of bytes in a Block
Referenced by get_block().
|
staticconstexpr |
Number of Blocks on the card
|
staticconstexpr |
Number of bytes in a MemoryCard
|
staticconstexpr |
Number of bytes in a Sector
Referenced by get_sector().