/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "error/error.h" #include "save/savefile.h" #include #define SAVE_DOLPHIN_FILE_NAME_MAX 32 #define SAVE_DOLPHIN_SECTOR_SIZE 8192 #ifndef SAVE_DOLPHIN_GAME_CODE #define SAVE_DOLPHIN_GAME_CODE "DUSK" #endif #ifndef SAVE_DOLPHIN_CHANNEL #define SAVE_DOLPHIN_CHANNEL CARD_SLOTA #endif typedef struct { card_file cardFile; uint8_t cardBuffer[CARD_WORKAREA] __attribute__((aligned(32))); bool_t mounted; } savedolphin_t; /** * Initializes the save system on GameCube (memory card slot A by default). * * @return An error code if initialization fails. */ errorret_t saveInitDolphin(void); /** * Disposes of the save system on GameCube. * * @return An error code if disposal fails. */ errorret_t saveDisposeDolphin(void); /** * Loads a save file from the memory card for the given slot. * * @param slot The save slot index. * @param file Output save file data. * @return An error code if the load fails. */ errorret_t saveLoadDolphin(const uint8_t slot, savefile_t *file); /** * Writes a save file to the memory card for the given slot. * * @param slot The save slot index. * @param file Save file data to write. * @return An error code if the write fails. */ errorret_t saveWriteDolphin(const uint8_t slot, const savefile_t *file); /** * Deletes the save file for the given slot from the memory card. * * @param slot The save slot index. * @return An error code if the delete fails. */ errorret_t saveDeleteDolphin(const uint8_t slot); /** * Builds the memory card file name for a given save slot, from * SAVE_DOLPHIN_GAME_CODE and the slot index. * * @param slot The save slot index. * @param out Destination buffer for the file name. * @param max Size of out, in bytes. */ void saveGetFileNameDolphin( const uint8_t slot, char_t *out, const size_t max ); /** * Describes a libogc CARD_ERROR_* result code (see * https://libogc.devkitpro.org/group__card__errors.html), for logging * alongside the raw numeric code. * * @param result The result code returned by a CARD_* libogc call. * @return A human-readable description of the result code, or * "unknown card error" if result doesn't match a known CARD_ERROR_* code. */ const char_t *saveCardErrorStringDolphin(const int32_t result);