Libretro: Add savedata support

This commit is contained in:
Jeffrey Pfau 2015-03-08 22:24:29 -07:00
parent 1b591b5844
commit de7bd2fb55
1 changed files with 22 additions and 9 deletions

View File

@ -171,9 +171,8 @@ bool retro_load_game(const struct retro_game_info* game) {
return false; return false;
} }
// TODO savedata = malloc(SIZE_CART_FLASH1M);
save = 0; save = VFileFromMemory(savedata, SIZE_CART_FLASH1M);
savedata = 0;
GBALoadROM(&gba, rom, save, game->path); GBALoadROM(&gba, rom, save, game->path);
ARMReset(&cpu); 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) { void* retro_get_memory_data(unsigned id) {
// TODO if (id != RETRO_MEMORY_SAVE_RAM) {
UNUSED(id); return 0;
return 0; }
return savedata;
} }
size_t retro_get_memory_size(unsigned id) { size_t retro_get_memory_size(unsigned id) {
// TODO if (id != RETRO_MEMORY_SAVE_RAM) {
UNUSED(id); return 0;
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) { void GBARetroLog(struct GBAThread* thread, enum GBALogLevel level, const char* format, va_list args) {