Skip to content

Commit ba63930

Browse files
authored
Merge pull request #786 from israpps/patch-24
fix libmc sample for latest SDK and make it check both ports
2 parents 566ed82 + 006f409 commit ba63930

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

ee/rpc/memorycard/samples/mc_example.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
# ____| | ____| | | |____|
44
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
55
#-----------------------------------------------------------------------
6-
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
6+
# Copyright 2001-2025, ps2dev - http://www.ps2dev.org
77
# Licenced under Academic Free License version 2.0
88
# Review ps2sdk README & LICENSE files for further details.
99
#
1010
# libmc API sample.
1111
*/
1212

13+
#define NEWLIB_PORT_AWARE
14+
1315
#include <tamtypes.h>
16+
#include <sjis.h>
1417
#include <kernel.h>
1518
#include <sifrpc.h>
1619
#include <loadfile.h>
@@ -33,7 +36,7 @@ void LoadModules(void);
3336
int CreateSave(void);
3437

3538
#define ARRAY_ENTRIES 64
36-
static mcTable mcDir[ARRAY_ENTRIES] __attribute__((aligned(64)));
39+
static sceMcTblGetDir mcDir[ARRAY_ENTRIES] __attribute__((aligned(64)));
3740
static int mc_Type, mc_Free, mc_Format;
3841

3942
int main() {
@@ -75,17 +78,21 @@ int main() {
7578
// if the memcard is formatted or not.
7679

7780
// Since this is the first call, -1 should be returned.
78-
mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format);
79-
mcSync(0, NULL, &ret);
80-
printf("mcGetInfo returned %d\n",ret);
81-
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
82-
83-
// Assuming that the same memory card is connected, this should return 0
84-
mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format);
85-
mcSync(0, NULL, &ret);
86-
printf("mcGetInfo returned %d\n",ret);
87-
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
81+
for (int p = 0; p < 2; p++)
82+
{
83+
printf("testing mcGetInfo for mc%d\n", p);
84+
mcGetInfo(p, 0, &mc_Type, &mc_Free, &mc_Format);
85+
mcSync(0, NULL, &ret);
86+
printf("mcGetInfo returned %d\n",ret);
87+
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
88+
// Assuming that the same memory card is connected, this should return 0
89+
mcGetInfo(p,0,&mc_Type,&mc_Free,&mc_Format);
90+
mcSync(0, NULL, &ret);
91+
printf("mcGetInfo returned %d\n",ret);
92+
printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format);
8893

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

106113
for(i=0; i < ret; i++)
107114
{
108-
if(mcDir[i].attrFile & MC_ATTR_SUBDIR)
109-
printf("[DIR] %s\n", mcDir[i].name);
115+
if(mcDir[i].AttrFile & MC_ATTR_SUBDIR)
116+
printf("[DIR] %s\n", mcDir[i].EntryName);
110117
else
111-
printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte);
118+
printf("%s - %d bytes\n", mcDir[i].EntryName, mcDir[i].FileSizeByte);
112119
}
113120

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

133140
for(i=0; i < ret; i++)
134141
{
135-
if(mcDir[i].attrFile & MC_ATTR_SUBDIR)
136-
printf("[DIR] %s\n", mcDir[i].name);
142+
if(mcDir[i].AttrFile & MC_ATTR_SUBDIR)
143+
printf("[DIR] %s\n", mcDir[i].EntryName);
137144
else
138-
printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte);
145+
printf("%s - %d bytes\n", mcDir[i].EntryName, mcDir[i].FileSizeByte);
139146
}
140147
}
141148

0 commit comments

Comments
 (0)