From 006f409dc2abef51d02a1a4a95a9620100fb326b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Israelson?= <57065102+israpps@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:32:50 -0300 Subject: [PATCH] port libmc sample to latest SDK and make it check both ports --- ee/rpc/memorycard/samples/mc_example.c | 43 +++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/ee/rpc/memorycard/samples/mc_example.c b/ee/rpc/memorycard/samples/mc_example.c index 71e62403822..3c9b2e1c144 100644 --- a/ee/rpc/memorycard/samples/mc_example.c +++ b/ee/rpc/memorycard/samples/mc_example.c @@ -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 +#include #include #include #include @@ -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() { @@ -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. @@ -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 @@ -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); } }