unit ps4_libSceNpScoreRanking;

{$mode objfpc}{$H+}
{$CALLING SysV_ABI_CDecl}

interface

uses
  subr_dynlib,
  ps4_libSceNpCommon,
  ps4_libSceNpManager;

implementation

function ps4_sceNpScoreCreateNpTitleCtx(npServiceLabel:SceNpServiceLabel;selfNpId:PSceNpId):Integer;
begin
 Result:=1;
end;

function ps4_sceNpScoreCreateNpTitleCtxA(npServiceLabel:SceNpServiceLabel;selfId:Integer):Integer;
begin
 Result:=2;
end;

function ps4_sceNpScoreCreateRequest(titleCtxId:Integer):Integer;
begin
 writeln('ScoreCreateRequest:',titleCtxId);
 Result:=894;
end;

function ps4_sceNpScoreDeleteRequest(reqId:Integer):Integer;
begin
 writeln('sceNpScoreDeleteRequest:',reqId);
 Result:=0;
end;

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;
  highestRank:DWORD;
  scoreValue :Int64;
  hasGameData:Integer;
  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;
  highestRank:DWORD;
  hasGameData:Integer;
  pad1       :array[0..3] of Byte;
  scoreValue :Int64;
  recordDate :QWORD;
  accountId  :QWORD;
  pad2       :array[0..7] of Byte;
 end;

const
 SCE_NP_SCORE_COMMENT_MAXLEN=63;

type
 PSceNpScoreComment=^SceNpScoreComment;
 SceNpScoreComment=packed record
  utf8Comment:array[0..SCE_NP_SCORE_COMMENT_MAXLEN] of Char;
 end;

const
 SCE_NP_SCORE_GAMEINFO_MAXSIZE=189;

type
 PSceNpScoreGameInfo=^SceNpScoreGameInfo;
 SceNpScoreGameInfo=packed record
  infoSize:size_t;
  data:array[0..SCE_NP_SCORE_GAMEINFO_MAXSIZE-1] of Byte;
  pad2:array[0..2] of Byte;
 end;

 PSceNpScoreGetFriendRankingOptParam=^SceNpScoreGetFriendRankingOptParam;
 SceNpScoreGetFriendRankingOptParam=packed record
  size           :size_t;
  startSerialRank: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;
             includeSelf:Integer;
             rankArray:PSceNpScoreRankData;
             rankArraySize:size_t;
             commentArray:PSceNpScoreComment;
             commentArraySize:size_t;
             infoArray:PSceNpScoreGameInfo;
             infoArraySize:size_t;
             arrayNum:size_t;
             lastSortDate:PQWORD;
             totalRecord:PDWORD;
             option:PSceNpScoreGetFriendRankingOptParam):Integer;
begin
 if (lastSortDate<>nil) then
 begin
  lastSortDate^:=0;
 end;
 if (totalRecord<>nil) then
 begin
  totalRecord^:=0;
 end;
 Result:=0;
end;

function ps4_sceNpScoreGetFriendsRankingA(
             reqId:Integer;
             boardId:DWORD;
             includeSelf:Integer;
             rankArray:PSceNpScoreRankDataA;
             rankArraySize:size_t;
             commentArray:PSceNpScoreComment;
             commentArraySize:size_t;
             infoArray:PSceNpScoreGameInfo;
             infoArraySize:size_t;
             arrayNum:size_t;
             lastSortDate:PQWORD;
             totalRecord:PDWORD;
             option:PSceNpScoreGetFriendRankingOptParam):Integer;
begin
 if (lastSortDate<>nil) then
 begin
  lastSortDate^:=0;
 end;
 if (totalRecord<>nil) then
 begin
  totalRecord^:=0;
 end;
 Result:=0;
end;

type
 PSceNpScoreAccountIdPcId=^SceNpScoreAccountIdPcId;
 SceNpScoreAccountIdPcId=packed record
  accountId:QWORD;
  pcId:Integer;
  pad:array[0..3] of Byte;
 end;

function ps4_sceNpScoreGetRankingByAccountIdPcId(
             reqId:Integer;
             boardId:DWORD;
             idArray:PSceNpScoreAccountIdPcId;
             idArraySize:size_t;
             rankArray:PSceNpScoreRankDataA;
             rankArraySize:size_t;
             commentArray:PSceNpScoreComment;
             commentArraySize:size_t;
             infoArray:PSceNpScoreGameInfo;
             infoArraySize:size_t;
             arrayNum:size_t;
             lastSortDate:PQWORD;
             totalRecord:PDWORD;
             option:Pointer):Integer;
begin
 if (lastSortDate<>nil) then
 begin
  lastSortDate^:=0;
 end;
 if (totalRecord<>nil) then
 begin
  totalRecord^:=0;
 end;
 Result:=0;
end;

function ps4_sceNpScoreGetRankingByRange(
             reqId:Integer;
             boardId:DWORD;
             startSerialRank:DWORD;
             rankArray:pSceNpScoreRankData;
             rankArraySize:QWORD;
             commentArray:pSceNpScoreComment;
             commentArraySize:QWORD;
             infoArray:pSceNpScoreGameInfo;
             infoArraySize:QWORD;
             arrayNum:QWORD;
             lastSortDate:PQWORD;
             totalRecord:PDWORD;
             option:Pointer):Integer;
begin
 if (lastSortDate<>nil) then
 begin
  lastSortDate^:=0;
 end;
 if (totalRecord<>nil) then
 begin
  totalRecord^:=0;
 end;
 Result:=0;
end;

function ps4_sceNpScoreRecordScore(
             reqId:Integer;
             boardId:DWORD;      //SceNpScoreBoardId
             score:Int64;        //SceNpScoreValue
             scoreComment:pSceNpScoreComment;
             gameInfo:pSceNpScoreGameInfo;
             tmpRank:pSceNpScoreRankNumber;
             compareDate:PQWORD; //SceRtcTick
             option:Pointer):Integer;
begin
 if (tmpRank<>nil) then
 begin
  tmpRank^:=0;
 end;
 Result:=0;
end;

function ps4_sceNpScoreRecordScoreAsync(
             reqId:Integer;
             boardId:DWORD;      //SceNpScoreBoardId
             score:Int64;        //SceNpScoreValue
             scoreComment:pSceNpScoreComment;
             gameInfo:pSceNpScoreGameInfo;
             tmpRank:pSceNpScoreRankNumber;
             compareDate:PQWORD; //SceRtcTick
             option:Pointer):Integer;
begin
 if (tmpRank<>nil) then
 begin
  tmpRank^:=0;
 end;
 Result:=0;
end;

function ps4_sceNpScorePollAsync(
             reqId:Integer;
             r_out:Pinteger):Integer;
begin
 if (r_out<>nil) then
 begin
  r_out^:=0;
 end;
 Result:=0;
end;

function ps4_sceNpScoreGetRankingByNpIdAsync():Integer;
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;
begin
 Result:=0;
end;

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

function Load_libSceNpScoreRanking(name:pchar):p_lib_info;
var
 lib:TLIBRARY;
begin
 Result:=obj_new_int('libSceNpScore');

 lib:=Result^.add_lib('libSceNpScore');
 lib.set_proc($2A7340D53120B412,@ps4_sceNpScoreCreateNpTitleCtx);
 lib.set_proc($1969D640D5D91F93,@ps4_sceNpScoreCreateNpTitleCtxA);
 lib.set_proc($816F2ACA362B51B9,@ps4_sceNpScoreCreateRequest);
 lib.set_proc($74AF3F4A061FEABE,@ps4_sceNpScoreDeleteRequest);
 lib.set_proc($F24B88CD4C3ABAD4,@ps4_sceNpScoreGetFriendsRanking);
 lib.set_proc($80C6CE9FEFFA7970,@ps4_sceNpScoreGetFriendsRankingA);
 lib.set_proc($F66644828884ABA6,@ps4_sceNpScoreGetRankingByAccountIdPcId);
 lib.set_proc($2811F10E3CA4FE30,@ps4_sceNpScoreGetRankingByRange);
 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;

var
 stub:t_int_file;

initialization
 RegisteredInternalFile(stub,'libSceNpScoreRanking.prx',@Load_libSceNpScoreRanking);

end.


