Skip to content

Commit

Permalink
SceHmd & SceNet Implementations (#154)
Browse files Browse the repository at this point in the history
* sceHmdReprojectionSetDisplayBuffers

* sceHmdOpen

* sceHmdGetFieldOfView

* sceHmdOpen fixes

* Fixes

* sceNetHtonll

* sceNetResolverStartNtoa

* Fixes

* Fixes

* fixes

---------

Co-authored-by: red-prig <[email protected]>
  • Loading branch information
Ordinary205 and red-prig authored Dec 27, 2023
1 parent c46781c commit 905a9a6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/ps4_libscehmd.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ interface
Classes,
SysUtils;

const
SCE_HMD_ERROR_PARAMETER_NULL=Integer($81110008);

type
pSceHmdOpenParam=^SceHmdOpenParam;
SceHmdOpenParam=packed record
reserve:array[0..7] of Byte;
end;

pSceHmdFieldOfView=^SceHmdFieldOfView;
SceHmdFieldOfView=packed record
tanOut :Single;
tanIn :Single;
tanTop :Single;
tanBottom:Single;
end;

implementation

function ps4_sceHmdInitialize(param:Pointer):Integer; SysV_ABI_CDecl;
Expand Down Expand Up @@ -77,6 +94,28 @@ function ps4_sceHmdReprojectionClearUserEventStart():Integer; SysV_ABI_CDecl;
Result:=0;
end;

function ps4_sceHmdReprojectionSetDisplayBuffers(videoOutHandle,index0,index1:Integer;option:Pointer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceHmdOpen(userId,_type,index:Integer;pParam:pSceHmdOpenParam):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;

function ps4_sceHmdGetFieldOfView(handle:Integer;fieldOfView:pSceHmdFieldOfView):Integer; SysV_ABI_CDecl;
begin
if (fieldOfView=nil) then Exit(SCE_HMD_ERROR_PARAMETER_NULL);

fieldOfView^.tanOut :=1.20743;
fieldOfView^.tanIn :=1.181346;
fieldOfView^.tanTop :=1.262872;
fieldOfView^.tanBottom:=1.262872;

Result:=0;
end;

function ps4_sceHmdTerminate():Integer; SysV_ABI_CDecl;
begin
Result:=0;
Expand All @@ -102,6 +141,9 @@ function Load_libSceHmd(Const name:RawByteString):TElf_node;
lib^.set_proc($88634DA430E3730A,@ps4_sceHmdReprojectionUnsetDisplayBuffers);
lib^.set_proc($66B579608A83D3D2,@ps4_sceHmdReprojectionFinalize);
lib^.set_proc($99DC856DA263EBA3,@ps4_sceHmdReprojectionClearUserEventStart);
lib^.set_proc($13E74F7E37902C72,@ps4_sceHmdReprojectionSetDisplayBuffers);
lib^.set_proc($776839223EC4533A,@ps4_sceHmdOpen);
lib^.set_proc($34F430605AA2D1BB,@ps4_sceHmdGetFieldOfView);
lib^.set_proc($CFF44C20BA8FEAD1,@ps4_sceHmdTerminate);
end;

Expand Down
24 changes: 24 additions & 0 deletions src/ps4_libscenet.pas
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ function ps4_sceNetNtohs(net16:Word):Integer; SysV_ABI_CDecl;
Result:=NToHs(net16);
end;

function htonll(Value:QWORD):QWORD; inline;
begin
Result:=htonl(Value shr 32) or (htonl(Value) shl 32)
end;

function ps4_sceNetHtonll(host64:QWORD):QWORD; SysV_ABI_CDecl;
begin
Result:=htonl(host64);
end;

function ps4_sceNetEpollControl(eid:Integer; op:Integer; id:Integer; event:pSceNetEpollEvent):Integer; SysV_ABI_CDecl;
begin
Result:=0;
Expand Down Expand Up @@ -413,6 +423,18 @@ function ps4_sceNetResolverStartAton(rid:Integer; const addr:pSceNetInAddr; host
Move(chost^,hostname^,Length(chost));
end;

function ps4_sceNetResolverStartNtoa(rid:Integer; const hostname:PChar; addr:pSceNetInAddr; timeout:Integer; retry:Integer; flags:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=0;

ps4_usleep(100);

if (addr<>nil) then
begin
addr^.s_addr:=SceNetInAddr_t(Pointer(@default_addr.sa_data)^);
end;
end;

function ps4_sceNetResolverDestroy(rid:Integer):Integer; SysV_ABI_CDecl;
begin
Result:=0;
Expand Down Expand Up @@ -710,9 +732,11 @@ function Load_libSceNet(Const name:RawByteString):TElf_node;
lib^.set_proc($868380A1F86146F1,@ps4_sceNetGetsockname);
lib^.set_proc($A501A91D8A290086,@ps4_sceNetNtohl);
lib^.set_proc($45BBEDFB9636884C,@ps4_sceNetNtohs);
lib^.set_proc($DC21E2D4AD70B024,@ps4_sceNetHtonll);
lib^.set_proc($655C38E9BB1AB009,@ps4_sceNetEpollControl);
lib^.set_proc($C6986B66EB25EFC1,@ps4_sceNetGetsockopt);
lib^.set_proc($0296F8603C4AB112,@ps4_sceNetResolverStartAton);
lib^.set_proc($35DF7559A5A61B6C,@ps4_sceNetResolverStartNtoa);
lib^.set_proc($9099581F9B8C0162,@ps4_sceNetResolverDestroy);
lib^.set_proc($3975D7E26524DEE9,@ps4_sceNetConnect);
lib^.set_proc($76B8C86C36C0ED44,@ps4_sceNetEpollWait);
Expand Down

0 comments on commit 905a9a6

Please sign in to comment.