All mc functions are async. You must use mc_sync to wait for completion.
The return value of a mc function is 0 if the function was started. mc_sync
will return the "actual" return value. From the mc_sync return values, -2 means unformatted card, -10
or less means no card.

It appears that the mc functions work better if you call mc_getinfo until it
indicates the same card has been connected for 2 calls (see below).

In mc functions, port is the controller port, either 0 or 1. slot is for use
with multitaps (which don't work with the rom memory card modules).


int mc_init(void);

Call to initialize mc functions.


int mc_sync(int mode, int *cmd, int *result);

mode == 0: wait for completion
mode == 1: check status and return immediately
cmd: pointer to store function # (see libmc.h) of running function
result: pointer to store result of running function


int mc_getinfo(int port, int slot, int *type, int *free);

type: pointer to store memcard type (set to 0 if not needed)
      0 = none
      1 = ps1
      2 = ps2
free: pointer to store free space, in kbyte (set to 0 if not needed)

return value (from mc_sync):
       0 = same card connected as previous mc_getinfo call
       -1 = switched cards
       -2 = unformatted card


mc_open / mc_close / mc_read / mc_seek / mc_write / mc_flush

All work like their normal counterparts. Use mc_flush to ensure written data
actually gets written (or close the file - data is flushed then).

int mc_getdir(int port, int slot, const char *name, unsigned int mode, int maxent, mc_dirent * table);

Use mc_getdir to get a directory listing.

mode == 0: start from beginning
mode == 1: start from where last call left off

maxent: number of entries to read at once (table must be big enough)

table: array of mc_dirent to store directory entries. See libmc.h for details.
       must be 64-byte aligned.


int mc_chdir(int port, int slot, const char *path, char *pwd);

Call to change directories.

path: directory to change to
pwd: pointer to storing path (set to 0 if not needed).


int mc_rename(int port, int slot, const char *old, const char *new);

Call to rename a file.

old: old filename
new: new filename

int mc_delete(int port, int slot, const char *name);

Call to delete a file.

name: file to delete

int mc_format(int port, int slot);

Call to format a memory card.

int mc_mkdir(int port, int slot, const char *name);

Call to create a directory

name: name of directory to create

int mc_unformat(int port, int slot);

Call to un-format a memory card. Use during development to test detecting an
unformatted (new) memory card.
