diff --git a/Core/HLE/sceNetAdhocMatching.cpp b/Core/HLE/sceNetAdhocMatching.cpp index 00a8f46108..df9d5c9188 100644 --- a/Core/HLE/sceNetAdhocMatching.cpp +++ b/Core/HLE/sceNetAdhocMatching.cpp @@ -2666,14 +2666,24 @@ int sceNetAdhocMatchingAbortSendData(int matchingId, const char *mac) { return hleLogDebug(Log::sceNet, 0); } +// A PSP keeps 0x20 bytes of the pool for itself. Its maximum is the largest allocation so far: 0 right +// after Init (pspautotests net/adhoc/matching). Once there's a context, half the pool, which +// isn't measured. +static u32 FakePoolSize() { + return fakePoolSize >= 0x20 ? fakePoolSize - 0x20 : 0; +} + +static u32 FakePoolMaxAlloc() { + return contexts != NULL ? FakePoolSize() / 2 : 0; +} + // Get the maximum memory usage by the matching library static int sceNetAdhocMatchingGetPoolMaxAlloc() { if (!g_Config.bEnableWlan) { return hleLogError(Log::sceNet, -1, "WLAN off"); } - // Lazy way out - hardcoded return value - return hleLogDebug(Log::sceNet, fakePoolSize / 2, "faked value"); + return hleLogDebug(Log::sceNet, FakePoolMaxAlloc(), "faked value"); } int sceNetAdhocMatchingGetPoolStat(u32 poolstatPtr) { @@ -2694,10 +2704,10 @@ int sceNetAdhocMatchingGetPoolStat(u32 poolstatPtr) { return hleLogError(Log::sceNet, SCE_NET_ADHOC_MATCHING_ERROR_INVALID_ARG, "adhocmatching invalid arg"); } - // Fill Poolstat with Fake Data - poolstat->pool = fakePoolSize; - poolstat->maximum = fakePoolSize / 2; // Max usage faked to halt the pool - poolstat->free = fakePoolSize - poolstat->maximum; + // Fake data, apart from right after Init. + poolstat->pool = FakePoolSize(); + poolstat->maximum = FakePoolMaxAlloc(); + poolstat->free = poolstat->pool - poolstat->maximum; // Return Success return hleLogDebug(Log::sceNet, 0); diff --git a/pspautotests b/pspautotests index 212f5b3f57..f979cad6c3 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit 212f5b3f5776aa770add6cb96a5d2bf5973f6770 +Subproject commit f979cad6c332e0c59084d46e47093a8d405ebf52