X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Flibretro.c;h=23f0694effbdc90ebf45d7a9a267f13e529a96f9;hb=126eb5f46978a7e97aae210971f1364ee548a646;hp=f59cf6720d5dfafb0c613410b37d2f95fed19228;hpb=51c089500cdaed23ca2532d0910a2ace62ea34ba;p=picodrive.git diff --git a/platform/libretro.c b/platform/libretro.c index f59cf67..23f0694 100644 --- a/platform/libretro.c +++ b/platform/libretro.c @@ -500,7 +500,7 @@ static unsigned int disk_get_image_index(void) static bool disk_set_image_index(unsigned int index) { - cd_img_type cd_type; + enum cd_img_type cd_type; int ret; if (index >= sizeof(disks) / sizeof(disks[0])) @@ -521,7 +521,7 @@ static bool disk_set_image_index(unsigned int index) ret = -1; cd_type = PicoCdCheck(disks[index].fname, NULL); if (cd_type != CIT_NOT_CD) - ret = Insert_CD(disks[index].fname, cd_type); + ret = cdd_load(disks[index].fname, cd_type); if (ret != 0) { lprintf("Load failed, invalid CD image?\n"); return 0; @@ -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) @@ -882,7 +893,6 @@ void retro_init(void) #endif PsndRate = 44100; PicoAutoRgnOrder = 0x184; // US, EU, JP - PicoCDBuffers = 0; vout_width = 320; vout_height = 240;