Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
memcard.c File Reference
#include "engine/game.h"
#include <libgs.h>
#include <libetc.h>
#include <libsnd.h>
Include dependency graph for memcard.c:

Go to the source code of this file.

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 syncMemCard (void)
 MemCardSync, retrying a failed command up to maxRetries times.
 
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 memCardCommand (s32 port, s32 cmd)
 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.
 

Variables

const char SAVE_FILE_NAME_JP [24] = "BISLPS-03446DMW3-JPN"
 
const char SAVE_FILE_NAMES [2][24]
 
MemCard MEMCARD = { 0 }
 
MemCardFuncs MEMCARD_FUNCS
 
s32 MEMCARD_SYNC_CMDS [MEMCARD_OP_UNFORMAT+1] = { 7, 8, 9, 10 }
 The commands of memCardCommand's operations.
 

Function Documentation

◆ initMemCard()

void initMemCard ( void  )

Starts libmcrd and sets up MEMCARD: the save file name and the section sizes.

Definition at line 7 of file memcard.c.

Here is the call graph for this function:

◆ setSaveFileName()

void setSaveFileName ( void  )

Definition at line 57 of file memcard.c.

Referenced by initMemCard().

Here is the caller graph for this function:

◆ setSaveHeader()

void setSaveHeader ( char *  title,
CardClut *  clut,
s32  count,
void **  icons 
)

The save file header: title (Shift-JIS), icon CLUT and 1-3 icon frames.

Definition at line 86 of file memcard.c.

Here is the call graph for this function:

◆ syncMemCard()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkMemCard()

s32 checkMemCard ( s32  port)

Checks whether a card is in port port (MemCardExist)

Definition at line 128 of file memcard.c.

Referenced by readSave(), and writeSave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acceptMemCard()

s32 acceptMemCard ( s32  port)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readSave()

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.

Definition at line 189 of file memcard.c.

Here is the call graph for this function:

◆ writeSave()

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)

Definition at line 270 of file memcard.c.

Here is the call graph for this function:

◆ memCardCommand()

s32 memCardCommand ( s32  port,
s32  cmd 
)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listSaves()

s32 listSaves ( s32  port)

Reads the card's directory into MEMCARD.files.

Definition at line 408 of file memcard.c.

Here is the call graph for this function:

◆ createSave()

s32 createSave ( s32  port)

Creates the save file on the card.

Definition at line 418 of file memcard.c.

Here is the call graph for this function:

◆ formatMemCard()

s32 formatMemCard ( s32  port)

Formats an unformatted card.

Definition at line 428 of file memcard.c.

Here is the call graph for this function:

◆ unformatMemCard()

s32 unformatMemCard ( void  )

memCardCommand's MEMCARD_OP_UNFORMAT, left out: always fails as if there were no card

Definition at line 438 of file memcard.c.

◆ verifyChecksum()

s32 verifyChecksum ( void *  data,
s32  size,
char  expected 
)

XOR of every byte.

Definition at line 443 of file memcard.c.

◆ computeChecksum()

u8 computeChecksum ( void *  data,
s32  size 
)

The XOR of every byte, which verifyChecksum checks.

Definition at line 455 of file memcard.c.

Variable Documentation

◆ SAVE_FILE_NAME_JP

const char SAVE_FILE_NAME_JP[24] = "BISLPS-03446DMW3-JPN"

Definition at line 46 of file memcard.c.

Referenced by setSaveFileName().

◆ SAVE_FILE_NAMES

const char SAVE_FILE_NAMES[2][24]
Initial value:
= {
"BASLUS-01436DMW3-USA",
"BESLES-03936DMW3-EUR",
}

Definition at line 48 of file memcard.c.

Referenced by setSaveFileName().

◆ MEMCARD

◆ MEMCARD_FUNCS

MemCardFuncs MEMCARD_FUNCS
Initial value:
= {
}
u8 computeChecksum(void *data, s32 size)
The XOR of every byte, which verifyChecksum checks.
Definition memcard.c:455
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)
Definition memcard.c:270
void setSaveHeader(char *title, CardClut *clut, s32 count, void **icons)
The save file header: title (Shift-JIS), icon CLUT and 1-3 icon frames.
Definition memcard.c:86
s32 checkMemCard(s32 port)
Checks whether a card is in port port (MemCardExist)
Definition memcard.c:128
s32 formatMemCard(s32 port)
Formats an unformatted card.
Definition memcard.c:428
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.
Definition memcard.c:189
s32 listSaves(s32 port)
Reads the card's directory into MEMCARD.files.
Definition memcard.c:408
void setSaveFileName(void)
Definition memcard.c:57
void initMemCard(void)
Starts libmcrd and sets up MEMCARD: the save file name and the section sizes.
Definition memcard.c:7
s32 verifyChecksum(void *data, s32 size, char expected)
XOR of every byte.
Definition memcard.c:443
s32 unformatMemCard(void)
memCardCommand's MEMCARD_OP_UNFORMAT, left out: always fails as if there were no card
Definition memcard.c:438
s32 acceptMemCard(s32 port)
Checks a card in port port in full, finding out whether it is new or unformatted (MemCardAccept)
Definition memcard.c:160
s32 createSave(s32 port)
Creates the save file on the card.
Definition memcard.c:418

Definition at line 468 of file memcard.c.

Referenced by main(), SHOCKTST_updateEditor(), STAGSLCT_updateStageSelect(), STDWTITL_leaveTitle(), and STGMCARD_loadFiles().

◆ MEMCARD_SYNC_CMDS

s32 MEMCARD_SYNC_CMDS[MEMCARD_OP_UNFORMAT+1] = { 7, 8, 9, 10 }

The commands of memCardCommand's operations.

the MemCardSync command of each MEMCARD_OP_*

Definition at line 474 of file memcard.c.

Referenced by memCardCommand().