From 0711463c1e4ff4d55d09a1e856f4500ff2ee6729 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sun, 13 Oct 2013 18:28:17 +0300 Subject: [PATCH] Allow partial SRAM load Different cores that emulate the same system may have slightly different understanding of SRAM, like it currently is for Genesis Plus GX vs PicoDrive. Currently Genesis Plus GX uses larger padding, which means it creates larger files. When loading such file for PicoDrive, current code refuses to load it and this effectively destroys user's save because new SRAM file is written on PicoDrive's exit. To fix this, allow partial load (and print a warning). --- file.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/file.c b/file.c index afb1b22f88..f74bbea6b8 100644 --- a/file.c +++ b/file.c @@ -424,8 +424,15 @@ void load_ram_file(const char *path, int type) void *buf = NULL; ssize_t rc = read_file(path, &buf); - if (rc > 0 && rc <= (ssize_t)size) + if (rc > 0) + { + if (rc > (ssize_t)size) + { + RARCH_WARN("SRAM is larger than implementation expects, doing partial load.\n"); + rc = size; + } memcpy(data, buf, rc); + } free(buf); }