|
Digimon World 3 decomp
The European version, SLES_039.36
|
Memory card saves (memcard/) More...
Go to the source code of this file.
Data Structures | |
| struct | CardClut |
| Memory card save header (first CARD_SECTOR_SIZE bytes of a save) More... | |
| struct | CardHeader |
| struct | CardDirEntry |
| Same layout as the kernel's struct DIRENTRY. More... | |
| struct | MemCard |
| Memory card access (MEMCARD), one step per call: every operation returns 0 while it runs, 1 when it succeeds and result + 1 when it fails. More... | |
| struct | MemCardFuncs |
| The memory card functions (MEMCARD_FUNCS); like MemCard's operations, the card ones return 0 while they run. More... | |
Macros | |
| #define | CARD_SECTOR_SIZE 0x80 |
| The bytes the card reads or writes at once: one sector. | |
| #define | SAVE_BLOCKS 4 |
| The blocks of the save file. | |
| #define | SAVE_MAX_ICONS 3 |
| The icon frames a save may have. | |
| #define | CARD_HEADER_ICONS 0x10 |
| CardHeader.type: this flag plus the icon frame count. | |
| #define | CARD_MAX_FILES 15 |
| The files MEMCARD lists from a card's directory. | |
| #define | CARD_ERR_NONE 0 |
| MemCard.result, as libmcrd's MemCardSync reports it (McErr*), plus CARD_ERR_NOT_STARTED when the command could not even be sent. | |
| #define | CARD_ERR_NO_CARD 1 |
| #define | CARD_ERR_INVALID 2 |
| McErrCardInvalid: "Cannot access Memory Card". | |
| #define | CARD_ERR_NEW_CARD 3 |
| #define | CARD_ERR_UNFORMATTED 4 |
| #define | CARD_ERR_NO_FILE 5 |
| McErrFileNotExist: "File cannot be found". | |
| #define | CARD_ERR_FILE_EXISTS 6 |
| McErrAlreadyExist: "File already exists". | |
| #define | CARD_ERR_FULL 7 |
| McErrBlockFull: "There are not enough blocks". | |
| #define | CARD_ERR_NOT_STARTED 8 |
Enumerations | |
| enum | MemCardState { MEMCARD_IDLE , MEMCARD_CHECKING , MEMCARD_ACCEPTING , MEMCARD_READING , MEMCARD_WRITING , MEMCARD_COMMAND } |
| MemCard.state: idle, or waiting for the command each operation sent. More... | |
| enum | SaveSection { SAVE_SECTION_HEADER , SAVE_SECTION_INFO , SAVE_SECTION_DATA } |
| readSave and writeSave's sections: the header, the info, then the data copies More... | |
| enum | MemCardOp { MEMCARD_OP_LIST , MEMCARD_OP_CREATE , MEMCARD_OP_FORMAT , MEMCARD_OP_UNFORMAT } |
| memCardCommand's operations More... | |
Functions | |
| void | initMemCard (void) |
| Starts libmcrd and sets up MEMCARD: the save file name and the section sizes. | |
| void | setSaveFileName (void) |
| void | setSaveHeader (char *title, CardClut *clut, s32 count, void **icons) |
| The save file header: title (Shift-JIS), icon CLUT and 1-3 icon frames. | |
| s32 | memCardCommand (s32 port, s32 op) |
| Reads the directory, creates the save file, formats or unformats (MEMCARD_OP_*) | |
| s32 | listSaves (s32 port) |
| Reads the card's directory into MEMCARD.files. | |
| s32 | createSave (s32 port) |
| Creates the save file on the card. | |
| s32 | formatMemCard (s32 port) |
| Formats an unformatted card. | |
| s32 | unformatMemCard (void) |
| memCardCommand's MEMCARD_OP_UNFORMAT, left out: always fails as if there were no card | |
| s32 | verifyChecksum (void *data, s32 size, char expected) |
| XOR of every byte. | |
| u8 | computeChecksum (void *data, s32 size) |
| The XOR of every byte, which verifyChecksum checks. | |
| s32 | checkMemCard (s32 port) |
Checks whether a card is in port port (MemCardExist) | |
| s32 | acceptMemCard (s32 port) |
Checks a card in port port in full, finding out whether it is new or unformatted (MemCardAccept) | |
| s32 | readSave (s32 port, void *buf, s32 size, s32 section) |
| Reads a section of the save (SAVE_SECTION_*, then 2-4 for the data), a sector a call. | |
| s32 | writeSave (s32 port, void *buf, s32 size, s32 section) |
| Writes a section (as readSave; section 0 takes the offset from bits 8 and up) | |
| s32 | syncMemCard (void) |
| MemCardSync, retrying a failed command up to maxRetries times. | |
| void | MemCardInit (long val) |
| The memory card library, declared here rather than from libmcrd.h, which takes the buffers as u_long * and MemCardSync's result as a long *, where the game passes u8 buffers and compares the result unsigned. | |
| void | MemCardStart (void) |
| long | MemCardSync (long mode, long *cmds, u_long *result) |
| long | MemCardExist (long chan) |
| long | MemCardAccept (long chan) |
| long | MemCardCreateFile (long chan, const char *file, long blocks) |
| long | MemCardFormat (long chan) |
| long | MemCardReadFile (long chan, const char *file, void *adrs, long ofs, long bytes) |
| long | MemCardWriteFile (long chan, const char *file, void *adrs, long ofs, long bytes) |
| long | MemCardUnformat (long chan) |
| long | MemCardGetDirentry (long chan, char *name, CardDirEntry *dir, long *files, long ofs, long max) |
Variables | |
| MemCard | MEMCARD |
| MemCardFuncs | MEMCARD_FUNCS |
| s32 | MEMCARD_SYNC_CMDS [] |
| the MemCardSync command of each MEMCARD_OP_* | |
| char | STR_ALL_FILES [] |
| the directory pattern that matches every file | |
Memory card saves (memcard/)
Definition in file memcard.h.
| #define CARD_SECTOR_SIZE 0x80 |
| #define CARD_HEADER_ICONS 0x10 |
CardHeader.type: this flag plus the icon frame count.
| #define CARD_MAX_FILES 15 |
| #define CARD_ERR_NONE 0 |
MemCard.result, as libmcrd's MemCardSync reports it (McErr*), plus CARD_ERR_NOT_STARTED when the command could not even be sent.
| #define CARD_ERR_INVALID 2 |
| #define CARD_ERR_NO_FILE 5 |
| #define CARD_ERR_FILE_EXISTS 6 |
| #define CARD_ERR_FULL 7 |
| enum MemCardState |
MemCard.state: idle, or waiting for the command each operation sent.
| Enumerator | |
|---|---|
| MEMCARD_IDLE | |
| MEMCARD_CHECKING | |
| MEMCARD_ACCEPTING | |
| MEMCARD_READING | |
| MEMCARD_WRITING | |
| MEMCARD_COMMAND | |
| enum SaveSection |
| enum MemCardOp |
| void initMemCard | ( | void | ) |
| void setSaveFileName | ( | void | ) |
Definition at line 57 of file memcard.c.
Referenced by initMemCard().
Reads the directory, creates the save file, formats or unformats (MEMCARD_OP_*)
Definition at line 351 of file memcard.c.
Referenced by createSave(), formatMemCard(), and listSaves().
| s32 unformatMemCard | ( | void | ) |
Checks whether a card is in port port (MemCardExist)
Definition at line 128 of file memcard.c.
Referenced by readSave(), and writeSave().
Checks a card in port port in full, finding out whether it is new or unformatted (MemCardAccept)
Definition at line 160 of file memcard.c.
Referenced by memCardCommand().
| s32 syncMemCard | ( | void | ) |
MemCardSync, retrying a failed command up to maxRetries times.
Definition at line 105 of file memcard.c.
Referenced by acceptMemCard(), checkMemCard(), readSave(), and writeSave().
| void MemCardInit | ( | long | val | ) |
The memory card library, declared here rather than from libmcrd.h, which takes the buffers as u_long * and MemCardSync's result as a long *, where the game passes u8 buffers and compares the result unsigned.
Referenced by initMemCard().
| void MemCardStart | ( | void | ) |
| long MemCardSync | ( | long | mode, |
| long * | cmds, | ||
| u_long * | result | ||
| ) |
| long MemCardExist | ( | long | chan | ) |
| long MemCardAccept | ( | long | chan | ) |
| long MemCardCreateFile | ( | long | chan, |
| const char * | file, | ||
| long | blocks | ||
| ) |
| long MemCardFormat | ( | long | chan | ) |
| long MemCardReadFile | ( | long | chan, |
| const char * | file, | ||
| void * | adrs, | ||
| long | ofs, | ||
| long | bytes | ||
| ) |
| long MemCardWriteFile | ( | long | chan, |
| const char * | file, | ||
| void * | adrs, | ||
| long | ofs, | ||
| long | bytes | ||
| ) |
| long MemCardUnformat | ( | long | chan | ) |
| long MemCardGetDirentry | ( | long | chan, |
| char * | name, | ||
| CardDirEntry * | dir, | ||
| long * | files, | ||
| long | ofs, | ||
| long | max | ||
| ) |
|
extern |
Definition at line 466 of file memcard.c.
Referenced by acceptMemCard(), checkMemCard(), initMemCard(), memCardCommand(), readSave(), setSaveFileName(), setSaveHeader(), STGMCARD_askError(), STGMCARD_writeHeader(), STGMCARD_writeIcons(), syncMemCard(), and writeSave().
|
extern |
Definition at line 468 of file memcard.c.
Referenced by main(), SHOCKTST_updateEditor(), STAGSLCT_updateStageSelect(), STDWTITL_leaveTitle(), and STGMCARD_loadFiles().
|
extern |
the MemCardSync command of each MEMCARD_OP_*
the MemCardSync command of each MEMCARD_OP_*
Definition at line 474 of file memcard.c.
Referenced by memCardCommand().
|
extern |
the directory pattern that matches every file
the directory pattern that matches every file
memcard/memcard.c reads STR_ALL_FILES through its address, so it is not its small data; and 16 bytes are too many for one small variable, so the original had more than one here: "*", 8 bytes of zeros and an unread grey (128, 128, 128). The attribute puts the 16 bytes where they were.
Definition at line 11 of file all_files_pattern.c.
Referenced by memCardCommand().