libretro-mirrors / beetle-saturn-libretro

Standalone port of Mednafen Saturn to the libretro API.
GNU General Public License v2.0
61 stars 40 forks source link

CD Image Cache doesn't work #189

Closed Sanaki closed 3 years ago

Sanaki commented 3 years ago

Pretty straightforward issue. The CD Image Cache option does nothing. I tested both chd and bin+cue formats on Linux and asked someone on Windows to confirm as well. There's no change in memory usage or behavior regardless of the setting's state. The core was fully closed and reopened between checks.

bslenul commented 3 years ago

Not a dev so no idea if this is a proper fix or not, but after a quick look I tried this and it seems to work for me:

diff --git a/libretro.cpp b/libretro.cpp
index 9a49488..c38415a 100644
--- a/libretro.cpp
+++ b/libretro.cpp
@@ -1688,7 +1688,7 @@ bool retro_load_game_special(unsigned, const struct retro_game_info *, size_t)
    return false;
 }

-static bool cdimagecache = false;
+static bool image_memcache = false;

 static bool boot = true;

@@ -1710,11 +1710,11 @@ static void check_variables(bool startup)
    if (startup)
    {
       var.key = "beetle_saturn_cdimagecache";
-      cdimagecache = false;
+      image_memcache = false;

       if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
          if (!strcmp(var.value, "enabled"))
-            cdimagecache = true;
+            image_memcache = true;

       var.key = "beetle_saturn_shared_int";

@@ -1970,7 +1970,7 @@ static bool MDFNI_LoadGame( const char *name )
          uint8 fd_id[16];
          char sgid[16 + 1] = { 0 };

-         if ( disc_load_content( MDFNGameInfo, name, fd_id, sgid, cdimagecache ) )
+         if ( disc_load_content( MDFNGameInfo, name, fd_id, sgid, image_memcache ) )
          {
             log_cb(RETRO_LOG_INFO, "Game ID is: %s\n", sgid );

Basically replacing every cdimagecache with image_memcache since that's what being used in dics.cpp/.h.

Tried with Panzer Dragoon Saga (a 4 discs game) and 1st launch took a while, and I clearly see a difference in memory usage now.

Sanaki commented 3 years ago

I can confirm this fix works. Seems to be the correct way to fix it. You want to make the PR?

bslenul commented 3 years ago

Done, thanks for testing! 👍

Sanaki commented 3 years ago

Already solved prior to this issue. Not entirely sure how we both ended up with builds without it solved....