Skip to content

Commit

Permalink
SceNpWebApi + SceNpSignaling + SceNpScore functions (#182)
Browse files Browse the repository at this point in the history
* sceNpWebApiRegisterExtdPushEventCallbackA

* sceNpSignalingCreateContext

* libSceNpScore functions

* +

---------

Co-authored-by: red-prig <vdpasha@mail.ru>
  • Loading branch information
Ordinary205 and red-prig authored Feb 2, 2024
1 parent f8d9ad0 commit 4a540f2
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/np/ps4_libscenpcommon.pas
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ interface

pSceNpOnlineId=^SceNpOnlineId;
SceNpOnlineId=packed record
data:array[0..SCE_NP_ONLINEID_MAX_LENGTH-1] of AnsiChar;
term:AnsiChar;
data :array[0..SCE_NP_ONLINEID_MAX_LENGTH-1] of AnsiChar;
term :AnsiChar;
dummy:array[0..2] of AnsiChar;
end;

PSceNpId=^SceNpId;
SceNpId=packed record
handle:SceNpOnlineId;
opt:array[0..7] of Byte;
handle :SceNpOnlineId;
opt :array[0..7] of Byte;
reserved:array[0..7] of Byte;
end;

Expand Down
94 changes: 69 additions & 25 deletions src/np/ps4_libscenpscore.pas
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ function ps4_sceNpScoreDeleteRequest(reqId:Integer):Integer; SysV_ABI_CDecl;
type
pSceNpScoreRankData=^SceNpScoreRankData;
SceNpScoreRankData=packed record
npId:SceNpId;
reserved:array[0..48] of Byte;
pad0:array[0..2] of Byte;
pcId:Integer;
serialRank:DWORD;
rank:DWORD;
npId :SceNpId;
reserved :array[0..48] of Byte;
pad0 :array[0..2] of Byte;
pcId :Integer;
serialRank :DWORD;
rank :DWORD;
highestRank:DWORD;
scoreValue:Int64;
scoreValue :Int64;
hasGameData:Integer;
pad1:array[0..3] of Byte;
recordDate:QWORD;
pad1 :array[0..3] of Byte;
recordDate :QWORD;
end;

PSceNpScoreRankDataA=^SceNpScoreRankDataA;
SceNpScoreRankDataA=packed record
onlineId:SceNpOnlineId;
reserved0:array[0..15] of Byte;
reserved:array[0..48] of Byte;
pad0:array[0..2] of Byte;
pcId:Integer;
serialRank:DWORD;
rank:DWORD;
onlineId :SceNpOnlineId;
reserved0 :array[0..15] of Byte;
reserved :array[0..48] of Byte;
pad0 :array[0..2] of Byte;
pcId :Integer;
serialRank :DWORD;
rank :DWORD;
highestRank:DWORD;
hasGameData:Integer;
pad1:array[0..3] of Byte;
scoreValue:Int64;
recordDate:QWORD;
accountId:QWORD;
pad2:array[0..7] of Byte;
pad1 :array[0..3] of Byte;
scoreValue :Int64;
recordDate :QWORD;
accountId :QWORD;
pad2 :array[0..7] of Byte;
end;

const
Expand All @@ -89,11 +89,24 @@ function ps4_sceNpScoreDeleteRequest(reqId:Integer):Integer; SysV_ABI_CDecl;

PSceNpScoreGetFriendRankingOptParam=^SceNpScoreGetFriendRankingOptParam;
SceNpScoreGetFriendRankingOptParam=packed record
size:size_t;
size :size_t;
startSerialRank:PInteger;
hits:PInteger;
hits :PInteger;
end;

pSceNpScoreBoardId=^SceNpScoreBoardId;
SceNpScoreBoardId=DWORD;

pSceNpScorePlayerRankDataA=^SceNpScorePlayerRankDataA;
SceNpScorePlayerRankDataA=packed record
hasData :Integer;
pad0 :array[0..3] of Byte;
rankData:SceNpScoreRankDataA;
end;

pSceNpScoreRankNumber=^SceNpScoreRankNumber;
SceNpScoreRankNumber=DWORD;

function ps4_sceNpScoreGetFriendsRanking(
reqId:Integer;
boardId:DWORD;
Expand Down Expand Up @@ -213,7 +226,7 @@ function ps4_sceNpScoreRecordScore(
score:Int64; //SceNpScoreValue
scoreComment:pSceNpScoreComment;
gameInfo:pSceNpScoreGameInfo;
tmpRank:PDWORD; //SceNpScoreRankNumber
tmpRank:pSceNpScoreRankNumber;
compareDate:PQWORD; //SceRtcTick
option:Pointer):Integer; SysV_ABI_CDecl;
begin
Expand All @@ -230,7 +243,7 @@ function ps4_sceNpScoreRecordScoreAsync(
score:Int64; //SceNpScoreValue
scoreComment:pSceNpScoreComment;
gameInfo:pSceNpScoreGameInfo;
tmpRank:PDWORD; //SceNpScoreRankNumber
tmpRank:pSceNpScoreRankNumber;
compareDate:PQWORD; //SceRtcTick
option:Pointer):Integer; SysV_ABI_CDecl;
begin
Expand All @@ -252,6 +265,34 @@ function ps4_sceNpScorePollAsync(
Result:=0;
end;

function ps4_sceNpScoreGetRankingByNpIdAsync():Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceNpScoreGetRankingByAccountId(reqId:Integer;
boardId:SceNpScoreBoardId;
const accountIdArray:SceNpAccountId;
accountIdArraySize:QWORD;
rankArray:pSceNpScorePlayerRankDataA;
rankArraySize:QWORD;
commentArray:pSceNpScoreComment;
commentArraySize:QWORD;
infoArray:pSceNpScoreGameInfo;
infoArraySize:QWORD;
arrayNum:QWORD;
lastSortDate:PQWORD; //SceRtcTick
totalRecord:pSceNpScoreRankNumber;
option:Pointer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceNpScoreDeleteNpTitleCtx(titleCtxId:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function Load_libSceNpScoreRanking(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
Expand All @@ -270,6 +311,9 @@ function Load_libSceNpScoreRanking(Const name:RawByteString):TElf_node;
lib^.set_proc($CD3D1706D82D3922,@ps4_sceNpScoreRecordScore);
lib^.set_proc($00D26CB0FCF7998D,@ps4_sceNpScoreRecordScoreAsync);
lib^.set_proc($9B50DF351B2D9124,@ps4_sceNpScorePollAsync);
lib^.set_proc($45DDBB76A505655F,@ps4_sceNpScoreGetRankingByNpIdAsync);
lib^.set_proc($2BDB653834D0C777,@ps4_sceNpScoreGetRankingByAccountId);
lib^.set_proc($1B4A44F91342C1F9,@ps4_sceNpScoreDeleteNpTitleCtx);
end;

initialization
Expand Down
24 changes: 23 additions & 1 deletion src/np/ps4_libscenpsignaling.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@
interface

uses
ps4_program;
ps4_program,
ps4_libSceNpCommon;

const
SCE_NP_SIGNALING_CONTEXT_MAX=8;

type
SceNpSignalingHandler=procedure(
ctxId :DWORD;
subjectId:DWORD;
event :Integer;
errorCode:Integer;
arg :Pointer
); SysV_ABI_CDecl;

implementation

Expand All @@ -17,6 +30,14 @@ function ps4_sceNpSignalingInitialize(poolSize:QWORD;
Result:=0;
end;

function ps4_sceNpSignalingCreateContext(npId:pSceNpId;
handler:SceNpSignalingHandler;
arg:Pointer;
ctxId:PDWORD):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function Load_libSceNpSignaling(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
Expand All @@ -26,6 +47,7 @@ function Load_libSceNpSignaling(Const name:RawByteString):TElf_node;

lib:=Result._add_lib('libSceNpSignaling');
lib^.set_proc($DCA3AE0B84666595,@ps4_sceNpSignalingInitialize);
lib^.set_proc($E7262311D778B7C6,@ps4_sceNpSignalingCreateContext)
end;

initialization
Expand Down
32 changes: 32 additions & 0 deletions src/np/ps4_libscenpwebapi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,30 @@ function ps4_sceNpWebApiReadData(requestId:Int64;
extdDataKeyNum:size_t;
end;

pSceNpWebApiExtdPushEventExtdData=^SceNpWebApiExtdPushEventExtdData;
SceNpWebApiExtdPushEventExtdData=packed record
extdDataKey:SceNpWebApiExtdPushEventExtdDataKey;
pData :PChar;
dataLen :QWORD;
end;

SceNpWebApiExtdPushEventCallbackA=procedure(
userCtxId :Integer;
callbackId :Integer;
pNpServiceName:PChar;
npServiceLabel:SceNpServiceLabel;
pTo :pSceNpPeerAddressA;
pToOnlineId :pSceNpOnlineId;
pFrom :pSceNpPeerAddressA;
pFromOnlineId :SceNpOnlineId;
pDataType :pSceNpWebApiPushEventDataType;
pData :PChar;
dataLen :QWORD;
pExtdData :pSceNpWebApiExtdPushEventExtdData;
extdDataNum :QWORD;
pUserArg :Pointer
); SysV_ABI_CDecl;

function ps4_sceNpWebApiCreatePushEventFilter(libCtxId:Integer;
pDataType:pSceNpWebApiPushEventDataType;
dataTypeNum:size_t):Integer; SysV_ABI_CDecl;
Expand Down Expand Up @@ -232,6 +256,13 @@ function ps4_sceNpWebApiRegisterExtdPushEventCallback(userCtxId,filterId:Integer
Result:=3;
end;

function ps4_sceNpWebApiRegisterExtdPushEventCallbackA(userCtxId,filterId:Integer;
cbFunc:SceNpWebApiExtdPushEventCallbackA;
pUserArg:Pointer):Integer; SysV_ABI_CDecl;
begin
Result:=3;
end;

procedure ps4_sceNpWebApiCheckTimeout(); SysV_ABI_CDecl;
begin
//
Expand Down Expand Up @@ -270,6 +301,7 @@ function Load_libSceNpWebApi(Const name:RawByteString):TElf_node;
lib^.set_proc($909409134B8A9B9C,@ps4_sceNpWebApiRegisterServicePushEventCallback);
lib^.set_proc($33605407E0CD1061,@ps4_sceNpWebApiCreateExtdPushEventFilter);
lib^.set_proc($BEB334D80E46CB53,@ps4_sceNpWebApiRegisterExtdPushEventCallback);
lib^.set_proc($8E15CA1902787A02,@ps4_sceNpWebApiRegisterExtdPushEventCallbackA);
lib^.set_proc($81534DCB17FFD528,@ps4_sceNpWebApiCheckTimeout);
lib^.set_proc($5D48DDB124D36775,@ps4_sceNpWebApiDeleteContext);
end;
Expand Down

0 comments on commit 4a540f2

Please sign in to comment.