diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index aa90bc2446..5061cdcab9 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -6,10 +6,13 @@ #include "Emu/IdManager.h" #include "Crypto/unedat.h" #include "Crypto/unself.h" +#include "cellRtc.h" #include "sceNp.h" logs::channel sceNp("sceNp", logs::level::notice); +s32 g_psn_connection_status = SCE_NP_MANAGER_STATUS_OFFLINE; + s32 sceNpInit(u32 poolsize, vm::ptr poolptr) { sceNp.warning("sceNpInit(poolsize=0x%x, poolptr=*0x%x)", poolsize, poolptr); @@ -348,31 +351,50 @@ s32 sceNpBasicGetPlayersHistoryEntryCount(u32 options, vm::ptr count) { sceNp.todo("sceNpBasicGetPlayersHistoryEntryCount(options=%d, count=*0x%x)", options, count); - return CELL_OK; -} + if (!count) + { + return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT; + } -s32 sceNpBasicGetPlayersHistoryEntry() -{ - UNIMPLEMENTED_FUNC(sceNp); - return CELL_OK; -} - -s32 sceNpBasicAddBlockListEntry() -{ - UNIMPLEMENTED_FUNC(sceNp); - return CELL_OK; -} - -s32 sceNpBasicGetBlockListEntryCount(u32 count) -{ - sceNp.todo("sceNpBasicGetBlockListEntryCount(count=%d)", count); + // TODO: Check if there are players histories + *count = 0; return CELL_OK; } -s32 sceNpBasicGetBlockListEntry() +s32 sceNpBasicGetPlayersHistoryEntry(u32 options, u32 index, vm::ptr npid) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpBasicGetPlayersHistoryEntry(options=%d, index=%d, npid=*0x%x)", options, index, npid); + + return CELL_OK; +} + +s32 sceNpBasicAddBlockListEntry(vm::cptr npid) +{ + sceNp.todo("sceNpBasicAddBlockListEntry(npid=*0x%x)", npid); + + return CELL_OK; +} + +s32 sceNpBasicGetBlockListEntryCount(vm::ptr count) +{ + sceNp.todo("sceNpBasicGetBlockListEntryCount(count=*0x%x)", count); + + if (!count) + { + return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT; + } + + // TODO: Check if there are block lists + *count = 0; + + return CELL_OK; +} + +s32 sceNpBasicGetBlockListEntry(u32 index, vm::ptr npid) +{ + sceNp.todo("sceNpBasicGetBlockListEntry(index=%d, npid=*0x%x)", index, npid); + return CELL_OK; } @@ -380,6 +402,14 @@ s32 sceNpBasicGetMessageAttachmentEntryCount(vm::ptr count) { sceNp.todo("sceNpBasicGetMessageAttachmentEntryCount(count=*0x%x)", count); + if (!count) + { + return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT; + } + + // TODO: Check if there are message attachments + *count = 0; + return CELL_OK; } @@ -390,15 +420,25 @@ s32 sceNpBasicGetMessageAttachmentEntry(u32 index, vm::ptr from) return CELL_OK; } -s32 sceNpBasicGetCustomInvitationEntryCount() +s32 sceNpBasicGetCustomInvitationEntryCount(vm::ptr count) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpBasicGetCustomInvitationEntryCount(count=*0x%x)", count); + + if (!count) + { + return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT; + } + + // TODO: Check if there are custom invitations + *count = 0; + return CELL_OK; } -s32 sceNpBasicGetCustomInvitationEntry() +s32 sceNpBasicGetCustomInvitationEntry(u32 index, vm::ptr from) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpBasicGetCustomInvitationEntry(index=%d, from=*0x%x)", index, from); + return CELL_OK; } @@ -406,6 +446,14 @@ s32 sceNpBasicGetMatchingInvitationEntryCount(vm::ptr count) { sceNp.todo("sceNpBasicGetMatchingInvitationEntryCount(count=*0x%x)", count); + if (!count) + { + return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT; + } + + // TODO: Check if there are matching invitations + *count = 0; + return CELL_OK; } @@ -420,6 +468,14 @@ s32 sceNpBasicGetClanMessageEntryCount(vm::ptr count) { sceNp.todo("sceNpBasicGetClanMessageEntryCount(count=*0x%x)", count); + if (!count) + { + return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT; + } + + // TODO: Check if there are clan messages + *count = 0; + return CELL_OK; } @@ -844,80 +900,234 @@ s32 sceNpLookupTitleSmallStorageAsync() return CELL_OK; } -s32 sceNpManagerRegisterCallback() +s32 sceNpManagerRegisterCallback(vm::ptr callback, vm::ptr arg) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerRegisterCallback(callback=*0x%x, arg=*0x%x)", callback, arg); + + if (!callback) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + return CELL_OK; } s32 sceNpManagerUnregisterCallback() { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerUnregisterCallback()"); + return CELL_OK; } -s32 sceNpManagerGetStatus(vm::ptr status) +s32 sceNpManagerGetStatus(vm::ptr status) { sceNp.warning("sceNpManagerGetStatus(status=*0x%x)", status); - // TODO: Support different statuses - *status = SCE_NP_MANAGER_STATUS_OFFLINE; + if (!status) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + *status = g_psn_connection_status; return CELL_OK; } -s32 sceNpManagerGetNetworkTime() +s32 sceNpManagerGetNetworkTime(vm::ptr pTick) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetNetworkTime(pTick=*0x%x)", pTick); + + if (!pTick) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetOnlineId() +s32 sceNpManagerGetOnlineId(vm::ptr onlineId) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetOnlineId(onlineId=*0x%x)", onlineId); + + if (!onlineId) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_LOGGING_IN || g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetNpId() +s32 sceNpManagerGetNpId(ppu_thread& ppu, vm::ptr npId) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetNpId(npId=*0x%x)", npId); + + if (!npId) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_LOGGING_IN || g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetOnlineName() +s32 sceNpManagerGetOnlineName(vm::ptr onlineName) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetOnlineName(onlineName=*0x%x)", onlineName); + + if (!onlineName) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetAvatarUrl() +s32 sceNpManagerGetAvatarUrl(vm::ptr avatarUrl) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetAvatarUrl(avatarUrl=*0x%x)", avatarUrl); + + if (!avatarUrl) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetMyLanguages() +s32 sceNpManagerGetMyLanguages(vm::ptr myLanguages) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetMyLanguages(myLanguages=*0x%x)", myLanguages); + + if (!myLanguages) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetAccountRegion() +s32 sceNpManagerGetAccountRegion(vm::ptr countryCode, vm::ptr language) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetAccountRegion(countryCode=*0x%x, language=*0x%x)", countryCode, language); + + if (!countryCode || !language) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_LOGGING_IN || g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetAccountAge() +s32 sceNpManagerGetAccountAge(vm::ptr age) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetAccountAge(age=*0x%x)", age); + + if (!age) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_LOGGING_IN || g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + return CELL_OK; } -s32 sceNpManagerGetContentRatingFlag(vm::ptr isRestricted, vm::ptr age) +s32 sceNpManagerGetContentRatingFlag(vm::ptr isRestricted, vm::ptr age) { sceNp.warning("sceNpManagerGetContentRatingFlag(isRestricted=*0x%x, age=*0x%x)", isRestricted, age); + if (!isRestricted || !age) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_LOGGING_IN || g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + // TODO: read user's parental control information *isRestricted = 0; *age = 18; @@ -925,9 +1135,28 @@ s32 sceNpManagerGetContentRatingFlag(vm::ptr isRestricted, vm::ptr age return CELL_OK; } -s32 sceNpManagerGetChatRestrictionFlag() +s32 sceNpManagerGetChatRestrictionFlag(vm::ptr isRestricted) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp.todo("sceNpManagerGetChatRestrictionFlag(isRestricted=*0x%x)", isRestricted); + + if (!isRestricted) + { + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + if (g_psn_connection_status == SCE_NP_MANAGER_STATUS_OFFLINE) + { + return SCE_NP_ERROR_OFFLINE; + } + + if (g_psn_connection_status != SCE_NP_MANAGER_STATUS_LOGGING_IN || g_psn_connection_status != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_ERROR_INVALID_STATE; + } + + // TODO: read user's parental control information + *isRestricted = 0; + return CELL_OK; }