Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions ee/rpc/memorycard/samples/mc_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Copyright 2001-2025, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# libmc API sample.
*/

#define NEWLIB_PORT_AWARE

#include <tamtypes.h>
#include <sjis.h>
#include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
Expand All @@ -33,7 +36,7 @@ void LoadModules(void);
int CreateSave(void);

#define ARRAY_ENTRIES 64
static mcTable mcDir[ARRAY_ENTRIES] __attribute__((aligned(64)));
static sceMcTblGetDir mcDir[ARRAY_ENTRIES] __attribute__((aligned(64)));
static int mc_Type, mc_Free, mc_Format;

int main() {
Expand Down Expand Up @@ -75,17 +78,21 @@ int main() {
// if the memcard is formatted or not.

// Since this is the first call, -1 should be returned.
mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format);
mcSync(0, NULL, &ret);
printf("mcGetInfo returned %d\n",ret);
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);

// Assuming that the same memory card is connected, this should return 0
mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format);
mcSync(0, NULL, &ret);
printf("mcGetInfo returned %d\n",ret);
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
for (int p = 0; p < 2; p++)
{
printf("testing mcGetInfo for mc%d\n", p);
mcGetInfo(p, 0, &mc_Type, &mc_Free, &mc_Format);
mcSync(0, NULL, &ret);
printf("mcGetInfo returned %d\n",ret);
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
// Assuming that the same memory card is connected, this should return 0
mcGetInfo(p,0,&mc_Type,&mc_Free,&mc_Format);
mcSync(0, NULL, &ret);
printf("mcGetInfo returned %d\n",ret);
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);

}

// int mcGetDir(int port, int slot, char *name, unsigned mode, int maxent, mcTable* table);
//
// mcGetDir retrieves the directory structure of a specific path on the memory card.
Expand All @@ -105,10 +112,10 @@ int main() {

for(i=0; i < ret; i++)
{
if(mcDir[i].attrFile & MC_ATTR_SUBDIR)
printf("[DIR] %s\n", mcDir[i].name);
if(mcDir[i].AttrFile & MC_ATTR_SUBDIR)
printf("[DIR] %s\n", mcDir[i].EntryName);
else
printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte);
printf("%s - %d bytes\n", mcDir[i].EntryName, mcDir[i].FileSizeByte);
}

// Check if existing save is present
Expand All @@ -132,10 +139,10 @@ int main() {

for(i=0; i < ret; i++)
{
if(mcDir[i].attrFile & MC_ATTR_SUBDIR)
printf("[DIR] %s\n", mcDir[i].name);
if(mcDir[i].AttrFile & MC_ATTR_SUBDIR)
printf("[DIR] %s\n", mcDir[i].EntryName);
else
printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte);
printf("%s - %d bytes\n", mcDir[i].EntryName, mcDir[i].FileSizeByte);
}
}

Expand Down