memcard.h

Header with all definitions and functions to work with memory cards


Detecting a memory card

Function: card_is_connected
Prototype: bool card_is_connected()
Description: Determines if there is a memory card connected to the console. You must check this using this function before attempting to access the card, or a memory access error may happen
Returns:
bool True when a memory card is present, false otherwise

Memory card signatures

Typedef:
Name Type Description
game_signature int[20] Buffer to hold a 'signature': The first 20 words of a memory card are taken as a unique signature to distinguish each game
Function: card_read_signature
Prototype: void card_read_signature( game_signature* signature )
Description: Reads the signature of the connected memory card
Arguments:
game_signature* signature Pointer to a signature that will receive the read data
Function: card_write_signature
Prototype: void card_write_signature( game_signature* signature )
Description: Writes the given signature into the connected memory card
Arguments:
game_signature* signature Pointer to the signature to write into the card
Function: card_signature_matches
Prototype: bool card_signature_matches( game_signature* expected_signature )
Description: Compares the signature from the connected card with the expected signature value
Returns:
bool True if both signatures match, false otherwise
Arguments:
game_signature* expected_signature Pointer to the expected signature value
Function: card_is_empty
Prototype: bool card_is_empty()
Description: Detects whether the connected card contains data. This is determined just by checking if the signature is empty (all zeroes)
Returns:
bool True if the card is considered empty (no signature). False otherwise

General access to memory card

Function: card_read_data
Prototype: void card_read_data( void* destination, int offset_in_card, int size )
Description: Reads data from the connected card and stores it into the destination buffer
Arguments:
void* destination Pointer to a buffer that will store the read data
int offset_in_card Position within the card where the first word that will be read. First 20 positions are interpreted as the signature
int size Number of words to read
Function: card_write_data
Prototype: void card_write_data( void* source, int offset_in_card, int size )
Description: Writes into the connected card the data stored in the source buffer
Arguments:
void* source Pointer to a buffer holding the data to write
int offset_in_card Position within the card where the first word that will be written. First 20 positions are interpreted as the signature
int size Number of words to write