diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c index 1fe3814d6..d6f67a34d 100644 --- a/src/platform/libretro/libretro.c +++ b/src/platform/libretro/libretro.c @@ -171,9 +171,8 @@ bool retro_load_game(const struct retro_game_info* game) { return false; } - // TODO - save = 0; - savedata = 0; + savedata = malloc(SIZE_CART_FLASH1M); + save = VFileFromMemory(savedata, SIZE_CART_FLASH1M); GBALoadROM(&gba, rom, save, game->path); ARMReset(&cpu); @@ -232,15 +231,29 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info* i } void* retro_get_memory_data(unsigned id) { - // TODO - UNUSED(id); - return 0; + if (id != RETRO_MEMORY_SAVE_RAM) { + return 0; + } + return savedata; } size_t retro_get_memory_size(unsigned id) { - // TODO - UNUSED(id); - return 0; + if (id != RETRO_MEMORY_SAVE_RAM) { + return 0; + } + switch (gba.memory.savedata.type) { + case SAVEDATA_AUTODETECT: + case SAVEDATA_FLASH1M: + return SIZE_CART_FLASH1M; + case SAVEDATA_FLASH512: + return SIZE_CART_FLASH512; + case SAVEDATA_EEPROM: + return SIZE_CART_EEPROM; + case SAVEDATA_SRAM: + return SIZE_CART_SRAM; + case SAVEDATA_FORCE_NONE: + return 0; + } } void GBARetroLog(struct GBAThread* thread, enum GBALogLevel level, const char* format, va_list args) {