Skip to content

Commit

Permalink
Libretro: Fix saving in GB games (fixes #486)
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Jan 5, 2017
1 parent 61a657a commit 68985d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -13,6 +13,7 @@ Bugfixes:
- GBA BIOS: Implement BitUnPack
- ARM7: Fix MLA/*MULL/*MLAL timing
- GBA: Fix multiboot ROM loading
- Libretro: Fix saving in GB games (fixes mgba.io/i/486)
Misc:
- SDL: Remove scancode key input
- GBA Video: Clean up unused timers
Expand Down
35 changes: 22 additions & 13 deletions src/platform/libretro/libretro.c
Expand Up @@ -13,12 +13,12 @@
#include <mgba/core/version.h>
#ifdef M_CORE_GB
#include <mgba/gb/core.h>
#include <mgba/internal/gb/gb.h>
#endif
#ifdef M_CORE_GBA
#include <mgba/gba/core.h>
#include <mgba/gba/interface.h>
#include <mgba/internal/gba/gba.h>
#include <mgba/internal/gba/video.h>
#endif
#include <mgba-util/circle-buffer.h>
#include <mgba-util/memory.h>
Expand Down Expand Up @@ -524,19 +524,28 @@ size_t retro_get_memory_size(unsigned id) {
if (id != RETRO_MEMORY_SAVE_RAM) {
return 0;
}
switch (((struct GBA*) core->board)->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;
#ifdef M_CORE_GBA
if (core->platform(core) == PLATFORM_GBA) {
switch (((struct GBA*) core->board)->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;
}
}
#endif
#ifdef M_CORE_GB
if (core->platform(core) == PLATFORM_GB) {
return ((struct GB*) core->board)->sramSize;
}
#endif
return 0;
}

Expand Down

0 comments on commit 68985d8

Please sign in to comment.