mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 11:03:45 +01:00
Merge pull request #13560 from unknownbrackets/free-space
Io: Account for free space on the host device
This commit is contained in:
5 files changed
+37
-14
No files matched your search
@@ -72,6 +72,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
|
||||
CheckSetting(iniFile, gameID, "ForceSoftwareRenderer", &flags_.ForceSoftwareRenderer);
|
||||
CheckSetting(iniFile, gameID, "DarkStalkersPresentHack", &flags_.DarkStalkersPresentHack);
|
||||
CheckSetting(iniFile, gameID, "ReportSmallMemstick", &flags_.ReportSmallMemstick);
|
||||
CheckSetting(iniFile, gameID, "MemstickFixedFree", &flags_.MemstickFixedFree);
|
||||
CheckSetting(iniFile, gameID, "DateLimited", &flags_.DateLimited);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ struct CompatFlags {
|
||||
bool ForceSoftwareRenderer;
|
||||
bool DarkStalkersPresentHack;
|
||||
bool ReportSmallMemstick;
|
||||
bool MemstickFixedFree;
|
||||
bool DateLimited;
|
||||
};
|
||||
|
||||
|
||||
+1
-2
@@ -621,8 +621,6 @@ static void __IoVblank() {
|
||||
}
|
||||
|
||||
void __IoInit() {
|
||||
MemoryStick_Init();
|
||||
|
||||
asyncNotifyEvent = CoreTiming::RegisterEvent("IoAsyncNotify", __IoAsyncNotify);
|
||||
syncNotifyEvent = CoreTiming::RegisterEvent("IoSyncNotify", __IoSyncNotify);
|
||||
|
||||
@@ -663,6 +661,7 @@ void __IoInit() {
|
||||
|
||||
__KernelRegisterWaitTypeFuncs(WAITTYPE_ASYNCIO, __IoAsyncBeginCallback, __IoAsyncEndCallback);
|
||||
|
||||
MemoryStick_Init();
|
||||
lastMemStickState = MemoryStick_State();
|
||||
lastMemStickFatState = MemoryStick_FatState();
|
||||
__DisplayListenVblank(__IoVblank);
|
||||
|
||||
+28
-12
@@ -15,6 +15,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <algorithm>
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
@@ -28,12 +29,13 @@ static MemStickState memStickState;
|
||||
static MemStickFatState memStickFatState;
|
||||
static bool memStickNeedsAssign = false;
|
||||
static u64 memStickInsertedAt = 0;
|
||||
static uint64_t memstickInitialFree = 0;
|
||||
|
||||
const u64 normalMemstickSize = 9ULL * 1024 * 1024 * 1024;
|
||||
const u64 smallMemstickSize = 1ULL * 1024 * 1024 * 1024;
|
||||
|
||||
void MemoryStick_DoState(PointerWrap &p) {
|
||||
auto s = p.Section("MemoryStick", 1, 4);
|
||||
auto s = p.Section("MemoryStick", 1, 5);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
@@ -46,6 +48,9 @@ void MemoryStick_DoState(PointerWrap &p) {
|
||||
u64 memStickSize = normalMemstickSize;
|
||||
Do(p, memStickSize);
|
||||
}
|
||||
if (s >= 5) {
|
||||
Do(p, memstickInitialFree);
|
||||
}
|
||||
|
||||
if (s >= 3) {
|
||||
Do(p, memStickNeedsAssign);
|
||||
@@ -71,18 +76,28 @@ u64 MemoryStick_SectorSize() {
|
||||
}
|
||||
|
||||
u64 MemoryStick_FreeSpace() {
|
||||
// Cap the memory stick size to avoid math errors when old games get sizes that were
|
||||
// hard to imagine back then.
|
||||
// We have a compat setting to make it even smaller for Harry Potter : Goblet of Fire, see #13266.
|
||||
const u64 memStickSize = PSP_CoreParameter().compat.flags().ReportSmallMemstick ? smallMemstickSize : (u64)g_Config.iMemStickSizeGB * 1024 * 1024 * 1024;
|
||||
u64 usedSpace = pspFileSystem.getDirSize("ms0:/PSP/SAVEDATA/");// Assume the memory stick is only used to store savedata.
|
||||
u64 freeSpace;
|
||||
if (usedSpace >= memStickSize)
|
||||
freeSpace = 0;
|
||||
else
|
||||
freeSpace = memStickSize - usedSpace;
|
||||
const CompatFlags &flags = PSP_CoreParameter().compat.flags();
|
||||
u64 realFreeSpace = pspFileSystem.FreeSpace("ms0:/");
|
||||
|
||||
return freeSpace;
|
||||
// Cap the memory stick size to avoid math errors when old games get sizes that were
|
||||
// not planned for back then (even though 2GB cards were available.)
|
||||
// We have a compat setting to make it even smaller for Harry Potter : Goblet of Fire, see #13266.
|
||||
const u64 memStickSize = flags.ReportSmallMemstick ? smallMemstickSize : (u64)g_Config.iMemStickSizeGB * 1024 * 1024 * 1024;
|
||||
// Assume the memory stick is only used to store savedata.
|
||||
u64 usedSpace = pspFileSystem.getDirSize("ms0:/PSP/SAVEDATA/");
|
||||
u64 simulatedFreeSpace = 0;
|
||||
if (usedSpace < memStickSize) {
|
||||
simulatedFreeSpace = memStickSize - usedSpace;
|
||||
}
|
||||
if (flags.MemstickFixedFree) {
|
||||
// Assassin's Creed: Bloodlines fails to save if free space changes incorrectly during game.
|
||||
realFreeSpace = 0;
|
||||
if (usedSpace <= memstickInitialFree) {
|
||||
realFreeSpace = memstickInitialFree - usedSpace;
|
||||
}
|
||||
}
|
||||
|
||||
return std::min(simulatedFreeSpace, realFreeSpace);
|
||||
}
|
||||
|
||||
void MemoryStick_SetFatState(MemStickFatState state) {
|
||||
@@ -116,4 +131,5 @@ void MemoryStick_Init() {
|
||||
}
|
||||
|
||||
memStickNeedsAssign = false;
|
||||
memstickInitialFree = pspFileSystem.FreeSpace("ms0:/") + pspFileSystem.getDirSize("ms0:/PSP/SAVEDATA/");
|
||||
}
|
||||
@@ -784,6 +784,12 @@ ULJM05225 = true
|
||||
CPCS01043 = true
|
||||
ULUS10062 = true
|
||||
|
||||
[MemstickFixedFree]
|
||||
ULJM05571 = true
|
||||
ULES01367 = true
|
||||
NPEH00029 = true
|
||||
ULUS10455 = true
|
||||
|
||||
[DateLimited]
|
||||
# Car Jack Streets - issue #12698
|
||||
NPUZ00043 = true
|
||||
|
||||
Reference in new issue
Block a user