Fix GameCube memory card slot B detection and free-space check

CARD_Mount() alone reliably reports CARD_ERROR_NOCARD for a card physically
present in slot B - unlike slot A, which the IPL polls automatically at
boot, slot B needs an explicit CARD_Probe() first (the standard pattern in
every official devkitPro CARD sample). Also fixes
saveDeviceDolphinCardHasFreeSpace() treating CARD_GetDirectory()'s
CARD_ERROR_NOFILE (a totally empty card, not an actual error) as a hard
failure, which made any card with zero existing save files - slot B's in
this case, since slot A already had leftover test data on it - get
reported as full.

Confirmed via Dolphin with slot A disabled/slot B set to a memory card:
previously reported "no save device found", now correctly detects it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 16:49:18 -05:00
parent d7223d7387
commit e3f10e0926
2 changed files with 40 additions and 15 deletions
@@ -53,6 +53,15 @@ errorret_t saveDeviceDolphinCardUpdate(savedevice_t *device);
*/
void saveDeviceDolphinCardCheckAvailability(savedevice_t *device);
/**
* Maps a libogc CARD_ERROR_* result (from CARD_Probe or CARD_Mount) to the
* matching reasonKey.
*
* @param result The card_errors result code to map.
* @return The matching reasonKey, or a generic fallback if unrecognized.
*/
const char_t *saveDeviceDolphinCardErrorReasonKey(const int32_t result);
/**
* Returns whether the mounted memory card in the given slot has at least
* one block of free space and one free file entry remaining, by summing