X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Flibretro.c;h=23f0694effbdc90ebf45d7a9a267f13e529a96f9;hb=9db6a54485501b56b0f2f5db4d093c38fe495bda;hp=ee15d9c820ced9f66951e15e1ff2bb1b4887749a;hpb=274fcc35aa20e9777a8e09630a94088757384329;p=picodrive.git diff --git a/platform/libretro.c b/platform/libretro.c index ee15d9c..23f0694 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)