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;
}
// 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) {