Permalink
Browse files

Core: Asynchronously load the main ELF.

Sometimes it takes a little time.  More importantly, this allows us to
load caches or do other things at start that might be a tad slow.

Not doing anything like that yet, though.
  • Loading branch information...
unknownbrackets committed Jan 2, 2018
1 parent 307efe7 commit b41413b8a5c5421257a7b9613fd893490f5756a2
Showing with 42 additions and 6 deletions.
  1. +38 −3 Core/PSPLoaders.cpp
  2. +4 −3 Core/System.cpp
View
@@ -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 <thread>
#include "file/file_util.h"
#include "util/text/utf8.h"
@@ -250,7 +251,20 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
g_Config.loadGameConfig(id);
host->SendUIMessage("config_loaded", "");
INFO_LOG(LOADER,"Loading %s...", bootpath.c_str());
return __KernelLoadExec(bootpath.c_str(), 0, error_string);
std::thread th([bootpath] {
// TODO: We can't use the initial error_string pointer.
bool success = __KernelLoadExec(bootpath.c_str(), 0, &PSP_CoreParameter().errorString);
if (success && coreState == CORE_POWERUP) {
coreState = PSP_CoreParameter().startPaused ? CORE_STEPPING : CORE_RUNNING;
} else {
coreState = CORE_ERROR;
// TODO: This is a crummy way to communicate the error...
PSP_CoreParameter().fileToStart = "";
}
});
th.detach();
return true;
}
static std::string NormalizePath(const std::string &path) {
@@ -354,13 +368,34 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
}
// End of temporary code
return __KernelLoadExec(finalName.c_str(), 0, error_string);
std::thread th([finalName] {
bool success = __KernelLoadExec(finalName.c_str(), 0, &PSP_CoreParameter().errorString);
if (success && coreState == CORE_POWERUP) {
coreState = PSP_CoreParameter().startPaused ? CORE_STEPPING : CORE_RUNNING;
} else {
coreState = CORE_ERROR;
// TODO: This is a crummy way to communicate the error...
PSP_CoreParameter().fileToStart = "";
}
});
th.detach();
return true;
}
bool Load_PSP_GE_Dump(FileLoader *fileLoader, std::string *error_string) {
BlobFileSystem *umd = new BlobFileSystem(&pspFileSystem, fileLoader, "data.ppdmp");
pspFileSystem.Mount("disc0:", umd);
__KernelLoadGEDump("disc0:/data.ppdmp", error_string);
std::thread th([] {
bool success = __KernelLoadGEDump("disc0:/data.ppdmp", &PSP_CoreParameter().errorString);
if (success && coreState == CORE_POWERUP) {
coreState = PSP_CoreParameter().startPaused ? CORE_STEPPING : CORE_RUNNING;
} else {
coreState = CORE_ERROR;
// TODO: This is a crummy way to communicate the error...
PSP_CoreParameter().fileToStart = "";
}
});
th.detach();
return true;
}
View
@@ -181,6 +181,8 @@ bool CPU_NextStateNot(CPUThreadState from, CPUThreadState to) {
}
bool CPU_IsReady() {
if (coreState == CORE_POWERUP)
return false;
return cpuThreadState == CPU_THREAD_RUNNING || cpuThreadState == CPU_THREAD_NOT_RUNNING;
}
@@ -270,7 +272,8 @@ void CPU_Init() {
// TODO: Check Game INI here for settings, patches and cheats, and modify coreParameter accordingly
// Why did we check for CORE_POWERDOWN here?
// If they shut down early, we'll catch it when load completes.
// Note: this may return before init is complete, which is checked if CPU_IsReady().
if (!LoadFile(&loadedFile, &coreParameter.errorString)) {
CPU_Shutdown();
coreParameter.fileToStart = "";
@@ -282,8 +285,6 @@ void CPU_Init() {
if (coreParameter.updateRecent) {
g_Config.AddRecent(filename);
}
coreState = coreParameter.startPaused ? CORE_STEPPING : CORE_RUNNING;
}
void CPU_Shutdown() {

0 comments on commit b41413b

Please sign in to comment.