2012-11-01 15:19:01 +00:00
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
2012-11-04 22:01:49 +00:00
// the Free Software Foundation, version 2.0 or later versions.
2012-11-01 15:19:01 +00:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
2013-12-29 23:11:29 +00:00
# include <algorithm>
2013-04-22 06:35:57 +00:00
# include <set>
2020-10-03 22:25:21 +00:00
# include "Common/Data/Format/IniFile.h"
2012-11-01 15:19:01 +00:00
2020-08-10 07:12:51 +00:00
# include "Common/Serialize/Serializer.h"
# include "Common/Serialize/SerializeFuncs.h"
# include "Common/Serialize/SerializeMap.h"
# include "Common/Serialize/SerializeSet.h"
2021-02-17 03:15:09 +00:00
# include "Core/Config.h"
# include "Core/CoreTiming.h"
2013-12-29 22:28:31 +00:00
# include "Core/HLE/HLE.h"
2021-02-27 21:15:12 +00:00
# include "Core/HLE/HLEHelperThread.h"
2014-03-15 18:22:19 +00:00
# include "Core/HLE/FunctionWrappers.h"
2013-12-29 22:28:31 +00:00
# include "Core/MIPS/MIPS.h"
2021-02-27 21:15:12 +00:00
# include "Core/MIPS/MIPSCodeUtils.h"
2013-12-29 22:28:31 +00:00
# include "Core/Reporting.h"
2018-11-27 14:45:51 +00:00
# include "Core/System.h"
2012-11-01 15:19:01 +00:00
2022-10-07 07:24:19 +00:00
# include "Core/HLE/sceJpeg.h"
2013-12-29 22:28:31 +00:00
# include "Core/HLE/sceKernel.h"
2021-08-15 03:15:34 +00:00
# include "Core/HLE/sceKernelInterrupt.h"
2014-07-23 06:30:40 +00:00
# include "Core/HLE/sceKernelMemory.h"
2013-12-29 22:28:31 +00:00
# include "Core/HLE/sceKernelThread.h"
2021-08-14 14:46:38 +00:00
# include "Core/HLE/scePower.h"
2013-12-29 22:28:31 +00:00
# include "Core/HLE/sceUtility.h"
# include "Core/Dialog/PSPSaveDialog.h"
# include "Core/Dialog/PSPMsgDialog.h"
# include "Core/Dialog/PSPPlaceholderDialog.h"
# include "Core/Dialog/PSPOskDialog.h"
# include "Core/Dialog/PSPGamedataInstallDialog.h"
# include "Core/Dialog/PSPNetconfDialog.h"
2021-03-12 07:32:33 +00:00
# include "Core/Dialog/PSPNpSigninDialog.h"
2014-04-28 13:54:52 +00:00
# include "Core/Dialog/PSPScreenshotDialog.h"
2013-09-26 01:05:44 +00:00
2014-04-25 21:29:03 +00:00
# define PSP_AV_MODULE_AVCODEC 0
# define PSP_AV_MODULE_SASCORE 1
# define PSP_AV_MODULE_ATRAC3PLUS 2 // Requires PSP_AV_MODULE_AVCODEC loading first
# define PSP_AV_MODULE_MPEGBASE 3 // Requires PSP_AV_MODULE_AVCODEC loading first
# define PSP_AV_MODULE_MP3 4
# define PSP_AV_MODULE_VAUDIO 5
# define PSP_AV_MODULE_AAC 6
# define PSP_AV_MODULE_G729 7
2015-03-15 13:08:11 +00:00
# define PSP_USB_MODULE_PSPCM 1
# define PSP_USB_MODULE_ACC 2
# define PSP_USB_MODULE_MIC 3 // Requires PSP_USB_MODULE_ACC loading first
# define PSP_USB_MODULE_CAM 4 // Requires PSP_USB_MODULE_ACC loading first
# define PSP_USB_MODULE_GPS 5 // Requires PSP_USB_MODULE_ACC loading first
2013-03-08 06:25:07 +00:00
const int SCE_ERROR_MODULE_BAD_ID = 0x80111101 ;
2013-04-22 06:35:57 +00:00
const int SCE_ERROR_MODULE_ALREADY_LOADED = 0x80111102 ;
const int SCE_ERROR_MODULE_NOT_LOADED = 0x80111103 ;
2013-03-09 20:53:53 +00:00
const int SCE_ERROR_AV_MODULE_BAD_ID = 0x80110F01 ;
2013-03-08 06:25:07 +00:00
2016-04-19 03:08:07 +00:00
static const int noDeps [ ] = { 0 } ;
static const int httpModuleDeps [ ] = { 0x0102 , 0x0103 , 0x0104 , 0 } ;
static const int sslModuleDeps [ ] = { 0x0102 , 0 } ;
static const int httpStorageModuleDeps [ ] = { 0x00100 , 0x0102 , 0x0103 , 0x0104 , 0x0105 , 0 } ;
static const int atrac3PlusModuleDeps [ ] = { 0x0300 , 0 } ;
static const int mpegBaseModuleDeps [ ] = { 0x0300 , 0 } ;
2016-08-27 17:14:34 +00:00
static const int mp4ModuleDeps [ ] = { 0x0300 , 0 } ;
2016-04-19 03:08:07 +00:00
2014-07-23 06:30:40 +00:00
struct ModuleLoadInfo {
2022-10-07 07:24:19 +00:00
ModuleLoadInfo ( int m , u32 s , void ( * n ) ( int ) = nullptr ) : mod ( m ) , size ( s ) , dependencies ( noDeps ) , notify ( n ) {
2016-04-19 03:08:07 +00:00
}
2022-10-07 07:24:19 +00:00
ModuleLoadInfo ( int m , u32 s , const int * d , void ( * n ) ( int ) = nullptr ) : mod ( m ) , size ( s ) , dependencies ( d ) , notify ( n ) {
2016-04-19 03:08:07 +00:00
}
2014-07-23 06:30:40 +00:00
const int mod ;
const u32 size ;
2016-04-19 03:08:07 +00:00
const int * const dependencies ;
2022-10-07 07:24:19 +00:00
void ( * notify ) ( int state ) ;
2014-07-23 06:30:40 +00:00
} ;
2022-10-07 07:24:19 +00:00
static void NotifyLoadStatusAvcodec ( int state ) {
JpegNotifyLoadStatus ( state ) ;
}
2014-07-23 06:30:40 +00:00
static const ModuleLoadInfo moduleLoadInfo [ ] = {
2016-04-19 03:08:07 +00:00
ModuleLoadInfo ( 0x0100 , 0x00014000 ) ,
ModuleLoadInfo ( 0x0101 , 0x00020000 ) ,
ModuleLoadInfo ( 0x0102 , 0x00058000 ) ,
ModuleLoadInfo ( 0x0103 , 0x00006000 ) ,
ModuleLoadInfo ( 0x0104 , 0x00002000 ) ,
ModuleLoadInfo ( 0x0105 , 0x00028000 , httpModuleDeps ) ,
ModuleLoadInfo ( 0x0106 , 0x00044000 , sslModuleDeps ) ,
ModuleLoadInfo ( 0x0107 , 0x00010000 ) ,
ModuleLoadInfo ( 0x0108 , 0x00008000 , httpStorageModuleDeps ) ,
ModuleLoadInfo ( 0x0200 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0201 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0202 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0203 , 0x00000000 ) ,
ModuleLoadInfo ( 0x02ff , 0x00000000 ) ,
2022-10-07 07:24:19 +00:00
ModuleLoadInfo ( 0x0300 , 0x00000000 , & NotifyLoadStatusAvcodec ) ,
2016-04-19 03:08:07 +00:00
ModuleLoadInfo ( 0x0301 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0302 , 0x00008000 , atrac3PlusModuleDeps ) ,
ModuleLoadInfo ( 0x0303 , 0x0000c000 , mpegBaseModuleDeps ) ,
ModuleLoadInfo ( 0x0304 , 0x00004000 ) ,
ModuleLoadInfo ( 0x0305 , 0x0000a300 ) ,
ModuleLoadInfo ( 0x0306 , 0x00004000 ) ,
ModuleLoadInfo ( 0x0307 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0308 , 0x0003c000 , mp4ModuleDeps ) ,
2022-04-27 07:26:57 +00:00
ModuleLoadInfo ( 0x03fe , 0x00000000 ) ,
2016-04-19 03:08:07 +00:00
ModuleLoadInfo ( 0x03ff , 0x00000000 ) ,
ModuleLoadInfo ( 0x0400 , 0x0000c000 ) ,
ModuleLoadInfo ( 0x0401 , 0x00018000 ) ,
ModuleLoadInfo ( 0x0402 , 0x00048000 ) ,
ModuleLoadInfo ( 0x0403 , 0x0000e000 ) ,
ModuleLoadInfo ( 0x0500 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0600 , 0x00000000 ) ,
ModuleLoadInfo ( 0x0601 , 0x00000000 ) ,
2014-07-23 06:30:40 +00:00
} ;
2013-03-18 02:01:58 +00:00
// Only a single dialog is allowed at a time.
static UtilityDialogType currentDialogType ;
2019-10-25 22:30:19 +00:00
bool currentDialogActive ;
2021-04-07 04:59:40 +00:00
static PSPSaveDialog * saveDialog ;
static PSPMsgDialog * msgDialog ;
static PSPOskDialog * oskDialog ;
static PSPNetconfDialog * netDialog ;
static PSPScreenshotDialog * screenshotDialog ;
static PSPGamedataInstallDialog * gamedataInstallDialog ;
2021-03-12 07:32:33 +00:00
static PSPNpSigninDialog * npSigninDialog ;
2012-11-01 15:19:01 +00:00
2021-04-08 04:22:31 +00:00
static int oldStatus = - 1 ;
2014-07-23 06:30:40 +00:00
static std : : map < int , u32 > currentlyLoadedModules ;
2021-02-17 03:15:09 +00:00
static int volatileUnlockEvent = - 1 ;
2021-02-27 21:15:12 +00:00
static HLEHelperThread * accessThread = nullptr ;
2021-09-16 15:57:20 +00:00
static bool accessThreadFinished = true ;
2021-09-16 04:06:12 +00:00
static const char * accessThreadState = " initial " ;
2022-12-19 15:56:23 +00:00
static int lastSaveStateVersion = - 1 ;
2021-02-27 21:15:12 +00:00
2021-09-16 04:06:12 +00:00
static void CleanupDialogThreads ( bool force = false ) {
if ( accessThread ) {
2021-09-16 15:57:20 +00:00
if ( accessThread - > Stopped ( ) | | accessThreadFinished ) {
2021-09-16 04:06:12 +00:00
delete accessThread ;
accessThread = nullptr ;
accessThreadState = " cleaned up " ;
} else if ( force ) {
2024-07-14 12:42:59 +00:00
ERROR_LOG_REPORT ( Log : : sceUtility , " Utility access thread still running, state: %s, dialog=%d/%d " , accessThreadState , ( int ) currentDialogType , currentDialogActive ) ;
2021-09-16 04:06:12 +00:00
// Try to force shutdown anyway.
accessThread - > Terminate ( ) ;
delete accessThread ;
accessThread = nullptr ;
accessThreadState = " force terminated " ;
// Try to unlock in case other dialog was shutting down.
KernelVolatileMemUnlock ( 0 ) ;
}
2021-02-27 21:15:12 +00:00
}
}
2013-04-22 06:35:57 +00:00
2020-12-13 18:55:37 +00:00
static void ActivateDialog ( UtilityDialogType type ) {
2021-09-16 04:06:12 +00:00
CleanupDialogThreads ( ) ;
2020-12-13 18:55:37 +00:00
if ( ! currentDialogActive ) {
currentDialogType = type ;
currentDialogActive = true ;
2021-04-08 04:22:31 +00:00
// So that we log the next one.
oldStatus = - 1 ;
2020-12-13 18:55:37 +00:00
}
}
static void DeactivateDialog ( ) {
2021-09-16 04:06:12 +00:00
CleanupDialogThreads ( ) ;
2020-12-13 18:55:37 +00:00
if ( currentDialogActive ) {
currentDialogActive = false ;
}
}
2021-04-07 05:23:17 +00:00
static PSPDialog * CurrentDialog ( UtilityDialogType type ) {
switch ( type ) {
case UtilityDialogType : : NONE :
break ;
case UtilityDialogType : : SAVEDATA :
return saveDialog ;
case UtilityDialogType : : MSG :
return msgDialog ;
case UtilityDialogType : : OSK :
return oskDialog ;
case UtilityDialogType : : NET :
return netDialog ;
case UtilityDialogType : : SCREENSHOT :
return screenshotDialog ;
case UtilityDialogType : : GAMESHARING :
break ;
case UtilityDialogType : : GAMEDATAINSTALL :
return gamedataInstallDialog ;
2021-03-12 07:32:33 +00:00
case UtilityDialogType : : NPSIGNIN :
return npSigninDialog ;
2021-04-07 05:23:17 +00:00
}
return nullptr ;
}
2021-02-17 03:15:09 +00:00
static void UtilityVolatileUnlock ( u64 userdata , int cyclesLate ) {
2021-04-07 05:23:17 +00:00
PSPDialog * dialog = CurrentDialog ( currentDialogType ) ;
if ( dialog )
dialog - > FinishVolatile ( ) ;
2021-02-17 03:15:09 +00:00
}
2014-07-23 06:30:40 +00:00
void __UtilityInit ( ) {
2021-04-07 04:59:40 +00:00
saveDialog = new PSPSaveDialog ( UtilityDialogType : : SAVEDATA ) ;
msgDialog = new PSPMsgDialog ( UtilityDialogType : : MSG ) ;
oskDialog = new PSPOskDialog ( UtilityDialogType : : OSK ) ;
netDialog = new PSPNetconfDialog ( UtilityDialogType : : NET ) ;
screenshotDialog = new PSPScreenshotDialog ( UtilityDialogType : : SCREENSHOT ) ;
gamedataInstallDialog = new PSPGamedataInstallDialog ( UtilityDialogType : : GAMEDATAINSTALL ) ;
2021-03-12 07:32:33 +00:00
npSigninDialog = new PSPNpSigninDialog ( UtilityDialogType : : NPSIGNIN ) ;
2021-04-07 04:59:40 +00:00
2021-02-27 21:43:12 +00:00
currentDialogType = UtilityDialogType : : NONE ;
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2012-12-24 09:41:15 +00:00
SavedataParam : : Init ( ) ;
2013-04-22 06:35:57 +00:00
currentlyLoadedModules . clear ( ) ;
2021-02-17 03:15:09 +00:00
volatileUnlockEvent = CoreTiming : : RegisterEvent ( " UtilityVolatileUnlock " , UtilityVolatileUnlock ) ;
2012-12-24 09:41:15 +00:00
}
2014-07-23 06:30:40 +00:00
void __UtilityDoState ( PointerWrap & p ) {
2021-03-12 07:32:33 +00:00
auto s = p . Section ( " sceUtility " , 1 , 6 ) ;
2014-07-23 06:30:40 +00:00
if ( ! s ) {
2013-09-15 03:23:03 +00:00
return ;
2014-07-23 06:30:40 +00:00
}
2013-09-15 03:23:03 +00:00
2020-08-10 04:20:42 +00:00
Do ( p , currentDialogType ) ;
Do ( p , currentDialogActive ) ;
2021-04-07 04:59:40 +00:00
saveDialog - > DoState ( p ) ;
msgDialog - > DoState ( p ) ;
oskDialog - > DoState ( p ) ;
netDialog - > DoState ( p ) ;
screenshotDialog - > DoState ( p ) ;
gamedataInstallDialog - > DoState ( p ) ;
2014-07-23 06:30:40 +00:00
if ( s > = 2 ) {
2020-08-10 04:20:42 +00:00
Do ( p , currentlyLoadedModules ) ;
2014-07-23 06:30:40 +00:00
} else {
std : : set < int > oldModules ;
2020-08-10 04:20:42 +00:00
Do ( p , oldModules ) ;
2014-07-23 06:30:40 +00:00
for ( auto it = oldModules . begin ( ) , end = oldModules . end ( ) ; it ! = end ; + + it ) {
currentlyLoadedModules [ * it ] = 0 ;
}
}
2021-02-17 03:15:09 +00:00
if ( s > = 3 ) {
Do ( p , volatileUnlockEvent ) ;
} else {
volatileUnlockEvent = - 1 ;
}
CoreTiming : : RestoreRegisterEvent ( volatileUnlockEvent , " UtilityVolatileUnlock " , UtilityVolatileUnlock ) ;
2021-02-27 21:15:12 +00:00
bool hasAccessThread = accessThread ! = nullptr ;
if ( s > = 4 ) {
Do ( p , hasAccessThread ) ;
if ( hasAccessThread ) {
Do ( p , accessThread ) ;
2021-09-16 04:06:12 +00:00
if ( p . mode = = p . MODE_READ )
accessThreadState = " from save state " ;
2021-02-27 21:15:12 +00:00
}
} else {
hasAccessThread = false ;
}
2021-09-16 15:57:20 +00:00
if ( s > = 5 )
Do ( p , accessThreadFinished ) ;
2021-03-12 07:32:33 +00:00
if ( s > = 6 ) {
npSigninDialog - > DoState ( p ) ;
2022-12-19 15:56:23 +00:00
lastSaveStateVersion = - 1 ;
} else {
lastSaveStateVersion = s . Version ( ) ;
2021-03-12 07:32:33 +00:00
}
2021-02-27 21:15:12 +00:00
if ( ! hasAccessThread & & accessThread ) {
accessThread - > Forget ( ) ;
delete accessThread ;
accessThread = nullptr ;
2021-09-16 04:06:12 +00:00
accessThreadState = " cleared from save state " ;
2021-02-27 21:15:12 +00:00
}
2012-12-28 21:36:37 +00:00
}
2014-07-23 06:30:40 +00:00
void __UtilityShutdown ( ) {
2021-04-07 04:59:40 +00:00
saveDialog - > Shutdown ( true ) ;
msgDialog - > Shutdown ( true ) ;
oskDialog - > Shutdown ( true ) ;
netDialog - > Shutdown ( true ) ;
screenshotDialog - > Shutdown ( true ) ;
gamedataInstallDialog - > Shutdown ( true ) ;
2021-03-12 07:32:33 +00:00
npSigninDialog - > Shutdown ( true ) ;
2021-02-27 21:15:12 +00:00
if ( accessThread ) {
2023-01-23 01:53:45 +00:00
// Don't need to free it during shutdown, may have already been freed.
accessThread - > Forget ( ) ;
2021-02-27 21:15:12 +00:00
delete accessThread ;
accessThread = nullptr ;
2021-09-16 04:06:12 +00:00
accessThreadState = " shutdown " ;
2021-02-27 21:15:12 +00:00
}
2021-09-16 15:57:20 +00:00
accessThreadFinished = true ;
2022-12-19 15:56:23 +00:00
lastSaveStateVersion = - 1 ;
2021-04-07 04:59:40 +00:00
delete saveDialog ;
delete msgDialog ;
delete oskDialog ;
delete netDialog ;
delete screenshotDialog ;
delete gamedataInstallDialog ;
2021-03-12 07:32:33 +00:00
delete npSigninDialog ;
2021-02-27 21:15:12 +00:00
}
2021-04-08 01:07:48 +00:00
void UtilityDialogInitialize ( UtilityDialogType type , int delayUs , int priority ) {
int partDelay = delayUs / 4 ;
const u32_le insts [ ] = {
2021-08-15 03:55:10 +00:00
// Make sure we don't discard/deadbeef a0.
2021-04-08 01:07:48 +00:00
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_S0 , MIPS_REG_A0 , 0 ) ,
2021-08-15 03:55:10 +00:00
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_ZERO , 0 ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A1 , MIPS_REG_ZERO , 0 ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A2 , MIPS_REG_ZERO , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceSuspendForUser " , " sceKernelVolatileMemLock " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
2021-04-08 01:07:48 +00:00
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_ZERO , ( int ) type ) ,
( u32_le ) MIPS_MAKE_JR_RA ( ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityInitDialog " ) ,
} ;
2021-09-16 04:06:12 +00:00
CleanupDialogThreads ( true ) ;
2021-04-08 01:07:48 +00:00
accessThread = new HLEHelperThread ( " ScePafJob " , insts , ( uint32_t ) ARRAY_SIZE ( insts ) , priority , 0x200 ) ;
accessThread - > Start ( partDelay , 0 ) ;
2021-09-16 15:57:20 +00:00
accessThreadFinished = false ;
2021-09-16 04:06:12 +00:00
accessThreadState = " initializing " ;
2021-04-08 01:07:48 +00:00
}
2021-02-27 21:43:12 +00:00
void UtilityDialogShutdown ( UtilityDialogType type , int delayUs , int priority ) {
2021-02-27 21:15:12 +00:00
// Break it up so better-priority rescheduling happens.
// The windows aren't this regular, but close.
int partDelay = delayUs / 4 ;
const u32_le insts [ ] = {
// Make sure we don't discard/deadbeef 'em.
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_S0 , MIPS_REG_A0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_S0 , 0 ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityWorkUs " ) ,
2021-02-27 21:43:12 +00:00
( u32_le ) MIPS_MAKE_ORI ( MIPS_REG_A0 , MIPS_REG_ZERO , ( int ) type ) ,
2021-02-27 21:15:12 +00:00
( u32_le ) MIPS_MAKE_JR_RA ( ) ,
( u32_le ) MIPS_MAKE_SYSCALL ( " sceUtility " , " __UtilityFinishDialog " ) ,
} ;
2021-09-16 04:06:12 +00:00
CleanupDialogThreads ( true ) ;
2021-08-15 03:15:34 +00:00
bool prevInterrupts = __InterruptsEnabled ( ) ;
__DisableInterrupts ( ) ;
2021-02-27 21:15:12 +00:00
accessThread = new HLEHelperThread ( " ScePafJob " , insts , ( uint32_t ) ARRAY_SIZE ( insts ) , priority , 0x200 ) ;
accessThread - > Start ( partDelay , 0 ) ;
2021-09-16 15:57:20 +00:00
accessThreadFinished = false ;
2021-09-16 04:06:12 +00:00
accessThreadState = " shutting down " ;
2021-08-15 03:15:34 +00:00
if ( prevInterrupts )
__EnableInterrupts ( ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:15:12 +00:00
static int UtilityWorkUs ( int us ) {
// This blocks, but other better priority threads can get time.
// Simulate this by allowing a reschedule.
2021-04-08 01:07:48 +00:00
if ( us > 1000 ) {
2021-04-26 01:38:30 +00:00
hleEatMicro ( 1000 ) ;
return hleDelayResult ( 0 , " utility work " , us - 1000 ) ;
2021-04-08 01:07:48 +00:00
}
2021-02-27 21:15:12 +00:00
hleEatMicro ( us ) ;
hleReSchedule ( " utility work " ) ;
return 0 ;
2021-02-17 03:15:09 +00:00
}
2021-04-08 01:07:48 +00:00
static int UtilityInitDialog ( int type ) {
PSPDialog * dialog = CurrentDialog ( ( UtilityDialogType ) type ) ;
2021-09-16 15:57:20 +00:00
accessThreadFinished = true ;
2021-09-16 04:06:12 +00:00
accessThreadState = " init finished " ;
2021-04-08 01:07:48 +00:00
if ( dialog )
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , dialog - > FinishInit ( ) ) ;
return hleLogError ( Log : : sceUtility , 0 , " invalid dialog type? " ) ;
2021-04-08 01:07:48 +00:00
}
2021-02-27 21:15:12 +00:00
static int UtilityFinishDialog ( int type ) {
2021-04-07 05:23:17 +00:00
PSPDialog * dialog = CurrentDialog ( ( UtilityDialogType ) type ) ;
2021-09-16 15:57:20 +00:00
accessThreadFinished = true ;
2021-09-16 04:06:12 +00:00
accessThreadState = " shutdown finished " ;
2021-04-07 05:23:17 +00:00
if ( dialog )
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , dialog - > FinishShutdown ( ) ) ;
return hleLogError ( Log : : sceUtility , 0 , " invalid dialog type? " ) ;
2021-02-17 03:15:09 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilitySavedataInitStart ( u32 paramAddr ) {
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : SAVEDATA ) {
if ( PSP_CoreParameter ( ) . compat . flags ( ) . YugiohSaveFix ) {
2024-07-14 12:42:59 +00:00
WARN_LOG_REPORT ( Log : : sceUtility , " Yugioh Savedata Correction (state=%d) " , lastSaveStateVersion ) ;
2021-08-14 14:46:38 +00:00
if ( accessThread ) {
accessThread - > Terminate ( ) ;
2021-09-16 04:06:12 +00:00
delete accessThread ;
accessThread = nullptr ;
2021-09-16 15:57:20 +00:00
accessThreadFinished = true ;
2021-09-16 04:06:12 +00:00
accessThreadState = " terminated " ;
2021-08-14 14:46:38 +00:00
// Try to unlock in case other dialog was shutting down.
KernelVolatileMemUnlock ( 0 ) ;
}
2021-02-27 21:43:12 +00:00
} else {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2018-11-26 13:34:00 +00:00
}
2013-03-18 02:01:58 +00:00
}
2014-04-27 05:43:51 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : SAVEDATA ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , saveDialog - > Init ( paramAddr ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 18:35:06 +00:00
static int sceUtilitySavedataShutdownStart ( ) {
2021-02-27 21:43:12 +00:00
if ( currentDialogType ! = UtilityDialogType : : SAVEDATA )
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2021-04-07 04:59:40 +00:00
int ret = saveDialog - > Shutdown ( ) ;
2021-02-27 21:15:12 +00:00
hleEatCycles ( 30000 ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , ret ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilitySavedataGetStatus ( ) {
if ( currentDialogType ! = UtilityDialogType : : SAVEDATA ) {
2014-03-15 08:18:35 +00:00
hleEatCycles ( 200 ) ;
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2021-04-07 04:59:40 +00:00
int status = saveDialog - > GetStatus ( ) ;
2021-04-07 05:18:28 +00:00
hleEatCycles ( 200 ) ;
CleanupDialogThreads ( ) ;
2014-04-27 05:43:51 +00:00
if ( oldStatus ! = status ) {
oldStatus = status ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , status ) ;
2014-04-27 05:43:51 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessVerboseI ( Log : : sceUtility , status ) ;
2012-12-08 22:39:47 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilitySavedataUpdate ( int animSpeed ) {
if ( currentDialogType ! = UtilityDialogType : : SAVEDATA ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-01-31 23:25:41 +00:00
2024-07-14 12:42:59 +00:00
int result = hleLogSuccessI ( Log : : sceUtility , saveDialog - > Update ( animSpeed ) ) ;
2013-03-18 04:39:06 +00:00
if ( result > = 0 )
return hleDelayResult ( result , " savedata update " , 300 ) ;
return result ;
2012-11-01 15:19:01 +00:00
}
2012-11-22 20:46:22 +00:00
2014-12-08 09:40:08 +00:00
static u32 sceUtilityLoadAvModule ( u32 module )
2012-11-01 15:19:01 +00:00
{
2013-03-09 20:53:53 +00:00
if ( module > 7 )
{
2024-07-14 12:42:59 +00:00
ERROR_LOG_REPORT ( Log : : sceUtility , " sceUtilityLoadAvModule(%i): invalid module id " , module ) ;
2013-03-09 20:53:53 +00:00
return SCE_ERROR_AV_MODULE_BAD_ID ;
}
2014-05-14 07:32:15 +00:00
2024-07-14 12:42:59 +00:00
INFO_LOG ( Log : : sceUtility , " 0=sceUtilityLoadAvModule(%i) " , module ) ;
2022-10-07 07:24:19 +00:00
if ( module = = 0 )
JpegNotifyLoadStatus ( 1 ) ;
2013-03-09 20:53:53 +00:00
return hleDelayResult ( 0 , " utility av module loaded " , 25000 ) ;
2012-12-31 12:43:38 +00:00
}
2014-12-08 09:40:08 +00:00
static u32 sceUtilityUnloadAvModule ( u32 module )
2012-12-31 12:43:38 +00:00
{
2024-07-14 12:42:59 +00:00
INFO_LOG ( Log : : sceUtility , " 0=sceUtilityUnloadAvModule(%i) " , module ) ;
2022-10-07 07:24:19 +00:00
if ( module = = 0 )
JpegNotifyLoadStatus ( - 1 ) ;
2013-03-09 20:53:53 +00:00
return hleDelayResult ( 0 , " utility av module unloaded " , 800 ) ;
2012-11-01 15:19:01 +00:00
}
2016-04-19 03:17:49 +00:00
static const ModuleLoadInfo * __UtilityModuleInfo ( int module ) {
2014-07-23 06:30:40 +00:00
const ModuleLoadInfo * info = 0 ;
for ( size_t i = 0 ; i < ARRAY_SIZE ( moduleLoadInfo ) ; + + i ) {
if ( moduleLoadInfo [ i ] . mod = = module ) {
info = & moduleLoadInfo [ i ] ;
break ;
}
}
return info ;
}
static u32 sceUtilityLoadModule ( u32 module ) {
const ModuleLoadInfo * info = __UtilityModuleInfo ( module ) ;
if ( ! info ) {
2024-07-14 12:42:59 +00:00
return hleReportError ( Log : : sceUtility , SCE_ERROR_MODULE_BAD_ID , " invalid module id " ) ;
2013-03-08 06:25:07 +00:00
}
2014-07-23 06:30:40 +00:00
if ( currentlyLoadedModules . find ( module ) ! = currentlyLoadedModules . end ( ) ) {
2024-07-14 12:42:59 +00:00
return hleLogError ( Log : : sceUtility , SCE_ERROR_MODULE_ALREADY_LOADED , " already loaded " ) ;
2013-04-22 06:35:57 +00:00
}
2014-07-23 06:30:40 +00:00
// Some games, like Kamen Rider Climax Heroes OOO, require an error if dependencies aren't loaded yet.
2016-04-19 03:08:07 +00:00
for ( const int * dep = info - > dependencies ; * dep ! = 0 ; + + dep ) {
2014-07-23 06:30:40 +00:00
if ( currentlyLoadedModules . find ( * dep ) = = currentlyLoadedModules . end ( ) ) {
2024-07-14 12:42:59 +00:00
u32 result = hleLogError ( Log : : sceUtility , SCE_KERNEL_ERROR_LIBRARY_NOTFOUND , " dependent module %04x not loaded " , * dep ) ;
2016-04-19 03:17:49 +00:00
return hleDelayResult ( result , " utility module load attempt " , 25000 ) ;
2014-07-23 06:30:40 +00:00
}
2013-10-22 13:08:36 +00:00
}
2014-07-23 06:30:40 +00:00
u32 allocSize = info - > size ;
char name [ 64 ] ;
snprintf ( name , sizeof ( name ) , " UtilityModule/%x " , module ) ;
2015-10-18 19:53:18 +00:00
if ( allocSize ! = 0 ) {
currentlyLoadedModules [ module ] = userMemory . Alloc ( allocSize , false , name ) ;
} else {
currentlyLoadedModules [ module ] = 0 ;
}
2013-10-22 13:08:36 +00:00
2022-10-07 07:24:19 +00:00
if ( info - > notify )
info - > notify ( 1 ) ;
2014-07-23 06:30:40 +00:00
// TODO: Each module has its own timing, technically, but this is a low-end.
2013-03-08 06:25:07 +00:00
if ( module = = 0x3FF )
2024-07-14 12:42:59 +00:00
return hleDelayResult ( hleLogSuccessInfoI ( Log : : sceUtility , 0 ) , " utility module loaded " , 130 ) ;
2013-03-08 06:25:07 +00:00
else
2024-07-14 12:42:59 +00:00
return hleDelayResult ( hleLogSuccessInfoI ( Log : : sceUtility , 0 ) , " utility module loaded " , 25000 ) ;
2012-12-31 12:43:38 +00:00
}
2014-07-23 06:30:40 +00:00
static u32 sceUtilityUnloadModule ( u32 module ) {
const ModuleLoadInfo * info = __UtilityModuleInfo ( module ) ;
if ( ! info ) {
2024-07-14 12:42:59 +00:00
return hleReportError ( Log : : sceUtility , SCE_ERROR_MODULE_BAD_ID , " invalid module id " ) ;
2013-03-08 06:25:07 +00:00
}
2014-07-23 06:30:40 +00:00
if ( currentlyLoadedModules . find ( module ) = = currentlyLoadedModules . end ( ) ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_MODULE_NOT_LOADED , " not yet loaded " ) ;
2013-04-22 06:35:57 +00:00
}
2014-07-23 06:30:40 +00:00
if ( currentlyLoadedModules [ module ] ! = 0 ) {
userMemory . Free ( currentlyLoadedModules [ module ] ) ;
}
2013-04-22 06:35:57 +00:00
currentlyLoadedModules . erase ( module ) ;
2022-10-07 07:24:19 +00:00
if ( info - > notify )
info - > notify ( - 1 ) ;
2013-03-08 06:25:07 +00:00
// TODO: Each module has its own timing, technically, but this is a low-end.
if ( module = = 0x3FF )
2024-07-14 12:42:59 +00:00
return hleDelayResult ( hleLogSuccessInfoI ( Log : : sceUtility , 0 ) , " utility module unloaded " , 110 ) ;
2013-03-08 06:25:07 +00:00
else
2024-07-14 12:42:59 +00:00
return hleDelayResult ( hleLogSuccessInfoI ( Log : : sceUtility , 0 ) , " utility module unloaded " , 400 ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityMsgDialogInitStart ( u32 paramAddr ) {
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : MSG ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-04-25 21:29:03 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : MSG ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessInfoX ( Log : : sceUtility , msgDialog - > Init ( paramAddr ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityMsgDialogShutdownStart ( ) {
if ( currentDialogType ! = UtilityDialogType : : MSG ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , msgDialog - > Shutdown ( ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityMsgDialogUpdate ( int animSpeed ) {
if ( currentDialogType ! = UtilityDialogType : : MSG ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-04-25 21:29:03 +00:00
2024-07-14 12:42:59 +00:00
int ret = hleLogSuccessX ( Log : : sceUtility , msgDialog - > Update ( animSpeed ) ) ;
2014-09-27 07:13:27 +00:00
if ( ret > = 0 )
return hleDelayResult ( ret , " msgdialog update " , 800 ) ;
2014-01-31 23:25:41 +00:00
return ret ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityMsgDialogGetStatus ( ) {
if ( currentDialogType ! = UtilityDialogType : : MSG ) {
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2021-04-07 04:59:40 +00:00
int status = msgDialog - > GetStatus ( ) ;
2021-04-07 05:18:28 +00:00
CleanupDialogThreads ( ) ;
2014-04-27 05:43:51 +00:00
if ( oldStatus ! = status ) {
oldStatus = status ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , status ) ;
2014-04-27 05:43:51 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessVerboseI ( Log : : sceUtility , status ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityMsgDialogAbort ( ) {
if ( currentDialogType ! = UtilityDialogType : : MSG ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-31 05:54:00 +00:00
}
2014-04-25 21:29:03 +00:00
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , msgDialog - > Abort ( ) ) ;
2013-03-31 05:54:00 +00:00
}
2012-11-18 12:04:49 +00:00
// On screen keyboard
2021-02-27 21:43:12 +00:00
static int sceUtilityOskInitStart ( u32 oskPtr ) {
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : OSK ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-04-25 21:29:03 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : OSK ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessInfoX ( Log : : sceUtility , oskDialog - > Init ( oskPtr ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityOskShutdownStart ( ) {
2021-04-07 05:18:28 +00:00
if ( currentDialogType ! = UtilityDialogType : : OSK ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , oskDialog - > Shutdown ( ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityOskUpdate ( int animSpeed ) {
if ( currentDialogType ! = UtilityDialogType : : OSK ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2014-04-25 21:29:03 +00:00
2023-02-14 19:14:49 +00:00
// This is the vblank period, plus a little slack. Needed to fix timing bug in Ghost Recon: Predator.
// See issue #12044.
hleEatCycles ( msToCycles ( 0.7315 + 0.1 ) ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , oskDialog - > Update ( animSpeed ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityOskGetStatus ( ) {
if ( currentDialogType ! = UtilityDialogType : : OSK ) {
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-03-18 02:01:58 +00:00
}
2021-04-07 04:59:40 +00:00
int status = oskDialog - > GetStatus ( ) ;
2021-04-07 05:18:28 +00:00
CleanupDialogThreads ( ) ;
2014-04-27 05:43:51 +00:00
if ( oldStatus ! = status ) {
oldStatus = status ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , status ) ;
2014-04-27 05:43:51 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessVerboseI ( Log : : sceUtility , status ) ;
2012-11-01 15:19:01 +00:00
}
2020-03-15 19:22:21 +00:00
static int sceUtilityNetconfInitStart ( u32 paramsAddr ) {
2021-02-27 21:43:12 +00:00
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : NET ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-10-13 02:43:49 +00:00
}
2014-04-25 21:29:03 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : NET ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessInfoI ( Log : : sceUtility , netDialog - > Init ( paramsAddr ) ) ;
2012-11-06 18:22:14 +00:00
}
2020-03-15 19:22:21 +00:00
static int sceUtilityNetconfShutdownStart ( ) {
2021-02-27 21:43:12 +00:00
if ( currentDialogType ! = UtilityDialogType : : NET ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-10-13 02:43:49 +00:00
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , netDialog - > Shutdown ( ) ) ;
2012-11-06 18:22:14 +00:00
}
2020-03-15 19:22:21 +00:00
static int sceUtilityNetconfUpdate ( int animSpeed ) {
2021-02-27 21:43:12 +00:00
if ( currentDialogType ! = UtilityDialogType : : NET ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2020-03-15 19:22:21 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , netDialog - > Update ( animSpeed ) ) ;
2012-11-06 18:22:14 +00:00
}
2020-03-15 19:22:21 +00:00
static int sceUtilityNetconfGetStatus ( ) {
2021-02-27 21:43:12 +00:00
if ( currentDialogType ! = UtilityDialogType : : NET ) {
2020-03-15 19:22:21 +00:00
// Spam in Danball Senki BOOST.
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-10-13 02:43:49 +00:00
}
2021-04-07 04:59:40 +00:00
int status = netDialog - > GetStatus ( ) ;
2021-04-07 05:18:28 +00:00
CleanupDialogThreads ( ) ;
2014-04-27 05:43:51 +00:00
if ( oldStatus ! = status ) {
oldStatus = status ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , status ) ;
2014-04-27 05:43:51 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessVerboseI ( Log : : sceUtility , status ) ;
2012-11-06 18:22:14 +00:00
}
2015-03-21 21:42:44 +00:00
static int sceUtilityCheckNetParam ( int id )
{
2015-03-21 21:58:00 +00:00
bool available = ( id > = 0 & & id < = 24 ) ;
int ret = available ? 0 : 0X80110601 ;
2024-07-14 12:42:59 +00:00
DEBUG_LOG ( Log : : sceUtility , " %08x=sceUtilityCheckNetParam(%d) " , ret , id ) ;
2015-03-21 21:58:00 +00:00
return ret ;
2015-03-21 21:42:44 +00:00
}
2013-06-12 08:46:06 +00:00
//TODO: Implement all sceUtilityScreenshot* for real, it doesn't seem to be complex
//but it requires more investigation
2021-02-27 21:43:12 +00:00
static int sceUtilityScreenshotInitStart ( u32 paramAddr ) {
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : SCREENSHOT ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-08-31 21:34:36 +00:00
}
2014-04-25 21:29:03 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : SCREENSHOT ) ;
2024-07-14 12:42:59 +00:00
return hleReportWarning ( Log : : sceUtility , screenshotDialog - > Init ( paramAddr ) ) ;
2013-06-12 08:46:06 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityScreenshotShutdownStart ( ) {
if ( currentDialogType ! = UtilityDialogType : : SCREENSHOT ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-08-31 21:34:36 +00:00
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , screenshotDialog - > Shutdown ( ) ) ;
2013-06-12 08:46:06 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityScreenshotUpdate ( u32 animSpeed ) {
if ( currentDialogType ! = UtilityDialogType : : SCREENSHOT ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-08-31 21:34:36 +00:00
}
2014-04-25 21:29:03 +00:00
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , screenshotDialog - > Update ( animSpeed ) ) ;
2013-06-12 08:46:06 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityScreenshotGetStatus ( ) {
if ( currentDialogType ! = UtilityDialogType : : SCREENSHOT ) {
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-08-31 21:34:36 +00:00
}
2021-04-07 04:59:40 +00:00
int status = screenshotDialog - > GetStatus ( ) ;
2021-04-07 05:18:28 +00:00
CleanupDialogThreads ( ) ;
2014-04-27 05:43:51 +00:00
if ( oldStatus ! = status ) {
oldStatus = status ;
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , status ) ;
2014-04-27 05:43:51 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessVerboseI ( Log : : sceUtility , status ) ;
2012-12-08 22:39:47 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityScreenshotContStart ( u32 paramAddr ) {
if ( currentDialogType ! = UtilityDialogType : : SCREENSHOT ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2014-03-30 06:42:29 +00:00
}
2014-04-25 21:29:03 +00:00
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , screenshotDialog - > ContStart ( ) ) ;
2014-03-30 06:42:29 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGamedataInstallInitStart ( u32 paramsAddr ) {
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : GAMEDATAINSTALL ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-09-13 15:07:43 +00:00
}
2020-12-13 18:55:37 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : GAMEDATAINSTALL ) ;
2022-09-19 03:39:13 +00:00
int result = gamedataInstallDialog - > Init ( paramsAddr ) ;
if ( result < 0 )
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessInfoX ( Log : : sceUtility , result ) ;
2013-09-13 15:07:43 +00:00
}
2014-12-08 09:40:08 +00:00
static int sceUtilityGamedataInstallShutdownStart ( ) {
2022-09-19 03:39:13 +00:00
if ( ! currentDialogActive | | currentDialogType ! = UtilityDialogType : : GAMEDATAINSTALL ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-09-13 15:07:43 +00:00
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , gamedataInstallDialog - > Shutdown ( ) ) ;
2013-09-13 15:07:43 +00:00
}
2014-12-08 09:40:08 +00:00
static int sceUtilityGamedataInstallUpdate ( int animSpeed ) {
2022-09-19 03:39:13 +00:00
if ( ! currentDialogActive | | currentDialogType ! = UtilityDialogType : : GAMEDATAINSTALL ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-09-27 14:52:25 +00:00
}
2014-04-25 21:29:03 +00:00
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , gamedataInstallDialog - > Update ( animSpeed ) ) ;
2012-12-19 00:05:45 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGamedataInstallGetStatus ( ) {
2023-10-15 17:36:27 +00:00
if ( currentDialogType ! = UtilityDialogType : : GAMEDATAINSTALL ) {
2013-11-06 09:34:56 +00:00
// This is called incorrectly all the time by some games. So let's not bother warning.
2022-09-19 03:39:13 +00:00
hleEatCycles ( 200 ) ;
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-09-13 15:07:43 +00:00
}
2021-04-07 04:59:40 +00:00
int status = gamedataInstallDialog - > GetStatus ( ) ;
2021-02-27 21:15:12 +00:00
CleanupDialogThreads ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , status ) ;
2013-09-13 15:07:43 +00:00
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGamedataInstallAbort ( ) {
2022-09-19 03:39:13 +00:00
if ( ! currentDialogActive | | currentDialogType ! = UtilityDialogType : : GAMEDATAINSTALL ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2013-09-13 15:07:43 +00:00
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessX ( Log : : sceUtility , gamedataInstallDialog - > Abort ( ) ) ;
2012-12-08 22:39:47 +00:00
}
2012-12-12 21:08:55 +00:00
//TODO: should save to config file
2014-12-08 09:40:08 +00:00
static u32 sceUtilitySetSystemParamString ( u32 id , u32 strPtr )
2012-12-12 21:08:55 +00:00
{
2024-07-14 12:42:59 +00:00
WARN_LOG_REPORT ( Log : : sceUtility , " sceUtilitySetSystemParamString(%i, %08x) " , id , strPtr ) ;
2012-12-12 21:08:55 +00:00
return 0 ;
}
2012-11-14 23:04:40 +00:00
2023-01-01 20:12:04 +00:00
static u32 sceUtilityGetSystemParamString ( u32 id , u32 destAddr , int destSize )
2012-11-14 23:04:40 +00:00
{
2023-01-01 20:12:04 +00:00
if ( ! Memory : : IsValidRange ( destAddr , destSize ) ) {
// TODO: What error code?
return - 1 ;
}
2024-07-14 12:42:59 +00:00
DEBUG_LOG ( Log : : sceUtility , " sceUtilityGetSystemParamString(%i, %08x, %i) " , id , destAddr , destSize ) ;
2023-01-01 20:12:04 +00:00
char * buf = ( char * ) Memory : : GetPointerWriteUnchecked ( destAddr ) ;
2012-11-14 23:04:40 +00:00
switch ( id ) {
2012-11-22 20:46:22 +00:00
case PSP_SYSTEMPARAM_ID_STRING_NICKNAME :
2013-04-20 16:30:46 +00:00
// If there's not enough space for the string and null terminator, fail.
if ( destSize < = ( int ) g_Config . sNickName . length ( ) )
return PSP_SYSTEMPARAM_RETVAL_STRING_TOO_LONG ;
2023-01-01 20:12:04 +00:00
// TODO: should we zero-pad the output as strncpy does? And what are the semantics for the terminating null if destSize == length?
2013-04-20 16:30:46 +00:00
strncpy ( buf , g_Config . sNickName . c_str ( ) , destSize ) ;
2012-11-22 20:46:22 +00:00
break ;
2012-11-14 23:04:40 +00:00
2012-11-22 20:46:22 +00:00
default :
return PSP_SYSTEMPARAM_RETVAL_FAIL ;
2012-11-14 23:04:40 +00:00
}
2012-11-06 18:22:14 +00:00
2012-11-14 23:04:40 +00:00
return 0 ;
2012-11-01 15:19:01 +00:00
}
2017-06-06 17:07:11 +00:00
static u32 sceUtilitySetSystemParamInt ( u32 id , u32 value )
2017-04-09 11:58:43 +00:00
{
2017-04-10 12:33:56 +00:00
switch ( id ) {
case PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL :
if ( value ! = 0 & & value ! = 1 & & value ! = 6 & & value ! = 11 ) {
return ERROR_UTILITY_INVALID_ADHOC_CHANNEL ;
}
//Settings.getInstance().writeInt(SYSTEMPARAM_SETTINGS_OPTION_ADHOC_CHANNEL, value);
break ;
case PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE :
// Settings.getInstance().writeInt(SYSTEMPARAM_SETTINGS_OPTION_WLAN_POWER_SAVE, value);
break ;
default :
// PSP can only set above int parameters
return ERROR_UTILITY_INVALID_SYSTEM_PARAM_ID ;
}
2017-04-09 11:58:43 +00:00
return 0 ;
}
2014-12-08 09:40:08 +00:00
static u32 sceUtilityGetSystemParamInt ( u32 id , u32 destaddr )
2012-11-14 23:04:40 +00:00
{
2012-11-27 09:18:36 +00:00
u32 param = 0 ;
2012-11-14 23:04:40 +00:00
switch ( id ) {
2012-11-22 20:46:22 +00:00
case PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL :
2013-04-19 18:59:24 +00:00
param = g_Config . iWlanAdhocChannel ;
2020-09-08 01:34:35 +00:00
if ( param = = PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC ) {
// FIXME: Actually.. it's always returning 0x800ADF4 regardless using Auto channel or Not, and regardless the connection state either,
// Not sure whether this error code only returned after Adhocctl Initialized (ie. netAdhocctlInited) or also before initialized.
// FIXME: Outputted channel (might be unchanged?) either 0 when not connected to a group yet (ie. adhocctlState == ADHOCCTL_STATE_DISCONNECTED),
// or -1 (0xFFFFFFFF) when a scan is in progress (ie. adhocctlState == ADHOCCTL_STATE_SCANNING),
// or 0x60 early when in connected state (ie. adhocctlState == ADHOCCTL_STATE_CONNECTED) right after Creating a group, regardless the channel settings.
Memory : : Write_U32 ( param , destaddr ) ;
return 0x800ADF4 ;
}
2012-11-22 20:46:22 +00:00
break ;
case PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE :
2013-04-19 18:59:24 +00:00
param = g_Config . bWlanPowerSave ? PSP_SYSTEMPARAM_WLAN_POWERSAVE_ON : PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF ;
2012-11-22 20:46:22 +00:00
break ;
case PSP_SYSTEMPARAM_ID_INT_DATE_FORMAT :
2013-04-19 18:59:24 +00:00
param = g_Config . iDateFormat ;
2012-11-22 20:46:22 +00:00
break ;
case PSP_SYSTEMPARAM_ID_INT_TIME_FORMAT :
2020-07-15 01:59:23 +00:00
if ( g_Config . iTimeFormat = = PSP_SYSTEMPARAM_TIME_FORMAT_12HR )
param = PSP_SYSTEMPARAM_TIME_FORMAT_12HR ;
else
param = PSP_SYSTEMPARAM_TIME_FORMAT_24HR ;
2012-11-22 20:46:22 +00:00
break ;
case PSP_SYSTEMPARAM_ID_INT_TIMEZONE :
2013-04-19 18:59:24 +00:00
param = g_Config . iTimeZone ;
2012-11-22 20:46:22 +00:00
break ;
case PSP_SYSTEMPARAM_ID_INT_DAYLIGHTSAVINGS :
2013-04-19 18:59:24 +00:00
param = g_Config . bDayLightSavings ? PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_SAVING : PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD ;
2012-11-22 20:46:22 +00:00
break ;
case PSP_SYSTEMPARAM_ID_INT_LANGUAGE :
2023-07-23 09:05:08 +00:00
param = g_Config . GetPSPLanguage ( ) ;
2022-11-13 22:16:09 +00:00
if ( PSP_CoreParameter ( ) . compat . flags ( ) . EnglishOrJapaneseOnly ) {
if ( param ! = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH & & param ! = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE ) {
param = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH ;
}
}
2012-11-22 20:46:22 +00:00
break ;
2013-01-20 06:05:01 +00:00
case PSP_SYSTEMPARAM_ID_INT_BUTTON_PREFERENCE :
2022-11-27 22:32:43 +00:00
param = PSP_CoreParameter ( ) . compat . flags ( ) . ForceCircleButtonConfirm ? PSP_SYSTEMPARAM_BUTTON_CIRCLE : g_Config . iButtonPreference ;
2012-11-22 20:46:22 +00:00
break ;
2013-02-01 17:06:37 +00:00
case PSP_SYSTEMPARAM_ID_INT_LOCK_PARENTAL_LEVEL :
2013-04-20 16:01:03 +00:00
param = g_Config . iLockParentalLevel ;
2013-02-01 17:06:37 +00:00
break ;
2012-11-22 20:46:22 +00:00
default :
return PSP_SYSTEMPARAM_RETVAL_FAIL ;
2012-11-14 23:04:40 +00:00
}
2024-07-16 13:14:15 +00:00
INFO_LOG ( Log : : sceUtility , " sceUtilityGetSystemParamInt(%i, %08x <- %08x) " , id , destaddr , param ) ;
2012-11-27 09:18:36 +00:00
Memory : : Write_U32 ( param , destaddr ) ;
2012-11-14 23:04:40 +00:00
return 0 ;
2012-11-01 15:19:01 +00:00
}
2014-12-08 09:40:08 +00:00
static u32 sceUtilityLoadNetModule ( u32 module )
2012-11-06 17:56:56 +00:00
{
2024-07-14 12:42:59 +00:00
DEBUG_LOG ( Log : : sceUtility , " FAKE: sceUtilityLoadNetModule(%i) " , module ) ;
2012-11-06 17:56:56 +00:00
return 0 ;
}
2014-12-08 09:40:08 +00:00
static u32 sceUtilityUnloadNetModule ( u32 module )
2012-12-12 21:08:55 +00:00
{
2024-07-14 12:42:59 +00:00
DEBUG_LOG ( Log : : sceUtility , " FAKE: sceUtilityUnloadNetModule(%i) " , module ) ;
2012-12-12 21:08:55 +00:00
return 0 ;
}
2020-03-15 20:04:32 +00:00
static int sceUtilityNpSigninInitStart ( u32 paramsPtr ) {
2021-03-12 07:32:33 +00:00
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : NPSIGNIN ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2021-03-12 07:32:33 +00:00
}
ActivateDialog ( UtilityDialogType : : NPSIGNIN ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessInfoI ( Log : : sceUtility , npSigninDialog - > Init ( paramsPtr ) ) ;
2021-03-12 07:32:33 +00:00
}
static int sceUtilityNpSigninShutdownStart ( ) {
if ( currentDialogType ! = UtilityDialogType : : NPSIGNIN ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2021-03-12 07:32:33 +00:00
}
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , npSigninDialog - > Shutdown ( ) ) ;
2020-03-15 20:04:32 +00:00
}
static int sceUtilityNpSigninUpdate ( int animSpeed ) {
2021-03-12 07:32:33 +00:00
if ( currentDialogType ! = UtilityDialogType : : NPSIGNIN ) {
2024-07-14 12:42:59 +00:00
return hleLogWarning ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2021-03-12 07:32:33 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , npSigninDialog - > Update ( animSpeed ) ) ;
2020-03-15 20:04:32 +00:00
}
static int sceUtilityNpSigninGetStatus ( ) {
2021-03-12 07:32:33 +00:00
if ( currentDialogType ! = UtilityDialogType : : NPSIGNIN ) {
2024-07-14 12:42:59 +00:00
return hleLogDebug ( Log : : sceUtility , SCE_ERROR_UTILITY_WRONG_TYPE , " wrong dialog type " ) ;
2021-03-12 07:32:33 +00:00
}
int status = npSigninDialog - > GetStatus ( ) ;
CleanupDialogThreads ( ) ;
if ( oldStatus ! = status ) {
oldStatus = status ;
2024-07-14 12:42:59 +00:00
return hleLogSuccessI ( Log : : sceUtility , status ) ;
2021-03-12 07:32:33 +00:00
}
2024-07-14 12:42:59 +00:00
return hleLogSuccessVerboseI ( Log : : sceUtility , status ) ;
2020-03-15 20:04:32 +00:00
}
2014-12-08 09:40:08 +00:00
static void sceUtilityInstallInitStart ( u32 unknown )
2012-12-19 00:05:45 +00:00
{
2024-07-14 12:42:59 +00:00
WARN_LOG_REPORT ( Log : : sceUtility , " UNIMPL sceUtilityInstallInitStart() " ) ;
2012-12-19 00:05:45 +00:00
}
2014-12-08 09:40:08 +00:00
static int sceUtilityStoreCheckoutShutdownStart ( )
2013-04-29 03:40:09 +00:00
{
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " UNIMPL sceUtilityStoreCheckoutShutdownStart() " ) ;
2013-04-29 03:40:09 +00:00
return 0 ;
}
2014-12-08 09:40:08 +00:00
static int sceUtilityStoreCheckoutInitStart ( u32 paramsPtr )
2013-04-29 03:40:09 +00:00
{
2024-07-14 12:42:59 +00:00
ERROR_LOG_REPORT ( Log : : sceUtility , " UNIMPL sceUtilityStoreCheckoutInitStart(%d) " , paramsPtr ) ;
2013-04-29 03:40:09 +00:00
return 0 ;
}
2014-12-08 09:40:08 +00:00
static int sceUtilityStoreCheckoutUpdate ( int drawSpeed )
2013-04-29 03:40:09 +00:00
{
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " UNIMPL sceUtilityStoreCheckoutUpdate(%d) " , drawSpeed ) ;
2013-04-29 03:40:09 +00:00
return 0 ;
}
2014-12-08 09:40:08 +00:00
static int sceUtilityStoreCheckoutGetStatus ( )
2013-04-29 03:40:09 +00:00
{
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " UNIMPL sceUtilityStoreCheckoutGetStatus() " ) ;
2013-04-29 03:40:09 +00:00
return 0 ;
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGameSharingShutdownStart ( ) {
if ( currentDialogType ! = UtilityDialogType : : GAMESHARING ) {
2024-07-14 12:42:59 +00:00
WARN_LOG ( Log : : sceUtility , " sceUtilityGameSharingShutdownStart(): wrong dialog type " ) ;
2013-08-31 21:34:36 +00:00
return SCE_ERROR_UTILITY_WRONG_TYPE ;
}
2014-04-25 21:29:03 +00:00
2020-12-13 18:55:37 +00:00
DeactivateDialog ( ) ;
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " UNIMPL sceUtilityGameSharingShutdownStart() " ) ;
2013-08-31 21:34:36 +00:00
return 0 ;
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGameSharingInitStart ( u32 paramsPtr ) {
if ( currentDialogActive & & currentDialogType ! = UtilityDialogType : : GAMESHARING ) {
2024-07-14 12:42:59 +00:00
WARN_LOG ( Log : : sceUtility , " sceUtilityGameSharingInitStart(%08x) " , paramsPtr ) ;
2013-08-31 21:34:36 +00:00
return SCE_ERROR_UTILITY_WRONG_TYPE ;
}
2014-04-25 21:29:03 +00:00
2021-02-27 21:43:12 +00:00
ActivateDialog ( UtilityDialogType : : GAMESHARING ) ;
2024-07-14 12:42:59 +00:00
ERROR_LOG_REPORT ( Log : : sceUtility , " UNIMPL sceUtilityGameSharingInitStart(%08x) " , paramsPtr ) ;
2013-08-31 21:34:36 +00:00
return 0 ;
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGameSharingUpdate ( int animSpeed ) {
if ( currentDialogType ! = UtilityDialogType : : GAMESHARING ) {
2024-07-14 12:42:59 +00:00
WARN_LOG ( Log : : sceUtility , " sceUtilityGameSharingUpdate(%i): wrong dialog type " , animSpeed ) ;
2013-08-31 21:34:36 +00:00
return SCE_ERROR_UTILITY_WRONG_TYPE ;
}
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " UNIMPL sceUtilityGameSharingUpdate(%i) " , animSpeed ) ;
2013-08-31 21:34:36 +00:00
return 0 ;
}
2021-02-27 21:43:12 +00:00
static int sceUtilityGameSharingGetStatus ( ) {
if ( currentDialogType ! = UtilityDialogType : : GAMESHARING ) {
2024-07-14 12:42:59 +00:00
DEBUG_LOG ( Log : : sceUtility , " sceUtilityGameSharingGetStatus(): wrong dialog type " ) ;
2013-08-31 21:34:36 +00:00
return SCE_ERROR_UTILITY_WRONG_TYPE ;
}
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " UNIMPL sceUtilityGameSharingGetStatus() " ) ;
2021-02-27 21:15:12 +00:00
CleanupDialogThreads ( ) ;
2013-08-31 21:34:36 +00:00
return 0 ;
}
2015-03-15 13:08:11 +00:00
static u32 sceUtilityLoadUsbModule ( u32 module )
{
if ( module < 1 | | module > 5 )
{
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " sceUtilityLoadUsbModule(%i): invalid module id " , module ) ;
2015-03-15 13:08:11 +00:00
}
2024-07-14 12:42:59 +00:00
ERROR_LOG_REPORT ( Log : : sceUtility , " UNIMPL sceUtilityLoadUsbModule(%i) " , module ) ;
2015-03-15 13:08:11 +00:00
return 0 ;
}
static u32 sceUtilityUnloadUsbModule ( u32 module )
{
if ( module < 1 | | module > 5 )
{
2024-07-14 12:42:59 +00:00
ERROR_LOG ( Log : : sceUtility , " sceUtilityUnloadUsbModule(%i): invalid module id " , module ) ;
2015-03-15 13:08:11 +00:00
}
2024-07-14 12:42:59 +00:00
ERROR_LOG_REPORT ( Log : : sceUtility , " UNIMPL sceUtilityUnloadUsbModule(%i) " , module ) ;
2015-03-15 13:08:11 +00:00
return 0 ;
}
2012-11-01 15:19:01 +00:00
const HLEFunction sceUtility [ ] =
{
2015-03-22 23:57:56 +00:00
{ 0X1579A159 , & WrapU_U < sceUtilityLoadNetModule > , " sceUtilityLoadNetModule " , ' x ' , " x " } ,
{ 0X64D50C56 , & WrapU_U < sceUtilityUnloadNetModule > , " sceUtilityUnloadNetModule " , ' x ' , " x " } ,
{ 0XF88155F6 , & WrapI_V < sceUtilityNetconfShutdownStart > , " sceUtilityNetconfShutdownStart " , ' i ' , " " } ,
{ 0X4DB1E739 , & WrapI_U < sceUtilityNetconfInitStart > , " sceUtilityNetconfInitStart " , ' i ' , " x " } ,
{ 0X91E70E35 , & WrapI_I < sceUtilityNetconfUpdate > , " sceUtilityNetconfUpdate " , ' i ' , " i " } ,
{ 0X6332AA39 , & WrapI_V < sceUtilityNetconfGetStatus > , " sceUtilityNetconfGetStatus " , ' i ' , " " } ,
{ 0X5EEE6548 , & WrapI_I < sceUtilityCheckNetParam > , " sceUtilityCheckNetParam " , ' i ' , " i " } ,
{ 0X434D4B3A , nullptr , " sceUtilityGetNetParam " , ' ? ' , " " } ,
{ 0X4FED24D8 , nullptr , " sceUtilityGetNetParamLatestID " , ' ? ' , " " } ,
{ 0X67AF3428 , & WrapI_V < sceUtilityMsgDialogShutdownStart > , " sceUtilityMsgDialogShutdownStart " , ' i ' , " " } ,
{ 0X2AD8E239 , & WrapI_U < sceUtilityMsgDialogInitStart > , " sceUtilityMsgDialogInitStart " , ' i ' , " x " } ,
{ 0X95FC253B , & WrapI_I < sceUtilityMsgDialogUpdate > , " sceUtilityMsgDialogUpdate " , ' i ' , " i " } ,
{ 0X9A1C91D7 , & WrapI_V < sceUtilityMsgDialogGetStatus > , " sceUtilityMsgDialogGetStatus " , ' i ' , " " } ,
{ 0X4928BD96 , & WrapI_V < sceUtilityMsgDialogAbort > , " sceUtilityMsgDialogAbort " , ' i ' , " " } ,
{ 0X9790B33C , & WrapI_V < sceUtilitySavedataShutdownStart > , " sceUtilitySavedataShutdownStart " , ' i ' , " " } ,
{ 0X50C4CD57 , & WrapI_U < sceUtilitySavedataInitStart > , " sceUtilitySavedataInitStart " , ' i ' , " x " } ,
{ 0XD4B95FFB , & WrapI_I < sceUtilitySavedataUpdate > , " sceUtilitySavedataUpdate " , ' i ' , " i " } ,
{ 0X8874DBE0 , & WrapI_V < sceUtilitySavedataGetStatus > , " sceUtilitySavedataGetStatus " , ' i ' , " " } ,
{ 0X3DFAEBA9 , & WrapI_V < sceUtilityOskShutdownStart > , " sceUtilityOskShutdownStart " , ' i ' , " " } ,
{ 0XF6269B82 , & WrapI_U < sceUtilityOskInitStart > , " sceUtilityOskInitStart " , ' i ' , " x " } ,
{ 0X4B85C861 , & WrapI_I < sceUtilityOskUpdate > , " sceUtilityOskUpdate " , ' i ' , " i " } ,
{ 0XF3F76017 , & WrapI_V < sceUtilityOskGetStatus > , " sceUtilityOskGetStatus " , ' i ' , " " } ,
{ 0X41E30674 , & WrapU_UU < sceUtilitySetSystemParamString > , " sceUtilitySetSystemParamString " , ' x ' , " xx " } ,
2017-06-06 17:07:11 +00:00
{ 0X45C18506 , & WrapU_UU < sceUtilitySetSystemParamInt > , " sceUtilitySetSystemParamInt " , ' x ' , " xx " } ,
2015-03-22 23:57:56 +00:00
{ 0X34B78343 , & WrapU_UUI < sceUtilityGetSystemParamString > , " sceUtilityGetSystemParamString " , ' x ' , " xxi " } ,
{ 0XA5DA2406 , & WrapU_UU < sceUtilityGetSystemParamInt > , " sceUtilityGetSystemParamInt " , ' x ' , " xx " } ,
{ 0XC492F751 , & WrapI_U < sceUtilityGameSharingInitStart > , " sceUtilityGameSharingInitStart " , ' i ' , " x " } ,
{ 0XEFC6F80F , & WrapI_V < sceUtilityGameSharingShutdownStart > , " sceUtilityGameSharingShutdownStart " , ' i ' , " " } ,
{ 0X7853182D , & WrapI_I < sceUtilityGameSharingUpdate > , " sceUtilityGameSharingUpdate " , ' i ' , " i " } ,
{ 0X946963F3 , & WrapI_V < sceUtilityGameSharingGetStatus > , " sceUtilityGameSharingGetStatus " , ' i ' , " " } ,
{ 0X2995D020 , nullptr , " sceUtilitySavedataErrInitStart " , ' ? ' , " " } ,
{ 0XB62A4061 , nullptr , " sceUtilitySavedataErrShutdownStart " , ' ? ' , " " } ,
{ 0XED0FAD38 , nullptr , " sceUtilitySavedataErrUpdate " , ' ? ' , " " } ,
{ 0X88BC7406 , nullptr , " sceUtilitySavedataErrGetStatus " , ' ? ' , " " } ,
{ 0XBDA7D894 , nullptr , " sceUtilityHtmlViewerGetStatus " , ' ? ' , " " } ,
{ 0XCDC3AA41 , nullptr , " sceUtilityHtmlViewerInitStart " , ' ? ' , " " } ,
{ 0XF5CE1134 , nullptr , " sceUtilityHtmlViewerShutdownStart " , ' ? ' , " " } ,
{ 0X05AFB9E4 , nullptr , " sceUtilityHtmlViewerUpdate " , ' ? ' , " " } ,
{ 0X16A1A8D8 , nullptr , " sceUtilityAuthDialogGetStatus " , ' ? ' , " " } ,
{ 0X943CBA46 , nullptr , " sceUtilityAuthDialogInitStart " , ' ? ' , " " } ,
{ 0X0F3EEAAC , nullptr , " sceUtilityAuthDialogShutdownStart " , ' ? ' , " " } ,
{ 0X147F7C85 , nullptr , " sceUtilityAuthDialogUpdate " , ' ? ' , " " } ,
{ 0XC629AF26 , & WrapU_U < sceUtilityLoadAvModule > , " sceUtilityLoadAvModule " , ' x ' , " x " } ,
{ 0XF7D8D092 , & WrapU_U < sceUtilityUnloadAvModule > , " sceUtilityUnloadAvModule " , ' x ' , " x " } ,
{ 0X2A2B3DE0 , & WrapU_U < sceUtilityLoadModule > , " sceUtilityLoadModule " , ' x ' , " x " } ,
{ 0XE49BFE92 , & WrapU_U < sceUtilityUnloadModule > , " sceUtilityUnloadModule " , ' x ' , " x " } ,
{ 0X0251B134 , & WrapI_U < sceUtilityScreenshotInitStart > , " sceUtilityScreenshotInitStart " , ' i ' , " x " } ,
{ 0XF9E0008C , & WrapI_V < sceUtilityScreenshotShutdownStart > , " sceUtilityScreenshotShutdownStart " , ' i ' , " " } ,
2020-03-15 20:04:32 +00:00
{ 0XAB083EA9 , & WrapI_U < sceUtilityScreenshotUpdate > , " sceUtilityScreenshotUpdate " , ' i ' , " i " } ,
2015-03-22 23:57:56 +00:00
{ 0XD81957B7 , & WrapI_V < sceUtilityScreenshotGetStatus > , " sceUtilityScreenshotGetStatus " , ' i ' , " " } ,
{ 0X86A03A27 , & WrapI_U < sceUtilityScreenshotContStart > , " sceUtilityScreenshotContStart " , ' i ' , " x " } ,
{ 0X0D5BC6D2 , & WrapU_U < sceUtilityLoadUsbModule > , " sceUtilityLoadUsbModule " , ' x ' , " x " } ,
{ 0XF64910F0 , & WrapU_U < sceUtilityUnloadUsbModule > , " sceUtilityUnloadUsbModule " , ' x ' , " x " } ,
{ 0X24AC31EB , & WrapI_U < sceUtilityGamedataInstallInitStart > , " sceUtilityGamedataInstallInitStart " , ' i ' , " x " } ,
{ 0X32E32DCB , & WrapI_V < sceUtilityGamedataInstallShutdownStart > , " sceUtilityGamedataInstallShutdownStart " , ' i ' , " " } ,
{ 0X4AECD179 , & WrapI_I < sceUtilityGamedataInstallUpdate > , " sceUtilityGamedataInstallUpdate " , ' i ' , " i " } ,
{ 0XB57E95D9 , & WrapI_V < sceUtilityGamedataInstallGetStatus > , " sceUtilityGamedataInstallGetStatus " , ' i ' , " " } ,
{ 0X180F7B62 , & WrapI_V < sceUtilityGamedataInstallAbort > , " sceUtilityGamedataInstallAbort " , ' i ' , " " } ,
2020-03-15 20:04:32 +00:00
{ 0X16D02AF0 , & WrapI_U < sceUtilityNpSigninInitStart > , " sceUtilityNpSigninInitStart " , ' i ' , " x " } ,
2021-03-12 07:32:33 +00:00
{ 0XE19C97D6 , & WrapI_V < sceUtilityNpSigninShutdownStart > , " sceUtilityNpSigninShutdownStart " , ' i ' , " " } ,
2020-03-15 20:04:32 +00:00
{ 0XF3FBC572 , & WrapI_I < sceUtilityNpSigninUpdate > , " sceUtilityNpSigninUpdate " , ' i ' , " i " } ,
{ 0X86ABDB1B , & WrapI_V < sceUtilityNpSigninGetStatus > , " sceUtilityNpSigninGetStatus " , ' i ' , " " } ,
2015-03-22 23:57:56 +00:00
{ 0X1281DA8E , & WrapV_U < sceUtilityInstallInitStart > , " sceUtilityInstallInitStart " , ' v ' , " x " } ,
{ 0X5EF1C24A , nullptr , " sceUtilityInstallShutdownStart " , ' ? ' , " " } ,
{ 0XA03D29BA , nullptr , " sceUtilityInstallUpdate " , ' ? ' , " " } ,
{ 0XC4700FA3 , nullptr , " sceUtilityInstallGetStatus " , ' ? ' , " " } ,
{ 0X54A5C62F , & WrapI_V < sceUtilityStoreCheckoutShutdownStart > , " sceUtilityStoreCheckoutShutdownStart " , ' i ' , " " } ,
{ 0XDA97F1AA , & WrapI_U < sceUtilityStoreCheckoutInitStart > , " sceUtilityStoreCheckoutInitStart " , ' i ' , " x " } ,
{ 0XB8592D5F , & WrapI_I < sceUtilityStoreCheckoutUpdate > , " sceUtilityStoreCheckoutUpdate " , ' i ' , " i " } ,
{ 0X3AAD51DC , & WrapI_V < sceUtilityStoreCheckoutGetStatus > , " sceUtilityStoreCheckoutGetStatus " , ' i ' , " " } ,
{ 0XD17A0573 , nullptr , " sceUtilityPS3ScanShutdownStart " , ' ? ' , " " } ,
{ 0X42071A83 , nullptr , " sceUtilityPS3ScanInitStart " , ' ? ' , " " } ,
{ 0XD852CDCE , nullptr , " sceUtilityPS3ScanUpdate " , ' ? ' , " " } ,
{ 0X89317C8F , nullptr , " sceUtilityPS3ScanGetStatus " , ' ? ' , " " } ,
{ 0XE1BC175E , nullptr , " sceUtility_E1BC175E " , ' ? ' , " " } ,
{ 0X43E521B7 , nullptr , " sceUtility_43E521B7 " , ' ? ' , " " } ,
{ 0XDB4149EE , nullptr , " sceUtility_DB4149EE " , ' ? ' , " " } ,
{ 0XCFE7C460 , nullptr , " sceUtility_CFE7C460 " , ' ? ' , " " } ,
{ 0XC130D441 , nullptr , " sceUtilityPsnShutdownStart " , ' ? ' , " " } ,
{ 0XA7BB7C67 , nullptr , " sceUtilityPsnInitStart " , ' ? ' , " " } ,
{ 0X0940A1B9 , nullptr , " sceUtilityPsnUpdate " , ' ? ' , " " } ,
{ 0X094198B8 , nullptr , " sceUtilityPsnGetStatus " , ' ? ' , " " } ,
{ 0X9F313D14 , nullptr , " sceUtilityAutoConnectShutdownStart " , ' ? ' , " " } ,
{ 0X3A15CD0A , nullptr , " sceUtilityAutoConnectInitStart " , ' ? ' , " " } ,
{ 0XD23665F4 , nullptr , " sceUtilityAutoConnectUpdate " , ' ? ' , " " } ,
{ 0XD4C2BD73 , nullptr , " sceUtilityAutoConnectGetStatus " , ' ? ' , " " } ,
{ 0X0E0C27AF , nullptr , " sceUtilityAutoConnectAbort " , ' ? ' , " " } ,
{ 0X06A48659 , nullptr , " sceUtilityRssSubscriberShutdownStart " , ' ? ' , " " } ,
{ 0X4B0A8FE5 , nullptr , " sceUtilityRssSubscriberInitStart " , ' ? ' , " " } ,
{ 0XA084E056 , nullptr , " sceUtilityRssSubscriberUpdate " , ' ? ' , " " } ,
{ 0X2B96173B , nullptr , " sceUtilityRssSubscriberGetStatus " , ' ? ' , " " } ,
{ 0X149A7895 , nullptr , " sceUtilityDNASShutdownStart " , ' ? ' , " " } ,
{ 0XDDE5389D , nullptr , " sceUtilityDNASInitStart " , ' ? ' , " " } ,
{ 0X4A833BA4 , nullptr , " sceUtilityDNASUpdate " , ' ? ' , " " } ,
{ 0XA50E5B30 , nullptr , " sceUtilityDNASGetStatus " , ' ? ' , " " } ,
{ 0XE7B778D8 , nullptr , " sceUtilityRssReaderShutdownStart " , ' ? ' , " " } ,
{ 0X81C44706 , nullptr , " sceUtilityRssReaderInitStart " , ' ? ' , " " } ,
{ 0X6F56F9CF , nullptr , " sceUtilityRssReaderUpdate " , ' ? ' , " " } ,
{ 0X8326AB05 , nullptr , " sceUtilityRssReaderGetStatus " , ' ? ' , " " } ,
{ 0XB0FB7FF5 , nullptr , " sceUtilityRssReaderContStart " , ' ? ' , " " } ,
{ 0XBC6B6296 , nullptr , " sceNetplayDialogShutdownStart " , ' ? ' , " " } ,
{ 0X3AD50AE7 , nullptr , " sceNetplayDialogInitStart " , ' ? ' , " " } ,
{ 0X417BED54 , nullptr , " sceNetplayDialogUpdate " , ' ? ' , " " } ,
{ 0XB6CEE597 , nullptr , " sceNetplayDialogGetStatus " , ' ? ' , " " } ,
{ 0X28D35634 , nullptr , " sceUtility_28D35634 " , ' ? ' , " " } ,
{ 0X70267ADF , nullptr , " sceUtility_70267ADF " , ' ? ' , " " } ,
{ 0XECE1D3E5 , nullptr , " sceUtility_ECE1D3E5 " , ' ? ' , " " } ,
{ 0XEF3582B2 , nullptr , " sceUtility_EF3582B2 " , ' ? ' , " " } ,
2021-02-27 21:15:12 +00:00
// Fake functions for PPSSPP's use.
{ 0xC0DE0001 , & WrapI_I < UtilityFinishDialog > , " __UtilityFinishDialog " , ' i ' , " i " } ,
{ 0xC0DE0002 , & WrapI_I < UtilityWorkUs > , " __UtilityWorkUs " , ' i ' , " i " } ,
2021-04-08 01:07:48 +00:00
{ 0xC0DE0003 , & WrapI_I < UtilityInitDialog > , " __UtilityInitDialog " , ' i ' , " i " } ,
2012-11-01 15:19:01 +00:00
} ;
void Register_sceUtility ( )
{
RegisterModule ( " sceUtility " , ARRAY_SIZE ( sceUtility ) , sceUtility ) ;
}