2
2
// SPDX-License-Identifier: GPL-2.0-or-later
3
3
4
4
#include " common/logging/log.h"
5
+ #include " common/singleton.h"
5
6
#include " core/file_format/playgo_chunk.h"
7
+ #include " core/file_sys/fs.h"
6
8
#include " core/libraries/error_codes.h"
7
9
#include " core/libraries/libs.h"
8
10
#include " core/libraries/system/systemservice.h"
@@ -29,10 +31,9 @@ s32 PS4_SYSV_ABI scePlayGoClose(OrbisPlayGoHandle handle) {
29
31
if (handle != PlaygoHandle) {
30
32
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
31
33
}
32
- if (!playgo-> initialized ) {
34
+ if (!playgo) {
33
35
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
34
36
}
35
- playgo.reset ();
36
37
return ORBIS_OK;
37
38
}
38
39
@@ -98,7 +99,7 @@ s32 PS4_SYSV_ABI scePlayGoGetInstallSpeed(OrbisPlayGoHandle handle,
98
99
if (outSpeed == nullptr ) {
99
100
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
100
101
}
101
- if (!playgo-> initialized ) {
102
+ if (!playgo) {
102
103
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
103
104
}
104
105
@@ -126,7 +127,7 @@ s32 PS4_SYSV_ABI scePlayGoGetLanguageMask(OrbisPlayGoHandle handle,
126
127
if (outLanguageMask == nullptr ) {
127
128
return ORBIS_PLAYGO_ERROR_BAD_POINTER;
128
129
}
129
- if (!playgo-> initialized ) {
130
+ if (!playgo) {
130
131
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
131
132
}
132
133
@@ -148,7 +149,7 @@ s32 PS4_SYSV_ABI scePlayGoGetLocus(OrbisPlayGoHandle handle, const OrbisPlayGoCh
148
149
if (numberOfEntries == 0 ) {
149
150
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
150
151
}
151
- if (!playgo-> initialized ) {
152
+ if (!playgo) {
152
153
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
153
154
}
154
155
if (playgo->GetPlaygoHeader ().file_size == 0 ) {
@@ -180,7 +181,7 @@ s32 PS4_SYSV_ABI scePlayGoGetProgress(OrbisPlayGoHandle handle, const OrbisPlayG
180
181
if (numberOfEntries == 0 ) {
181
182
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
182
183
}
183
- if (!playgo-> initialized ) {
184
+ if (!playgo) {
184
185
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
185
186
}
186
187
if (playgo->GetPlaygoHeader ().file_size == 0 ) {
@@ -219,7 +220,7 @@ s32 PS4_SYSV_ABI scePlayGoGetToDoList(OrbisPlayGoHandle handle, OrbisPlayGoToDo*
219
220
if (numberOfEntries == 0 ) {
220
221
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
221
222
}
222
- if (!playgo-> initialized ) {
223
+ if (!playgo) {
223
224
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
224
225
}
225
226
*outEntries = 0 ; // nothing to do
@@ -242,17 +243,24 @@ s32 PS4_SYSV_ABI scePlayGoInitialize(OrbisPlayGoInitParams* param) {
242
243
if (param->bufSize < 0x200000 ) {
243
244
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
244
245
}
246
+ if (playgo) {
247
+ return ORBIS_PLAYGO_ERROR_ALREADY_INITIALIZED;
248
+ }
249
+
250
+ using namespace SystemService ;
245
251
246
252
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" );
255
258
}
259
+
260
+ s32 system_lang = 0 ;
261
+ sceSystemServiceParamGetInt (OrbisSystemServiceParamId::Lang, &system_lang);
262
+ playgo->langMask = scePlayGoConvertLanguage (system_lang);
263
+
256
264
return ORBIS_OK;
257
265
}
258
266
@@ -265,7 +273,7 @@ s32 PS4_SYSV_ABI scePlayGoOpen(OrbisPlayGoHandle* outHandle, const void* param)
265
273
if (param) {
266
274
return ORBIS_PLAYGO_ERROR_INVALID_ARGUMENT;
267
275
}
268
- if (!playgo-> initialized ) {
276
+ if (!playgo) {
269
277
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
270
278
}
271
279
if (playgo->GetPlaygoHeader ().file_size == 0 ) {
@@ -289,7 +297,7 @@ s32 PS4_SYSV_ABI scePlayGoPrefetch(OrbisPlayGoHandle handle, const OrbisPlayGoCh
289
297
if (numberOfEntries == 0 ) {
290
298
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
291
299
}
292
- if (!playgo-> initialized ) {
300
+ if (!playgo) {
293
301
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
294
302
}
295
303
@@ -310,7 +318,7 @@ s32 PS4_SYSV_ABI scePlayGoSetInstallSpeed(OrbisPlayGoHandle handle, OrbisPlayGoI
310
318
if (handle != PlaygoHandle) {
311
319
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
312
320
}
313
- if (!playgo-> initialized ) {
321
+ if (!playgo) {
314
322
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
315
323
}
316
324
@@ -339,7 +347,7 @@ s32 PS4_SYSV_ABI scePlayGoSetLanguageMask(OrbisPlayGoHandle handle,
339
347
if (handle != 1 ) {
340
348
return ORBIS_PLAYGO_ERROR_BAD_HANDLE;
341
349
}
342
- if (!playgo-> initialized ) {
350
+ if (!playgo) {
343
351
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
344
352
}
345
353
@@ -360,7 +368,7 @@ s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayG
360
368
if (numberOfEntries == 0 ) {
361
369
return ORBIS_PLAYGO_ERROR_BAD_SIZE;
362
370
}
363
- if (!playgo-> initialized ) {
371
+ if (!playgo) {
364
372
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
365
373
}
366
374
return ORBIS_OK;
@@ -369,11 +377,10 @@ s32 PS4_SYSV_ABI scePlayGoSetToDoList(OrbisPlayGoHandle handle, const OrbisPlayG
369
377
s32 PS4_SYSV_ABI scePlayGoTerminate () {
370
378
LOG_INFO (Lib_PlayGo, " called" );
371
379
372
- if (playgo->initialized ) {
373
- playgo->initialized = false ;
374
- } else {
380
+ if (!playgo) {
375
381
return ORBIS_PLAYGO_ERROR_NOT_INITIALIZED;
376
382
}
383
+ playgo.reset ();
377
384
return ORBIS_OK;
378
385
}
379
386
0 commit comments