diff --git a/Common/System/System.h b/Common/System/System.h index 8bc5d71b98..e171d9f760 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -219,6 +219,8 @@ enum SystemProperty { SYSPROP_CAN_READ_BATTERY_PERCENTAGE, SYSPROP_BATTERY_PERCENTAGE, + + SYSPROP_ENOUGH_RAM_FOR_FULL_ISO, }; enum class SystemNotification { diff --git a/Core/FileLoaders/RamCachingFileLoader.cpp b/Core/FileLoaders/RamCachingFileLoader.cpp index 826e0b11c4..5e7eb07e62 100644 --- a/Core/FileLoaders/RamCachingFileLoader.cpp +++ b/Core/FileLoaders/RamCachingFileLoader.cpp @@ -21,6 +21,7 @@ #include "Common/Thread/ThreadUtil.h" #include "Common/TimeUtil.h" +#include "Common/Log.h" #include "Core/FileLoaders/RamCachingFileLoader.h" // Takes ownership of backend. @@ -91,6 +92,7 @@ void RamCachingFileLoader::InitCache() { // Overallocate for the last block. cache_ = (u8 *)malloc((size_t)blockCount << BLOCK_SHIFT); if (cache_ == nullptr) { + ERROR_LOG(Log::IO, "Failed to allocate cache for Cache full ISO in RAM! Will fall back to regular reads."); return; } aheadRemaining_ = blockCount; @@ -178,6 +180,8 @@ void RamCachingFileLoader::SaveIntoCache(s64 pos, size_t bytes, Flags flags) { if (blocksToRead >= MAX_BLOCKS_PER_READ) { break; } + + // TODO: Shouldn't we break as soon as we see a 1? } } } diff --git a/Core/System.cpp b/Core/System.cpp index 4da27e3232..27a27998ef 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -425,15 +425,17 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) { IdentifiedFileType type = Identify_File(loadedFile, &g_CoreParameter.errorString); g_CoreParameter.fileType = type; - if (g_Config.bCacheFullIsoInRam) { - switch (g_CoreParameter.fileType) { - case IdentifiedFileType::PSP_ISO: - case IdentifiedFileType::PSP_ISO_NP: - loadedFile = new RamCachingFileLoader(loadedFile); - break; - default: - INFO_LOG(Log::System, "RAM caching is on, but file is not an ISO, so ignoring"); - break; + if (System_GetPropertyBool(SYSPROP_ENOUGH_RAM_FOR_FULL_ISO)) { + if (g_Config.bCacheFullIsoInRam) { + switch (g_CoreParameter.fileType) { + case IdentifiedFileType::PSP_ISO: + case IdentifiedFileType::PSP_ISO_NP: + loadedFile = new RamCachingFileLoader(loadedFile); + break; + default: + INFO_LOG(Log::System, "RAM caching is on, but file is not an ISO, so ignoring"); + break; + } } } diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 1dd710ac35..537f250762 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -625,7 +625,13 @@ bool System_GetPropertyBool(SystemProperty prop) { #endif case SYSPROP_CAN_READ_BATTERY_PERCENTAGE: return true; -default: + case SYSPROP_ENOUGH_RAM_FOR_FULL_ISO: +#if defined(MOBILE_DEVICE) + return false; +#else + return true; +#endif + default: return false; } } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index ce9ad044db..a6d2e9d55a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1341,7 +1341,10 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { if (System_GetPropertyBool(SYSPROP_HAS_KEYBOARD)) systemSettings->Add(new CheckBox(&g_Config.bBypassOSKWithKeyboard, sy->T("Use system native keyboard"))); - systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")))->SetEnabled(!PSP_IsInited()); + if (System_GetPropertyBool(SYSPROP_ENOUGH_RAM_FOR_FULL_ISO)) { + systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")))->SetEnabled(!PSP_IsInited()); + } + systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, sy->T("VersionCheck", "Check for new versions of PPSSPP"))); systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, sy->T("Screenshots as PNG"))); static const char *screenshotModeChoices[] = { "Final processed image", "Raw game image" }; diff --git a/Windows/main.cpp b/Windows/main.cpp index 5b38d02c75..f9ede5e66f 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -406,6 +406,8 @@ bool System_GetPropertyBool(SystemProperty prop) { return true; case SYSPROP_CAN_READ_BATTERY_PERCENTAGE: return true; + case SYSPROP_ENOUGH_RAM_FOR_FULL_ISO: + return true; default: return false; }