1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

Merge pull request #1144 from tambry/tea

Saving fix and improvements to sceNp2 and cellCamera
This commit is contained in:
Hykem 2015-07-14 18:03:33 +01:00
commit 93e850404e
10 changed files with 411 additions and 93 deletions

View File

@ -46,6 +46,7 @@ extern Module cellVoice;
extern Module cellVpost;
extern Module libmixer;
extern Module sceNp;
extern Module sceNp2;
extern Module sceNpClans;
extern Module sceNpCommerce2;
extern Module sceNpSns;
@ -117,7 +118,7 @@ static const g_module_list[] =
{ 0x0035, "cellSysutilRec", nullptr },
{ 0x0036, "cellVideoExport", nullptr },
{ 0x0037, "cellGameExec", nullptr },
{ 0x0038, "sceNp2", nullptr },
{ 0x0038, "sceNp2", &sceNp2 },
{ 0x0039, "cellSysutilAp", &cellSysutilAp },
{ 0x003a, "cellSysutilNpClans", nullptr },
{ 0x003b, "cellSysutilOskExt", nullptr },

View File

@ -121,25 +121,31 @@ s32 cellCameraGetType(s32 dev_num, vm::ptr<s32> type)
s32 cellCameraIsAvailable(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
cellCamera.Todo("cellCameraIsAvailable(dev_num=%d)", dev_num);
return CELL_OK;
}
s32 cellCameraIsAttached(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
return CELL_OK;
cellCamera.Warning("cellCameraIsAttached(dev_num=%d)", dev_num);
if (Ini.Camera.GetValue() == 1)
{
return 1;
}
return CELL_OK; // CELL_OK means that no camera is attached
}
s32 cellCameraIsOpen(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
cellCamera.Todo("cellCameraIsOpen(dev_num=%d)", dev_num);
return CELL_OK;
}
s32 cellCameraIsStarted(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
cellCamera.Todo("cellCameraIsStarted(dev_num=%d)", dev_num);
return CELL_OK;
}

View File

@ -57,6 +57,7 @@ never_inline s32 savedata_op(
if (!lock)
{
cellSysutil.Error("savedata_op(): failed to lock the mutex.");
return CELL_SAVEDATA_ERROR_BUSY;
}
@ -191,6 +192,7 @@ never_inline s32 savedata_op(
if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcList returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}
@ -302,6 +304,7 @@ never_inline s32 savedata_op(
if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcFixed returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}
@ -343,10 +346,31 @@ never_inline s32 savedata_op(
PSFLoader psf;
// Create save directory if necessary
if (save_entry.isNew)
{
if (!Emu.GetVFS().ExistsDir(dir_path) && !Emu.GetVFS().CreateDir(dir_path))
{
cellSysutil.Error("savedata_op(): Savedata directory creation failed.");
}
else
{
// Is loading the PARAM.SFO really necessary? Setting empty stuff seems to fix a couple games.
psf.SetInteger("ATTRIBUTE", 0);
psf.SetString("TITLE", "");
psf.SetString("SUB_TITLE", "");
psf.SetString("DETAIL", "");
psf.SetString("SAVEDATA_LIST_PARAM", "");
}
}
// Load PARAM.SFO
{
vfsFile f(sfo_path);
psf.Load(f);
if (!save_entry.isNew)
{
vfsFile f(sfo_path);
psf.Load(f);
}
}
// Get save stats
@ -436,6 +460,7 @@ never_inline s32 savedata_op(
if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcStat returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}
@ -485,12 +510,6 @@ never_inline s32 savedata_op(
}
}
// Create save directory if necessary
if (save_entry.isNew && !Emu.GetVFS().CreateDir(dir_path))
{
// Let's ignore this error for now
}
// Enter the loop where the save files are read/created/deleted
vm::stackvar<CellSaveDataFileGet> fileGet(CPU);
vm::stackvar<CellSaveDataFileSet> fileSet(CPU);
@ -504,6 +523,7 @@ never_inline s32 savedata_op(
if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcFile returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}

View File

@ -12,74 +12,55 @@
extern Module sceNp;
struct sceNpInternal
{
bool m_bSceNpInitialized;
bool m_bSceNp2Initialized;
bool m_bScoreInitialized;
bool m_bLookupInitialized;
bool m_bSceNpUtilBandwidthTestInitialized;
sceNpInternal()
: m_bSceNpInitialized(false),
m_bSceNp2Initialized(false),
m_bScoreInitialized(false),
m_bLookupInitialized(false),
m_bSceNpUtilBandwidthTestInitialized(false)
{
}
};
sceNpInternal sceNpInstance;
s32 sceNpInit(u32 mem_size, u32 mem_addr)
s32 sceNpInit(u32 poolsize, vm::ptr<u32> poolptr)
{
sceNp.Warning("sceNpInit(mem_size=0x%x, mem_addr=0x%x)", mem_size, mem_addr);
sceNp.Warning("sceNpInit(poolsize=%d, poolptr=0x%x)", poolsize, poolptr);
if (sceNpInstance.m_bSceNpInitialized)
{
sceNp.Error("sceNpInit(): sceNp has been already initialized.");
return SCE_NP_ERROR_ALREADY_INITIALIZED;
}
if (poolsize == 0)
{
sceNp.Error("sceNpInit(): poolsize given is 0.");
return SCE_NP_ERROR_INVALID_ARGUMENT;
}
else if (poolsize < 128 * 1024)
{
sceNp.Error("sceNp2Init(): poolsize given is under 131072 bytes.");
return SCE_NP_ERROR_INSUFFICIENT_BUFFER;
}
if (!poolptr)
{
sceNp.Error("sceNpInit(): poolptr is invalid.");
return SCE_NP_ERROR_INVALID_ARGUMENT;
}
sceNpInstance.m_bSceNpInitialized = true;
return CELL_OK;
}
s32 sceNp2Init(u32 mem_size, u32 mem_addr)
{
sceNp.Warning("sceNp2Init(mem_size=0x%x, mem_addr=0x%x)", mem_size, mem_addr);
if (sceNpInstance.m_bSceNp2Initialized)
return SCE_NP_ERROR_ALREADY_INITIALIZED;
sceNpInstance.m_bSceNp2Initialized = true;
return CELL_OK;
}
s32 sceNpTerm()
{
sceNp.Warning("sceNpTerm()");
if (!sceNpInstance.m_bSceNpInitialized)
{
sceNp.Error("sceNpTerm(): sceNp has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}
sceNpInstance.m_bSceNpInitialized = false;
return CELL_OK;
}
s32 sceNp2Term()
{
sceNp.Warning("sceNp2Term()");
if (!sceNpInstance.m_bSceNp2Initialized)
return SCE_NP_ERROR_NOT_INITIALIZED;
sceNpInstance.m_bSceNp2Initialized = false;
return CELL_OK;
}
s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr<char> drm_path)
{
if (!Emu.GetVFS().ExistsFile(drm_path.get_ptr()))
@ -191,14 +172,7 @@ s32 sceNpDrmGetTimelimit(vm::ptr<const char> path, vm::ptr<u64> time_remain)
s32 sceNpDrmProcessExitSpawn(vm::cptr<char> path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags)
{
sceNp.Warning("sceNpDrmProcessExitSpawn()");
sceNp.Warning("path: %s", path.get_ptr());
sceNp.Warning("argv: 0x%x", argv_addr);
sceNp.Warning("envp: 0x%x", envp_addr);
sceNp.Warning("data: 0x%x", data_addr);
sceNp.Warning("data_size: 0x%x", data_size);
sceNp.Warning("prio: %d", prio);
sceNp.Warning("flags: %d", flags);
sceNp.Warning("sceNpDrmProcessExitSpawn() -> sys_game_process_exitspawn");
sys_game_process_exitspawn(path, argv_addr, envp_addr, data_addr, data_size, prio, flags);
@ -207,14 +181,7 @@ s32 sceNpDrmProcessExitSpawn(vm::cptr<char> path, u32 argv_addr, u32 envp_addr,
s32 sceNpDrmProcessExitSpawn2(vm::cptr<char> path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags)
{
sceNp.Warning("sceNpDrmProcessExitSpawn2()");
sceNp.Warning("path: %s", path.get_ptr());
sceNp.Warning("argv: 0x%x", argv_addr);
sceNp.Warning("envp: 0x%x", envp_addr);
sceNp.Warning("data: 0x%x", data_addr);
sceNp.Warning("data_size: 0x%x", data_size);
sceNp.Warning("prio: %d", prio);
sceNp.Warning("flags: %d", flags);
sceNp.Warning("sceNpDrmProcessExitSpawn2() -> sys_game_process_exitspawn2");
sys_game_process_exitspawn2(path, argv_addr, envp_addr, data_addr, data_size, prio, flags);
@ -1639,16 +1606,13 @@ s32 _sceNpSysutilClientFree()
Module sceNp("sceNp", []()
{
sceNpInstance.m_bSceNpInitialized = false;
sceNpInstance.m_bSceNp2Initialized = false;
sceNpInstance.m_bScoreInitialized = false;
sceNpInstance.m_bLookupInitialized = false;
sceNpInstance.m_bSceNpUtilBandwidthTestInitialized = false;
REG_FUNC(sceNp, sceNpInit);
REG_FUNC(sceNp, sceNp2Init);
REG_FUNC(sceNp, sceNpUtilBandwidthTestInitStart);
REG_FUNC(sceNp, sceNpTerm);
REG_FUNC(sceNp, sceNp2Term);
REG_FUNC(sceNp, sceNpUtilBandwidthTestShutdown);
REG_FUNC(sceNp, sceNpDrmIsAvailable);
REG_FUNC(sceNp, sceNpDrmIsAvailable2);

View File

@ -31,6 +31,7 @@ enum
SCE_NP_ERROR_ALREADY_USED = 0x8002aa15,
SCE_NP_ERROR_DIFFERENT_USER = 0x8002aa16,
SCE_NP_ERROR_ALREADY_DONE = 0x8002aa17,
// NP Basic Utility
SCE_NP_BASIC_ERROR_ALREADY_INITIALIZED = 0x8002a661,
SCE_NP_BASIC_ERROR_NOT_INITIALIZED = 0x8002a662,
@ -65,6 +66,7 @@ enum
SCE_NP_EXT_ERROR_CONTEXT_ALREADY_EXISTS = 0x8002a6a2,
SCE_NP_EXT_ERROR_NO_CONTEXT = 0x8002a6a3,
SCE_NP_EXT_ERROR_NO_ORIGIN = 0x8002a6a4,
// NP Community Utility
SCE_NP_COMMUNITY_ERROR_ALREADY_INITIALIZED = 0x8002a101,
SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED = 0x8002a102,
@ -97,10 +99,144 @@ enum
SCE_NP_COMMUNITY_ERROR_TOO_LARGE_RANGE = 0x8002a1ae,
SCE_NP_COMMUNITY_ERROR_INVALID_PARTITION = 0x8002a1af,
SCE_NP_COMMUNITY_ERROR_TOO_MANY_SLOTID = 0x8002a1b1,
// NP Matching 2 Utility
SCE_NP_MATCHING2_ERROR_OUT_OF_MEMORY = 0x80022301,
SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED = 0x80022302,
SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED = 0x80022303,
SCE_NP_MATCHING2_ERROR_CONTEXT_MAX = 0x80022304,
SCE_NP_MATCHING2_ERROR_CONTEXT_ALREADY_EXISTS = 0x80022305,
SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND = 0x80022306,
SCE_NP_MATCHING2_ERROR_CONTEXT_ALREADY_STARTED = 0x80022307,
SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED = 0x80022308,
SCE_NP_MATCHING2_ERROR_SERVER_NOT_FOUND = 0x80022309,
SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT = 0x8002230a,
SCE_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID = 0x8002230b,
SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID = 0x8002230c,
SCE_NP_MATCHING2_ERROR_INVALID_WORLD_ID = 0x8002230d,
SCE_NP_MATCHING2_ERROR_INVALID_LOBBY_ID = 0x8002230e,
SCE_NP_MATCHING2_ERROR_INVALID_ROOM_ID = 0x8002230f,
SCE_NP_MATCHING2_ERROR_INVALID_MEMBER_ID = 0x80022310,
SCE_NP_MATCHING2_ERROR_INVALID_ATTRIBUTE_ID = 0x80022311,
SCE_NP_MATCHING2_ERROR_INVALID_CASTTYPE = 0x80022312,
SCE_NP_MATCHING2_ERROR_INVALID_SORT_METHOD = 0x80022313,
SCE_NP_MATCHING2_ERROR_INVALID_MAX_SLOT = 0x80022314,
SCE_NP_MATCHING2_ERROR_INVALID_MATCHING_SPACE = 0x80022316,
SCE_NP_MATCHING2_ERROR_INVALID_BLOCK_KICK_FLAG = 0x80022318,
SCE_NP_MATCHING2_ERROR_INVALID_MESSAGE_TARGET = 0x80022319,
SCE_NP_MATCHING2_ERROR_RANGE_FILTER_MAX = 0x8002231a,
SCE_NP_MATCHING2_ERROR_INSUFFICIENT_BUFFER = 0x8002231b,
SCE_NP_MATCHING2_ERROR_DESTINATION_DISAPPEARED = 0x8002231c,
SCE_NP_MATCHING2_ERROR_REQUEST_TIMEOUT = 0x8002231d,
SCE_NP_MATCHING2_ERROR_INVALID_ALIGNMENT = 0x8002231e,
SCE_NP_MATCHING2_ERROR_REQUEST_CB_QUEUE_OVERFLOW = 0x8002231f,
SCE_NP_MATCHING2_ERROR_EVENT_CB_QUEUE_OVERFLOW = 0x80022320,
SCE_NP_MATCHING2_ERROR_MSG_CB_QUEUE_OVERFLOW = 0x80022321,
SCE_NP_MATCHING2_ERROR_CONNECTION_CLOSED_BY_SERVER = 0x80022322,
SCE_NP_MATCHING2_ERROR_SSL_VERIFY_FAILED = 0x80022323,
SCE_NP_MATCHING2_ERROR_SSL_HANDSHAKE = 0x80022324,
SCE_NP_MATCHING2_ERROR_SSL_SEND = 0x80022325,
SCE_NP_MATCHING2_ERROR_SSL_RECV = 0x80022326,
SCE_NP_MATCHING2_ERROR_JOINED_SESSION_MAX = 0x80022327,
SCE_NP_MATCHING2_ERROR_ALREADY_JOINED = 0x80022328,
SCE_NP_MATCHING2_ERROR_INVALID_SESSION_TYPE = 0x80022329,
SCE_NP_MATCHING2_ERROR_CLAN_LOBBY_NOT_EXIST = 0x8002232a,
SCE_NP_MATCHING2_ERROR_NP_SIGNED_OUT = 0x8002232b,
SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE = 0x8002232c,
SCE_NP_MATCHING2_ERROR_SERVER_NOT_AVAILABLE = 0x8002232d,
SCE_NP_MATCHING2_ERROR_NOT_ALLOWED = 0x8002232e,
SCE_NP_MATCHING2_ERROR_ABORTED = 0x8002232f,
SCE_NP_MATCHING2_ERROR_REQUEST_NOT_FOUND = 0x80022330,
SCE_NP_MATCHING2_ERROR_SESSION_DESTROYED = 0x80022331,
SCE_NP_MATCHING2_ERROR_CONTEXT_STOPPED = 0x80022332,
SCE_NP_MATCHING2_ERROR_INVALID_REQUEST_PARAMETER = 0x80022333,
SCE_NP_MATCHING2_ERROR_NOT_NP_SIGN_IN = 0x80022334,
SCE_NP_MATCHING2_ERROR_ROOM_NOT_FOUND = 0x80022335,
SCE_NP_MATCHING2_ERROR_ROOM_MEMBER_NOT_FOUND = 0x80022336,
SCE_NP_MATCHING2_ERROR_LOBBY_NOT_FOUND = 0x80022337,
SCE_NP_MATCHING2_ERROR_LOBBY_MEMBER_NOT_FOUND = 0x80022338,
SCE_NP_MATCHING2_ERROR_EVENT_DATA_NOT_FOUND = 0x80022339,
SCE_NP_MATCHING2_ERROR_KEEPALIVE_TIMEOUT = 0x8002233a,
SCE_NP_MATCHING2_ERROR_TIMEOUT_TOO_SHORT = 0x8002233b,
SCE_NP_MATCHING2_ERROR_TIMEDOUT = 0x8002233c,
SCE_NP_MATCHING2_ERROR_CREATE_HEAP = 0x8002233d,
SCE_NP_MATCHING2_ERROR_INVALID_ATTRIBUTE_SIZE = 0x8002233e,
SCE_NP_MATCHING2_ERROR_CANNOT_ABORT = 0x8002233f,
SCE_NP_MATCHING2_RESOLVER_ERROR_NO_DNS_SERVER = 0x800223a2,
SCE_NP_MATCHING2_RESOLVER_ERROR_INVALID_PACKET = 0x800223ad,
SCE_NP_MATCHING2_RESOLVER_ERROR_TIMEOUT = 0x800223b0,
SCE_NP_MATCHING2_RESOLVER_ERROR_NO_RECORD = 0x800223b1,
SCE_NP_MATCHING2_RESOLVER_ERROR_RES_PACKET_FORMAT = 0x800223b2,
SCE_NP_MATCHING2_RESOLVER_ERROR_RES_SERVER_FAILURE = 0x800223b3,
SCE_NP_MATCHING2_RESOLVER_ERROR_NO_HOST = 0x800223b4,
SCE_NP_MATCHING2_RESOLVER_ERROR_RES_NOT_IMPLEMENTED = 0x800223b5,
SCE_NP_MATCHING2_RESOLVER_ERROR_RES_SERVER_REFUSED = 0x800223b6,
SCE_NP_MATCHING2_RESOLVER_ERROR_RESP_TRUNCATED = 0x800223bc,
SCE_NP_MATCHING2_SERVER_ERROR_BAD_REQUEST = 0x80022b01,
SCE_NP_MATCHING2_SERVER_ERROR_SERVICE_UNAVAILABLE = 0x80022b02,
SCE_NP_MATCHING2_SERVER_ERROR_BUSY = 0x80022b03,
SCE_NP_MATCHING2_SERVER_ERROR_END_OF_SERVICE = 0x80022b04,
SCE_NP_MATCHING2_SERVER_ERROR_INTERNAL_SERVER_ERROR = 0x80022b05,
SCE_NP_MATCHING2_SERVER_ERROR_PLAYER_BANNED = 0x80022b06,
SCE_NP_MATCHING2_SERVER_ERROR_FORBIDDEN = 0x80022b07,
SCE_NP_MATCHING2_SERVER_ERROR_BLOCKED = 0x80022b08,
SCE_NP_MATCHING2_SERVER_ERROR_UNSUPPORTED_NP_ENV = 0x80022b09,
SCE_NP_MATCHING2_SERVER_ERROR_INVALID_TICKET = 0x80022b0a,
SCE_NP_MATCHING2_SERVER_ERROR_INVALID_SIGNATURE = 0x80022b0b,
SCE_NP_MATCHING2_SERVER_ERROR_EXPIRED_TICKET = 0x80022b0c,
SCE_NP_MATCHING2_SERVER_ERROR_ENTITLEMENT_REQUIRED = 0x80022b0d,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_CONTEXT = 0x80022b0e,
SCE_NP_MATCHING2_SERVER_ERROR_CLOSED = 0x80022b0f,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_TITLE = 0x80022b10,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_WORLD = 0x80022b11,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_LOBBY = 0x80022b12,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_ROOM = 0x80022b13,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_LOBBY_INSTANCE = 0x80022b14,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_ROOM_INSTANCE = 0x80022b15,
SCE_NP_MATCHING2_SERVER_ERROR_PASSWORD_MISMATCH = 0x80022b17,
SCE_NP_MATCHING2_SERVER_ERROR_LOBBY_FULL = 0x80022b18,
SCE_NP_MATCHING2_SERVER_ERROR_ROOM_FULL = 0x80022b19,
SCE_NP_MATCHING2_SERVER_ERROR_GROUP_FULL = 0x80022b1b,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_USER = 0x80022b1c,
SCE_NP_MATCHING2_SERVER_ERROR_TITLE_PASSPHRASE_MISMATCH = 0x80022b1e,
SCE_NP_MATCHING2_SERVER_ERROR_DUPLICATE_LOBBY = 0x80022b25,
SCE_NP_MATCHING2_SERVER_ERROR_DUPLICATE_ROOM = 0x80022b26,
SCE_NP_MATCHING2_SERVER_ERROR_NO_JOIN_GROUP_LABEL = 0x80022b29,
SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_GROUP = 0x80022b2a,
SCE_NP_MATCHING2_SERVER_ERROR_NO_PASSWORD = 0x80022b2b,
SCE_NP_MATCHING2_SERVER_ERROR_MAX_OVER_SLOT_GROUP = 0x80022b2c,
SCE_NP_MATCHING2_SERVER_ERROR_MAX_OVER_PASSWORD_MASK = 0x80022b2d,
SCE_NP_MATCHING2_SERVER_ERROR_DUPLICATE_GROUP_LABEL = 0x80022b2e,
SCE_NP_MATCHING2_SERVER_ERROR_REQUEST_OVERFLOW = 0x80022b2f,
SCE_NP_MATCHING2_SERVER_ERROR_ALREADY_JOINED = 0x80022b30,
SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH = 0x80022b31,
SCE_NP_MATCHING2_SERVER_ERROR_ROOM_INCONSISTENCY = 0x80022b32,
// SCE_NP_MATCHING2_NET_ERRNO_BASE = 0x800224XX,
// SCE_NP_MATCHING2_NET_H_ERRNO_BASE = 0x800225XX,
};
using SceNpBasicEventHandler = func_def<s32(s32 event, s32 retCode, u32 reqId, vm::ptr<void> arg)>;
struct sceNpInternal
{
bool m_bSceNpInitialized;
bool m_bScoreInitialized;
bool m_bLookupInitialized;
bool m_bSceNpUtilBandwidthTestInitialized;
sceNpInternal()
: m_bSceNpInitialized(false),
m_bScoreInitialized(false),
m_bLookupInitialized(false),
m_bSceNpUtilBandwidthTestInitialized(false)
{
}
};
extern sceNpInternal sceNpInstance;
// NP Manager Utility statuses
enum
{
@ -874,8 +1010,7 @@ typedef void(SceNpManagerCallback)(s32 event, s32 result, u32 arg_addr);
// Request callback function
typedef void(*SceNpMatching2RequestCallback)(u16 ctxId, u32 reqId, u16 event,
u32 eventKey, s32 errorCode, u32 dataSize, u32 *arg
);
u32 eventKey, s32 errorCode, u32 dataSize, u32 *arg);
// NOTE: Use SceNpCommunicationPassphrase instead
// Np communication passphrase
@ -1237,7 +1372,7 @@ struct SceNpMatching2SignalingOptParam
u8 type;
u8 reserved1[1];
be_t<u16> hubMemberId;
//u8 reserved2[4];
u8 reserved2[4];
};
// Option parameters for requests
@ -1698,7 +1833,7 @@ struct SceNpMatching2GetLobbyMemberDataInternalListResponse
struct SceNpMatching2SignalingGetPingInfoRequest
{
be_t<u64> roomId;
//u8 reserved[16];
u8 reserved[16];
};
// Response data for obtaining Ping information
@ -1709,7 +1844,7 @@ struct SceNpMatching2SignalingGetPingInfoResponse
be_t<u32> worldId;
be_t<u64> roomId;
be_t<u32> rtt;
//u8 reserved[20];
u8 reserved[20];
};
// Join request parameters for room in prohibitive mode
@ -1852,7 +1987,7 @@ struct SceNpMatching2UtilityInitParam
be_t<u32> requestCbQueueLen;
be_t<u32> sessionEventCbQueueLen;;
be_t<u32> sessionMsgCbQueueLen;;
//u8 reserved[16];
u8 reserved[16];
};
// Matching2 memory information
@ -1861,7 +1996,7 @@ struct SceNpMatching2MemoryInfo
be_t<u32> totalMemSize;
be_t<u32> curMemUsage;;
be_t<u32> maxMemUsage;;
//u8 reserved[12];
u8 reserved[12];
};
// Matching2 information on the event data queues in the system
@ -1876,7 +2011,7 @@ struct SceNpMatching2CbQueueInfo
be_t<u32> sessionMsgCbQueueLen;;
be_t<u32> curSessionMsgCbQueueLen;;
be_t<u32> maxSessionMsgCbQueueLen;;
//u8 reserved[12];
u8 reserved[12];
};
// Score data unique to the application
@ -1934,7 +2069,7 @@ struct SceNpScoreNpIdPcId
{
SceNpId npId;
be_t<s32> pcId;
//u8 pad[4];
u8 pad[4];
};
// Basic clan information to be used in raking
@ -1942,7 +2077,7 @@ struct SceNpScoreClanBasicInfo
{
s8 clanName[SCE_NP_CLANS_CLAN_NAME_MAX_LENGTH + 1];
s8 clanTag[SCE_NP_CLANS_CLAN_TAG_MAX_LENGTH + 1];
//u8 reserved[10];
u8 reserved[10];
};
// Clan member information handled in ranking

View File

@ -0,0 +1,174 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "sceNp.h"
extern Module sceNp2;
struct sceNp2Internal
{
bool m_bSceNp2Initialized;
bool m_bSceNp2Matching2Initialized;
bool m_bSceNp2Matching2Initialized2;
sceNp2Internal()
: m_bSceNp2Initialized(false),
m_bSceNp2Matching2Initialized(false),
m_bSceNp2Matching2Initialized2(false)
{
}
};
sceNp2Internal sceNp2Instance;
s32 sceNp2Init(u32 poolsize, vm::ptr<u32> poolptr)
{
sceNp2.Warning("sceNp2Init(poolsize=%d, poolptr=0x%x)", poolsize, poolptr);
if (sceNp2Instance.m_bSceNp2Initialized)
{
sceNp2.Error("sceNp2Init(): sceNp2 has been already initialized.");
return SCE_NP_ERROR_ALREADY_INITIALIZED;
}
if (poolsize == 0)
{
sceNp2.Error("sceNp2Init(): poolsize given is 0.");
return SCE_NP_ERROR_INVALID_ARGUMENT;
}
else if (poolsize < 128 * 1024)
{
sceNp2.Error("sceNp2Init(): poolsize given is under 131072 bytes.");
return SCE_NP_ERROR_INSUFFICIENT_BUFFER;
}
if (!poolptr)
{
sceNp2.Error("sceNp2Init(): poolptr is invalid.");
return SCE_NP_ERROR_INVALID_ARGUMENT;
}
sceNpInstance.m_bSceNpInitialized = true;
sceNp2Instance.m_bSceNp2Initialized = true;
return CELL_OK;
}
s32 sceNpMatching2Init(u32 poolsize, s32 priority)
{
sceNp2.Todo("sceNpMatching2Init(poolsize=%d, priority=%d)", poolsize, priority);
if (!sceNp2Instance.m_bSceNp2Initialized)
{
sceNp2.Error("sceNpMatching2Init(): sceNp2 has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}
if (sceNp2Instance.m_bSceNp2Matching2Initialized)
{
sceNp2.Error("sceNpMatching2Init(): sceNpMatching2 has already been intialized.");
return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED;
}
sceNp2Instance.m_bSceNp2Matching2Initialized = true;
return CELL_OK;
}
s32 sceNpMatching2Init2(u32 poolsize, s32 priority, vm::ptr<SceNpMatching2UtilityInitParam> param)
{
sceNp2.Todo("sceNpMatching2Init2(poolsize=%d, priority=%d, param_addr=0x%x)", poolsize, priority, param.addr());
if (!sceNp2Instance.m_bSceNp2Initialized)
{
sceNp2.Error("sceNpMatching2Init2(): sceNp2 has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}
if (sceNp2Instance.m_bSceNp2Matching2Initialized2)
{
sceNp2.Error("sceNpMatching2Init2(): new sceNpMatching2 has already been intialized.");
return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED;
}
sceNp2Instance.m_bSceNp2Matching2Initialized2 = true;
// TODO:
// 1. Create an internal thread
// 2. Create heap area to be used by the NP matching 2 utility
// 3. Set maximum lengths for the event data queues in the system
return CELL_OK;
}
s32 sceNp2Term()
{
sceNp2.Warning("sceNp2Term()");
if (!sceNp2Instance.m_bSceNp2Initialized)
{
sceNp2.Error("sceNp2Term(): sceNp2 has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}
sceNp2Instance.m_bSceNp2Initialized = false;
return CELL_OK;
}
s32 sceNpMatching2Term(PPUThread& ppu)
{
sceNp2.Warning("sceNpMatching2Term()");
if (!sceNp2Instance.m_bSceNp2Initialized)
{
sceNp2.Error("sceNpMatching2Term(): sceNp2 has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}
if (!sceNp2Instance.m_bSceNp2Matching2Initialized)
{
sceNp2.Error("sceNpMatching2Term(): sceNpMatching2 has not been intialized.");
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
sceNp2Instance.m_bSceNp2Matching2Initialized = false;
return CELL_OK;
}
s32 sceNpMatching2Term2()
{
sceNp2.Warning("sceNpMatching2Term2()");
if (!sceNp2Instance.m_bSceNp2Initialized)
{
sceNp2.Error("sceNpMatching2Term2(): sceNp2 has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}
if (!sceNp2Instance.m_bSceNp2Matching2Initialized2)
{
sceNp2.Error("sceNpMatching2Term(): new sceNpMatching2 has not been intialized.");
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
}
sceNp2Instance.m_bSceNp2Matching2Initialized2 = false;
return CELL_OK;
}
Module sceNp2("sceNp2", []()
{
sceNp2Instance.m_bSceNp2Initialized = false;
sceNp2Instance.m_bSceNp2Matching2Initialized = false;
sceNp2Instance.m_bSceNp2Matching2Initialized2 = false;
REG_FUNC(sceNp2, sceNp2Init);
REG_FUNC(sceNp2, sceNpMatching2Init);
REG_FUNC(sceNp2, sceNpMatching2Init2);
REG_FUNC(sceNp2, sceNp2Term);
REG_FUNC(sceNp2, sceNpMatching2Term);
REG_FUNC(sceNp2, sceNpMatching2Term2);
});

View File

@ -157,6 +157,7 @@ s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr<
if (!ctxt)
{
sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT");
return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT;
}
@ -164,43 +165,56 @@ s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr<
if (!hndl)
{
sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE");
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
}
TRPLoader trp(*ctxt->trp_stream);
if (!trp.LoadHeader())
{
sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE");
return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE;
}
// Rename or discard certain entries based on the files found
const size_t kTargetBufferLength = 31;
char target[kTargetBufferLength+1];
char target[kTargetBufferLength + 1];
target[kTargetBufferLength] = 0;
strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", Ini.SysLanguage.GetValue()));
if (trp.ContainsEntry(target)) {
if (trp.ContainsEntry(target))
{
trp.RemoveEntry("TROPCONF.SFM");
trp.RemoveEntry("TROP.SFM");
trp.RenameEntry(target, "TROPCONF.SFM");
}
else if (trp.ContainsEntry("TROP.SFM")) {
else if (trp.ContainsEntry("TROP.SFM"))
{
trp.RemoveEntry("TROPCONF.SFM");
trp.RenameEntry("TROP.SFM", "TROPCONF.SFM");
}
else if (!trp.ContainsEntry("TROPCONF.SFM")) {
else if (!trp.ContainsEntry("TROPCONF.SFM"))
{
return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE;
}
// Discard unnecessary TROP_XX.SFM files
for (s32 i=0; i<=18; i++) {
for (s32 i = 0; i <= 18; i++)
{
strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", i));
if (i != Ini.SysLanguage.GetValue())
{
trp.RemoveEntry(target);
}
}
// TODO: Get the path of the current user
std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name;
if (!trp.Install(trophyPath))
{
sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE");
return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE;
}
TROPUSRLoader* tropusr = new TROPUSRLoader();
std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT";

View File

@ -16,7 +16,7 @@ TRPLoader::~TRPLoader()
bool TRPLoader::Install(std::string dest, bool show)
{
if(!trp_f.IsOpened())
if (!trp_f.IsOpened())
return false;
if (!dest.empty() && dest.back() != '/')

View File

@ -267,6 +267,7 @@
<ClCompile Include="Emu\SysCalls\Modules\libsnd3.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\libsynth2.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\sceNp.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\sceNp2.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\sceNpClans.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\sceNpCommerce2.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\sceNpSns.cpp" />

View File

@ -269,6 +269,9 @@
<ClCompile Include="Emu\SysCalls\Modules\sceNp.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\sceNp2.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\sceNpClans.cpp">
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>