From d0d833bd305f300362200a78f3ee80af54684865 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sat, 5 May 2018 18:24:51 +0900 Subject: libretro.c: Use common memory card 2 for all games Memory card 2 is in the same folder as the loaded game. --- frontend/libretro.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 634242f..1e888e1 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1667,7 +1667,15 @@ void retro_init(void) if(!__ctr_svchax) Config.Cpu = CPU_INTERPRETER; #endif - strcpy(Config.Mcd2, "memcard2.mcd"); + if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir) { + const char CARD_FILE[] = "pcsx-card2.mcd"; + if (strlen(dir) + strlen(CARD_FILE) + 2 > sizeof(Config.Mcd2)) { + SysPrintf("Path '%s' is too long. Cannot use memcard 2. Use a shorter path.\n", dir); + } else { + snprintf(Config.Mcd2, sizeof(Config.Mcd2), "%s/%s", dir, CARD_FILE); + SysPrintf("Use memory card2: %s\n", Config.Mcd2); + } + } ret |= emu_core_init(); if (ret != 0) { -- cgit v1.2.3