Wondercard  v0.2.1
A fully virtual emulation of the protocol used by Memory Cards for the PlayStation.
Public Member Functions | List of all members
com::saxbophone::wondercard::MemoryCardSlot Class Reference

A MemoryCardSlot is a device which a MemoryCard can be inserted into and read/written from. More...

#include <MemoryCardSlot.hpp>

Public Member Functions

bool send (TriState command, TriState &data)
 Sends the given command byte to the inserted MemoryCard. More...
 
bool insert_card (MemoryCard &card)
 Attempts to insert the given MemoryCard into this MemoryCardSlot. More...
 
bool remove_card ()
 Attempts to remove a MemoryCard from this MemoryCardSlot. More...
 
bool read_card (std::span< Byte, MemoryCard::CARD_SIZE > data)
 Reads the entire contents of the inserted card. More...
 
bool write_card (std::span< Byte, MemoryCard::CARD_SIZE > data)
 Writes data from the given span to the entire card. More...
 
bool read_block (std::size_t index, MemoryCard::Block data)
 Reads the specified block of the inserted card. More...
 
bool write_block (std::size_t index, MemoryCard::Block data)
 Writes data from the given span to the specified block of the inserted card. More...
 
bool read_sector (std::size_t index, MemoryCard::Sector data)
 Reads the specified sector of the inserted card. More...
 
bool write_sector (std::size_t index, MemoryCard::Sector data)
 Writes data from the given span to the specified sector of the inserted card. More...
 

Detailed Description

A MemoryCardSlot is a device which a MemoryCard can be inserted into and read/written from.

Member Function Documentation

◆ insert_card()

bool com::saxbophone::wondercard::MemoryCardSlot::insert_card ( MemoryCard card)

Attempts to insert the given MemoryCard into this MemoryCardSlot.

Returns
true when card inserted successfully
false when another card is already inserted
Parameters
cardMemoryCard to attempt to insert

References com::saxbophone::wondercard::MemoryCard::power_on().

Here is the call graph for this function:

◆ read_block()

bool com::saxbophone::wondercard::MemoryCardSlot::read_block ( std::size_t  index,
MemoryCard::Block  data 
)

Reads the specified block of the inserted card.

Returns
true/false indicating read sucess/failure
Parameters
indexBlock to read from
[out]datadestination to write read data to
Todo:
Change return type to an enum or introduce exception throwing so the variety of causes of failure can be determined by the caller.

◆ read_card()

bool com::saxbophone::wondercard::MemoryCardSlot::read_card ( std::span< Byte, MemoryCard::CARD_SIZE data)

Reads the entire contents of the inserted card.

Returns
true/false indicating read sucess/failure
Parameters
[out]datadestination to write read data to
Warning
Not Implemented

◆ read_sector()

bool com::saxbophone::wondercard::MemoryCardSlot::read_sector ( std::size_t  index,
MemoryCard::Sector  data 
)

Reads the specified sector of the inserted card.

Returns
true/false indicating read sucess/failure
Parameters
indexSector to read from
[out]datadestination to write read data to
Todo:
Change return type to an enum or introduce exception throwing so the variety of causes of failure can be determined by the caller.

◆ remove_card()

bool com::saxbophone::wondercard::MemoryCardSlot::remove_card ( )

Attempts to remove a MemoryCard from this MemoryCardSlot.

Returns
true when a card was removed successfully
false when there was no card in the slot to remove

References com::saxbophone::wondercard::MemoryCard::power_off().

Here is the call graph for this function:

◆ send()

bool com::saxbophone::wondercard::MemoryCardSlot::send ( TriState  command,
TriState data 
)

Sends the given command byte to the inserted MemoryCard.

Returns
false when there is no MemoryCard inserted
Response value from inserted MemoryCard when one is inserted
Parameters
commandCommand byte to send (pass std::nullopt for High-Z)
[out]dataDestination to write response data to

◆ write_block()

bool com::saxbophone::wondercard::MemoryCardSlot::write_block ( std::size_t  index,
MemoryCard::Block  data 
)

Writes data from the given span to the specified block of the inserted card.

Returns
true/false indicating write sucess/failure
Parameters
indexBlock to write to
dataData to write to the block

◆ write_card()

bool com::saxbophone::wondercard::MemoryCardSlot::write_card ( std::span< Byte, MemoryCard::CARD_SIZE data)

Writes data from the given span to the entire card.

Returns
true/false indicating write sucess/failure
Parameters
dataData to write to the card

◆ write_sector()

bool com::saxbophone::wondercard::MemoryCardSlot::write_sector ( std::size_t  index,
MemoryCard::Sector  data 
)

Writes data from the given span to the specified sector of the inserted card.

Returns
true/false indicating write sucess/failure
Parameters
indexSector to write to
dataData to write to the sector

The documentation for this class was generated from the following files: