Implemented sceNpBasicGetEvent, sceNpLookupInit and sceNpLookupTerm

Updated writing to pointers for sys_get_random_number,
sceNpBasicGetFriendListEntryCount and sceNpBasicGetMessageEntryCount.
Fixed some pointers and TODOs in cellNetCtl.
This commit is contained in:
Raul Tambre 2014-09-25 20:07:06 +03:00
parent c329942482
commit d17322948d
4 changed files with 74 additions and 16 deletions

View File

@ -44,7 +44,7 @@ int cellNetCtlTerm()
return CELL_OK; return CELL_OK;
} }
int cellNetCtlGetState(vm::ptr<be_t<u32>> state) int cellNetCtlGetState(vm::ptr<u32> state)
{ {
cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.addr()); cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.addr());
@ -53,16 +53,16 @@ int cellNetCtlGetState(vm::ptr<be_t<u32>> state)
return CELL_OK; return CELL_OK;
} }
int cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler, vm::ptr<be_t<u32>> arg, s32 hid) int cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler, vm::ptr<u32> arg, vm::ptr<s32> 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; return CELL_OK;
} }
int cellNetCtlDelHandler(s32 hid) int cellNetCtlDelHandler(s32 hid)
{ {
cellNetCtl->Todo("cellNetCtlDelHandler(hid=%x)", hid); cellNetCtl->Todo("cellNetCtlDelHandler(hid=0x%x)", hid);
return CELL_OK; return CELL_OK;
} }

View File

@ -16,11 +16,13 @@ struct sceNpInternal
bool m_bSceNpInitialized; bool m_bSceNpInitialized;
bool m_bSceNp2Initialized; bool m_bSceNp2Initialized;
bool m_bScoreInitialized; bool m_bScoreInitialized;
bool m_bLookupInitialized;
sceNpInternal() sceNpInternal()
: m_bSceNpInitialized(false), : m_bSceNpInitialized(false),
m_bSceNp2Initialized(false), m_bSceNp2Initialized(false),
m_bScoreInitialized(false) m_bScoreInitialized(false),
m_bLookupInitialized(false)
{ {
} }
}; };
@ -282,7 +284,7 @@ int sceNpBasicAddFriend()
return CELL_OK; return CELL_OK;
} }
int sceNpBasicGetFriendListEntryCount(u32 count) int sceNpBasicGetFriendListEntryCount(vm::ptr<u32> count)
{ {
sceNp->Warning("sceNpBasicGetFriendListEntryCount(count=%d)", count); sceNp->Warning("sceNpBasicGetFriendListEntryCount(count=%d)", count);
@ -290,7 +292,7 @@ int sceNpBasicGetFriendListEntryCount(u32 count)
return SCE_NP_BASIC_ERROR_NOT_INITIALIZED; return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
// TODO: Check if there are any friends // TODO: Check if there are any friends
vm::write32(count, 0); *count = 0;
return CELL_OK; return CELL_OK;
} }
@ -415,7 +417,7 @@ int sceNpBasicGetClanMessageEntry()
return CELL_OK; return CELL_OK;
} }
int sceNpBasicGetMessageEntryCount(u32 type, u32 count) int sceNpBasicGetMessageEntryCount(u32 type, vm::ptr<u32> count)
{ {
sceNp->Warning("sceNpBasicGetMessageEntryCount(type=%d, count=%d)", type, 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; return SCE_NP_BASIC_ERROR_NOT_INITIALIZED;
// TODO: Check if there are messages // TODO: Check if there are messages
vm::write32(count, 0); *count = 0;
return CELL_OK; return CELL_OK;
} }
@ -434,9 +436,16 @@ int sceNpBasicGetMessageEntry()
return CELL_OK; return CELL_OK;
} }
int sceNpBasicGetEvent() int sceNpBasicGetEvent(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<s32> data, vm::ptr<u32> 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; return CELL_OK;
} }
@ -694,13 +703,27 @@ int sceNpFriendlistAbortGui()
int sceNpLookupInit() 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; return CELL_OK;
} }
int sceNpLookupTerm() 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; return CELL_OK;
} }
@ -1527,6 +1550,7 @@ void sceNp_unload()
sceNpInstance.m_bSceNpInitialized = false; sceNpInstance.m_bSceNpInitialized = false;
sceNpInstance.m_bSceNp2Initialized = false; sceNpInstance.m_bSceNp2Initialized = false;
sceNpInstance.m_bScoreInitialized = false; sceNpInstance.m_bScoreInitialized = false;
sceNpInstance.m_bLookupInitialized = false;
} }
void sceNp_init(Module *pxThis) void sceNp_init(Module *pxThis)

View File

@ -96,6 +96,8 @@ enum
SCE_NP_COMMUNITY_ERROR_TOO_MANY_SLOTID = 0x8002a1b1, SCE_NP_COMMUNITY_ERROR_TOO_MANY_SLOTID = 0x8002a1b1,
}; };
typedef int(*SceNpBasicEventHandler)(s32 event, s32 retCode, u32 reqId, vm::ptr<void> arg);
// NP Manager Utility statuses // NP Manager Utility statuses
enum enum
{ {
@ -106,6 +108,38 @@ enum
SCE_NP_MANAGER_STATUS_ONLINE = 3, 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 // IDs for attachment data objects
enum enum
{ {

View File

@ -149,14 +149,14 @@ int sys_raw_spu_image_load(int id, vm::ptr<sys_spu_image> img)
return CELL_OK; return CELL_OK;
} }
int sys_get_random_number(u32 addr, u64 size) int sys_get_random_number(vm::ptr<u32> 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) if (size > 4096)
size = 4096; size = 4096;
vm::write32(addr, rand() % size); *addr = rand() % size;
return CELL_OK; return CELL_OK;
} }