From d17322948d0ca58da1769e6b7503c6d97f70e2f7 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 25 Sep 2014 20:07:06 +0300 Subject: [PATCH 1/3] Implemented sceNpBasicGetEvent, sceNpLookupInit and sceNpLookupTerm Updated writing to pointers for sys_get_random_number, sceNpBasicGetFriendListEntryCount and sceNpBasicGetMessageEntryCount. Fixed some pointers and TODOs in cellNetCtl. --- rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp | 8 ++-- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 42 +++++++++++++++----- rpcs3/Emu/SysCalls/Modules/sceNp.h | 34 ++++++++++++++++ rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp | 6 +-- 4 files changed, 74 insertions(+), 16 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp index 657f4fbd47..05c9dd1bd1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp @@ -44,7 +44,7 @@ int cellNetCtlTerm() return CELL_OK; } -int cellNetCtlGetState(vm::ptr> state) +int cellNetCtlGetState(vm::ptr state) { cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.addr()); @@ -53,16 +53,16 @@ int cellNetCtlGetState(vm::ptr> state) return CELL_OK; } -int cellNetCtlAddHandler(vm::ptr handler, vm::ptr> arg, s32 hid) +int cellNetCtlAddHandler(vm::ptr handler, vm::ptr arg, vm::ptr hid) { - cellNetCtl->Todo("cellNetCtlAddHandler(handler_addr=0x%x, arg_addr=0x%x, hid=%x)", handler.addr(), arg.addr(), hid); + cellNetCtl->Todo("cellNetCtlAddHandler(handler_addr=0x%x, arg_addr=0x%x, hid=0x%x)", handler.addr(), arg.addr(), hid.addr()); return CELL_OK; } int cellNetCtlDelHandler(s32 hid) { - cellNetCtl->Todo("cellNetCtlDelHandler(hid=%x)", hid); + cellNetCtl->Todo("cellNetCtlDelHandler(hid=0x%x)", hid); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 9e4cb3b07b..32e775d2f4 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -16,11 +16,13 @@ struct sceNpInternal bool m_bSceNpInitialized; bool m_bSceNp2Initialized; bool m_bScoreInitialized; + bool m_bLookupInitialized; sceNpInternal() : m_bSceNpInitialized(false), m_bSceNp2Initialized(false), - m_bScoreInitialized(false) + m_bScoreInitialized(false), + m_bLookupInitialized(false) { } }; @@ -282,7 +284,7 @@ int sceNpBasicAddFriend() return CELL_OK; } -int sceNpBasicGetFriendListEntryCount(u32 count) +int sceNpBasicGetFriendListEntryCount(vm::ptr count) { sceNp->Warning("sceNpBasicGetFriendListEntryCount(count=%d)", count); @@ -290,7 +292,7 @@ int sceNpBasicGetFriendListEntryCount(u32 count) return SCE_NP_BASIC_ERROR_NOT_INITIALIZED; // TODO: Check if there are any friends - vm::write32(count, 0); + *count = 0; return CELL_OK; } @@ -415,7 +417,7 @@ int sceNpBasicGetClanMessageEntry() return CELL_OK; } -int sceNpBasicGetMessageEntryCount(u32 type, u32 count) +int sceNpBasicGetMessageEntryCount(u32 type, vm::ptr count) { sceNp->Warning("sceNpBasicGetMessageEntryCount(type=%d, count=%d)", type, count); @@ -423,7 +425,7 @@ int sceNpBasicGetMessageEntryCount(u32 type, u32 count) return SCE_NP_BASIC_ERROR_NOT_INITIALIZED; // TODO: Check if there are messages - vm::write32(count, 0); + *count = 0; return CELL_OK; } @@ -434,9 +436,16 @@ int sceNpBasicGetMessageEntry() return CELL_OK; } -int sceNpBasicGetEvent() +int sceNpBasicGetEvent(vm::ptr event, vm::ptr from, vm::ptr data, vm::ptr size) { - UNIMPLEMENTED_FUNC(sceNp); + sceNp->Warning("sceNpBasicGetEvent(event_addr=0x%x, from_addr=0x%x, data_addr=0x%x, size_addr=0x%x)", event.addr(), from.addr(), data.addr(), size.addr()); + + if (!sceNpInstance.m_bSceNpInitialized) + return SCE_NP_BASIC_ERROR_NOT_INITIALIZED; + + // TODO: Check for other error and pass other events + *event = SCE_NP_BASIC_EVENT_OFFLINE; + return CELL_OK; } @@ -694,13 +703,27 @@ int sceNpFriendlistAbortGui() int sceNpLookupInit() { - UNIMPLEMENTED_FUNC(sceNp); + sceNp->Warning("sceNpLookupInit()"); + + // TODO: Make sure the error code returned is right, + // since there are no error codes for Lookup utility. + if (sceNpInstance.m_bLookupInitialized) + return SCE_NP_COMMUNITY_ERROR_ALREADY_INITIALIZED; + + sceNpInstance.m_bLookupInitialized = true; + return CELL_OK; } int sceNpLookupTerm() { - UNIMPLEMENTED_FUNC(sceNp); + sceNp->Warning("sceNpLookupTerm()"); + + if (!sceNpInstance.m_bLookupInitialized) + return SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED; + + sceNpInstance.m_bLookupInitialized = false; + return CELL_OK; } @@ -1527,6 +1550,7 @@ void sceNp_unload() sceNpInstance.m_bSceNpInitialized = false; sceNpInstance.m_bSceNp2Initialized = false; sceNpInstance.m_bScoreInitialized = false; + sceNpInstance.m_bLookupInitialized = false; } void sceNp_init(Module *pxThis) diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.h b/rpcs3/Emu/SysCalls/Modules/sceNp.h index a41ab4c538..ddce57f3dd 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.h @@ -96,6 +96,8 @@ enum SCE_NP_COMMUNITY_ERROR_TOO_MANY_SLOTID = 0x8002a1b1, }; +typedef int(*SceNpBasicEventHandler)(s32 event, s32 retCode, u32 reqId, vm::ptr arg); + // NP Manager Utility statuses enum { @@ -106,6 +108,38 @@ enum SCE_NP_MANAGER_STATUS_ONLINE = 3, }; +// Event types +enum +{ + SCE_NP_BASIC_EVENT_UNKNOWN = -1, + SCE_NP_BASIC_EVENT_OFFLINE = 0, + SCE_NP_BASIC_EVENT_PRESENCE = 1, + SCE_NP_BASIC_EVENT_MESSAGE = 2, + SCE_NP_BASIC_EVENT_ADD_FRIEND_RESULT = 3, + SCE_NP_BASIC_EVENT_INCOMING_ATTACHMENT = 4, + SCE_NP_BASIC_EVENT_INCOMING_INVITATION = 5, + SCE_NP_BASIC_EVENT_END_OF_INITIAL_PRESENCE = 6, + SCE_NP_BASIC_EVENT_SEND_ATTACHMENT_RESULT = 7, + SCE_NP_BASIC_EVENT_RECV_ATTACHMENT_RESULT = 8, + SCE_NP_BASIC_EVENT_OUT_OF_CONTEXT = 9, + SCE_NP_BASIC_EVENT_FRIEND_REMOVED = 10, + SCE_NP_BASIC_EVENT_ADD_BLOCKLIST_RESULT = 11, + SCE_NP_BASIC_EVENT_SEND_MESSAGE_RESULT = 12, + SCE_NP_BASIC_EVENT_SEND_INVITATION_RESULT = 13, + SCE_NP_BASIC_EVENT_RECV_INVITATION_RESULT = 14, + SCE_NP_BASIC_EVENT_MESSAGE_MARKED_AS_USED_RESULT = 15, + SCE_NP_BASIC_EVENT_INCOMING_CUSTOM_INVITATION = 16, + SCE_NP_BASIC_EVENT_INCOMING_CLAN_MESSAGE = 17, + SCE_NP_BASIC_EVENT_ADD_PLAYERS_HISTORY_RESULT = 18, + SCE_NP_BASIC_EVENT_SEND_CUSTOM_DATA_RESULT = 19, + SCE_NP_BASIC_EVENT_RECV_CUSTOM_DATA_RESULT = 20, + SCE_NP_BASIC_EVENT_INCOMING_CUSTOM_DATA_MESSAGE = 21, + SCE_NP_BASIC_EVENT_SEND_URL_ATTACHMENT_RESULT = 22, + SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_INVITATION = 23, + SCE_NP_BASIC_EVENT_BLOCKLIST_UPDATE = 24, + SCE_NP_BASIC_EVENT_INCOMING_BOOTABLE_CUSTOM_DATA_MESSAGE = 25, +}; + // IDs for attachment data objects enum { diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp index 8730463aff..95b8f2f561 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.cpp @@ -149,14 +149,14 @@ int sys_raw_spu_image_load(int id, vm::ptr img) return CELL_OK; } -int sys_get_random_number(u32 addr, u64 size) +int sys_get_random_number(vm::ptr addr, u64 size) { - sysPrxForUser->Warning("sys_get_random_number(addr=0x%x, size=%d)", addr, size); + sysPrxForUser->Warning("sys_get_random_number(addr=0x%x, size=%d)", addr.addr(), size); if (size > 4096) size = 4096; - vm::write32(addr, rand() % size); + *addr = rand() % size; return CELL_OK; } From b5fa247eb3b10030c9a5182e4bb9a96661104ad6 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 25 Sep 2014 20:16:23 +0300 Subject: [PATCH 2/3] Updated ASMJIT --- asmjit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asmjit b/asmjit index 9ead0cfb4c..0cff228354 160000 --- a/asmjit +++ b/asmjit @@ -1 +1 @@ -Subproject commit 9ead0cfb4cb5eb1bcf8c12b4a1ea115e438c44fa +Subproject commit 0cff228354124bd81050b949097282f78ad0e91a From c87c75a45b1900a632fcbb8819856662578c59a9 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 25 Sep 2014 21:51:52 +0300 Subject: [PATCH 3/3] Fix some things --- rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp index 05c9dd1bd1..9c7f0d2ac8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp @@ -44,7 +44,7 @@ int cellNetCtlTerm() return CELL_OK; } -int cellNetCtlGetState(vm::ptr state) +int cellNetCtlGetState(vm::ptr> state) { cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.addr()); @@ -53,7 +53,7 @@ int cellNetCtlGetState(vm::ptr state) return CELL_OK; } -int cellNetCtlAddHandler(vm::ptr handler, vm::ptr arg, vm::ptr hid) +int cellNetCtlAddHandler(vm::ptr handler, vm::ptr arg, vm::ptr> hid) { cellNetCtl->Todo("cellNetCtlAddHandler(handler_addr=0x%x, arg_addr=0x%x, hid=0x%x)", handler.addr(), arg.addr(), hid.addr());