Parity with ChrisNonyminus:Cemu:savestates; Add SS menu; Move SS func to CafeSystem

This commit is contained in:
Chris Spegal 2023-07-16 12:56:32 -04:00
parent bfbeeae6f6
commit 0f9d27ae12
19 changed files with 573 additions and 5 deletions

View file

@ -2638,6 +2638,16 @@ namespace coreinit
return FSA_RESULT::OK;
}
void FSSave(MemStreamWriter& s)
{
s.writeData(g_fsRegisteredClientBodies, sizeof(FSClientBody_t));
}
void FSRestore(MemStreamReader& s)
{
s.readData(g_fsRegisteredClientBodies, sizeof(FSClientBody_t));
}
void InitializeFS()
{
cafeExportRegister("coreinit", FSInit, LogType::CoreinitFile);

View file

@ -308,5 +308,8 @@ namespace coreinit
FS_VOLSTATE FSGetVolumeState(FSClient_t* fsClient);
void FSSave(MemStreamWriter& s);
void FSRestore(MemStreamReader& s);
void InitializeFS();
}; // namespace coreinit

View file

@ -198,6 +198,65 @@ namespace coreinit
return __currentCoreThread[currentInstance->spr.UPIR];
}
void SuspendAllThreads()
{
for (auto& thr : activeThread)
{
auto* ptr = (OSThread_t*)memory_getPointerFromVirtualOffset(thr);
if (thr != 0)
{
OSSuspendThread(ptr);
}
}
if (__currentCoreThread[0])
OSSuspendThread(__currentCoreThread[0]);
if (__currentCoreThread[1])
OSSuspendThread(__currentCoreThread[1]);
if (__currentCoreThread[2])
OSSuspendThread(__currentCoreThread[2]);
}
void ResumeAllThreads(bool* runningThreads)
{
for (auto& thr : activeThread)
{
int i = 0;
auto* ptr = (OSThread_t*)memory_getPointerFromVirtualOffset(thr);
if (thr != 0)
{
if (runningThreads && runningThreads[i])
{
if (s_threadToFiber.find(ptr) == s_threadToFiber.end())
__OSCreateHostThread(ptr);
OSResumeThread(ptr);
}
else if (!runningThreads)
{
if (s_threadToFiber.find(ptr) == s_threadToFiber.end())
__OSCreateHostThread(ptr);
OSResumeThread(ptr);
}
}
i++;
}
if (__currentCoreThread[0])
OSResumeThread(__currentCoreThread[0]);
if (__currentCoreThread[1])
OSResumeThread(__currentCoreThread[1]);
if (__currentCoreThread[2])
OSResumeThread(__currentCoreThread[2]);
}
std::vector<OSThread_t*> GetAllThreads()
{
auto ret = std::vector<OSThread_t*>();
ret.push_back(__currentCoreThread[0]);
ret.push_back(__currentCoreThread[1]);
ret.push_back(__currentCoreThread[2]);
return ret;
}
MPTR funcPtr_threadEntry = 0;
void threadEntry(PPCInterpreter_t* hCPU)

View file

@ -524,6 +524,9 @@ namespace coreinit
sint32 __OSResumeThreadInternal(OSThread_t* thread, sint32 resumeCount);
sint32 OSResumeThread(OSThread_t* thread);
void SuspendAllThreads();
void ResumeAllThreads(bool* runningThreads);
std::vector<OSThread_t*> GetAllThreads();
void OSContinueThread(OSThread_t* thread);
void __OSSuspendThreadInternal(OSThread_t* thread);
void __OSSuspendThreadNolock(OSThread_t* thread);