From: notaz Date: Sun, 13 Oct 2013 15:46:48 +0000 (+0300) Subject: libretro: empty srm prevention hack X-Git-Tag: v1.92~78 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fd6751db80565b9c0c1ba66e37c647fc724e6f2;p=picodrive.git libretro: empty srm prevention hack --- diff --git a/platform/libretro.c b/platform/libretro.c index ee15d9c8..23f0694e 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -741,14 +741,25 @@ void *retro_get_memory_data(unsigned id) size_t retro_get_memory_size(unsigned id) { + unsigned int i; + int sum; + if (id != RETRO_MEMORY_SAVE_RAM) return 0; if (PicoAHW & PAHW_MCD) // bram return 0x2000; - else + + if (Pico.m.frame_count == 0) return SRam.size; + + // if game doesn't write to sram, don't report it to + // libretro so that RA doesn't write out zeroed .srm + for (i = 0, sum = 0; i < SRam.size; i++) + sum |= SRam.data[i]; + + return (sum != 0) ? SRam.size : 0; } void retro_reset(void)