mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-31 22:01:57 +00:00
In multithreadead, load the game async.
This way if it takes time to load, things aren't frozen while it's doing that. This allows us to show any sort of loading animation or etc. we want. Before, it might show a odd looking game select screen while loading, and then finally go to black. Now it immediately goes to black. Fixes #2030.
This commit is contained in:
parent
0fa371ccbf
commit
a73b15b963
@ -301,8 +301,13 @@ void System_Wake() {
|
||||
}
|
||||
|
||||
static bool pspIsInited = false;
|
||||
static bool pspIsIniting = false;
|
||||
|
||||
bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) {
|
||||
if (pspIsIniting) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) {
|
||||
#if defined(_WIN32) && defined(_M_X64)
|
||||
INFO_LOG(BOOT, "PPSSPP %s Windows 64 bit", PPSSPP_GIT_VERSION);
|
||||
#elif defined(_WIN32) && !defined(_M_X64)
|
||||
@ -312,17 +317,30 @@ bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) {
|
||||
#endif
|
||||
coreParameter = coreParam;
|
||||
coreParameter.errorString = "";
|
||||
pspIsIniting = true;
|
||||
|
||||
if (g_Config.bSeparateCPUThread) {
|
||||
Core_ListenShutdown(System_Wake);
|
||||
CPU_SetState(CPU_THREAD_PENDING);
|
||||
cpuThread = new std::thread(&CPU_RunLoop);
|
||||
cpuThread->detach();
|
||||
CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsReady);
|
||||
} else {
|
||||
CPU_Init();
|
||||
}
|
||||
|
||||
*error_string = coreParameter.errorString;
|
||||
return coreParameter.fileToStart != "";
|
||||
}
|
||||
|
||||
bool PSP_InitUpdate(std::string *error_string) {
|
||||
if (pspIsInited || !pspIsIniting) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (g_Config.bSeparateCPUThread && !CPU_IsReady()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = coreParameter.fileToStart != "";
|
||||
*error_string = coreParameter.errorString;
|
||||
if (success) {
|
||||
@ -333,7 +351,22 @@ bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) {
|
||||
}
|
||||
}
|
||||
pspIsInited = success;
|
||||
return success;
|
||||
pspIsIniting = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) {
|
||||
PSP_InitStart(coreParam, error_string);
|
||||
|
||||
if (g_Config.bSeparateCPUThread) {
|
||||
CPU_WaitStatus(cpuThreadReplyCond, &CPU_IsReady);
|
||||
}
|
||||
|
||||
return PSP_InitUpdate(error_string);
|
||||
}
|
||||
|
||||
bool PSP_IsIniting() {
|
||||
return pspIsIniting;
|
||||
}
|
||||
|
||||
bool PSP_IsInited() {
|
||||
@ -362,6 +395,7 @@ void PSP_Shutdown() {
|
||||
host->SetWindowTitle(0);
|
||||
currentMIPS = 0;
|
||||
pspIsInited = false;
|
||||
pspIsIniting = false;
|
||||
}
|
||||
|
||||
void PSP_RunLoopUntil(u64 globalticks) {
|
||||
|
@ -49,6 +49,9 @@ extern GlobalUIState globalUIState;
|
||||
void UpdateUIState(GlobalUIState newState);
|
||||
|
||||
bool PSP_Init(const CoreParameter &coreParam, std::string *error_string);
|
||||
bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string);
|
||||
bool PSP_InitUpdate(std::string *error_string);
|
||||
bool PSP_IsIniting();
|
||||
bool PSP_IsInited();
|
||||
void PSP_Shutdown();
|
||||
void PSP_RunLoopUntil(u64 globalticks);
|
||||
|
@ -63,14 +63,29 @@ EmuScreen::EmuScreen(const std::string &filename)
|
||||
}
|
||||
|
||||
void EmuScreen::bootGame(const std::string &filename) {
|
||||
booted_ = true;
|
||||
std::string fileToStart = filename;
|
||||
if (PSP_IsIniting()) {
|
||||
std::string error_string;
|
||||
booted_ = PSP_InitUpdate(&error_string);
|
||||
if (booted_) {
|
||||
invalid_ = !PSP_IsInited();
|
||||
if (invalid_) {
|
||||
errorMessage_ = error_string;
|
||||
ERROR_LOG(BOOT, "%s", errorMessage_.c_str());
|
||||
System_SendMessage("event", "failstartgame");
|
||||
return;
|
||||
}
|
||||
bootComplete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
invalid_ = true;
|
||||
|
||||
CoreParameter coreParam;
|
||||
coreParam.cpuCore = g_Config.bJit ? CPU_JIT : CPU_INTERPRETER;
|
||||
coreParam.gpuCore = g_Config.bSoftwareRendering ? GPU_SOFTWARE : GPU_GLES;
|
||||
coreParam.enableSound = g_Config.bEnableSound;
|
||||
coreParam.fileToStart = fileToStart;
|
||||
coreParam.fileToStart = filename;
|
||||
coreParam.mountIso = "";
|
||||
coreParam.startPaused = false;
|
||||
coreParam.printfEmuLog = false;
|
||||
@ -92,23 +107,24 @@ void EmuScreen::bootGame(const std::string &filename) {
|
||||
coreParam.pixelHeight = pixel_yres;
|
||||
|
||||
std::string error_string;
|
||||
if (PSP_Init(coreParam, &error_string)) {
|
||||
invalid_ = false;
|
||||
} else {
|
||||
if (!PSP_InitStart(coreParam, &error_string)) {
|
||||
booted_ = true;
|
||||
invalid_ = true;
|
||||
errorMessage_ = error_string;
|
||||
ERROR_LOG(BOOT, "%s", errorMessage_.c_str());
|
||||
System_SendMessage("event", "failstartgame");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void EmuScreen::bootComplete() {
|
||||
globalUIState = UISTATE_INGAME;
|
||||
host->BootDone();
|
||||
host->UpdateDisassembly();
|
||||
|
||||
g_gameInfoCache.FlushBGs();
|
||||
|
||||
NOTICE_LOG(BOOT, "Loading %s...", fileToStart.c_str());
|
||||
NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str());
|
||||
autoLoad();
|
||||
|
||||
I18NCategory *s = GetI18NCategory("Screen");
|
||||
|
@ -48,6 +48,7 @@ protected:
|
||||
|
||||
private:
|
||||
void bootGame(const std::string &filename);
|
||||
void bootComplete();
|
||||
void processAxis(const AxisInput &axis, int direction);
|
||||
|
||||
void pspKey(int pspKeyCode, int flags);
|
||||
|
Loading…
x
Reference in New Issue
Block a user