Skip to content

Commit b00a321

Browse files
authored
playgo: Fix loading PlayGo file. (#1639)
1 parent 394a146 commit b00a321

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

src/core/file_format/playgo_chunk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct PlaygoChunk {
9797

9898
class PlaygoFile {
9999
public:
100-
bool initialized = false;
101100
OrbisPlayGoHandle handle = 0;
102101
OrbisPlayGoChunkId id = 0;
103102
OrbisPlayGoLocus locus = OrbisPlayGoLocus::NotDownloaded;

src/core/libraries/playgo/playgo.cpp

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// SPDX-License-Identifier: GPL-2.0-or-later
33

44
#include "common/logging/log.h"
5+
#include "common/singleton.h"
56
#include "core/file_format/playgo_chunk.h"
7+
#include "core/file_sys/fs.h"
68
#include "core/libraries/error_codes.h"
79
#include "core/libraries/libs.h"
810
#include "core/libraries/system/systemservice.h"
@@ -29,10 +31,9 @@ s32 PS4_SYSV_ABI scePlayGoClose(OrbisPlayGoHandle handle) {
2931
if (handle != PlaygoHandle) {
3032
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
3133
}
32-
if (!playgo->initialized) {
34+
if (!playgo) {
3335
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
3436
}
35-
playgo.reset();
3637
return ORBIS_OK;
3738
}
3839

@@ -98,7 +99,7 @@ s32 PS4_SYSV_ABI scePlayGoGetInstallSpeed(OrbisPlayGoHandle handle,
9899
if (outSpeed == nullptr) {
99100
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
100101
}
101-
if (!playgo->initialized) {
102+
if (!playgo) {
102103
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
103104
}
104105

@@ -126,7 +127,7 @@ s32 PS4_SYSV_ABI scePlayGoGetLanguageMask(OrbisPlayGoHandle handle,
126127
if (outLanguageMask == nullptr) {
127128
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
128129
}
129-
if (!playgo->initialized) {
130+
if (!playgo) {
130131
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
131132
}
132133

@@ -148,7 +149,7 @@ s32 PS4_SYSV_ABI scePlayGoGetLocus(OrbisPlayGoHandle handle, const OrbisPlayGoCh
148149
if (numberOfEntries == 0) {
149150
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
150151
}
151-
if (!playgo->initialized) {
152+
if (!playgo) {
152153
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
153154
}
154155
if (playgo->GetPlaygoHeader().file_size == 0) {
@@ -180,7 +181,7 @@ s32 PS4_SYSV_ABI scePlayGoGetProgress(OrbisPlayGoHandle handle, const OrbisPlayG
180181
if (numberOfEntries == 0) {
181182
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
182183
}
183-
if (!playgo->initialized) {
184+
if (!playgo) {
184185
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
185186
}
186187
if (playgo->GetPlaygoHeader().file_size == 0) {
@@ -219,7 +220,7 @@ s32 PS4_SYSV_ABI scePlayGoGetToDoList(OrbisPlayGoHandle handle, OrbisPlayGoToDo*
219220
if (numberOfEntries == 0) {
220221
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
221222
}
222-
if (!playgo->initialized) {
223+
if (!playgo) {
223224
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
224225
}
225226
*outEntries = 0; // nothing to do
@@ -242,17 +243,24 @@ s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) {
242243
if (param->bufSize < 0x200000) {
243244
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
244245
}
246+
if (playgo) {
247+
return ORBIS_PLAYGO_ERROR_ALREADY_INITIALIZED;
248+
}
249+
250+
using namespace SystemService;
245251

246252
playgo = std::make_unique<PlaygoFile>();
247-
if (!playgo->initialized) {
248-
using namespace SystemService;
249-
s32 system_lang = 0;
250-
sceSystemServiceParamGetInt(OrbisSystemServiceParamId::Lang, &system_lang);
251-
playgo->langMask = scePlayGoConvertLanguage(system_lang);
252-
playgo->initialized = true;
253-
} else {
254-
return ORBIS_PLAYGO_ERROR_ALREADY_INITIALIZED;
253+
254+
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
255+
const auto file_path = mnt->GetHostPath("/app0/sce_sys/playgo-chunk.dat");
256+
if (!playgo->Open(file_path)) {
257+
LOG_WARNING(Lib_PlayGo, "Could not open PlayGo file");
255258
}
259+
260+
s32 system_lang = 0;
261+
sceSystemServiceParamGetInt(OrbisSystemServiceParamId::Lang, &system_lang);
262+
playgo->langMask = scePlayGoConvertLanguage(system_lang);
263+
256264
return ORBIS_OK;
257265
}
258266

@@ -265,7 +273,7 @@ s32 PS4_SYSV_ABI scePlayGoOpen(OrbisPlayGoHandle* outHandle, const void* param)
265273
if (param) {
266274
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
267275
}
268-
if (!playgo->initialized) {
276+
if (!playgo) {
269277
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
270278
}
271279
if (playgo->GetPlaygoHeader().file_size == 0) {
@@ -289,7 +297,7 @@ s32 PS4_SYSV_ABI scePlayGoPrefetch(OrbisPlayGoHandle handle, const OrbisPlayGoCh
289297
if (numberOfEntries == 0) {
290298
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
291299
}
292-
if (!playgo->initialized) {
300+
if (!playgo) {
293301
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
294302
}
295303

@@ -310,7 +318,7 @@ s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(OrbisPlayGoHandle handle, OrbisPlayGoI
310318
if (handle != PlaygoHandle) {
311319
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
312320
}
313-
if (!playgo->initialized) {
321+
if (!playgo) {
314322
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
315323
}
316324

@@ -339,7 +347,7 @@ s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle,
339347
if (handle != 1) {
340348
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
341349
}
342-
if (!playgo->initialized) {
350+
if (!playgo) {
343351
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
344352
}
345353

@@ -360,7 +368,7 @@ s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayG
360368
if (numberOfEntries == 0) {
361369
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
362370
}
363-
if (!playgo->initialized) {
371+
if (!playgo) {
364372
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
365373
}
366374
return ORBIS_OK;
@@ -369,11 +377,10 @@ s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayG
369377
s32 PS4_SYSV_ABI scePlayGoTerminate() {
370378
LOG_INFO(Lib_PlayGo, "called");
371379

372-
if (playgo->initialized) {
373-
playgo->initialized = false;
374-
} else {
380+
if (!playgo) {
375381
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
376382
}
383+
playgo.reset();
377384
return ORBIS_OK;
378385
}
379386

src/emulator.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "common/scm_rev.h"
2323
#include "common/singleton.h"
2424
#include "common/version.h"
25-
#include "core/file_format/playgo_chunk.h"
2625
#include "core/file_format/psf.h"
2726
#include "core/file_format/splash.h"
2827
#include "core/file_format/trp.h"
@@ -157,12 +156,6 @@ void Emulator::Run(const std::filesystem::path& file) {
157156
fw_version = param_sfo->GetInteger("SYSTEM_VER").value_or(0x4700000);
158157
app_version = param_sfo->GetString("APP_VER").value_or("Unknown version");
159158
LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version);
160-
} else if (entry.path().filename() == "playgo-chunk.dat") {
161-
auto* playgo = Common::Singleton<PlaygoFile>::Instance();
162-
auto filepath = sce_sys_folder / "playgo-chunk.dat";
163-
if (!playgo->Open(filepath)) {
164-
LOG_ERROR(Loader, "PlayGo: unable to open file");
165-
}
166159
} else if (entry.path().filename() == "pic1.png") {
167160
auto* splash = Common::Singleton<Splash>::Instance();
168161
if (splash->IsLoaded()) {

0 commit comments

Comments
 (0)